- Author:
- Weiwei Ai <wai484@aucklanduni.ac.nz>
- Date:
- 2024-05-28 09:13:47+12:00
- Desc:
- Reduce the number of steps
- Permanent Source URI:
- https://models.physiomeproject.org/workspace/b65/rawfile/867012d2ec640dec0bef5ed61320faa18f15eb8e/src/GLUT2_ss_oi.py
import sys
import os
# Get the directory containing the current file
current_dir = os.path.dirname(os.path.abspath(__file__))
# Append the 'sedmlEditor' directory to the system path
sys.path.append(os.path.join(current_dir, '../sedmlEditor/'))
from sedDict import create_dict_sedDocment, add_sedTask2dict
from sedEditor import create_sedDocment,write_sedml, validate_sedml
# Convert the model to CellML 2.0 if needed
model_name='GLUT2_ss_oi'
# ********** The following is to create a dictionary for the sedml file **********
dict_sedDocument=create_dict_sedDocment()
# This is the sedml file (relative) path and name, assuming in the same folder with the CellML model file
path_='../Facilitated transporter/CellMLV2/'
# model_name='Boron_acid_EA'
model_id = model_name # This is the model id in the sedml, could be different from the model file name
sedFilename = model_name+'.sedml'
full_path = os.path.join(current_dir, path_, sedFilename)
model_path ='../'
# ********** The following is to add the task information to the dictionary **********
# Note: the following is an example, you can modify it to add more tasks
# Note: the valid sedml id should start with a letter, and only contain letters, numbers, and underscores
# This is the model file name, assuming in the same folder with the sedml file
model_source = model_path + model_name + '.cellml'
# This is to modify the model parameters if needed
changes={
}
# the format is {'id':{'component':str,'name':str,'newValue':str}}
# Example: changes={'V_m':{'component':'main','name':'V_m','newValue':'-0.055'}
# This is the output of the simulation, and the key is part of the output id
# The value is a dictionary with the following keys: 'component', 'name', 'scale'
# component is the component name in the CellML model where the output variable is defined
# name is the variable name of the outputs
# scale is the scaling factor for the output variable
outputs={'t':{'component':'GLUT2_BG','name':'t','scale':1},
'v_free':{'component':'GLUT2_BG','name':'v_free','scale':1},
'v':{'component':'GLUT2_BG','name':'v','scale':1},
'q_Ao':{'component':'GLUT2_BG','name':'q_Ao','scale':1/0.09},
}
# You can add more outputs if needed
# The following is the simulation setting
# This is to set the maximum step size for the simulation
dict_algorithmParameter={'kisaoID':'KISAO:0000467', 'name':'max_step','value':'100'}
# You can set more algorithm parameters if needed. You can refer to get_KISAO_parameters() in src/simulator.py file to get the parameters for the specific algorithm
# Add the algorithm parameters to listOfAlgorithmParameters
# You can choose one of the simulation algorithms specified by KISAO_ALGORITHMS in src/simulator.py file
dict_algorithm={'kisaoID':'KISAO:0000535','name':'VODE','listOfAlgorithmParameters':[]}
# This is the simulation setting
# You can choose one of the following simulation types: 'UniformTimeCourse', 'OneStep'
simSetting={'type':'UniformTimeCourse','algorithm':dict_algorithm,'initialTime':0,'outputStartTime':0,'outputEndTime':25,'numberOfSteps':250}
# simSetting={'type':'OneStep','algorithm':dict_algorithm,'step':0.1}
# The following is to add the task information to the dictionary
add_sedTask2dict(dict_sedDocument, model_id, model_source,changes,simSetting,outputs)
# You can repeat the above steps to add more tasks with DIFFERENT model names.
# ********** The following is to create the sedml file, no need to modify **********
try:
doc=create_sedDocment(dict_sedDocument)
except ValueError as err:
print(err)
write_sedml(doc,full_path)
print(validate_sedml(full_path))