From 993482f8c042c1c495828ed68a22fd6e2e93e65e Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Mon, 29 Sep 2025 16:58:46 +0200
Subject: [PATCH] Deal with mulitple parents and set downstreamReactor for
improved boundary conditions
---
src/specificClass.js | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/specificClass.js b/src/specificClass.js
index 4d329b6..83829d8 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -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];