Deal with mulitple parents and set downstreamReactor for improved boundary conditions

This commit is contained in:
2025-09-29 16:58:46 +02:00
parent 5f4ebdc2af
commit 993482f8c0

View File

@@ -27,7 +27,9 @@ class Reactor {
this.measurements = new MeasurementContainer();
this.upstreamReactor = null;
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();
@@ -114,6 +116,10 @@ class Reactor {
}
}
setDownstreamReactor() {
this.downstreamReactor = this.parent.find((x) => x.config.functionality.softwareType == "reactor");
}
_connectMeasurement(measurementChild) {
if (!measurementChild) {
this.logger.warn("Invalid measurement provided.");
@@ -152,6 +158,7 @@ class Reactor {
}
this.upstreamReactor = reactorChild;
reactorChild.setDownstreamReactor();
reactorChild.emitter.on("stateChange", (data) => {
this.logger.debug(`State change of upstream reactor detected.`);
@@ -323,7 +330,7 @@ class Reactor_PFR extends Reactor {
_updateMeasurement(measurementType, value, position, context) {
switch(measurementType) {
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
break;
default:
@@ -350,9 +357,8 @@ class Reactor_PFR extends Reactor {
}
}
const downstreamReactor = this.parent;
if (downstreamReactor) {
state[this.n_x-1] = downstreamReactor.state[0];
if (this.downstreamReactor) {
state[this.n_x-1] = this.downstreamReactor.state[0];
} else {
// Neumann BC (no flux)
state[this.n_x-1] = state[this.n_x-2];