@@ -38,10 +38,13 @@ class SurfaceCoefficient:
3838 value : float or str
3939 Value of the coefficient (float) or the name of the coefficient that
4040 it is equivalent to (str).
41+ positive : bool
42+ Does the surface coefficient must be positive. Defaults to False.
4143
4244 """
43- def __init__ (self , value ):
45+ def __init__ (self , value , positive = False ):
4446 self .value = value
47+ self .positive = positive
4548
4649 def __get__ (self , instance , owner = None ):
4750 if instance is None :
@@ -56,6 +59,8 @@ def __set__(self, instance, value):
5659 if isinstance (self .value , Real ):
5760 raise AttributeError ('This coefficient is read-only' )
5861 check_type (f'{ self .value } coefficient' , value , Real )
62+ if self .positive :
63+ check_greater_than (f'{ self .value } coefficient' , value , 0.0 )
5964 instance ._coefficients [self .value ] = value
6065
6166
@@ -1261,7 +1266,7 @@ def __subclasshook__(cls, c):
12611266 x0 = SurfaceCoefficient ('x0' )
12621267 y0 = SurfaceCoefficient ('y0' )
12631268 z0 = SurfaceCoefficient ('z0' )
1264- r = SurfaceCoefficient ('r' )
1269+ r = SurfaceCoefficient ('r' , positive = True )
12651270 dx = SurfaceCoefficient ('dx' )
12661271 dy = SurfaceCoefficient ('dy' )
12671272 dz = SurfaceCoefficient ('dz' )
@@ -1427,7 +1432,7 @@ def __init__(self, y0=0., z0=0., r=1., *args, **kwargs):
14271432 x0 = SurfaceCoefficient (0. )
14281433 y0 = SurfaceCoefficient ('y0' )
14291434 z0 = SurfaceCoefficient ('z0' )
1430- r = SurfaceCoefficient ('r' )
1435+ r = SurfaceCoefficient ('r' , positive = True )
14311436 dx = SurfaceCoefficient (1. )
14321437 dy = SurfaceCoefficient (0. )
14331438 dz = SurfaceCoefficient (0. )
@@ -1525,7 +1530,7 @@ def __init__(self, x0=0., z0=0., r=1., *args, **kwargs):
15251530 x0 = SurfaceCoefficient ('x0' )
15261531 y0 = SurfaceCoefficient (0. )
15271532 z0 = SurfaceCoefficient ('z0' )
1528- r = SurfaceCoefficient ('r' )
1533+ r = SurfaceCoefficient ('r' , positive = True )
15291534 dx = SurfaceCoefficient (0. )
15301535 dy = SurfaceCoefficient (1. )
15311536 dz = SurfaceCoefficient (0. )
@@ -1623,7 +1628,7 @@ def __init__(self, x0=0., y0=0., r=1., *args, **kwargs):
16231628 x0 = SurfaceCoefficient ('x0' )
16241629 y0 = SurfaceCoefficient ('y0' )
16251630 z0 = SurfaceCoefficient (0. )
1626- r = SurfaceCoefficient ('r' )
1631+ r = SurfaceCoefficient ('r' , positive = True )
16271632 dx = SurfaceCoefficient (0. )
16281633 dy = SurfaceCoefficient (0. )
16291634 dz = SurfaceCoefficient (1. )
@@ -1723,7 +1728,7 @@ def __init__(self, x0=0., y0=0., z0=0., r=1., *args, **kwargs):
17231728 x0 = SurfaceCoefficient ('x0' )
17241729 y0 = SurfaceCoefficient ('y0' )
17251730 z0 = SurfaceCoefficient ('z0' )
1726- r = SurfaceCoefficient ('r' )
1731+ r = SurfaceCoefficient ('r' , positive = True )
17271732
17281733 def _get_base_coeffs (self ):
17291734 x0 , y0 , z0 , r = self .x0 , self .y0 , self .z0 , self .r
@@ -1849,7 +1854,7 @@ def __subclasshook__(cls, c):
18491854 x0 = SurfaceCoefficient ('x0' )
18501855 y0 = SurfaceCoefficient ('y0' )
18511856 z0 = SurfaceCoefficient ('z0' )
1852- r2 = SurfaceCoefficient ('r2' )
1857+ r2 = SurfaceCoefficient ('r2' , positive = True )
18531858 dx = SurfaceCoefficient ('dx' )
18541859 dy = SurfaceCoefficient ('dy' )
18551860 dz = SurfaceCoefficient ('dz' )
@@ -1985,7 +1990,7 @@ def __init__(self, x0=0., y0=0., z0=0., r2=1., *args, **kwargs):
19851990 x0 = SurfaceCoefficient ('x0' )
19861991 y0 = SurfaceCoefficient ('y0' )
19871992 z0 = SurfaceCoefficient ('z0' )
1988- r2 = SurfaceCoefficient ('r2' )
1993+ r2 = SurfaceCoefficient ('r2' , positive = True )
19891994 dx = SurfaceCoefficient (1. )
19901995 dy = SurfaceCoefficient (0. )
19911996 dz = SurfaceCoefficient (0. )
@@ -2087,7 +2092,7 @@ def __init__(self, x0=0., y0=0., z0=0., r2=1., *args, **kwargs):
20872092 x0 = SurfaceCoefficient ('x0' )
20882093 y0 = SurfaceCoefficient ('y0' )
20892094 z0 = SurfaceCoefficient ('z0' )
2090- r2 = SurfaceCoefficient ('r2' )
2095+ r2 = SurfaceCoefficient ('r2' , positive = True )
20912096 dx = SurfaceCoefficient (0. )
20922097 dy = SurfaceCoefficient (1. )
20932098 dz = SurfaceCoefficient (0. )
@@ -2189,7 +2194,7 @@ def __init__(self, x0=0., y0=0., z0=0., r2=1., *args, **kwargs):
21892194 x0 = SurfaceCoefficient ('x0' )
21902195 y0 = SurfaceCoefficient ('y0' )
21912196 z0 = SurfaceCoefficient ('z0' )
2192- r2 = SurfaceCoefficient ('r2' )
2197+ r2 = SurfaceCoefficient ('r2' , positive = True )
21932198 dx = SurfaceCoefficient (0. )
21942199 dy = SurfaceCoefficient (0. )
21952200 dz = SurfaceCoefficient (1. )
@@ -2292,9 +2297,9 @@ def __init__(self, x0=0., y0=0., z0=0., a=0., b=0., c=0., **kwargs):
22922297 x0 = SurfaceCoefficient ('x0' )
22932298 y0 = SurfaceCoefficient ('y0' )
22942299 z0 = SurfaceCoefficient ('z0' )
2295- a = SurfaceCoefficient ('a' )
2296- b = SurfaceCoefficient ('b' )
2297- c = SurfaceCoefficient ('c' )
2300+ a = SurfaceCoefficient ('a' , positive = True )
2301+ b = SurfaceCoefficient ('b' , positive = True )
2302+ c = SurfaceCoefficient ('c' , positive = True )
22982303
22992304 def translate (self , vector , inplace = False ):
23002305 surf = self if inplace else self .clone ()
0 commit comments