Deal with mulitple parents and set downstreamReactor for improved boundary conditions
This commit is contained in:
@@ -27,7 +27,9 @@ class Reactor {
|
|||||||
this.measurements = new MeasurementContainer();
|
this.measurements = new MeasurementContainer();
|
||||||
this.upstreamReactor = null;
|
this.upstreamReactor = null;
|
||||||
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
||||||
this.parent = null; // Gets assigned via child registration
|
this.parent = []; // Gets assigned via child registration
|
||||||
|
|
||||||
|
this.upstreamReactor = null;
|
||||||
|
|
||||||
this.asm = new ASM3();
|
this.asm = new ASM3();
|
||||||
|
|
||||||
@@ -114,6 +116,10 @@ class Reactor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDownstreamReactor() {
|
||||||
|
this.downstreamReactor = this.parent.find((x) => x.config.functionality.softwareType == "reactor");
|
||||||
|
}
|
||||||
|
|
||||||
_connectMeasurement(measurementChild) {
|
_connectMeasurement(measurementChild) {
|
||||||
if (!measurementChild) {
|
if (!measurementChild) {
|
||||||
this.logger.warn("Invalid measurement provided.");
|
this.logger.warn("Invalid measurement provided.");
|
||||||
@@ -152,6 +158,7 @@ class Reactor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.upstreamReactor = reactorChild;
|
this.upstreamReactor = reactorChild;
|
||||||
|
reactorChild.setDownstreamReactor();
|
||||||
|
|
||||||
reactorChild.emitter.on("stateChange", (data) => {
|
reactorChild.emitter.on("stateChange", (data) => {
|
||||||
this.logger.debug(`State change of upstream reactor detected.`);
|
this.logger.debug(`State change of upstream reactor detected.`);
|
||||||
@@ -323,7 +330,7 @@ class Reactor_PFR extends Reactor {
|
|||||||
_updateMeasurement(measurementType, value, position, context) {
|
_updateMeasurement(measurementType, value, position, context) {
|
||||||
switch(measurementType) {
|
switch(measurementType) {
|
||||||
case "quantity (oxygen)":
|
case "quantity (oxygen)":
|
||||||
grid_pos = Math.round(position / this.config.length * this.n_x);
|
let grid_pos = Math.round(position / this.config.length * this.n_x);
|
||||||
this.state[grid_pos][S_O_INDEX] = value; // naive approach for reconciling measurements and simulation
|
this.state[grid_pos][S_O_INDEX] = value; // naive approach for reconciling measurements and simulation
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -350,9 +357,8 @@ class Reactor_PFR extends Reactor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const downstreamReactor = this.parent;
|
if (this.downstreamReactor) {
|
||||||
if (downstreamReactor) {
|
state[this.n_x-1] = this.downstreamReactor.state[0];
|
||||||
state[this.n_x-1] = downstreamReactor.state[0];
|
|
||||||
} else {
|
} else {
|
||||||
// Neumann BC (no flux)
|
// Neumann BC (no flux)
|
||||||
state[this.n_x-1] = state[this.n_x-2];
|
state[this.n_x-1] = state[this.n_x-2];
|
||||||
|
|||||||
Reference in New Issue
Block a user