14
14
ConstantCoefficient
15
15
)
16
16
17
- class IntegrationPointMock :
18
- def __init__ (self , y ):
19
- self .y = y
20
- def __getitem__ (self , idx ):
21
- return [0 , self .y ][idx ]
22
-
23
17
class TestCoefficients (unittest .TestCase ):
24
18
25
19
def test_TotalXSCoefficient (self ):
@@ -32,20 +26,20 @@ def test_TotalXSCoefficient(self):
32
26
def test_ScatteringXSCoefficient (self ):
33
27
xs_s_data = [0.5 , 1.5 , 2.5 ]
34
28
coeff = ScatteringXSCoefficient (xs_s_data , 1.0 , 4.0 )
35
- self .assertAlmostEqual (coeff .EvalValue ([0 , 0 ]), 0.5 )
36
- self .assertAlmostEqual (coeff .EvalValue ([0 , 0 .5 ]), 1.5 )
29
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 1. 0 ]), 0.5 )
30
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 2 .5 ]), 1.5 )
37
31
38
32
def test_StoppingPowerCoefficient (self ):
39
33
S_data = [10 , 20 , 30 ]
40
34
coeff = StoppingPowerCoefficient (S_data , 2.0 , 5.0 )
41
- self .assertAlmostEqual (coeff .EvalValue ([0 , 0 ]), 10 )
42
- self .assertAlmostEqual (coeff .EvalValue ([0 , 1 ]), 30 )
35
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 2. 0 ]), 10 )
36
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 4.9 ]), 30 )
43
37
44
38
def test_StoppingPowerDerivativeCoefficient (self ):
45
39
dS_data = [- 1 , - 2 , - 3 ]
46
- coeff = StoppingPowerDerivativeCoefficient (dS_data = dS_data , E_start = 0.0 , E_end = 3.0 )
47
- self .assertAlmostEqual (coeff .EvalValue ([0 , 0 ]), - 1 )
48
- self .assertAlmostEqual (coeff .EvalValue ([0 , 1 ]), - 3 )
40
+ coeff = StoppingPowerDerivativeCoefficient (dS_data , E_start = 0.0 , E_end = 3.0 )
41
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 0.0 ]), - 1 )
42
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 2.9 ]), - 3 )
49
43
50
44
def test_InflowCoefficientSN_positive_mu (self ):
51
45
coeff = InflowCoefficientSN (in_flux = 5.0 , mu = 0.7 )
@@ -64,14 +58,28 @@ def test_QCoefficient_constant(self):
64
58
def test_QCoefficient_energy_dependent (self ):
65
59
Q_data = [1.0 , 2.0 , 3.0 , 4.0 ]
66
60
coeff = QCoefficient (Q_data , 0.0 , 4.0 )
67
- self .assertEqual (coeff .EvalValue ([0 , 0 ]), 1.0 )
68
- self .assertEqual (coeff .EvalValue ([0 , 1 ]), 4.0 )
61
+ self .assertEqual (coeff .EvalValue ([0 , 0.0 ]), 1.0 )
62
+ self .assertEqual (coeff .EvalValue ([0 , 3.9 ]), 4.0 )
69
63
70
64
def test_EnergyDependentCoefficient (self ):
71
65
data = [10.0 , 20.0 , 30.0 ]
72
66
coeff = EnergyDependentCoefficient (data , 0 , 3 )
73
- self .assertAlmostEqual (coeff .EvalValue ([0 , 0 ]), 10.0 )
74
- self .assertAlmostEqual (coeff .EvalValue ([0 , 1 ]), 30.0 )
67
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 0.0 ]), 10.0 )
68
+ self .assertAlmostEqual (coeff .EvalValue ([0 , 2.9 ]), 30.0 )
69
+
70
+ def test_VelocityCoefficient (self ):
71
+ mu = 0.8
72
+ S_arr = [1.0 , 2.0 , 3.0 ]
73
+ E_start , E_end = 0.0 , 3.0
74
+ coeff = VelocityCoefficient (mu , S_arr , E_start , E_end )
75
+ self .assertEqual (coeff .EvalValue ([0 , 0.0 ]), [0.8 , 1.0 ])
76
+ self .assertEqual (coeff .EvalValue ([0 , 2.9 ]), [0.8 , 3.0 ])
77
+
78
+ def test_ConstantCoefficient (self ):
79
+ const_value = 7.0
80
+ coeff = ConstantCoefficient (const_value )
81
+ self .assertEqual (coeff .EvalValue ([0 , 0.5 ]), 7.0 )
82
+ self .assertEqual (coeff .EvalValue ([10 , 100 ]), 7.0 )
75
83
76
84
def test_XDependentCoefficient (self ):
77
85
data = [1.0 , 3.0 , 5.0 ]
@@ -86,19 +94,5 @@ def test_VelocityCoefficientOld(self):
86
94
self .assertEqual (coeff ._EvalPy ([0 , 0 ]), [0.5 , 2.0 ])
87
95
self .assertEqual (coeff ._EvalPy ([1 , 1 ]), [0.5 , 2.0 ])
88
96
89
- def test_VelocityCoefficient (self ):
90
- mu = 0.8
91
- S_arr = [1.0 , 2.0 , 3.0 ]
92
- E_start , E_end = 0.0 , 3.0
93
- coeff = VelocityCoefficient (mu , S_arr , E_start , E_end )
94
- self .assertEqual (coeff .EvalValue ([0 , 0 ]), [0.8 , 1.0 ])
95
- self .assertEqual (coeff .EvalValue ([0 , 1 ]), [0.8 , 3.0 ])
96
-
97
- def test_ConstantCoefficient (self ):
98
- const_value = 7.0
99
- coeff = ConstantCoefficient (const_value )
100
- self .assertEqual (coeff .EvalValue ([0 , 0.5 ]), 7.0 )
101
- self .assertEqual (coeff .EvalValue ([10 , 100 ]), 7.0 )
102
-
103
97
if __name__ == '__main__' :
104
98
unittest .main ()
0 commit comments