Enhance makeDoperator to support higher-order central gradient schemes and improve boundary handling
This commit is contained in:
30
dependencies/reactor_class.js
vendored
30
dependencies/reactor_class.js
vendored
@@ -201,10 +201,32 @@ class Reactor_PFR {
|
|||||||
return new_state;
|
return new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeDoperator(central=false) { // create the upwind scheme gradient operator
|
makeDoperator(central=false, higher_order=false) { // create gradient operator
|
||||||
const I = math.resize(math.diag(Array(this.n_x).fill(1/(1+central)), central), [this.n_x, this.n_x]);
|
if (higher_order) {
|
||||||
const A = math.resize(math.diag(Array(this.n_x).fill(-1/(1+central)), -1), [this.n_x, this.n_x]);
|
if (central) {
|
||||||
const D = math.add(I, A);
|
const I = math.resize(math.diag(Array(this.n_x).fill(1/12), -2), [this.n_x, this.n_x]);
|
||||||
|
const A = math.resize(math.diag(Array(this.n_x).fill(-2/3), -1), [this.n_x, this.n_x]);
|
||||||
|
const B = math.resize(math.diag(Array(this.n_x).fill(2/3), 1), [this.n_x, this.n_x]);
|
||||||
|
const C = math.resize(math.diag(Array(this.n_x).fill(-1/12), 2), [this.n_x, this.n_x]);
|
||||||
|
const D = math.add(I, A);
|
||||||
|
const NearBoundary = Array(this.n_x).fill(0.0);
|
||||||
|
NearBoundary[1] = -25/12;
|
||||||
|
NearBoundary[2] = 4;
|
||||||
|
NearBoundary[3] = -3;
|
||||||
|
NearBoundary[4] = 4/3;
|
||||||
|
NearBoundary[5] = -1/4;
|
||||||
|
D[1] = NearBoundary;
|
||||||
|
NearBoundary.reverse();
|
||||||
|
D[this.n_x-2] = math.multiply(-1, NearBoundary)
|
||||||
|
} else {
|
||||||
|
throw new Error("Upwind higher order method not implemented! Use central scheme instead.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const I = math.resize(math.diag(Array(this.n_x).fill(1/(1+central)), central), [this.n_x, this.n_x]);
|
||||||
|
const A = math.resize(math.diag(Array(this.n_x).fill(-1/(1+central)), -1), [this.n_x, this.n_x]);
|
||||||
|
const D = math.add(I, A);
|
||||||
|
}
|
||||||
|
|
||||||
D[0] = Array(this.n_x).fill(0); // set by BCs elsewhere
|
D[0] = Array(this.n_x).fill(0); // set by BCs elsewhere
|
||||||
D[this.n_x-1] = Array(this.n_x).fill(0);
|
D[this.n_x-1] = Array(this.n_x).fill(0);
|
||||||
return D;
|
return D;
|
||||||
|
|||||||
Reference in New Issue
Block a user