Files
reactor/dependencies/reactor_class.js

21 lines
614 B
JavaScript

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));