|
2 | 2 | import numpy as np |
3 | 3 | import matplotlib.pyplot as plt |
4 | 4 | import time |
5 | | -print("plotym") |
| 5 | +print("plot ym") |
6 | 6 |
|
7 | | -concore.delay = 0.02 |
| 7 | +concore.delay = 0.005 |
8 | 8 | concore.default_maxtime(150) |
9 | | -init_simtime_u = "[0.0, 0.0, 0.0]" |
10 | | -init_simtime_ym = "[0, 103, 0]" |
| 9 | +init_simtime_u = "[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]" |
| 10 | +init_simtime_ym = "[0.0, 0.0, 0.0]" |
| 11 | +ut = [] |
11 | 12 | ymt = [] |
12 | | - |
13 | 13 | ym = concore.initval(init_simtime_ym) |
14 | 14 | while(concore.simtime<concore.maxtime): |
15 | 15 | while concore.unchanged(): |
16 | 16 | ym = concore.read(1,"ym",init_simtime_ym) |
17 | 17 | concore.write(1,"ym",ym) |
18 | | - print("ym="+str(ym)) |
19 | | - ymt.append(ym) |
| 18 | + print(" ym="+str(ym)) |
| 19 | + ymt.append(np.array(ym).T) |
20 | 20 | print("retry="+str(concore.retrycount)) |
21 | 21 |
|
22 | 22 | ################# |
23 | | -ylabelstring = ['Heart rate (bpm)', 'MAP (mmHg)'] |
24 | | -# plot inputs and outputs |
25 | 23 |
|
26 | | -for k in range(2): |
27 | | - vv = [] |
28 | | - for x in ymt: |
29 | | - vv.append(x[k]) |
| 24 | +# plot inputs and outputs |
| 25 | +ym1 = [x[0].item() for x in ymt] |
| 26 | +ym2 = [x[1].item() for x in ymt] |
| 27 | +Nsim = len(ym1) |
30 | 28 |
|
31 | | - Nsim = len(vv) |
32 | | - plt.figure(k) |
33 | | - plt.plot(range(Nsim), vv) |
34 | | - plt.ylabel(ylabelstring[k]) |
35 | | - |
36 | | - plt.xlabel('Heart cycles') |
37 | | - plt.savefig("ym" + str(k) +".pdf") |
| 29 | +plt.figure() |
| 30 | +plt.subplot(211) |
| 31 | +plt.plot(range(Nsim), ym1) |
| 32 | +plt.ylabel('MAP (mmHg)') |
| 33 | +plt.legend(['MAP'], loc=0) |
| 34 | +plt.subplot(212) |
| 35 | +plt.plot(range(Nsim), ym2) |
| 36 | +plt.xlabel('Cycles') |
| 37 | +plt.ylabel('HR (bpm)') |
| 38 | +plt.legend(['HR'], loc=0) |
| 39 | +plt.savefig("hrmap.pdf") |
38 | 40 | plt.show() |
0 commit comments