Refactor boundary condition handling to use adjustable parameter alpha in advanced-reactor and specificClass

This commit is contained in:
2025-07-08 10:03:03 +02:00
parent 01318a2d3b
commit 5c03dddb79
3 changed files with 13 additions and 34 deletions

View File

@@ -8,7 +8,7 @@
volume: { value: 0., required: true },
length: { value: 0.},
resolution_L: { value: 0.},
boundary_condition: {value: "Generalised"},
alpha: {value: 0},
n_inlets: { value: 1, required: true},
kla: { value: null },
S_O_init: { value: 0., required: true },
@@ -76,17 +76,9 @@
$(".PFR").show();
}
});
$("#node-input-boundary_condition").typedInput({
types: [
{
value: "Generalised",
options: [
{ value: "Generalised", label: "Generalised"},
{ value: "Dirichlet", label: "Dirichlet"},
{ value: "Danckwerts", label: "Danckwerts"}
]
}
]
$("#node-input-alpha").typedInput({
type:"num",
types:["num"]
})
// Set initial visibility on dialog open
const initialType = $("#node-input-reactor_type").typedInput("value");
@@ -131,9 +123,12 @@
<label for="node-input-resolution_L"><i class="fa fa-tag"></i> Resolution</label>
<input type="text" id="node-input-resolution_L" placeholder="#">
</div>
<div class="form-row PFR">
<label for="node-input-boundary_condition"><i class="fa fa-tag"></i>Inlet boundary condition</label>
<input type="text" id="node-input-boundary_condition">
<div class="PFR">
<p> Inlet boundary condition parameter &alpha; (&alpha; = 0: Danckwerts BC / &alpha; = 1: Dirichlet BC) </p>
<div class="form-row">
<label for="node-input-alpha"><i class="fa fa-tag"></i>Adjustable parameter BC</label>
<input type="text" id="node-input-alpha">
</div>
</div>
<div class="form-row">
<label for="node-input-n_inlets"><i class="fa fa-tag"></i> Number of inlets</label>

View File

@@ -70,7 +70,7 @@ class nodeClass {
volume: parseFloat(uiConfig.volume),
length: parseFloat(uiConfig.length),
resolution_L: parseInt(uiConfig.resolution_L),
boundary_condition: uiConfig.boundary_condition,
alpha: parseFloat(uiConfig.alpha),
n_inlets: parseInt(uiConfig.n_inlets),
kla: parseFloat(uiConfig.kla),
initialState: [

View File

@@ -149,7 +149,7 @@ class Reactor_PFR extends Reactor {
this.d_x = this.length / this.n_x;
this.A = this.volume / this.length; // crosssectional area [m2]
this.BC = config.boundary_condition;
this.alpha = config.alpha;
this.state = Array.from(Array(this.n_x), () => config.initialState.slice())
@@ -208,23 +208,7 @@ class Reactor_PFR extends Reactor {
const BC_gradient = Array(this.n_x).fill(0);
BC_gradient[0] = -1;
BC_gradient[1] = 1;
let BC_term = 0;
switch(this.BC) {
case "Dirichlet":
BC_term = 0;
break;
case "Danckwerts":
BC_term = this.D*this.A / math.sum(this.Fs);
break;
case "Generalised":
let Pe = this.length * math.sum(this.Fs) / (this.D * this.A);
let residence_time = this.volume/math.sum(this.Fs);
BC_term = (1 - (1 + 4*residence_time/Pe)^0.5) / Pe
break;
default:
console.warn("Unknown boundary condition: " + this.BC);
}
const BC_dispersion = math.multiply(BC_term/this.d_x, [BC_gradient], state)[0];
const BC_dispersion = math.multiply((1 - this.alpha) * this.D*this.A / (math.sum(this.Fs) * this.d_x), [BC_gradient], state)[0];
state[0] = math.add(BC_C_in, BC_dispersion).map(val => val < 0 ? 0 : val);
} else { // Neumann BC (no flux)
state[0] = state[1];