Add boundary condition input and update reactor configuration handling
This commit is contained in:
@@ -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 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];
|
||||
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);
|
||||
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