-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprototype.py
52 lines (45 loc) · 1.11 KB
/
prototype.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
52
import matplotlib.pylab as plt
import numpy as np
import scipy.integrate
def dose(t, X):
return X
def rhs(t, y, Q_p1, V_c, V_p1, CL, X):
q_c, q_p1 = y
transition = Q_p1 * (q_c / V_c - q_p1 / V_p1)
dqc_dt = dose(t, X) - q_c / V_c * CL - transition
dqp1_dt = transition
return [dqc_dt, dqp1_dt]
model1_args = {
'name': 'model1',
'Q_p1': 1.0,
'V_c': 1.0,
'V_p1': 1.0,
'CL': 1.0,
'X': 1.0,
}
model2_args = {
'name': 'model2',
'Q_p1': 2.0,
'V_c': 1.0,
'V_p1': 1.0,
'CL': 1.0,
'X': 1.0,
}
t_eval = np.linspace(0, 1, 1000)
y0 = np.array([0.0, 0.0])
fig = plt.figure()
for model in [model1_args, model2_args]:
args = [
model['Q_p1'], model['V_c'], model['V_p1'], model['CL'], model['X']
]
sol = scipy.integrate.solve_ivp(
fun=lambda t, y: rhs(t, y, *args),
t_span=[t_eval[0], t_eval[-1]],
y0=y0, t_eval=t_eval
)
plt.plot(sol.t, sol.y[0, :], label=model['name'] + '- q_c')
plt.plot(sol.t, sol.y[1, :], label=model['name'] + '- q_p1')
plt.legend()
plt.ylabel('drug mass [ng]')
plt.xlabel('time [h]')
plt.show()