# 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 Temp_list = [27, 32, 37, 42, 47] DPG_rbc = [0.003, 0.0045, 0.006, 0.0075, 0.009] pH_rbc = [6.92, 7.08, 7.24, 7.40, 7.56] PO2_list = [10, 40, 70, 100, 500] ####### #pH(rbc) is a variable SHbCO2 = {} simulation = opencor.open_simulation("Figure01(UR).sedml") data = simulation.data() data.set_ending_point(99.5) data.set_point_interval(1) for i, pH in enumerate(pH_rbc): # reset everything in case we are running interactively and have existing results simulation.reset(True) simulation.clear_results() data.constants()["main/pO2"] = 100 data.constants()["main/pH"] = pH simulation.run() ds = simulation.results().data_store() SHbCO2[pH] = ds.voi_and_variables()["main/SHbCO2"].values() # print((glucose_i)) # for key, value in glucose_i.items(): # print(key, value) # cache results for plotting outfile = open("SHbCO2(pH).csv", 'w') cols = [] for key, item in SHbCO2.items(): outfile.write(str(key) + ",") cols.append(item) 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() ###### #PO2 is a variable SHbCO2 = {} for i, PO2 in enumerate(PO2_list): # reset everything in case we are running interactively and have existing results simulation.reset(True) simulation.clear_results() data.constants()["main/pH"] = 7.24 data.constants()["main/pO2"] = PO2 simulation.run() ds = simulation.results().data_store() SHbCO2[PO2] = ds.voi_and_variables()["main/SHbCO2"].values() # print((glucose_i)) # for key, value in glucose_i.items(): # print(key, value) # cache results for plotting outfile = open("SHbCO2(PO2).csv", 'w') cols = [] for key, item in SHbCO2.items(): outfile.write(str(key) + ",") cols.append(item) 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() ####### #DPG is a variable SHbCO2 = {} for i, DPG in enumerate(DPG_rbc): # reset everything in case we are running interactively and have existing results simulation.reset(True) simulation.clear_results() data.constants()["main/pH"] = 7.24 data.constants()["main/pO2"] = 100 data.constants()["main/DPG"] = DPG simulation.run() ds = simulation.results().data_store() SHbCO2[DPG] = ds.voi_and_variables()["main/SHbCO2"].values() # print((glucose_i)) # for key, value in glucose_i.items(): # print(key, value) # cache results for plotting outfile = open("SHbCO2(DPG).csv", 'w') cols = [] for key, item in SHbCO2.items(): outfile.write(str(key) + ",") cols.append(item) 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() ####### #Temp is a variable SHbCO2 = {} for i, Temp in enumerate(Temp_list): # reset everything in case we are running interactively and have existing results simulation.reset(True) simulation.clear_results() data.constants()["main/pH"] = 7.24 data.constants()["main/pO2"] = 100 data.constants()["main/Temp"] = Temp simulation.run() ds = simulation.results().data_store() SHbCO2[Temp] = ds.voi_and_variables()["main/SHbCO2"].values() # print((glucose_i)) # for key, value in glucose_i.items(): # print(key, value) # cache results for plotting outfile = open("SHbCO2(Temp).csv", 'w') cols = [] for key, item in SHbCO2.items(): outfile.write(str(key) + ",") cols.append(item) 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()