Skip to content

Commit cc47e15

Browse files
committed
reaction balancing test new compound style
1 parent 7139625 commit cc47e15

File tree

1 file changed

+95
-95
lines changed

1 file changed

+95
-95
lines changed

test/miscellaneous_tests/reaction_balancing.jl

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ let
66
@parameters k
77
@species H(t) O(t)
88
@compounds begin
9-
H2(t) = 2H
10-
O2(t) = 2O
11-
H2O(t) = 2H + 1O
9+
H2 ~ 2H
10+
O2 ~ 2O
11+
H2O ~ 2H + 1O
1212
end
1313

1414
rx = Reaction(k,[H2,O2],[H2O])
@@ -30,10 +30,10 @@ let
3030
@variables t
3131
@parameters k
3232
@species C(t) H(t) O(t)
33-
@compound O2(t) = 2O
34-
@compound CO2(t) = 1C + 2O
35-
@compound H2O(t) = 2H + 1O
36-
@compound C6H12O6(t) = 6C + 12H + 6O
33+
@compound O2 ~ 2O
34+
@compound CO2 ~ 1C + 2O
35+
@compound H2O ~ 2H + 1O
36+
@compound C6H12O6 ~ 6C + 12H + 6O
3737

3838
rx = Reaction(k,[CO2,H2O],[C6H12O6,O2])
3939

@@ -54,7 +54,7 @@ end
5454
let
5555
@variables t
5656
@species H(t) O(t)
57-
@compound H2O(t) = 2H + O
57+
@compound H2O ~ 2H + O
5858

5959
rx = Reaction(1.0, [H2O], [H2O], [2], [2])
6060

@@ -68,7 +68,7 @@ end
6868
let
6969
@variables t
7070
@species H(t) O(t)
71-
@compound H2O(t) = 2H + O
71+
@compound H2O ~ 2H + O
7272

7373
rx = Reaction(1.0, [H, O], [H2O], [23, 1], [7])
7474

@@ -83,10 +83,10 @@ let
8383
@variables t
8484
@species H(t) O(t) C(t)
8585
@compounds begin
86-
CH4(t) = C + 4H
87-
O2(t) = 2O
88-
CO2(t) = C + 2O
89-
H2O(t) = 2H + O
86+
CH4 ~ C + 4H
87+
O2 ~ 2O
88+
CO2 ~ C + 2O
89+
H2O ~ 2H + O
9090
end
9191

9292
rx = Reaction(1.0, [CH4, O2], [CO2, H2O])
@@ -101,9 +101,9 @@ end
101101
let
102102
@variables t
103103
@species H(t) N(t)
104-
@compound N2(t) = 2N
105-
@compound H2(t) = 2H
106-
@compound NH3(t) = N + 3H
104+
@compound N2 ~ 2N
105+
@compound H2 ~ 2H
106+
@compound NH3 ~ N + 3H
107107

108108
rx = Reaction(1.0, [N2, H2], [NH3])
109109

@@ -117,10 +117,10 @@ end
117117
let
118118
@variables t
119119
@species C(t) H(t) O(t)
120-
@compound C2H5OH(t) = 2C + 6H + O
121-
@compound CH3COOH(t) = 2C + 4H + 2O
122-
@compound C4H8O2(t) = 4C + 8H + 2O
123-
@compound H2O(t) = 2H + O
120+
@compound C2H5OH ~ 2C + 6H + O
121+
@compound CH3COOH ~ 2C + 4H + 2O
122+
@compound C4H8O2 ~ 4C + 8H + 2O
123+
@compound H2O ~ 2H + O
124124

125125
rx = Reaction(1.0, [C2H5OH, CH3COOH], [C4H8O2, H2O])
126126

@@ -134,9 +134,9 @@ end
134134
let
135135
@variables t
136136
@species Ca(t) P(t) O(t)
137-
@compound Ca3PO42(t) = 3Ca + 2P + 8O
138-
@compound CaO(t) = Ca + O
139-
@compound P4O10(t) = 4P + 10O
137+
@compound Ca3PO42 ~ 3Ca + 2P + 8O
138+
@compound CaO ~ Ca + O
139+
@compound P4O10 ~ 4P + 10O
140140

141141
rx = Reaction(1.0, [Ca3PO42], [CaO, P4O10])
142142

@@ -150,9 +150,9 @@ end
150150
let
151151
@variables t
152152
@species Fe(t) O(t) H(t)
153-
@compound O2(t) = 2O
154-
@compound H2O(t) = 2H + O
155-
@compound FeOH3(t) = Fe + 3H + 3O
153+
@compound O2 ~ 2O
154+
@compound H2O ~ 2H + O
155+
@compound FeOH3 ~ Fe + 3H + 3O
156156

157157
rx = Reaction(1.0, [Fe, O2, H2O], [FeOH3])
158158

@@ -166,11 +166,11 @@ end
166166
let
167167
@variables t
168168
@species Na(t) O(t) H(t) S(t)
169-
@compound SO4(t) = S + 4O
170-
@compound NaOH(t) = Na + O + H
171-
@compound H2SO4(t) = 2H + 1S + 4O
172-
@compound Na2SO4(t) = 2Na + 1S + 4O
173-
@compound H2O(t) = 2H + O
169+
@compound SO4 ~ S + 4O
170+
@compound NaOH ~ Na + O + H
171+
@compound H2SO4 ~ 2H + 1S + 4O
172+
@compound Na2SO4 ~ 2Na + 1S + 4O
173+
@compound H2O ~ 2H + O
174174

175175
rx = Reaction(1.0, [NaOH,H2SO4], [Na2SO4,H2O])
176176

@@ -184,8 +184,8 @@ end
184184
let
185185
@variables t
186186
@species N(t) O(t)
187-
@compound NO2(t) = N + 2O
188-
@compound N2O4(t) = 2N + 4O
187+
@compound NO2 ~ N + 2O
188+
@compound N2O4 ~ 2N + 4O
189189

190190
rx = Reaction(1.0, [NO2], [N2O4])
191191

@@ -199,11 +199,11 @@ end
199199
let
200200
@variables t
201201
@species C(t) H(t) O(t) Ca(t) Cl(t)
202-
@compound H2O(t) = 2H + 1O
203-
@compound CO2(t) = 1C + 2O
204-
@compound CaCO3(t) = 1Ca + 1C + 3O
205-
@compound HCl(t) = 1H + 1Cl
206-
@compound CaCl2(t) = 1Ca + 2Cl
202+
@compound H2O ~ 2H + 1O
203+
@compound CO2 ~ 1C + 2O
204+
@compound CaCO3 ~ 1Ca + 1C + 3O
205+
@compound HCl ~ 1H + 1Cl
206+
@compound CaCl2 ~ 1Ca + 2Cl
207207

208208
rx = Reaction(1.0,[CaCO3,HCl],[CaCl2,CO2,H2O])
209209
balanced_rx = Reaction(1.0,[CaCO3,HCl],[CaCl2,CO2,H2O], [1, 2], [1, 1, 1])
@@ -216,10 +216,10 @@ end
216216
let
217217
@variables t
218218
@species Si(t) Cl(t) H(t) O(t)
219-
@compound SiCl4(t) = 1Si + 4Cl
220-
@compound H2O(t) = 2H + O
221-
@compound H4SiO4(t) = 4H + Si + 4O
222-
@compound HCl(t) = H + Cl
219+
@compound SiCl4 ~ 1Si + 4Cl
220+
@compound H2O ~ 2H + O
221+
@compound H4SiO4 ~ 4H + Si + 4O
222+
@compound HCl ~ H + Cl
223223

224224
rx = Reaction(1.0,[SiCl4,H2O],[H4SiO4,HCl])
225225
balanced_rx = Reaction(1.0,[SiCl4,H2O],[H4SiO4,HCl], [1,4], [1,4])
@@ -232,9 +232,9 @@ end
232232
let
233233
@variables t
234234
@species Al(t) Cl(t) H(t)
235-
@compound HCl(t) = H + Cl
236-
@compound AlCl3(t) = Al + 3Cl
237-
@compound H2(t) = 2H
235+
@compound HCl ~ H + Cl
236+
@compound AlCl3 ~ Al + 3Cl
237+
@compound H2 ~ 2H
238238

239239
rx = Reaction(1.0,[Al,HCl],[AlCl3,H2])
240240
balanced_rx = Reaction(1.0,[Al,HCl],[AlCl3,H2],[2,6], [2,3])
@@ -247,11 +247,11 @@ end
247247
let
248248
@variables t
249249
@species Na(t) C(t) O(t) H(t) Cl(t)
250-
@compound Na2CO3(t) = 2Na + C + 3O
251-
@compound HCl(t) = H + Cl
252-
@compound NaCl(t) = Na + Cl
253-
@compound H2O(t) = 2H + O
254-
@compound CO2(t) = C + 2O
250+
@compound Na2CO3 ~ 2Na + C + 3O
251+
@compound HCl ~ H + Cl
252+
@compound NaCl ~ Na + Cl
253+
@compound H2O ~ 2H + O
254+
@compound CO2 ~ C + 2O
255255

256256
rx = Reaction(1.0,[Na2CO3,HCl],[NaCl,H2O,CO2])
257257
balanced_rx = Reaction(1.0,[Na2CO3,HCl],[NaCl,H2O,CO2], [1,2], [2,1,1])
@@ -264,10 +264,10 @@ end
264264
let
265265
@variables t
266266
@species C(t) H(t) O(t)
267-
@compound C7H6O2(t) = 7C + 6H + 2O
268-
@compound O2(t) = 2O
269-
@compound CO2(t) = C + 2O
270-
@compound H2O(t) = 2H + O
267+
@compound C7H6O2 ~ 7C + 6H + 2O
268+
@compound O2 ~ 2O
269+
@compound CO2 ~ C + 2O
270+
@compound H2O ~ 2H + O
271271

272272
rx = Reaction(1.0,[C7H6O2,O2],[CO2,H2O])
273273
balanced_rx = Reaction(1.0,[C7H6O2,O2],[CO2,H2O], [2,15], [14,6])
@@ -280,10 +280,10 @@ end
280280
let
281281
@variables t
282282
@species Fe(t) S(t) O(t) H(t) K(t)
283-
@compound Fe2S3O12(t) = 2Fe + 3S + 12O
284-
@compound KOH(t) = K + O + H
285-
@compound K2SO4(t) = 2K + S + 4O
286-
@compound FeO3H3(t) = Fe + 3O + 3H
283+
@compound Fe2S3O12 ~ 2Fe + 3S + 12O
284+
@compound KOH ~ K + O + H
285+
@compound K2SO4 ~ 2K + S + 4O
286+
@compound FeO3H3 ~ Fe + 3O + 3H
287287

288288
rx = Reaction(1.0,[Fe2S3O12,KOH],[K2SO4,FeO3H3]) #5x4 matrix
289289
balanced_rx = Reaction(1.0,[Fe2S3O12,KOH],[K2SO4,FeO3H3], [1,6], [3,2])
@@ -296,10 +296,10 @@ end
296296
let
297297
@variables t
298298
@species Ca(t) P(t) O(t) Si(t)
299-
@compound Ca3P2O8(t) = 3Ca + 2P + 8O
300-
@compound SiO2(t) = Si + 2O
301-
@compound P4O10(t) = 4P + 10O
302-
@compound CaSiO3(t) = Ca + Si + 3O
299+
@compound Ca3P2O8 ~ 3Ca + 2P + 8O
300+
@compound SiO2 ~ Si + 2O
301+
@compound P4O10 ~ 4P + 10O
302+
@compound CaSiO3 ~ Ca + Si + 3O
303303

304304
rx = Reaction(1.0,[Ca3P2O8,SiO2],[P4O10,CaSiO3]) #5x4 matrix
305305
balanced_rx = Reaction(1.0,[Ca3P2O8,SiO2],[P4O10,CaSiO3], [2,6] , [1,6])
@@ -312,9 +312,9 @@ end
312312
let
313313
@variables t
314314
@species K(t) Cl(t) O(t)
315-
@compound KClO3(t) = K + Cl + 3O
316-
@compound KClO4(t) = K + Cl + 4O
317-
@compound KCl(t) = K + Cl
315+
@compound KClO3 ~ K + Cl + 3O
316+
@compound KClO4 ~ K + Cl + 4O
317+
@compound KCl ~ K + Cl
318318

319319
rx = Reaction(1.0,[KClO3],[KClO4,KCl])
320320
balanced_rx = Reaction(1.0,[KClO3],[KClO4,KCl], [4], [3,1])
@@ -327,10 +327,10 @@ end
327327
let
328328
@variables t
329329
@species Al(t) S(t) O(t) Ca(t) O(t) (H)
330-
@compound Al2S3O12(t) = 2Al + 3S + 12O
331-
@compound CaO2H2(t) = Ca + 2O + 2H
332-
@compound AlO3H3(t) = Al + 3O + 3H
333-
@compound CaSO4(t) = Ca + S + 4O
330+
@compound Al2S3O12 ~ 2Al + 3S + 12O
331+
@compound CaO2H2 ~ Ca + 2O + 2H
332+
@compound AlO3H3 ~ Al + 3O + 3H
333+
@compound CaSO4 ~ Ca + S + 4O
334334

335335
rx = Reaction(1.0,[Al2S3O12,CaO2H2],[AlO3H3,CaSO4])
336336
balanced_rx = Reaction(1.0,[Al2S3O12,CaO2H2],[AlO3H3,CaSO4], [1,3], [2,3])
@@ -343,11 +343,11 @@ end
343343
let
344344
@variables t
345345
@species H(t) S(t) O(t) I(t)
346-
@compound H2SO4(t) = 2H + S + 4O
347-
@compound HI(t) = H + I
348-
@compound H2S(t) = 2H + S
349-
@compound I2(t) = 2I
350-
@compound H2O(t) = 2H + O
346+
@compound H2SO4 ~ 2H + S + 4O
347+
@compound HI ~ H + I
348+
@compound H2S ~ 2H + S
349+
@compound I2 ~ 2I
350+
@compound H2O ~ 2H + O
351351

352352
rx = Reaction(1.0,[H2SO4,HI],[H2S,I2,H2O])
353353
balanced_rx = Reaction(1.0,[H2SO4,HI],[H2S,I2,H2O], [1,8], [1,4,4])
@@ -360,10 +360,10 @@ end
360360
let
361361
@variables t
362362
@species C(t) H(t) O(t)
363-
@compound C2H4(t) = 2C + 4H
364-
@compound O2(t) = 2O
365-
@compound CO2(t) = C + 2O
366-
@compound H2O(t) = 2H + O
363+
@compound C2H4 ~ 2C + 4H
364+
@compound O2 ~ 2O
365+
@compound CO2 ~ C + 2O
366+
@compound H2O ~ 2H + O
367367

368368
rx = Reaction(1.0,[C2H4,O2],[CO2,H2O])
369369
balanced_rx = Reaction(1.0,[C2H4,O2],[CO2,H2O],[1,3],[2,2])
@@ -376,11 +376,11 @@ end
376376
let
377377
@variables t
378378
@species C(t) H(t) O(t)
379-
@compound CO(t) = C + O
380-
@compound CO2(t) = C + 2O
381-
@compound H2(t) = 2H
382-
@compound CH4(t) = C + 4H
383-
@compound H2O(t) = 2H + O
379+
@compound CO ~ C + O
380+
@compound CO2 ~ C + 2O
381+
@compound H2 ~ 2H
382+
@compound CH4 ~ C + 4H
383+
@compound H2O ~ 2H + O
384384

385385
rx = Reaction(1.0,[CO,CO2,H2],[CH4,H2O])
386386
brxs = balance_reaction(rx)
@@ -393,11 +393,11 @@ let
393393
@variables t
394394
@species Fe(t) S(t) O(t) H(t) N(t)
395395

396-
@compound FeS2(t) = Fe + 2S
397-
@compound HNO3(t) = H + N + 3O
398-
@compound Fe2S3O12(t) = 2Fe + 3S + 12O
399-
@compound NO(t) = N + O
400-
@compound H2SO4(t) = 2H + S + 4O
396+
@compound FeS2 ~ Fe + 2S
397+
@compound HNO3 ~ H + N + 3O
398+
@compound Fe2S3O12 ~ 2Fe + 3S + 12O
399+
@compound NO ~ N + O
400+
@compound H2SO4 ~ 2H + S + 4O
401401

402402
rx = Reaction(1.0,[FeS2,HNO3],[Fe2S3O12,NO,H2SO4])
403403
brxs = balance_reaction(rx)
@@ -409,9 +409,9 @@ end
409409
let
410410
@variables t
411411
@species C(t) H(t) O(t)
412-
@compound CO(t) = C + O
413-
@compound H2(t) = 2H
414-
@compound COH2(t) = CO + H2
412+
@compound CO ~ C + O
413+
@compound H2 ~ 2H
414+
@compound COH2 ~ CO + H2
415415

416416
rx = Reaction(1.0, [CO, H2], [COH2])
417417
@test_throws Catalyst.COMPOUND_OF_COMPOUND_ERROR balance_reaction(rx)
@@ -422,10 +422,10 @@ let
422422
rn = complete(@reaction_network begin
423423
@species C(t) H(t) O(t)
424424
@compounds begin
425-
O2(t) = 2O
426-
CO2(t) = 1C + 2O
427-
H2O(t) = 2H + 1O
428-
C6H12O6(t) = 6C + 12H + 6O
425+
O2 ~ 2O
426+
CO2 ~ 1C + 2O
427+
H2O ~ 2H + 1O
428+
C6H12O6 ~ 6C + 12H + 6O
429429
end
430430
k, CO2 + H2O --> C6H12O6 + O2
431431
end)

0 commit comments

Comments
 (0)