Fix boundary conditions in gradient and second derivative operators for Reactor_PFR

This commit is contained in:
2025-06-24 16:38:07 +02:00
parent 2e76f733a8
commit 9f13229785

View File

@@ -179,20 +179,20 @@ class Reactor_PFR {
}
makeDoperator() { // create the upwind scheme gradient operator
const I = math.diag(Array(this.n_x).fill(-1), 0);
const A = math.resize(math.diag(Array(this.n_x).fill(1), 1), [this.n_x, this.n_x]);
const I = math.diag(Array(this.n_x).fill(1), 0);
const A = math.resize(math.diag(Array(this.n_x).fill(-1), -1), [this.n_x, this.n_x]);
I[0][0] = 0;
I[0][1] = -1;
I[this.n_x-1][this.n_x-1] = 0; // Neumann boundary condition at x=L
return math.add(I, A);
}
makeD2operator() { // create the upwind scheme second derivative operator
makeD2operator() { // create the central second derivative operator
const I = math.diag(Array(this.n_x).fill(-2), 0);
const A = math.resize(math.diag(Array(this.n_x).fill(1), 1), [this.n_x, this.n_x]);
const B = math.resize(math.diag(Array(this.n_x).fill(1), -1), [this.n_x, this.n_x]);
I[0][0] = 0;
I[0][1] = -1;
I[0][0] = -1; // Dichelet boundary condition at outlet
return math.add(I, A, B);
}
}