Prevent negative values in reactor state

This commit is contained in:
2025-06-18 12:34:19 +02:00
parent 288cf905d1
commit 5bd094f4a6
2 changed files with 2 additions and 2 deletions

View File

@@ -19,7 +19,7 @@
X_H_init: { value: 30., required: true }, X_H_init: { value: 30., required: true },
X_STO_init: { value: 0., required: true }, X_STO_init: { value: 0., required: true },
X_A_init: { value: 0.001, required: true }, X_A_init: { value: 0.001, required: true },
X_TS_init: { value: 125., required: true } X_TS_init: { value: 125.0009, required: true }
}, },
inputs: 1, inputs: 1,
outputs: 1, outputs: 1,

View File

@@ -65,7 +65,7 @@ class Reactor_CSTR {
const dC_total = math.multiply(math.add(dC_in, dC_out, r, t_O), time_step); const dC_total = math.multiply(math.add(dC_in, dC_out, r, t_O), time_step);
this.state = math.add(this.state, dC_total); this.state = math.abs(math.add(this.state, dC_total)); // make sure that concentrations do not go negative
return this.state; return this.state;
} }
} }