Fix recirculation flow calculation to prevent negative flow rates and improve variable naming
This commit is contained in:
@@ -76,11 +76,12 @@ class Reactor {
|
||||
const Cs = isArray(this.state.at(-1)) ? this.state.at(-1) : this.state;
|
||||
const effluent = [{ topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: Cs }, timestamp: this.currentTime }];
|
||||
if (this.returnPump) {
|
||||
const recirculationFlow = this.returnPump.measurements.type("flow").variant("measured").position("atequipment").getCurrentValue();
|
||||
const recirculationFlow = this.returnPump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue();
|
||||
// constrain flow to prevent negatives
|
||||
const F_main = Math.max(effluent[0].payload.F - recirculationFlow, 0);
|
||||
const F_side_constrained = effluent[0].payload.F < recirculationFlow ? effluent[0].payload.F : recirculationFlow;
|
||||
const F_sidestream = effluent[0].payload.F < recirculationFlow ? effluent[0].payload.F : recirculationFlow;
|
||||
effluent[0].payload.F = F_main;
|
||||
effluent.push({ topic: "Fluent", payload: { inlet: 1, F: F_side_constrained, C: Cs }, timestamp: this.currentTime });
|
||||
effluent.push({ topic: "Fluent", payload: { inlet: 1, F: F_sidestream, C: Cs }, timestamp: this.currentTime });
|
||||
}
|
||||
return effluent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user