Fix CSTR PFR distinctions
This commit is contained in:
@@ -164,10 +164,6 @@ class Reactor {
|
|||||||
this.logger.warn("Reactor children of reactors should always be upstream.");
|
this.logger.warn("Reactor children of reactors should always be upstream.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (math.abs(reactorChild.d_x - this.d_x) / this.d_x < 0.025) {
|
|
||||||
this.logger.warn("Significant grid sizing discrepancies between adjacent reactors! Change resolutions to match reactors grid step, or implement boundary value interpolation.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// set upstream and downstream reactor variable in current and child nodes respectively for easy access
|
// set upstream and downstream reactor variable in current and child nodes respectively for easy access
|
||||||
this.upstreamReactor = reactorChild;
|
this.upstreamReactor = reactorChild;
|
||||||
reactorChild.downstreamReactor = this;
|
reactorChild.downstreamReactor = this;
|
||||||
@@ -245,6 +241,23 @@ class Reactor_CSTR extends Reactor {
|
|||||||
this.state = config.initialState;
|
this.state = config.initialState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateMeasurement(measurementType, value, position, context) {
|
||||||
|
|
||||||
|
switch(measurementType) {
|
||||||
|
case "quantity (oxygen)":
|
||||||
|
this.state[ASM_CONSTANTS.S_O_INDEX] = value;
|
||||||
|
break;
|
||||||
|
case "quantity (ammonium)":
|
||||||
|
this.state[ASM_CONSTANTS.S_NH_INDEX] = value;
|
||||||
|
break;
|
||||||
|
case "quantity (nox)":
|
||||||
|
this.state[ASM_CONSTANTS.S_NO_INDEX] = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
super._updateMeasurement(measurementType, value, position, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tick the reactor state using the forward Euler method.
|
* Tick the reactor state using the forward Euler method.
|
||||||
* @param {number} time_step - Time step for the simulation [d].
|
* @param {number} time_step - Time step for the simulation [d].
|
||||||
@@ -255,7 +268,7 @@ class Reactor_CSTR extends Reactor {
|
|||||||
const outflow = math.multiply(-1 * math.sum(this.Fs) / this.volume, this.state);
|
const outflow = math.multiply(-1 * math.sum(this.Fs) / this.volume, this.state);
|
||||||
const reaction = this.asm.compute_dC(this.state, this.temperature);
|
const reaction = this.asm.compute_dC(this.state, this.temperature);
|
||||||
const transfer = Array(ASM_CONSTANTS.NUM_SPECIES).fill(0.0);
|
const transfer = Array(ASM_CONSTANTS.NUM_SPECIES).fill(0.0);
|
||||||
transfer[ASM_CONSTANTS.S_O_INDEX] = isNaN(this.kla) ? this.OTR : this._calcOTR(this.state[S_O_INDEX], this.temperature); // calculate OTR if kla is not NaN, otherwise use externaly calculated OTR
|
transfer[ASM_CONSTANTS.S_O_INDEX] = isNaN(this.kla) ? this.OTR : this._calcOTR(this.state[ASM_CONSTANTS.S_O_INDEX], this.temperature); // calculate OTR if kla is not NaN, otherwise use externaly calculated OTR
|
||||||
|
|
||||||
const dC_total = math.multiply(math.add(inflow, outflow, reaction, transfer), time_step)
|
const dC_total = math.multiply(math.add(inflow, outflow, reaction, transfer), time_step)
|
||||||
this.state = this._arrayClip2Zero(math.add(this.state, dC_total)); // clip value element-wise to avoid negative concentrations
|
this.state = this._arrayClip2Zero(math.add(this.state, dC_total)); // clip value element-wise to avoid negative concentrations
|
||||||
@@ -304,6 +317,13 @@ class Reactor_PFR extends Reactor {
|
|||||||
this.D = this._constrainDispersion(input.payload);
|
this.D = this._constrainDispersion(input.payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_connectReactor(reactorChild) {
|
||||||
|
if (math.abs(reactorChild.d_x - this.d_x) / this.d_x < 0.025) {
|
||||||
|
this.logger.warn("Significant grid sizing discrepancies between adjacent reactors! Change resolutions to match reactors grid step, or implement boundary value interpolation.");
|
||||||
|
}
|
||||||
|
super._connectReactor(reactorChild);
|
||||||
|
}
|
||||||
|
|
||||||
updateState(newTime) {
|
updateState(newTime) {
|
||||||
super.updateState(newTime);
|
super.updateState(newTime);
|
||||||
// let Pe_local = this.d_x*math.sum(this.Fs)/(this.D*this.A)
|
// let Pe_local = this.d_x*math.sum(this.Fs)/(this.D*this.A)
|
||||||
|
|||||||
Reference in New Issue
Block a user