-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim.py
51 lines (42 loc) · 1.2 KB
/
sim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class Sim:
def __init__(self, model, sol_init, dt, ind, tstep):
self.model = model
self.sol_init = sol_init
self.dt = dt
self.ind = ind
self.tstep = tstep
self.step_solver = model.default_solver
def do_step(self, y, t, inputs):
self.sol_init.y[:, -1] = y
self.sol_init.t[-1] = t
return self.step_solver.step(
self.sol_init,
self.model,
dt=self.dt,
npts=2,
inputs=inputs,
save=False,
)
class SimPool:
def __init__(self, model, sol_init, dt, end_time, inputs):
self.model = model
self.sol_init = sol_init
self.dt = dt
self.end_time = end_time
self.inputs = inputs
self.step_solver = model.default_solver
def do_step(self, sol_init):
return self.step_solver.step(
sol_init,
self.model,
dt=self.dt,
npts=2,
inputs=self.inputs,
save=False,
)
class SimSolve:
def __init__(self, model, dt, end_time, inputs):
self.model = model
self.dt = dt
self.end_time = end_time
self.inputs = inputs