Add additional ASM constants, add other sensor handling, fix bug in kla model
This commit is contained in:
@@ -2,6 +2,8 @@ const math = require('mathjs');
|
|||||||
|
|
||||||
const ASM_CONSTANTS = {
|
const ASM_CONSTANTS = {
|
||||||
S_O_INDEX: 0,
|
S_O_INDEX: 0,
|
||||||
|
S_NH_INDEX: 3,
|
||||||
|
S_NO_INDEX: 5,
|
||||||
NUM_SPECIES: 13
|
NUM_SPECIES: 13
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ const math = require('mathjs');
|
|||||||
|
|
||||||
const ASM_CONSTANTS = {
|
const ASM_CONSTANTS = {
|
||||||
S_O_INDEX: 0,
|
S_O_INDEX: 0,
|
||||||
|
S_NH_INDEX: 3,
|
||||||
|
S_NO_INDEX: 5,
|
||||||
NUM_SPECIES: 13
|
NUM_SPECIES: 13
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -320,14 +320,14 @@ class Reactor_PFR extends Reactor {
|
|||||||
const advection = math.multiply(-1 * math.sum(this.Fs) / (this.A*this.d_x), this.D_op, this.extendedState);
|
const advection = math.multiply(-1 * math.sum(this.Fs) / (this.A*this.d_x), this.D_op, this.extendedState);
|
||||||
const reaction = this.extendedState.map((state_slice) => this.asm.compute_dC(state_slice, this.temperature));
|
const reaction = this.extendedState.map((state_slice) => this.asm.compute_dC(state_slice, this.temperature));
|
||||||
const transfer = Array.from(Array(this.n_x+2*BC_PADDING), () => new Array(ASM_CONSTANTS.NUM_SPECIES).fill(0));
|
const transfer = Array.from(Array(this.n_x+2*BC_PADDING), () => new Array(ASM_CONSTANTS.NUM_SPECIES).fill(0));
|
||||||
|
|
||||||
if (isNaN(this.kla)) { // calculate OTR if kla is not NaN, otherwise use externally calculated OTR
|
if (isNaN(this.kla)) { // calculate OTR if kla is not NaN, otherwise use externally calculated OTR
|
||||||
for (let i = BC_PADDING+1; i < BC_PADDING+this.n_x - 1; i++) {
|
for (let i = BC_PADDING+1; i < BC_PADDING+this.n_x - 1; i++) {
|
||||||
transfer[i][ASM_CONSTANTS.S_O_INDEX] = this.OTR * this.n_x/(this.n_x-2);
|
transfer[i][ASM_CONSTANTS.S_O_INDEX] = this.OTR * this.n_x/(this.n_x-2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i = BC_PADDING+1; i < BC_PADDING+this.n_x - 1; i++) {
|
for (let i = BC_PADDING+1; i < BC_PADDING+this.n_x - 1; i++) {
|
||||||
transfer[i][ASM_CONSTANTS.S_O_INDEX] = this._calcOTR(this.extendedState[i][ASM_CONSTANTS.S_O_INDEX], this.temperature) * this.n_x/(this.n_x-2);
|
transfer[i][ASM_CONSTANTS.S_O_INDEX] = this._calcOTR(this.extendedState[i][ASM_CONSTANTS.S_O_INDEX], this.temperature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,10 +349,19 @@ class Reactor_PFR extends Reactor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateMeasurement(measurementType, value, position, context) {
|
_updateMeasurement(measurementType, value, position, context) {
|
||||||
|
const grid_pos = Math.round(context.distance / this.config.length * this.n_x);
|
||||||
|
|
||||||
|
// naive approach for reconciling measurements and simulation
|
||||||
|
// could benefit from Kalman filter?
|
||||||
switch(measurementType) {
|
switch(measurementType) {
|
||||||
case "quantity (oxygen)":
|
case "quantity (oxygen)":
|
||||||
const grid_pos = Math.round(context.distance / this.config.length * this.n_x);
|
this.state[grid_pos][ASM_CONSTANTS.S_O_INDEX] = value;
|
||||||
this.state[grid_pos][0] = value; // naive approach for reconciling measurements and simulation
|
break;
|
||||||
|
case "quantity (ammonium)":
|
||||||
|
this.state[grid_pos][ASM_CONSTANTS.S_NH_INDEX] = value;
|
||||||
|
break;
|
||||||
|
case "quantity (nox)":
|
||||||
|
this.state[grid_pos][ASM_CONSTANTS.S_NO_INDEX] = value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
super._updateMeasurement(measurementType, value, position, context);
|
super._updateMeasurement(measurementType, value, position, context);
|
||||||
@@ -375,6 +384,7 @@ class Reactor_PFR extends Reactor {
|
|||||||
const BC_C_in = math.multiply(1 / math.sum(this.Fs), [this.Fs], this.Cs_in)[0];
|
const BC_C_in = math.multiply(1 / math.sum(this.Fs), [this.Fs], this.Cs_in)[0];
|
||||||
const BC_dispersion_term = this.D*this.A/(math.sum(this.Fs)*this.d_x);
|
const BC_dispersion_term = this.D*this.A/(math.sum(this.Fs)*this.d_x);
|
||||||
this.extendedState[BC_PADDING] = math.multiply(1/(1+BC_dispersion_term), math.add(BC_C_in, math.multiply(BC_dispersion_term, this.extendedState[BC_PADDING+1])));
|
this.extendedState[BC_PADDING] = math.multiply(1/(1+BC_dispersion_term), math.add(BC_C_in, math.multiply(BC_dispersion_term, this.extendedState[BC_PADDING+1])));
|
||||||
|
// Numerical boundary condition
|
||||||
this.extendedState[BC_PADDING-1] = math.add(math.multiply(2, this.extendedState[BC_PADDING]), math.multiply(-2, this.extendedState[BC_PADDING+2]), this.extendedState[BC_PADDING+3]);
|
this.extendedState[BC_PADDING-1] = math.add(math.multiply(2, this.extendedState[BC_PADDING]), math.multiply(-2, this.extendedState[BC_PADDING+2]), this.extendedState[BC_PADDING+3]);
|
||||||
} else {
|
} else {
|
||||||
// Neumann BC (no flux)
|
// Neumann BC (no flux)
|
||||||
|
|||||||
Reference in New Issue
Block a user