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:
21
dependencies/reactor_class.js
vendored
Normal file
21
dependencies/reactor_class.js
vendored
Normal 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));
|
||||
Reference in New Issue
Block a user