Compare commits
6 Commits
boundary-c
...
6de4f9ec3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6de4f9ec3e | ||
|
|
7b38c2f51a | ||
|
|
018215934e | ||
|
|
3a820df7f2 | ||
|
|
670c4deacb | ||
| 442ddc60ed |
@@ -32,6 +32,7 @@ class Reactor {
|
|||||||
|
|
||||||
this.upstreamReactor = null;
|
this.upstreamReactor = null;
|
||||||
this.downstreamReactor = null;
|
this.downstreamReactor = null;
|
||||||
|
this.returnPump = null;
|
||||||
|
|
||||||
this.asm = new ASM3();
|
this.asm = new ASM3();
|
||||||
|
|
||||||
@@ -72,10 +73,17 @@ class Reactor {
|
|||||||
* @returns {object} Effluent data object (msg), defaults to inlet 0.
|
* @returns {object} Effluent data object (msg), defaults to inlet 0.
|
||||||
*/
|
*/
|
||||||
get getEffluent() { // getter for Effluent, defaults to inlet 0
|
get getEffluent() { // getter for Effluent, defaults to inlet 0
|
||||||
if (isArray(this.state.at(-1))) {
|
const Cs = isArray(this.state.at(-1)) ? this.state.at(-1) : this.state;
|
||||||
return { topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: this.state.at(-1) }, timestamp: this.currentTime };
|
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();
|
||||||
|
// constrain flow to prevent negatives
|
||||||
|
const F_main = Math.max(effluent[0].payload.F - recirculationFlow, 0);
|
||||||
|
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_sidestream, C: Cs }, timestamp: this.currentTime });
|
||||||
}
|
}
|
||||||
return { topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: this.state }, timestamp: this.currentTime };
|
return effluent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,13 +113,17 @@ class Reactor {
|
|||||||
registerChild(child, softwareType) {
|
registerChild(child, softwareType) {
|
||||||
switch (softwareType) {
|
switch (softwareType) {
|
||||||
case "measurement":
|
case "measurement":
|
||||||
this.logger.debug(`Registering measurement child.`);
|
this.logger.debug(`Registering measurement child...`);
|
||||||
this._connectMeasurement(child);
|
this._connectMeasurement(child);
|
||||||
break;
|
break;
|
||||||
case "reactor":
|
case "reactor":
|
||||||
this.logger.debug(`Registering reactor child.`);
|
this.logger.debug(`Registering reactor child...`);
|
||||||
this._connectReactor(child);
|
this._connectReactor(child);
|
||||||
break;
|
break;
|
||||||
|
case "machine":
|
||||||
|
this.logger.debug(`Registering rotating machine child...`);
|
||||||
|
this._connectRotatingMachine(child);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this.logger.error(`Unrecognized softwareType: ${softwareType}`);
|
this.logger.error(`Unrecognized softwareType: ${softwareType}`);
|
||||||
@@ -150,7 +162,7 @@ class Reactor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reactorChild.functionality.positionVsParent != "upstream") {
|
if (reactorChild.config.functionality.positionVsParent != "upstream") {
|
||||||
this.logger.warn("Reactor children of reactors should always be upstream.");
|
this.logger.warn("Reactor children of reactors should always be upstream.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +170,7 @@ class Reactor {
|
|||||||
this.logger.warn("Significant grid sizing discrepancies between adjacent reactors! Change resolutions to match reactors grid step, or implement boundary value interpolation.");
|
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
|
||||||
this.upstreamReactor = reactorChild;
|
this.upstreamReactor = reactorChild;
|
||||||
reactorChild.downstreamReactor = this;
|
reactorChild.downstreamReactor = this;
|
||||||
|
|
||||||
@@ -167,6 +180,16 @@ class Reactor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_connectRotatingMachine(rotatingMachineChild) {
|
||||||
|
if (!rotatingMachineChild) {
|
||||||
|
this.logger.warn("Invalid rotating machine provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotatingMachineChild.config.functionality.positionVsParent == "downstream") {
|
||||||
|
this.returnPump = rotatingMachineChild;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_updateMeasurement(measurementType, value, position, context) {
|
_updateMeasurement(measurementType, value, position, context) {
|
||||||
this.logger.debug(`---------------------- updating ${measurementType} ------------------ `);
|
this.logger.debug(`---------------------- updating ${measurementType} ------------------ `);
|
||||||
@@ -190,7 +213,7 @@ class Reactor {
|
|||||||
const day2ms = 1000 * 60 * 60 * 24;
|
const day2ms = 1000 * 60 * 60 * 24;
|
||||||
|
|
||||||
if (this.upstreamReactor) {
|
if (this.upstreamReactor) {
|
||||||
this.setInfluent = this.upstreamReactor.getEffluent;
|
this.setInfluent = this.upstreamReactor.getEffluent[0]; // grab main effluent upstream reactor
|
||||||
}
|
}
|
||||||
|
|
||||||
let n_iter = Math.floor(this.speedUpFactor * (newTime-this.currentTime) / (this.timeStep*day2ms));
|
let n_iter = Math.floor(this.speedUpFactor * (newTime-this.currentTime) / (this.timeStep*day2ms));
|
||||||
|
|||||||
Reference in New Issue
Block a user