Skip to content

Commit 302872b

Browse files
committed
bench: adding the pH neutralization tank model
1 parent eeab857 commit 302872b

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

‎benchmark/0_bench_setup.jl‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## -------------------------- linear CSTR model ----------------------------------
2+
13
Ts = 400.0
24
sys = [ tf(1.90,[1800.0,1]) tf(1.90,[1800.0,1]) tf(1.90,[1800.0,1]);
35
tf(-0.74,[800.0,1]) tf(0.74,[800.0,1]) tf(-0.74,[800.0,1]) ]
@@ -28,6 +30,7 @@ uop, yop, dop = [20, 20], [50, 30], [20]
2830
CSTR_model = setop!(LinModel(G, 2.0); uop, yop)
2931
CSTR_model_d = setop!(LinModel([G G[1:2, 2]], 2.0; i_d=[3]); uop, yop, dop)
3032

33+
## ------------------------ pendulum model -------------------------------------
3134
function f!(ẋ, x, u, _ , p)
3235
g, L, K, m = p
3336
θ, ω = x[1], x[2]
@@ -44,4 +47,33 @@ pendulum_p = p
4447
h2!(y, x, _ , _ ) = (y[1] = 180/π*x[1]; y[2]=x[2])
4548
nu, nx, ny = 1, 2, 2
4649
pendulum_model2 = NonLinModel(f!, h2!, Ts, nu, nx, ny; p)
47-
pendulum_p2 = p
50+
pendulum_p2 = p
51+
52+
# --------------------------- pH neutralization reactor model ----------------------------
53+
function fq_ph!(dx̂, res, x̂, a, u, d, p̂)
54+
c_Bin, Kw, Ka, V = p̂
55+
q_Ain, q_Bin = d[1], u[1]
56+
c_A, c_B = x̂[1], x̂[2]
57+
c_Ain = x̂[3]
58+
pH = a[1]
59+
q_out = q_Ain + q_Bin
60+
c_Aout = c_A
61+
c_Bout = c_B
62+
a_H = 10.0^(-pH)
63+
dx̂[1] = (60/V)*(q_Ain * c_Ain - q_out * c_Aout)
64+
dx̂[2] = (60/V)*(q_Bin * c_Bin - q_out * c_Bout)
65+
dx̂[3] = 0
66+
res[1] = a_H + c_B - (Kw / a_H) - (Ka * c_A / (Ka + a_H))
67+
return nothing
68+
end
69+
h_ph!(y, _ , a , _ , _ ) = (y .= a; nothing)
70+
p = [0.1, 1.0e-14, 1.75e-5, 1000.0]
71+
Ts = 0.5
72+
nu, nx, na, ny, nd = 1, 2+1, 1, 1, 1
73+
xs_0, as_0 = [0.025, 0.025, 0.1], [7]
74+
transcription = TrapezoidalCollocation()
75+
ph_model = NonLinModelDAE(
76+
fq_ph!, h_ph!, Ts, nu, nx, na, ny, nd; p, xs_0, as_0, transcription, unit="h"
77+
)
78+
ph_p = p
79+
ph_x_0 = [0.0, 0.0, 0.1]

0 commit comments

Comments
 (0)