-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreactions.jl
576 lines (491 loc) · 18.5 KB
/
reactions.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# Collect input
function pre_input(inputs, inputs_norm, Q, Y, lambda, inputs_mean, inputs_std)
i = (blockIdx().x-1i32)* blockDim().x + threadIdx().x
j = (blockIdx().y-1i32)* blockDim().y + threadIdx().y
k = (blockIdx().z-1i32)* blockDim().z + threadIdx().z
if i > Nxp || j > Ny || k > Nz
return
end
@inbounds inputs[1, i + Nxp*(j-1 + Ny*(k-1))] = Q[i+NG, j+NG, k+NG, 6] # T
@inbounds inputs[2, i + Nxp*(j-1 + Ny*(k-1))] = Q[i+NG, j+NG, k+NG, 5] # p
for n = 3:Nspecs+2
@inbounds Yi = Y[i+NG, j+NG, k+NG, n-2]
@inbounds inputs[n, i + Nxp*(j-1 + Ny*(k-1))] = (Yi^lambda - 1) / lambda
end
for n = 1:Nspecs+2
@inbounds inputs_norm[n, i + Nxp*(j-1 + Ny*(k-1))] = (inputs[n, i + Nxp*(j-1 + Ny*(k-1))] - inputs_mean[n]) / inputs_std[n]
end
return
end
# Parse prediction
function post_predict(yt_pred, inputs, U, Q, ρi, dt, lambda, thermo)
i = (blockIdx().x-1i32)* blockDim().x + threadIdx().x
j = (blockIdx().y-1i32)* blockDim().y + threadIdx().y
k = (blockIdx().z-1i32)* blockDim().z + threadIdx().z
if i > Nxp || j > Ny || k > Nz
return
end
@inbounds ρ = Q[i+NG, j+NG, k+NG, 1]
@inbounds T = Q[i+NG, j+NG, k+NG, 6]
@inbounds P = Q[i+NG, j+NG, k+NG, 5]
@inbounds rhoi = @view ρi[i+NG, j+NG, k+NG, :]
ρnew = MVector{Nspecs, Float64}(undef)
# only T > 2000 K calculate reaction
if T > T_criteria
@inbounds T1 = T + yt_pred[Nspecs+1, i + Nxp*(j-1 + Ny*(k-1))] * dt
for n = 1:Nspecs
@inbounds Yi = (lambda * (yt_pred[n, i + Nxp*(j-1 + Ny*(k-1))] * dt + inputs[n+2, i + Nxp*(j-1 + Ny*(k-1))]) + 1) ^ (1/lambda)
@inbounds ρnew[n] = Yi * ρ
end
@inbounds U[i+NG, j+NG, k+NG, 5] += InternalEnergy(T1, ρnew, thermo) - InternalEnergy(T, rhoi, thermo)
for n = 1:Nspecs
@inbounds rhoi[n] = ρnew[n]
end
end
return
end
# Zero GPU allocation
function evalModel(Y1, Y2, output, w1, w2, w3, b1, b2, b3, input)
mul!(Y1, w1, input)
Y1 .+= b1
@. Y1 = gelu(Y1)
mul!(Y2, w2, Y1)
Y2 .+= b2
@. Y2 = gelu(Y2)
mul!(output, w3, Y2)
output .+= b3
return
end
# Collect input for CPU evaluation (1 D)
function pre_input_cpu(inputs, Q, ρi)
i = (blockIdx().x-1i32)* blockDim().x + threadIdx().x
j = (blockIdx().y-1i32)* blockDim().y + threadIdx().y
k = (blockIdx().z-1i32)* blockDim().z + threadIdx().z
if i > Nxp || j > Ny || k > Nz
return
end
@inbounds ρinv = 1/Q[i+NG, j+NG, k+NG, 1]
@inbounds inputs[1, i + Nxp*(j-1 + Ny*(k-1))] = Q[i+NG, j+NG, k+NG, 6] # T
@inbounds inputs[2, i + Nxp*(j-1 + Ny*(k-1))] = Q[i+NG, j+NG, k+NG, 5] # p
for n = 3:Nspecs+2
@inbounds inputs[n, i + Nxp*(j-1 + Ny*(k-1))] = ρi[i+NG, j+NG, k+NG, n-2] * ρinv
end
return
end
# Parse output for CPU evaluation (1 D)
function post_eval_cpu(yt_pred, U, Q, ρi, thermo)
i = (blockIdx().x-1i32)* blockDim().x + threadIdx().x
j = (blockIdx().y-1i32)* blockDim().y + threadIdx().y
k = (blockIdx().z-1i32)* blockDim().z + threadIdx().z
if i > Nxp || j > Ny || k > Nz
return
end
@inbounds T = Q[i+NG, j+NG, k+NG, 6]
if T >= T_criteria
@inbounds ρ = Q[i+NG, j+NG, k+NG, 1]
@inbounds rhoi = @view ρi[i+NG, j+NG, k+NG, :]
ρnew = MVector{Nspecs, Float64}(undef)
for n = 3:Nspecs+2
@inbounds ρnew[n-2] = ρ * yt_pred[n, i + Nxp*(j-1 + Ny*(k-1))]
end
@inbounds T1::Float64 = yt_pred[1, i + Nxp*(j-1 + Ny*(k-1))]
@inbounds P1::Float64 = yt_pred[2, i + Nxp*(j-1 + Ny*(k-1))]
Δei = InternalEnergy(T1, ρnew, thermo) - InternalEnergy(T, rhoi, thermo)
@inbounds U[i+NG, j+NG, k+NG, 5] += Δei
for n = 1:Nspecs
@inbounds rhoi[n] = ρnew[n]
end
# update primitives
∑ρ::Float64 = 0.0
for n = 1:Nspecs
@inbounds rhoi[n] = max(rhoi[n], 0.0)
@inbounds ∑ρ += rhoi[n]
end
for n = 1:Nspecs
@inbounds rhoi[n] *= ρ/∑ρ
end
# @inbounds rho[Nspecs] += ρ - ∑ρ
@inbounds Q[i+NG, j+NG, k+NG, 5] = P1
@inbounds Q[i+NG, j+NG, k+NG, 6] = T1
@inbounds Q[i+NG, j+NG, k+NG, 7] += Δei
end
return
end
# serial on cpu using cantera: use compiled dynamic library, Openmp parallel
function eval_cpu(inputs, dt)
# C++ interface
nPoints::Int64 = Nxp*Ny*Nz
@ccall "./libchem.so".run(nPoints::Cint,
Nspecs::Cint,
dt::Cdouble,
inputs::Ptr{Cdouble},
T_criteria::Cdouble,
mech::Cstring,
nthreads_cantera::Cint)::Cvoid
# python interface
# println("Evaluating on CPU: cantera-python")
# ct = pyimport("cantera")
# gas = ct.Solution(mech)
# @inbounds @simd for i = 1:Nxp*Ny*Nz
# T = inputs[1, i]
# if T > T_criteria
# P = inputs[2, i]
# Yi = @view inputs[3:end, i]
# gas.TPY = T, P, Yi
# r = ct.IdealGasReactor(gas)
# sim = ct.ReactorNet([r])
# sim.advance(dt)
# inputs[3:end,i] = gas.Y
# inputs[1, i] = gas.T
# end
# end
end
# GPU chemical reaction
function eval_gpu(U, Q, ρi, dt, thermo, react, tag)
i = (blockIdx().x-1i32)* blockDim().x + threadIdx().x
j = (blockIdx().y-1i32)* blockDim().y + threadIdx().y
k = (blockIdx().z-1i32)* blockDim().z + threadIdx().z
if i > Nxp+NG || j > Ny+NG || k > Nz+NG || i < NG+1 || j < NG+1 || k < NG+1
return
end
if tag[i, j, k] ≠ 0
return
end
@inbounds T = Q[i, j, k, 6]
if T > T_criteria
sc = MVector{Nspecs, Float64}(undef)
wdot = @MVector zeros(Float64, Nspecs)
@inbounds rho = @view ρi[i, j, k, :]
for n = 1:Nspecs
@inbounds sc[n] = rho[n]/thermo.mw[n] * 1e-6
end
vproductionRate(wdot, sc, T, thermo, react)
Δei::Float64 = 0
for n = 1:Nspecs
@inbounds Δρ = wdot[n] * thermo.mw[n] * 1e6 * dt
@inbounds Δei += -thermo.coeffs_lo[6, n] * Δρ * thermo.Ru / thermo.mw[n]
@inbounds rho[n] += Δρ
end
@inbounds U[i, j, k, 5] += Δei
# update primitives
@inbounds ρ = max(Q[i, j, k, 1], CUDA.eps(Float64))
∑ρ::Float64 = 0.0
for n = 1:Nspecs
@inbounds rho[n] = max(rho[n], 0.0)
@inbounds ∑ρ += rho[n]
end
for n = 1:Nspecs
@inbounds rho[n] *= ρ/∑ρ
end
# @inbounds rho[Nspecs] += ρ - ∑ρ
@inbounds ein = Q[i, j, k, 7]
ein += Δei
T = max(GetT(ein, rho, thermo), CUDA.eps(Float64))
p = max(Pmixture(T, rho, thermo), CUDA.eps(Float64))
@inbounds Q[i, j, k, 5] = p
@inbounds Q[i, j, k, 6] = T
@inbounds Q[i, j, k, 7] = ein
end
return
end
# For stiff reaction, point implicit
function eval_gpu_stiff(U, Q, ρi, dt, thermo, react, tag)
i = (blockIdx().x-1i32)* blockDim().x + threadIdx().x
j = (blockIdx().y-1i32)* blockDim().y + threadIdx().y
k = (blockIdx().z-1i32)* blockDim().z + threadIdx().z
if i > Nxp+NG || j > Ny+NG || k > Nz+NG || i < NG+1 || j < NG+1 || k < NG+1
return
end
if tag[i, j, k] ≠ 0
return
end
@inbounds T = Q[i, j, k, 6]
if T > T_criteria
sc = MVector{Nspecs, Float64}(undef)
Δρ = MVector{Nspecs, Float64}(undef)
Δρn = MVector{Nspecs, Float64}(undef)
wdot = @MVector zeros(Float64, Nspecs)
Arate = @MMatrix zeros(Float64, Nspecs, Nspecs)
A1 = MMatrix{Nspecs, Nspecs, Float64}(undef)
@inbounds rho = @view ρi[i, j, k, :]
for n = 1:Nspecs
@inbounds sc[n] = rho[n]/thermo.mw[n] * 1e-6
end
vproductionRate_Jac(wdot, sc, Arate, T, thermo, react)
# I - AⁿΔt
for l = 1:Nspecs
for n = 1:Nspecs
@inbounds A1[n, l] = (n == l ? 1.0 : 0.0) -
Arate[n, l] * thermo.mw[n] / thermo.mw[l] * dt
end
end
for n = 1:Nspecs
@inbounds Δρ[n] = wdot[n] * thermo.mw[n] * 1e6 * dt
end
# solve(x, A, b): Ax=b
solve(Δρn, A1, Δρ)
Δei::Float64 = 0
for n = 1:Nspecs
@inbounds Δei += -thermo.coeffs_lo[n, 6] * Δρn[n] * thermo.Ru / thermo.mw[n]
@inbounds rho[n] += Δρn[n]
end
@inbounds U[i, j, k, 5] += Δei
# update primitives
@inbounds ρ = max(Q[i, j, k, 1], CUDA.eps(Float64))
∑ρ::Float64 = 0.0
for n = 1:Nspecs
@inbounds rho[n] = max(rho[n], 0.0)
@inbounds ∑ρ += rho[n]
end
for n = 1:Nspecs
@inbounds rho[n] *= ρ/∑ρ
end
# @inbounds rho[Nspecs] += ρ - ∑ρ
@inbounds ein = Q[i, j, k, 7]
ein += Δei
T = max(GetT(ein, rho, thermo), CUDA.eps(Float64))
p = max(Pmixture(T, rho, thermo), CUDA.eps(Float64))
@inbounds Q[i, j, k, 5] = p
@inbounds Q[i, j, k, 6] = T
@inbounds Q[i, j, k, 7] = ein
end
return
end
@inline function vproductionRate(wdot, sc, T, thermo, react)
gi_T = MVector{Nspecs, Float64}(undef)
k_f_s = MVector{Nreacs, Float64}(undef)
Kc_s = MVector{Nreacs, Float64}(undef)
lgT = log(T)
invT = 1.0 / T
@inbounds @fastmath for n = 1:Nreacs
k_f_s[n] = react.Arr[1,n] * exp(react.Arr[2,n] * lgT - react.Arr[3,n] * invT)
end
# compute the Gibbs free energy
gibbs(gi_T, T, lgT, invT, thermo)
RsT::Float64 = thermo.Ru / react.atm * 1e6 * T
for n = 1:Nreacs
Δgi::Float64 = 0
for m = 1:Nspecs
@inbounds Δgi += gi_T[m] * (react.vf[m, n]-react.vr[m, n])
end
@inbounds Kc_s[n] = RsT ^ react.sgm[n] * @fastmath(exp(Δgi))
end
for n = 1:Nreacs
@inbounds q_f = k_f_s[n]
@inbounds q_r = q_f / Kc_s[n]
for m = 1:Nspecs
@inbounds vf = react.vf[m, n]
@inbounds vr = react.vr[m, n]
if vf != 0
@inbounds q_f *= sc[m] ^ vf
end
if vr != 0
@inbounds q_r *= sc[m] ^ vr
end
end
mixture::Float64 = 0.0
# three body reaction
if react.reaction_type[n] == 2
for m = 1:Nspecs
@inbounds mixture += react.ef[m, n] * sc[m]
end
q_f *= mixture
q_r *= mixture
elseif react.reaction_type[n] == 3
for m = 1:Nspecs
@inbounds mixture += react.ef[m, n] * sc[m]
end
@inbounds @fastmath redP = mixture / k_f_s[n] * react.loP[1,n] * exp(react.loP[2,n] * lgT - react.loP[3,n] * invT)
@fastmath @fastmath logPred = log10(redP)
@inbounds A = react.Troe[1,n]
@inbounds @fastmath logFcent = log10((1-A)*exp(-T/react.Troe[2,n]) + A*exp(-T/react.Troe[3,n]) + exp(-react.Troe[4,n]*invT))
troe_c = -0.4 - 0.67 * logFcent
troe_n = 0.75 - 1.27 * logFcent
troe = (troe_c + logPred) / (troe_n - 0.14 * (troe_c + logPred))
F_troe = 10.0 ^ (logFcent / (1.0 + troe * troe))
k_1 = (redP / (1.0 + redP)) * F_troe
q_f *= k_1
q_r *= k_1
end
for m = 1:Nspecs
@inbounds wdot[m] += (q_f - q_r) * (react.vr[m, n] - react.vf[m, n])
end
end
return
end
@inline function vproductionRate_Jac(wdot, sc, Arate, T, thermo, react)
gi_T = MVector{Nspecs, Float64}(undef)
k_f_s = MVector{Nreacs, Float64}(undef)
Kc_s = MVector{Nreacs, Float64}(undef)
lgT = log(T)
invT = 1.0 / T
@inbounds @fastmath for n = 1:Nreacs
k_f_s[n] = react.Arr[1,n] * exp(react.Arr[2,n] * lgT - react.Arr[3,n] * invT)
end
# compute the Gibbs free energy
gibbs(gi_T, T, lgT, invT, thermo)
RsT::Float64 = thermo.Ru / react.atm * 1e6 * T
for n = 1:Nreacs
Δgi::Float64 = 0
for m = 1:Nspecs
@inbounds Δgi += gi_T[m] * (react.vf[m, n]-react.vr[m, n])
end
@inbounds Kc_s[n] = RsT ^ react.sgm[n] * @fastmath(exp(Δgi))
end
for n = 1:Nreacs
@inbounds q_f = k_f_s[n]
@inbounds q_r = q_f / Kc_s[n]
for m = 1:Nspecs
@inbounds vf = react.vf[m, n]
@inbounds vr = react.vr[m, n]
if vf != 0
@inbounds q_f *= sc[m] ^ vf
end
if vr != 0
@inbounds q_r *= sc[m] ^ vr
end
end
mixture::Float64 = 0.0
# three body reaction
if react.reaction_type[n] == 2
for m = 1:Nspecs
@inbounds mixture += react.ef[m, n] * sc[m]
end
q_f *= mixture
q_r *= mixture
elseif react.reaction_type[n] == 3
for m = 1:Nspecs
@inbounds mixture += react.ef[m, n] * sc[m]
end
@inbounds @fastmath redP = mixture / k_f_s[n] * react.loP[1,n] * exp(react.loP[2,n] * lgT - react.loP[3,n] * invT)
@fastmath logPred = log10(redP)
@inbounds A = react.Troe[1,n]
@inbounds @fastmath logFcent = log10((1-A)*exp(-T/react.Troe[2,n]) + A*exp(-T/react.Troe[3,n]) + exp(-react.Troe[4,n]*invT))
troe_c = -0.4 - 0.67 * logFcent
troe_n = 0.75 - 1.27 * logFcent
troe = (troe_c + logPred) / (troe_n - 0.14 * (troe_c + logPred))
F_troe = 10.0 ^ (logFcent / (1.0 + troe * troe))
k_1 = (redP / (1.0 + redP)) * F_troe
q_f *= k_1
q_r *= k_1
end
for m = 1:Nspecs
@inbounds wdot[m] += (q_f - q_r) * (react.vr[m, n] - react.vf[m, n])
@inbounds invsc::Float64 = 1/(sc[m] + eps(Float64))
@inbounds Awf = react.vf[m, n] * q_f * invsc
@inbounds Awr = react.vr[m, n] * q_r * invsc
for l = 1:Nspecs
@inbounds Arate[l, m] += (Awf - Awr) * (react.vr[l, n] - react.vf[l, n])
end
end
end
return
end
# Solve Ax = b with Gauss Elimination
@inline function solve(x, a, b)
@inbounds for k = 1:Nspecs-1
# find main element
fmax = abs(a[k,k])
kk = k
@inbounds for i = k+1:Nspecs
absa = abs(a[i, k])
if absa > fmax
fmax = absa
kk = i
end
end
# exchange line
@inbounds for j = k:Nspecs
t = a[k,j]
a[k,j] = a[kk,j]
a[kk,j] = t
end
t = b[k]
b[k] = b[kk]
b[kk] = t
# Elimination
@inbounds for i = k+1:Nspecs
f = -a[i,k]/a[k,k]
@inbounds for j = 1:Nspecs
a[i,j] += f*a[k,j]
end
b[i] += f*b[k]
end
end
# get x
@inbounds x[Nspecs] = b[Nspecs]/a[Nspecs,Nspecs]
@inbounds for i = Nspecs-1:-1:1
x[i] = b[i]
@inbounds for j = i+1:Nspecs
x[i] -= a[i,j]*x[j]
end
x[i] /= a[i,i]
end
end
# column major
function initReact(mech)
ct = pyimport("cantera")
gas = ct.Solution(mech)
atm = ct.one_atm
spec_names = gas.species_names
reactant_stoich::Matrix{Int64} = gas.reactant_stoich_coeffs3
product_stoich::Matrix{Int64} = gas.product_stoich_coeffs3
reaction_type = zeros(Int64, Nreacs)
delta_order = zeros(Int64, Nreacs)
Arrhenius_rate = zeros(Float64, 3, Nreacs)
low_rate = zeros(Float64, 3, Nreacs)
Troe_coeffs = zeros(Float64, 4, Nreacs)
efficiencies = zeros(Float64, Nspecs, Nreacs)
for j = 1:Nreacs
reaction_i = gas.reaction(j-1)
if reaction_i.reaction_type == "Arrhenius"
order = sum(reactant_stoich[:,j])
reaction_type[j] = 1
Arrhenius_rate[1, j] = reaction_i.rate.pre_exponential_factor * 1e3 ^ (order-1) # A, [m, mol, s]
Arrhenius_rate[2, j] = reaction_i.rate.temperature_exponent # b
Arrhenius_rate[3, j] = reaction_i.rate.activation_energy/ct.gas_constant # E, K
elseif reaction_i.reaction_type == "three-body-Arrhenius"
order = sum(reactant_stoich[:,j]) + 1
reaction_type[j] = 2
for i = 1:Nspecs
efficiencies[i, j] = reaction_i.third_body.efficiency(spec_names[i])
end
Arrhenius_rate[1, j] = reaction_i.rate.pre_exponential_factor * 1e3 ^ (order-1) # A, [m, mol, s]
Arrhenius_rate[2, j] = reaction_i.rate.temperature_exponent # b
Arrhenius_rate[3, j] = reaction_i.rate.activation_energy/ct.gas_constant # E, K
elseif reaction_i.reaction_type == "falloff-Troe"
order = sum(reactant_stoich[:,j])
reaction_type[j] = 3
for i = 1:Nspecs
efficiencies[i, j] = reaction_i.third_body.efficiency(spec_names[i])
end
Arrhenius_rate[1, j] = reaction_i.rate.high_rate.pre_exponential_factor * 1e3 ^ (order-1) # A, [m, mol, s]
Arrhenius_rate[2, j] = reaction_i.rate.high_rate.temperature_exponent # b
Arrhenius_rate[3, j] = reaction_i.rate.high_rate.activation_energy/ct.gas_constant # E, K
low_rate[1, j] = reaction_i.rate.low_rate.pre_exponential_factor * 1e3 ^ (order) # A, [m, mol, s]
low_rate[2, j] = reaction_i.rate.low_rate.temperature_exponent # b
low_rate[3, j] = reaction_i.rate.low_rate.activation_energy/ct.gas_constant # E, K
len = length(reaction_i.rate.falloff_coeffs)
if len == 3
Troe_coeffs[1:3, j] = reaction_i.rate.falloff_coeffs
Troe_coeffs[4, j] = 1e30
elseif len == 4
Troe_coeffs[:, j] = reaction_i.rate.falloff_coeffs
else
error("Not correct Troe coefficients in reaction $j")
end
else
error("Not supported reaction type of reaction $j")
end
d_order::Int64 = 0
for i = 1:Nspecs
d_order += reactant_stoich[i,j] - product_stoich[i,j]
end
delta_order[j] = d_order
end
react = reactionProperty(atm, CuArray(reaction_type), CuArray(delta_order),
CuArray(reactant_stoich), CuArray(product_stoich),
CuArray(Arrhenius_rate), CuArray(efficiencies),
CuArray(low_rate), CuArray(Troe_coeffs))
return react
end