Browse Source

Setting default to use volumes also for diffusion based bindings between compartments

Andrej 2 years ago
parent
commit
ed6ca51151
1 changed files with 9 additions and 6 deletions
  1. 9 6
      pythonScripts/cModel.py

+ 9 - 6
pythonScripts/cModel.py

@@ -25,9 +25,9 @@ class model:
       vSPar=self.getVolumePar(sourceCompartment,scaleToVolume)
       vTPar=self.getVolumePar(targetCompartment,scaleToVolume)
 
-#the source equation (where we subtract the current)
+      #the source equation (where we subtract the current)
       addValue(cSrc['targets'],sourceCompartment,-get(k)/get(pc)/get(vSPar))
-#the target equation (where we add the current)
+      #the target equation (where we add the current)
       addValue(cTarg['targets'],sourceCompartment,get(k)/get(pc)/get(vTPar))
         
                     
@@ -76,7 +76,7 @@ class model:
       targetV=self.getVolumePar(target,useVolume)
       doAdd=(variable!="volume" or calculateDerivative(targetV))
 
-#the target equation (where we add the current)
+      #the target equation (where we add the current)
       if doAdd:
          if variable=="volume":
              parName=targetV["name"]
@@ -184,6 +184,9 @@ class model:
                  self.flows[pairName]=f
                  
       for b in self.mod['bindings']['diffusion']:
+         #whether to scale transfer constants to organ volume
+         #default is true, but changing here will assume no scaling
+         useVolume=1
          comps=b.split('->')
          try:
              pcParName=self.mod['partitionCoefficients'][b]
@@ -193,15 +196,15 @@ class model:
          
          kParName=self.mod['bindings']['diffusion'][b]
          kPar=pars[kParName]
-         self.bind(comps[0],comps[1],kPar,pcPar)
+         self.bind(comps[0],comps[1],kPar,pcPar,useVolume)
          
          #add derivatives calculateDerivative returns true
          if calculateDerivative(kPar):
              self.bindDerivative(kParName,"diffusionParameter",\
-               comps[0],comps[1],kPar,pcPar,0)
+               comps[0],comps[1],kPar,pcPar,useVolume)
          if calculateDerivative(pcPar):
              self.bindDerivative(pcParName,"partitionCoefficient",\
-             comps[0],comps[1],kPar,pcPar,0)
+             comps[0],comps[1],kPar,pcPar,useVolume)
          
       for q in self.mod['bindings']['flow']:
          comps=q.split('->')