Added speed-up factor
This commit is contained in:
15
dependencies/reactor_class.js
vendored
15
dependencies/reactor_class.js
vendored
@@ -16,7 +16,8 @@ class Reactor_CSTR {
|
||||
this.kla = kla; // if NaN, use external OTR [d-1]
|
||||
|
||||
this.currentTime = Date.now(); // milliseconds since epoch [ms]
|
||||
this.timeStep = 1/(24*60*15) // time step [d]
|
||||
this.timeStep = 1/(24*60*15); // time step [d]
|
||||
this.speedUpFactor = 30;
|
||||
}
|
||||
|
||||
set setInfluent(input) { // setter for C_in (WIP)
|
||||
@@ -39,20 +40,18 @@ class Reactor_CSTR {
|
||||
}
|
||||
|
||||
// expect update with timestamp
|
||||
updateState(timestamp) {
|
||||
let newTime = timestamp;
|
||||
updateState(newTime) {
|
||||
|
||||
const day2ms = 1000 * 60 * 60 * 24;
|
||||
|
||||
let n_iter = Math.floor((newTime - this.currentTime) / (this.timeStep * day2ms));
|
||||
if (n_iter > 0) {
|
||||
let n_iter = Math.floor(this.speedUpFactor*(newTime - this.currentTime) / (this.timeStep * day2ms));
|
||||
if (n_iter) {
|
||||
let n = 0;
|
||||
while (n < n_iter) {
|
||||
console.log(this.tick_fe(this.timeStep));
|
||||
this.tick_fe(this.timeStep);
|
||||
n += 1;
|
||||
}
|
||||
this.currentTime += n_iter * this.timeStep * day2ms;
|
||||
n_iter = 0;
|
||||
this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user