Add boundary condition input and update reactor configuration handling
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
volume: { value: 0., required: true },
|
||||
length: { value: 0.},
|
||||
resolution_L: { value: 0.},
|
||||
boundary_condition: {value: "Generalised"},
|
||||
n_inlets: { value: 1, required: true},
|
||||
kla: { value: null },
|
||||
S_O_init: { value: 0., required: true },
|
||||
@@ -75,6 +76,18 @@
|
||||
$(".PFR").show();
|
||||
}
|
||||
});
|
||||
$("#node-input-boundary_condition").typedInput({
|
||||
types: [
|
||||
{
|
||||
value: "Generalised",
|
||||
options: [
|
||||
{ value: "Generalised", label: "Generalised"},
|
||||
{ value: "Diriclet", label: "Diriclet"},
|
||||
{ value: "Danckwerts", label: "Danckwerts"}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
// Set initial visibility on dialog open
|
||||
const initialType = $("#node-input-reactor_type").typedInput("value");
|
||||
if (initialType === "CSTR") {
|
||||
@@ -117,6 +130,10 @@
|
||||
<div class="form-row PFR">
|
||||
<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>
|
||||
<div class="form-row">
|
||||
<label for="node-input-n_inlets"><i class="fa fa-tag"></i> Number of inlets</label>
|
||||
|
||||
@@ -70,6 +70,7 @@ class nodeClass {
|
||||
volume: parseFloat(uiConfig.volume),
|
||||
length: parseFloat(uiConfig.length),
|
||||
resolution_L: parseInt(uiConfig.resolution_L),
|
||||
boundary_condition: uiConfig.boundary_condition,
|
||||
n_inlets: parseInt(uiConfig.n_inlets),
|
||||
kla: parseFloat(uiConfig.kla),
|
||||
initialState: [
|
||||
|
||||
@@ -10,7 +10,7 @@ const math = create(all, config);
|
||||
|
||||
const S_O_INDEX = 0;
|
||||
const NUM_SPECIES = 13;
|
||||
const DEBUG = false;
|
||||
const DEBUG = true;
|
||||
|
||||
class Reactor {
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ class Reactor {
|
||||
|
||||
this.currentTime = Date.now(); // milliseconds since epoch [ms]
|
||||
this.timeStep = 1 / (24*60*15); // time step [d]
|
||||
this.speedUpFactor = 60; // speed up factor for simulation, 60 means 1 minute per simulated second
|
||||
this.speedUpFactor = 1; // speed up factor for simulation, 60 means 1 minute per simulated second
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,6 +149,8 @@ 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.state = Array.from(Array(this.n_x), () => config.initialState.slice())
|
||||
|
||||
// console.log("Initial State: ")
|
||||
@@ -178,6 +180,7 @@ class Reactor_PFR extends Reactor {
|
||||
set setInfluent(input) {
|
||||
super.setInfluent = input;
|
||||
if(DEBUG) {
|
||||
console.log("Inlet state max " + math.max(this.state[0]))
|
||||
console.log("Pe total " + this.length*math.sum(this.Fs)/(this.D*this.A));
|
||||
console.log("Pe local " + this.d_x*math.sum(this.Fs)/(this.D*this.A));
|
||||
console.log("Co ad " + math.sum(this.Fs)*this.timeStep/(this.A*this.d_x));
|
||||
@@ -205,9 +208,23 @@ 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 "Diriclet":
|
||||
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);
|
||||
const BC_dispersion = math.multiply((1 - (1 + 4*residence_time/Pe)^0.5) / (Pe*this.d_x), [BC_gradient], state)[0];
|
||||
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];
|
||||
state[0] = math.add(BC_C_in, BC_dispersion).map(val => val < 0 ? 0 : val);
|
||||
} else { // Neumann BC (no flux)
|
||||
state[0] = state[1];
|
||||
|
||||
Reference in New Issue
Block a user