s = (Simulation(). set_pragma_autocompact(True). add([ ODESystemMass(f_decay_a, [DotMap(attr={ 'sub-a': 'u' }), DotMap(attr={ 'sub-a': 'd' })], dt=0.1), ODESystemMass(f_decay_b, [DotMap(attr={ 'sub-b': 'u' }), DotMap(attr={ 'sub-b': 'd' })], dt=0.1), Group(m=1000, attr={ 'sub-a': 'u' }), Group(m=1000, attr={ 'sub-b': 'u' }), probe_u, probe_d ]). run(1000) ) # ---------------------------------------------------------------------------------------------------------------------- # (4) Results: # Time series plot (group mass) -- Undecayed: # series = [ # { 'var': 'pau', 'lw': 2, 'linestyle': '-', 'marker': '+', 'color': 'red', 'markersize': 0, 'lbl': 'Substance A' }, # { 'var': 'pbu', 'lw': 2, 'linestyle': '--', 'marker': 'o', 'color': 'blue', 'markersize': 0, 'lbl': 'Substance B' } # ] # probe_u.plot(series, fpath_fig=None, figsize=(20,4), legend_loc='upper right', dpi=150) # Time series plot (group mass) -- Decayed: series = [ { 'var': 'pad', 'lw': 2, 'linestyle': '-', 'marker': '+', 'color': 'red', 'markersize': 0, 'lbl': 'Substance A' }, { 'var': 'pbd', 'lw': 2, 'linestyle': '--', 'marker': 'o', 'color': 'blue', 'markersize': 0, 'lbl': 'Substance B' } ] probe_d.plot(series, fpath_fig=None, figsize=(20,4), legend_loc='lower right', dpi=150)
Group(m=950, attr={ 'flu': 's' }), Group(m= 50, attr={ 'flu': 'i' }), probe ]). run(1000) ) # ---------------------------------------------------------------------------------------------------------------------- # (4) Results: # Time series plot (group mass): cmap = plt.get_cmap('tab20') series = [ { 'var': 'ps', 'lw': 2, 'linestyle': '--', 'marker': '+', 'color': cmap(0), 'markersize': 0, 'lbl': 'Susceptible' }, { 'var': 'pi', 'lw': 2, 'linestyle': '-', 'marker': 'o', 'color': cmap(4), 'markersize': 0, 'lbl': 'Infectious' }, { 'var': 'pr', 'lw': 2, 'linestyle': ':', 'marker': 'x', 'color': cmap(6), 'markersize': 0, 'lbl': 'Recovered' } ] probe.plot(series, fpath_fig=None, figsize=(24,8), legend_loc='upper right', dpi=150) # Time series plot (numeric integrator history): # h = s.rules[0].get_hist() # plt.plot(h[0], h[1][0], 'b-', h[0], h[1][1], 'g-', h[0], h[1][2], 'r-') # S-blue, I-green, R-red # plt.show() # Phase plot (numeric integrator history): # h = s.rules[0].get_hist() # plt.plot(h[1][0], h[1][1], 'k-') # plt.show()
'lbl': 'Blue @ A' }, { 'var': 'p1', 'lw': 2, 'linestyle': '-', 'marker': '', 'color': 'red', 'markersize': 0, 'lbl': 'Red @ A' }, { 'var': 'p2', 'lw': 2, 'linestyle': '-', 'marker': '', 'color': 'navy', 'markersize': 0, 'lbl': 'Blue @ B' }, { 'var': 'p3', 'lw': 2, 'linestyle': '-', 'marker': '', 'color': 'firebrick', 'markersize': 0, 'lbl': 'Red @ B' }] fig = probe_sim.plot(series, figsize=(8, 6)) fig.suptitle(f'Segregation PRAM Model - {runs} iterations', y=0.965) fig.savefig("Segregation_PRAM_out")