Improved wieghted finite differencing

This commit is contained in:
2025-07-01 13:04:32 +02:00
parent 3cc876533c
commit f4824b822c

View File

@@ -211,18 +211,15 @@ class Reactor_PFR {
const B = 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 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, B, C); const D = math.add(I, A, B, C);
D[1][0] = -1;
D[1][1] = 0;
D[1][2] = 1;
D[1][3] = 0;
const NearBoundary = Array(this.n_x).fill(0.0); const NearBoundary = Array(this.n_x).fill(0.0);
NearBoundary[1] = -25/12; NearBoundary[0] = -1/4;
NearBoundary[2] = 4; NearBoundary[1] = -5/6;
NearBoundary[3] = -3; NearBoundary[2] = 3/2;
NearBoundary[4] = 4/3; NearBoundary[3] = -1/2;
NearBoundary[5] = -1/4; NearBoundary[4] = 1/12;
D[1] = NearBoundary;
NearBoundary.reverse(); NearBoundary.reverse();
D[this.n_x-2] = NearBoundary; D[this.n_x-2] = math.multiply(-1, NearBoundary);
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;