@@ -18,7 +18,7 @@ def define_system(self):
1818 D = mc .Species (name = "D" )
1919 E = mc .Species (name = "E" )
2020 F = mc .Species (name = "F" )
21- species = { "A" : A , "B" : B , "C" : C , "D" : D , "E" : E , "F" : F }
21+ species = {"A" : A , "B" : B , "C" : C , "D" : D , "E" : E , "F" : F }
2222 gas = mc .Phase (name = "gas" , species = list (species .values ()))
2323
2424 return gas , species
@@ -32,38 +32,38 @@ def create_box_model(self, mechanism):
3232
3333 # Set the initial conditions
3434 box_model .initial_conditions = Conditions (
35- temperature = 298.15 ,
36- pressure = 101325.0 ,
37- species_concentrations = {
38- "A" : 1.0 ,
39- "B" : 0.0 ,
40- "C" : 0.0 ,
41- "D" : 10.0 ,
42- "E" : 0.0 ,
43- "F" : 0.0 ,
44- })
35+ temperature = 298.15 ,
36+ pressure = 101325.0 ,
37+ species_concentrations = {
38+ "A" : 1.0 ,
39+ "B" : 0.0 ,
40+ "C" : 0.0 ,
41+ "D" : 10.0 ,
42+ "E" : 0.0 ,
43+ "F" : 0.0 ,
44+ })
4545
4646 # Set the evolving conditions
4747 box_model .add_evolving_condition (
48- 300.0 ,
49- Conditions (
50- temperature = 310.0 ,
51- pressure = 100100.0 ,
52- species_concentrations = {
53- "D" : 1.0 ,
54- "E" : 0.0 ,
55- "F" : 0.0 ,
56- }))
48+ 300.0 ,
49+ Conditions (
50+ temperature = 310.0 ,
51+ pressure = 100100.0 ,
52+ species_concentrations = {
53+ "D" : 1.0 ,
54+ "E" : 0.0 ,
55+ "F" : 0.0 ,
56+ }))
5757 box_model .add_evolving_condition (
58- 450.0 ,
59- Conditions (
60- temperature = 280.0 ,
61- pressure = 90500.0 ,
62- species_concentrations = {
63- "A" : 100.0 ,
64- "B" : 0.0 ,
65- "C" : 0.0 ,
66- }))
58+ 450.0 ,
59+ Conditions (
60+ temperature = 280.0 ,
61+ pressure = 90500.0 ,
62+ species_concentrations = {
63+ "A" : 100.0 ,
64+ "B" : 0.0 ,
65+ "C" : 0.0 ,
66+ }))
6767
6868 # Set the time step and duration
6969 box_model .box_model_options .simulation_length = 600.0
@@ -177,48 +177,47 @@ def solve_and_compare(self, box_model, calc_k1, calc_k2, calc_k3, calc_k4):
177177 assert math .isclose (A_conc , A_conc_model , rel_tol = 1e-6 , abs_tol = 1.0e-3 ), f"A concentrations differ at time { time } "
178178 assert math .isclose (B_conc , B_conc_model , rel_tol = 1e-6 , abs_tol = 1.0e-3 ), f"B concentrations differ at time { time } "
179179 assert math .isclose (C_conc , C_conc_model , rel_tol = 1e-6 , abs_tol = 1.0e-3 ), f"C concentrations differ at time { time } "
180-
181-
180+
182181 def test_arrhenius (self ):
183182 """
184183 Test the Arrhenius reaction mechanism.
185184 """
186185 gas , species = self .define_system ()
187186 arr1 = mc .Arrhenius (name = "A->B" , A = 4.0e-3 , C = 50 ,
188- reactants = [species ["A" ]], products = [species ["B" ]], gas_phase = gas )
187+ reactants = [species ["A" ]], products = [species ["B" ]], gas_phase = gas )
189188 arr2 = mc .Arrhenius (name = "B->C" , A = 1.2e-4 , B = 2.5 , C = 75 , D = 50 , E = 0.5 ,
190- reactants = [species ["B" ]], products = [species ["C" ]], gas_phase = gas )
189+ reactants = [species ["B" ]], products = [species ["C" ]], gas_phase = gas )
191190 arr3 = mc .Arrhenius (name = "D->E" , A = 4.0e-3 , C = 35 ,
192- reactants = [species ["D" ]], products = [species ["E" ]], gas_phase = gas )
191+ reactants = [species ["D" ]], products = [species ["E" ]], gas_phase = gas )
193192 arr4 = mc .Arrhenius (name = "E->F" , A = 1.2e-4 , B = 1.4 , C = 75 , D = 50 , E = 0.1 ,
194- reactants = [species ["E" ]], products = [species ["F" ]], gas_phase = gas )
193+ reactants = [species ["E" ]], products = [species ["F" ]], gas_phase = gas )
195194 mechanism = mc .Mechanism (name = "test_mechanism" , species = list (species .values ()),
196- phases = [gas ], reactions = [arr1 , arr2 , arr3 , arr4 ])
197-
195+ phases = [gas ], reactions = [arr1 , arr2 , arr3 , arr4 ])
196+
198197 box_model = self .create_box_model (mechanism )
199198
200199 # Define the rate constants as functions of temperature, pressure, and air density
201200 def calc_k1 (temperature , pressure , air_density ):
202201 return 4.0e-3 * math .exp (50 / temperature )
203202
204203 def calc_k2 (temperature , pressure , air_density ):
205- return (
204+ return (
206205 1.2e-4
207206 * math .exp (75 / temperature )
208207 * (temperature / 50 ) ** 2.5
209208 * (1.0 + 0.5 * pressure )
210- )
211-
209+ )
210+
212211 def calc_k3 (temperature , pressure , air_density ):
213212 return 4.0e-3 * math .exp (35 / temperature )
214213
215214 def calc_k4 (temperature , pressure , air_density ):
216- return (
215+ return (
217216 1.2e-4
218217 * math .exp (75 / temperature )
219218 * (temperature / 50 ) ** 1.4
220219 * (1.0 + 0.1 * pressure )
221- )
220+ )
222221
223222 self .solve_and_compare (box_model , calc_k1 , calc_k2 , calc_k3 , calc_k4 )
224223
@@ -227,7 +226,3 @@ def calc_k4(temperature, pressure, air_density):
227226 logging .basicConfig (level = logging .DEBUG )
228227 test = TestInCodeMechanism ()
229228 test .test_arrhenius ()
230-
231-
232-
233-
0 commit comments