# To reproduce the data needed for Figure 4 in associated Physiome 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 Figure03.py # import opencor as opencor # import numpy as np # Na_m = [0.13, 0.1275, 0.125, 0.1175, 0.11, 0.105] # Cl_m = [0.131, 0.1285, 0.126, 0.1185, 0.111, 0.106] # glucose_m = [0.0, 0.005, 0.01, 0.025, 0.04, 0.05] ####### #pH(rbc) is a variable simulation = opencor.open_simulation("Figure03.sedml") data = simulation.data() data.set_ending_point(99.5) data.set_point_interval(1) data.constants()["main/pH"] = 6.92 # simulation.reset(True) simulation.run() # cache the reference results ds = simulation.results().data_store() variables = ds.voi_and_variables() outfile = open("pH(6.92).csv", 'w') cols = [] for key, item in variables.items(): outfile.write(key + ",") cols.append(list(item.values())) outfile.write("\n") for i in range(0, len(cols[0])): for j in range(0, len(cols)): outfile.write(str(cols[j][i]) + ",") outfile.write("\n") outfile.close() # clear the results simulation.reset(True) data.constants()["main/pH"] = 7.24 simulation.run() # cache the reference results ds = simulation.results().data_store() variables = ds.voi_and_variables() outfile = open("pH(7.24).csv", 'w') cols = [] for key, item in variables.items(): outfile.write(key + ",") cols.append(list(item.values())) outfile.write("\n") for i in range(0, len(cols[0])): for j in range(0, len(cols)): outfile.write(str(cols[j][i]) + ",") outfile.write("\n") outfile.close() simulation.reset(True) # simulation.clear_results() data.constants()["main/pH"] = 7.56 simulation.run() # cache the reference results ds = simulation.results().data_store() variables = ds.voi_and_variables() outfile = open("pH(7.56).csv", 'w') cols = [] for key, item in variables.items(): outfile.write(key + ",") cols.append(list(item.values())) outfile.write("\n") for i in range(0, len(cols[0])): for j in range(0, len(cols)): outfile.write(str(cols[j][i]) + ",") outfile.write("\n") outfile.close()