Non-functioning prototype with partial rotating machine integration
This commit is contained in:
@@ -32,6 +32,7 @@ class Reactor {
|
||||
|
||||
this.upstreamReactor = null;
|
||||
this.downstreamReactor = null;
|
||||
this.returnPump = null;
|
||||
|
||||
this.asm = new ASM3();
|
||||
|
||||
@@ -72,10 +73,14 @@ class Reactor {
|
||||
* @returns {object} Effluent data object (msg), defaults to inlet 0.
|
||||
*/
|
||||
get getEffluent() { // getter for Effluent, defaults to inlet 0
|
||||
if (isArray(this.state.at(-1))) {
|
||||
return { topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: this.state.at(-1) }, timestamp: this.currentTime };
|
||||
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("atEquipement").getValue();
|
||||
effluent[0].F -= recirculationFlow;
|
||||
effluent.push({ topic: "Fluent", payload: { inlet: 1, F: recirculationFlow, 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 +110,17 @@ class Reactor {
|
||||
registerChild(child, softwareType) {
|
||||
switch (softwareType) {
|
||||
case "measurement":
|
||||
this.logger.debug(`Registering measurement child.`);
|
||||
this.logger.debug(`Registering measurement child...`);
|
||||
this._connectMeasurement(child);
|
||||
break;
|
||||
case "reactor":
|
||||
this.logger.debug(`Registering reactor child.`);
|
||||
this.logger.debug(`Registering reactor child...`);
|
||||
this._connectReactor(child);
|
||||
break;
|
||||
case "machine":
|
||||
this.logger.debug(`Registering rotating machine child...`);
|
||||
this._connectRotatingMachine(child);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.logger.error(`Unrecognized softwareType: ${softwareType}`);
|
||||
@@ -150,7 +159,7 @@ class Reactor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (reactorChild.functionality.positionVsParent != "upstream") {
|
||||
if (reactorChild.config.functionality.positionVsParent != "upstream") {
|
||||
this.logger.warn("Reactor children of reactors should always be upstream.");
|
||||
}
|
||||
|
||||
@@ -158,6 +167,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.");
|
||||
}
|
||||
|
||||
// set upstream and downstream reactor variable in current and child nodes respectively for easy access
|
||||
this.upstreamReactor = reactorChild;
|
||||
reactorChild.downstreamReactor = this;
|
||||
|
||||
@@ -167,6 +177,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) {
|
||||
this.logger.debug(`---------------------- updating ${measurementType} ------------------ `);
|
||||
@@ -190,7 +210,7 @@ class Reactor {
|
||||
const day2ms = 1000 * 60 * 60 * 24;
|
||||
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user