Location: Imtiaz_IP3_2002 @ 81e638b3f094 / Simulation / Figure3 / Fig3_sim.py

Author:
Leyla <lnor300>
Date:
2022-11-02 15:33:57+13:00
Desc:
..
Permanent Source URI:
https://models.cellml.org/workspace/763/rawfile/81e638b3f094d00aade965d9e2ca7bd101f33371/Simulation/Figure3/Fig3_sim.py

# Author : Leyla Noroozbabaee
# Date: 2/10/2021
# To reproduce the data needed for Figure 3 in associated original paper,
# execute this script in the Python console in OpenCOR. This can be done
# with the following commands at the prompt in the OpenCOR Python console:

#  In [1]: cd path/to/folder_this_file_is_in
#  In [2]: run Fig3_sim.py

import opencor as oc
import numpy as np
prefilename = 'Fig3'
simfile = 'IP3_Imtiaz_2002.sedml'
simulation = oc.open_simulation(simfile)
data = simulation.data()

# Run the simulation for KO scenarios
data.constants()['vm/t_1'] = 30.0
data.constants()['vm/t_2'] = 31.5
data.constants()['vm/t_3'] = 60
data.constants()['vm/t_4'] = 63
data.constants()['vm/I_clamp1'] = 2.25
data.constants()['vm/I_clamp2'] = 2.25
data.constants()['vm/vm_init'] = -65.02
data.constants()['p_ip3/b_ip3'] = 0.7533
data.constants()['ca/y_init'] = 4.11341208572137
data.constants()['ca/z_init'] = 0.478526130219779
data.constants()['p_ip3/p_ip3_init'] = 0.408438668750528
# run simulation a couple of times to make sure we're at steady state
simulation.run()
simulation.clear_results()
simulation.run()
simulation.clear_results()
simulation.run()
simulation.clear_results()


# simulation interval is set in the SED-ML document
start = 0
end = 90
pointInterval = 0.01

# Run the steady-state simulation for KO scenarios
simulation.run()
# Access simulation results
results = simulation.results()
# Grab a selected algebraic variable results
varName = np.array([ "time", "Vm", "z","ip3","y"])
vars = np.reshape(varName, (1, 5))
rows = end * 100 + 1
print(rows)
r = np.zeros((rows, len(varName)))

r[:,0] = results.voi().values()
r[:,1] = results.states()['vm/vm'].values()
r[:,2] = results.states()['ca/z'].values()
r[:,3] = results.states()['p_ip3/p_ip3'].values()
r[:,4] = results.states()['ca/y'].values()
filename = '%s.csv' % prefilename
np.savetxt(filename, vars, fmt='%s', delimiter=",")
with open(filename, "ab") as f:
    np.savetxt(f, r, delimiter=",")
f.close