Location: Hodgkin & Huxley (1952) model @ ab2962b87966 / BG / scripts_BG / GHK_IV.py

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-03-31 10:48:40+13:00
Desc:
Add open channel IV of HH models; Add simulation and plot python scripts
Permanent Source URI:
https://models.cellml.org/workspace/64f/rawfile/ab2962b8796666ad9938a2577611c954f006b5fd/BG/scripts_BG/GHK_IV.py

# importing modules
from asyncio import constants
import sys as sys
import os 
import numpy
import opencor as oc
import pandas as pd 
# getting the name of the directory
# where the this file is present.
current = os.path.dirname(os.path.realpath(__file__))  # scripts_BG
# Getting the parent directory name
# where the current directory is present.
parent = os.path.dirname(current) # BG
gparent = os.path.dirname(parent) # VPH-MIP
mpath = gparent + '\\cellLib\\src'
# appending a path
sys.path.append(mpath)
import simExp


filename = current+'\\paraCell.csv'
data = pd.read_csv(filename)
A = data['$A_{cap}$']   
A_cap = float(A[1])
filename = current+'\\paraHH.csv'
data = pd.read_csv(filename)
Xi = data['$[X_i](mM)$']   
Nai = Xi[0]
Ki = Xi[1]
Xo = data['$[X_o](mM)$']   
Nao = Xo[0]
Ko = Xo[1]

print(A_cap,Nai,Nao,Ki,Ko)

simfile = parent+'\\INa_HH_open.sedml'
savefiles=[current+'\\INa_HH_open']
simulation = oc.open_simulation(simfile)
data = simulation.data()
ending=data.ending_point()
indexStart = 0
indexEnd = int(ending/data.point_interval()) + 1 
varSet = {'INa_HH_open/A_cap':{'constants':A_cap},'INa_HH_open/Nai':{'constants':Nai},'INa_HH_open/Nao':{'constants':Nao}}
varLoop = {'INa_HH_open/A_cap':{'constants':numpy.array([A_cap])}}
varSave = {'INa_HH_open/V':{'states':False},'INa_HH_open/I_Na_fA':{'algebraic':False}}

simExp.simExp(simfile, savefiles,ending,indexStart,indexEnd,varSet,varLoop,varSave)

simfile = parent+'\\IK_HH_open.sedml'
savefiles=[current+'\\IK_HH_open']
simulation = oc.open_simulation(simfile)
data = simulation.data()
ending=data.ending_point()
indexStart = 0
indexEnd = int(ending/data.point_interval()) + 1 
varSet = {'IK_HH_open/A_cap':{'constants':A_cap},'IK_HH_open/Ki':{'constants':Ki},'IK_HH_open/Ko':{'constants':Ko}}
varLoop = {'IK_HH_open/A_cap':{'constants':numpy.array([A_cap])}}
varSave = {'IK_HH_open/V':{'states':False},'IK_HH_open/I_K_fA':{'algebraic':False}}

simExp.simExp(simfile, savefiles,ending,indexStart,indexEnd,varSet,varLoop,varSave)

simfile = parent+'\\INa_BG_open.sedml'
savefiles=[current+'\\INa_BG_open']
simulation = oc.open_simulation(simfile)
data = simulation.data()
ending=data.ending_point()
indexStart = 0
indexEnd = int(ending/data.point_interval()) + 1 
varSet = {'INa_BG_open/z_Na':{'constants':1}}
varLoop = {'INa_BG_open/z_Na':{'constants':numpy.array([1])}}
varSave = {'boundary_conditions/V_m':{'states':False},'outputs/I_Na':{'algebraic':False}}
simExp.simExp(simfile, savefiles,ending,indexStart,indexEnd,varSet,varLoop,varSave)

simfile = parent+'\\IK_BG_open.sedml'
savefiles=[current+'\\IK_BG_open']
simulation = oc.open_simulation(simfile)
data = simulation.data()
ending=data.ending_point()
indexStart = 0
indexEnd = int(ending/data.point_interval()) + 1 
varSet = {'IK_BG_open/z_K':{'constants':1}}
varLoop = {'IK_BG_open/z_K':{'constants':numpy.array([1])}}
varSave = {'boundary_conditions/V_m':{'states':False},'outputs/I_K':{'algebraic':False}}
simExp.simExp(simfile, savefiles,ending,indexStart,indexEnd,varSet,varLoop,varSave)