Skip to content

Commit 21b3c62

Browse files
committed
hcm_bang to play with
1 parent 8984b66 commit 21b3c62

6 files changed

Lines changed: 7457 additions & 0 deletions

File tree

tools/bangbang.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import numpy as np
2+
import concore
3+
4+
5+
def bangbang_controller(ym):
6+
amp = 0
7+
if ym[0]>70:
8+
amp = 3
9+
elif ym[0]<65:
10+
amp = 1
11+
12+
13+
ustar = np.array([amp,30])
14+
return ustar
15+
16+
17+
concore.default_maxtime(150)
18+
concore.delay = 0.02
19+
init_simtime_u = "[0.0, 0.0,0.0]"
20+
init_simtime_ym = "[0.0, 70.0,91]"
21+
u = np.array([concore.initval(init_simtime_u)]).T
22+
while(concore.simtime<concore.maxtime):
23+
while concore.unchanged():
24+
ym = concore.read(1,"ym",init_simtime_ym)
25+
ym = np.array(ym)
26+
27+
ustar = bangbang_controller(ym)
28+
29+
print(str(concore.simtime) + " u="+str(ustar) + "ym="+str(ym))
30+
concore.write(1,"u",list(ustar),delta=0)
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
2+
"""
3+
Created on Thu Sep 30 05:21:27 2021
4+
5+
@author: Sanmi
6+
"""
7+
import numpy as np
8+
9+
10+
11+
12+
#cardiosystem
13+
14+
Csa = 0.28
15+
Csp = 2.05
16+
Cep = 1.36
17+
Cmp = 0.31
18+
Csv = 43.11
19+
Cev = 28.4
20+
Cmv = 6.6
21+
Ctv = 33
22+
Cpa = 0.67
23+
Cpp = 5.80
24+
Cpv = 25.37
25+
26+
27+
28+
Vusa = 0
29+
Vusp = 274.4
30+
Vuep = 274.1
31+
Vusv = 986.48
32+
Vuev = 484
33+
Vupa = 0
34+
Vupp = 123
35+
Vupv = 120
36+
Vumv = 93.1
37+
Vump = 62.5
38+
Vutv = 0
39+
40+
41+
Rsa = 0.06
42+
Rsp = 3.307
43+
Rep = 1.725
44+
Rmp = 4.13
45+
Rsv = 0.038
46+
Rev = 0.0197
47+
Rmv = 0.0848
48+
Rtv = 0.0054
49+
Rpa = 0.023
50+
Rpp = 0.0894
51+
Rpv = 0.0056
52+
53+
54+
55+
Rd = 10000
56+
57+
58+
P0 = 3.9
59+
60+
#left heart
61+
Cla = 19.23
62+
Vula = 25
63+
Rla = 0.003
64+
Polv = 1.5
65+
Kelv = 0.014
66+
Vulv = 16.77
67+
68+
KRlv = 0.0004
69+
70+
#right heart
71+
Cra = 31.25
72+
Vura = 25
73+
Rra = 0.0025
74+
Porv = 1.5
75+
Kerv = 0.011
76+
Vurv = 40.8
77+
KRrv = 0.0014
78+
79+
80+
ksys = 0.075
81+
Tsys0 = 0.4
82+
Vt = 5000
83+
84+
85+
Lsa = 0.00022
86+
Lpa = 0.00018
87+
88+
#baroreceptor
89+
fbrmin = 2.52
90+
tauz = 6.37
91+
fbrmax = 47.78
92+
taup = 2.067
93+
Pn = 92
94+
ka = 11.758
95+
96+
Tresp = 4
97+
98+
#cpr receptor
99+
fmaxl = 20
100+
Ptn = 10.8
101+
kl = 11.758
102+
taucp = 2
103+
104+
#lung stretch receptor
105+
taulung = 2
106+
Gal = 12
107+
vlung0 = 0.583
108+
109+
#parasympathetic branch # br, cpr, lr
110+
111+
fmin = np.array([0.3, 0.451, 2.75])
112+
midpt = np.array([44.3, 10.2, 10])
113+
fmax = np.array([21.5, 28.357, 31.57 ])
114+
k = np.array([2.14,1.636, 7.516])
115+
116+
117+
kreceptor = np.array([[1,1,1],[0,1,1]])
118+
119+
120+
121+
#NA, DMV, NActr
122+
123+
foutmin = np.array([4.88, 2.59, 0.61])
124+
foutmidpt = np.array([60, 43.1, 9.8])
125+
foutmax = np.array([15.78,6.66, 11])
126+
foutk = np.array([2.55, 1.24, 1.2])
127+
128+
#T, Emaxlv, Emaxrv effectors
129+
tauv = np.array([1.5,2,2])
130+
Gv = np.array([0.09, 0.205, 0.347])
131+
dv = 0.2
132+
133+
#sympathetic branch
134+
G = np.array([[1, 2, -1.1541],[1, 2.5, 0.33],[1,0,0]]) # br, cpr,lr,
135+
136+
fesinf = 2.1
137+
fes0 = 16.11
138+
fesmin = 2.66
139+
kes = 0.0675
140+
141+
theta0 = np.array([0.58, 1.283, 0.757, 2.49, 0.96, 4.13, 1435.4, 1247, 290])
142+
143+
Gs = np.array([-0.13, -0.13, -0.22, 0.695, 0.653, 2.81, -265.4, -107.5, -25])
144+
taus = np.array([2,2,2,6,6,6,20,20,6])
145+
ds = np.array([2,2,2])
146+
147+
148+
Vu = np.array([Vusa,Vusp,theta0[6], theta0[7],theta0[8], Vutv, Vura, Vupa, Vupp,Vupv, Vula, Vulv, Vurv])
149+
xstart = np.concatenate((np.zeros(15),np.array([-0.25, 1, -0.25, 1]),Vu))

0 commit comments

Comments
 (0)