← Module 2 · Modeling Assignment M2 (OpenHydroQual)

Reactions in a batch reactor: first-order decay, a series network, and three rate laws

An illustrated, step-by-step worked example · about 60 minutes · the latest OpenHydroQual · uses Module 2, Sections 1, 2, 5 and 6, and the OpenHydroQual basics of Modeling Assignment M1

What you will build

A closed, completely mixed batch reactor: one Reactor block with no inflow and no links, so the only thing that changes a concentration is reaction (Module 2, Section 1: \(dC/dt = r\)). You will add a first-order reaction A → B, extend it to the series network A → B → C, and then race three substances that start at the same rate but follow different rate laws.

StageWhat changesWhat to look forSaved as
1A → B, first order, \(k_1 = 0.3\) d⁻¹\(A = 100e^{-0.3t}\), \(t_{1/2} = 2.31\) d, \(A + B = 100\)M2_stage1_first_order.ohq
2+ C and B → C, \(k_2 = 0.1\) d⁻¹B peaks at \(t_{\max} = 5.49\) d at 57.7 g/m³; \(A + B + C = 100\)M2_stage2_series.ohq
3three substances: first order, second order, saturatingsame initial rate (5 g/m³/d), very different tailsM2_stage3_rate_laws.ohq

The system

ItemValue
Batch reactorone Reactor block, \(V = 1\) m³, no inflow, no links (any volume gives the same concentrations)
Stages 1–2\(A_0 = 100\) g/m³, \(B_0 = C_0 = 0\); \(k_1 = 0.3\) d⁻¹, \(k_2 = 0.1\) d⁻¹
Stage 3each substance starts at 10 g/m³; first order \(k = 0.5\) d⁻¹; second order \(k = 0.05\) m³/(g·d); saturating \(k_{\max} = 10\) g/(m³·d), \(K = 10\) g/m³
Simulation0–20 days (Stage 1), 0–40 days (Stage 2), 0–15 days (Stage 3)

OpenHydroQual adds to every block's balance a reaction term \(\nu\,r\,V\) for each reaction, where \(r\) is your rate expression (per unit volume, g/m³/day) and \(\nu\) the stoichiometric constant of that constituent (negative for a reactant, positive for a product). This is exactly the bookkeeping of Module 2, Sections 1 and 6.

1New model, plugin and two constituents

Start a new model and load the Mass Transfer plugin (M1, Step 1). Create two Chemical constituents (M1, Step 2) and rename them A and B. Leave the diffusion coefficient and dispersivity at 0.

Add Objects, Chemistry, Chemical constituent
As in M1: 1 Add Objects → 2 Chemistry → 3 Chemical constituent. Notice two more items in the same menu, Chemical reaction and Reaction Parameter: you will use them in Steps 3–4.
Object Browser with constituents A and B
1 The two constituents, A and B, under Constituents in the Object Browser.

2The batch: a Reactor with no flow

Add one Reactor block (M1, Step 3). This time it gets no inflow and no links: nothing enters or leaves, so it is a batch.

Blocks toolbar: Reactor icon
1 The Reactor icon, as in M1.
Batch properties
Properties of the batch.
PropertyValueMeaning
1A:Concentration100 g/m³initial concentration of A, \(A_0\)
2B:Concentration0 g/m³no B at the start
3Initial Storage1 m³the volume; with no flow it never changes
4Constant Inflow0 m³/dayno flow: a closed batch
5NameBatch

3A rate constant: the Reaction Parameter

Rate constants are stored as Reaction Parameters, named values that any reaction can use. Choose Add Objects → Chemistry → Reaction Parameter. A new parameter appears under Reaction Parameters in the Object Browser.

Add Objects, Chemistry menu with Chemical reaction and Reaction Parameter
1 Add Objects → 2 Chemistry → 3 Reaction Parameter (now) and 4 Chemical reaction (Step 4).
Reaction parameter properties
The parameter's properties: 1 Arrhenius temperature correction factor 1 (no temperature effect), 2 Value 0.3, 3 Name k1. Leave the reference temperature and the temperature time series as they are.

The "Arrhenius temperature correction factor" is the \(\theta\) of Module 2, Section 4: OpenHydroQual computes the parameter as Value × θ(T − Tref). With θ = 1 the temperature does not matter. The units of the value are whatever your rate expression needs: here 1/day, because the expression will be \(k_1A\).

4The reaction A → B

Choose Add Objects → Chemistry → Chemical reaction. A reaction has a rate expression, which is \(|r|\) of Module 2 in g/m³/day, and one stoichiometric constant for every constituent. OpenHydroQual multiplies the rate by each constant: −1 means "consumed at the rate", +1 "produced at the rate", 0 "not involved".

Reaction properties for A to B
Properties of the reaction.
PropertyValueMeaning
1A:Stoichiometric Constant−1A is consumed: \(dA/dt = -k_1A\)
2B:Stoichiometric Constant1one B is made per A: \(dB/dt = +k_1A\)
3NameA_to_Bno spaces
4Rate Expressionk1*Athe first-order rate law, using the parameter and the constituent by name
Rate Expression value open for editing in the property panel
Double-clicking the Rate Expression value opens it for editing in place. 1 Type k1*A and press Enter. (The saved file shows it in parentheses, (k1*A); that is the same expression.)
Why is the rate positive and the stoichiometric constant negative?
The rate expression is the rate of the reaction, \(r_{\text{rxn}}\) of Module 2, Section 1, which is always positive. The sign and size of each species' change comes from its stoichiometric constant. This is what lets one reaction change several constituents in fixed proportions; Module 3 uses it for a reaction in which 0.14 g of oxygen is consumed per gram of iron.

5Simulation time and time step

As in M1, Step 6: General Settings → Simulation end time 20 days; Solver Settings → initial time-step 0.01 and maximum allowable time-step increase factor 5.

Solver settings
Solver Settings, as in M1: 1 initial time-step 0.01, 2 maximum time-step increase factor 5.

Stage 1First-order decay, A → B

Save as M2_stage1_first_order.ohq and press Run Model.

Run Model button
1 Run Model, as in M1.
Right-click Batch, Results, A:Concentration
Right-click Batch → 1 Results → 2 A:Concentration. Repeat for B:Concentration.
Concentration of A falling exponentially
A falls along \(100e^{-0.3t}\): 54.9 g/m³ at 2 days, 22.3 at 5, 4.98 at 10. It passes 50 g/m³ at the half-life, \(\ln 2/0.3 = 2.31\) days.
Concentration of B rising toward 100
B is the mirror image: every gram of A that reacts appears as B, so \(B = 100 - A\).

Check the half-life yourself: read the time at which A crosses 50, 25 and 12.5 g/m³. For a first-order reaction the three intervals are equal (Module 2, Section 2).

Stage 2A series network, A → B → C

Save a copy as M2_stage2_series.ohq. Add:

  1. a third constituent, C (initial concentration 0 in Batch);
  2. a second Reaction Parameter, k2 = 0.1;
  3. a second reaction, B_to_C, with rate expression k2*B and stoichiometric constants A = 0, B = −1, C = 1.

Check that the first reaction now has C:Stoichiometric Constant = 0 (new constituents start at 0 in existing reactions). Set the end time to 40 days, save and run.

Object Browser for stage 2
The Object Browser: 1 constituents A, B, C; 2 reactions A_to_B and B_to_C; 3 reaction parameters k1 and k2.
Properties of reaction B to C
Reaction B_to_C: 1 A 0, 2 B −1, 3 C 1, 4 Rate Expression k2*B.

Before you look at the results, predict the peak with Module 2, Section 6:

\[ t_{\max} = \frac{\ln(k_1/k_2)}{k_1 - k_2} = \frac{\ln 3}{0.2} = 5.49\ \text{days}, \qquad B_{\max} = 100\left(\frac{0.1}{0.3}\right)^{0.1/0.2} = 57.7\ \text{g/m}^3 . \]
B rises to a peak and falls
B rises while A supplies it faster than it decays, peaks near 5.5 days at about 57.5 g/m³, then decays at the slower rate \(k_2\).
C rising with a delay
C starts slowly (it needs B first): an S-shaped curve. A + B + C stays at 100 g/m³ at every time.

Stage 3Three rate laws, one starting rate

Start a new model (or save a copy and delete A, B, C and both reactions). Create three constituents named First, Second and Saturating, each starting at 10 g/m³ in Batch. Each is destroyed by its own rate law; none makes a product you need to track.

ReactionRate ExpressionStoichiometric constantsParametersInitial rate at 10 g/m³
first_orderk_first*FirstFirst −1, others 0k_first = 0.5 (1/d)0.5 × 10 = 5
second_orderk_second*Second^2Second −1, others 0k_second = 0.05 (m³/(g·d))0.05 × 10² = 5
saturatingkmax*Saturating/(K_half+Saturating)Saturating −1, others 0kmax = 10 (g/(m³·d)), K_half = 10 (g/m³)10 × 10/20 = 5

All three start at 5 g/m³/day, so for the first few hours they are indistinguishable. Set the end time to 15 days, save and run.

Compare the three models on one plot. Right-click Batch → Results → First:Concentration; keep this plot window open. Open Second:Concentration the same way in a second window, right-click its chart → Copy curve, then right-click the chart of the first window → Paste. Close the second window and do the same for Saturating:Concentration. All three curves are now on one panel, each in its own colour.

Object Browser for stage 3
1 Three constituents, 2 three reactions, 3 four reaction parameters.
Properties of the saturating reaction
Reaction saturating: 1 Saturating:Stoichiometric Constant −1, 2 Rate Expression kmax*Saturating/(K_half+Saturating).
The three substances against time
First, Second and Saturating on one panel (First plotted, the other two pasted in). After 4 days: 1.35, 3.33 and 0.48 g/m³. The saturating law stays near its maximum rate while \(S\) is above \(K\), so it removes the substance fastest at first; once \(S \ll K\) it becomes first order with \(k = k_{\max}/K = 1\) d⁻¹, still faster than the first-order reaction. The second-order reaction slows down most, with the long tail of Module 2, Section 2.

Compare with the formulas of Module 2: \(10e^{-0.5t}\), \(10/(1 + 0.5t)\), and for the saturating law \(t = [10\ln(10/S) + (10 - S)]/10\), which you can evaluate at the model's concentrations.

Checkpoints

Read these from your own runs; small differences in the last digit are normal. Because of the time step (M1, Step 6), the model lags the formula slightly: it reacts a little more slowly, so its values sit about 0.5 % above the formula at day 2, and the gap grows as the concentration falls (about 1 % at day 5 and 2 % at day 10 in Stage 1).

StageQuantityModelFormula
1A at 2 / 5 / 10 days (g/m³)55.12 / 22.56 / 5.0954.88 / 22.31 / 4.98
1Time A reaches 50 g/m³ (days)2.332.31
1A + B (g/m³), all times100.00100
2B at 5 / 10 / 20 days (g/m³)57.25 / 47.68 / 20.0157.51 / 47.71 / 19.93
2Peak of B: time (d) and value (g/m³)5.53 / 57.505.49 / 57.74
2C at 10 / 20 days (g/m³)47.22 / 79.7347.31 / 79.82
3First / Second / Saturating at 2 days (g/m³)3.72 / 5.04 / 2.833.68 / 5.00 / 2.79
3First / Second / Saturating at 4 days (g/m³)1.39 / 3.36 / 0.501.35 / 3.33 / 0.48

Explore

Save a copy with File → Save as and change one thing at a time.

Troubleshooting

Nothing happens: A stays at 100.The rate expression refers to a name the model does not know yet (a typo, or a name that differs in upper/lower case), or A's stoichiometric constant is 0. Check both.
A rises instead of falling.The stoichiometric constant of A is +1; a reactant needs −1.
A + B is not constant.B's stoichiometric constant is not +1, or the block has a Constant Inflow or a link left over from M1.
In Stage 2, C never appears.C's stoichiometric constant in B_to_C is 0, or the rate expression is k2*A instead of k2*B.
The second-order curve looks first order.The expression must be k_second*Second^2 (or Second*Second), not k_second*Second*2.
The model values are a little above the formula.That is the time step (M1, Step 6): the model reacts slightly more slowly than the formula, and the relative gap grows as the concentration gets small. A difference of a percent or two is normal.

What to submit