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