Refactor ASM3 constructor to remove state parameter and update compute_dC method to use state directly; add Reactor_CSTR class for reactor simulation with forward Euler method

This commit is contained in:
2025-06-11 15:17:09 +02:00
parent 333efcda52
commit 341af6db4d
2 changed files with 27 additions and 10 deletions

21
dependencies/reactor_class.js vendored Normal file
View File

@@ -0,0 +1,21 @@
const ASM3 = require('./asm3_class')
const math = require('mathjs')
class Reactor_CSTR {
constructor(initial_state){
this.state = initial_state;
this.asm = new ASM3();
}
tick_fe(time_step){ // tick reactor state using forward Euler method
const delta = this.asm.compute_dC(this.state);
this.state = math.add(this.state, math.multiply(delta, time_step));
return this.state;
}
}
// testing stuff
let state = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1];
const Reactor = new Reactor_CSTR(state);
console.log(Reactor.tick_fe(0.001));