Attachment 'CellDiffusionCalculatorSteppable.py'

Download

   1 from PySteppables import *
   2 import CompuCell
   3 import sys
   4 import time
   5 from math import *
   6 
   7 
   8 class CellDiffusionCalculatorSteppable(SteppablePy):
   9    def __init__(self,_simulator,_frequency=1):
  10       SteppablePy.__init__(self,_frequency)
  11       self.simulator=_simulator
  12       self.frequ=_frequency
  13       #self.aa=[]
  14       self.inventory=self.simulator.getPotts().getCellInventory()
  15       self.cellList=CellList(self.inventory)
  16       self.nTrackerPlugin=CompuCell.getNeighborTrackerPlugin()
  17       self.cellFieldG=self.simulator.getPotts().getCellFieldG()
  18       self.dim=self.cellFieldG.getDim()
  19 
  20       #self.output_file = open("cellDiffusionData.txt",'w')
  21       
  22    def start(self):
  23       for cell in self.cellList:
  24 	if cell.type == 1 or cell.type == 2:
  25 	    list_attrib=CompuCell.getPyAttrib(cell)
  26 	    ptx=float(cell.xCM/float(cell.volume)) 
  27 	    pty=float(cell.yCM/float(cell.volume)) 
  28 	    list_attrib[0:2]=[ptx,pty]
  29       import CompuCellSetup
  30       self.pW=CompuCellSetup.viewManager.plotManager.getNewPlotWindow()
  31       if not self.pW:
  32           return
  33       #Plot Title - properties           
  34       self.pW.setTitle("Cell Diffusion")
  35       self.pW.setTitleSize(12)
  36       self.pW.setTitleColor("Green")
  37         
  38       #plot background
  39       self.pW.setPlotBackgroundColor("orange")
  40         
  41       # properties of x axis
  42       self.pW.setXAxisTitle("MonteCarlo Step (MCS)")
  43       self.pW.setXAxisTitleSize(10)      
  44       self.pW.setXAxisTitleColor("blue")              
  45         
  46       # properties of y axis
  47       self.pW.setYAxisTitle("<displacement^2>/4")        
  48       #self.pW.setYAxisLogScale()
  49       self.pW.setYAxisTitleSize(10)        
  50       self.pW.setYAxisTitleColor("red")                      
  51         
  52       self.pW.addPlot("Non-Condensing")
  53       self.pW.addPlot("Condensing")
  54       # plot MCS
  55       self.pW.changePlotProperty("Non-Condensing","LineWidth",1)
  56       self.pW.changePlotProperty("Non-Condensing","LineColor","red")     
  57       # plot MCS1
  58       self.pW.changePlotProperty("Condensing","LineWidth",1)
  59       self.pW.changePlotProperty("Condensing","LineColor","green")
  60 
  61       
  62       self.pW.addGrid()
  63       #adding automatically generated legend
  64       # default possition is at the bottom of the plot but here we put it at the top
  65       self.pW.addAutoLegend("top")
  66 
  67       self.pW2=CompuCellSetup.viewManager.plotManager.getNewPlotWindow()
  68       if not self.pW2:
  69           return
  70       #Plot Title - properties           
  71       self.pW2.setTitle("Cell Displacement/MCS")
  72       self.pW2.setTitleSize(12)
  73       self.pW2.setTitleColor("Green")
  74         
  75       #plot background
  76       self.pW2.setPlotBackgroundColor("orange")
  77         
  78       # properties of x axis
  79       self.pW2.setXAxisTitle("MonteCarlo Step (MCS)")
  80       self.pW2.setXAxisTitleSize(10)      
  81       self.pW2.setXAxisTitleColor("blue")              
  82         
  83       # properties of y axis
  84       self.pW2.setYAxisTitle("<Displacement>")        
  85       #self.pW.setYAxisLogScale()
  86       self.pW2.setYAxisTitleSize(10)        
  87       self.pW2.setYAxisTitleColor("red")                      
  88         
  89       self.pW2.addPlot("Non-Condensing")
  90       self.pW2.addPlot("Condensing")
  91       # plot MCS
  92       self.pW2.changePlotProperty("Non-Condensing","LineWidth",1)
  93       self.pW2.changePlotProperty("Non-Condensing","LineColor","red")     
  94       # plot MCS1
  95       self.pW2.changePlotProperty("Condensing","LineWidth",1)
  96       self.pW2.changePlotProperty("Condensing","LineColor","green")
  97 
  98       
  99       self.pW2.addGrid()
 100       #adding automatically generated legend
 101       # default possition is at the bottom of the plot but here we put it at the top
 102       self.pW2.addAutoLegend("top")
 103 
 104 
 105       self.pW3=CompuCellSetup.viewManager.plotManager.getNewPlotWindow()
 106       if not self.pW3:
 107           return
 108       #Plot Title - properties           
 109       self.pW3.setTitle("Average Volume")
 110       self.pW3.setTitleSize(12)
 111       self.pW3.setTitleColor("Green")
 112         
 113       #plot background
 114       self.pW3.setPlotBackgroundColor("orange")
 115         
 116       # properties of x axis
 117       self.pW3.setXAxisTitle("MonteCarlo Step (MCS)")
 118       self.pW3.setXAxisTitleSize(10)      
 119       self.pW3.setXAxisTitleColor("blue")              
 120         
 121       # properties of y axis
 122       self.pW3.setYAxisTitle("volume")        
 123       #self.pW.setYAxisLogScale()
 124       self.pW3.setYAxisTitleSize(10)        
 125       self.pW3.setYAxisTitleColor("red")                      
 126         
 127       self.pW3.addPlot("Non-Condensing")
 128       self.pW3.addPlot("Condensing")
 129       # plot MCS
 130       self.pW3.changePlotProperty("Non-Condensing","LineWidth",1)
 131       self.pW3.changePlotProperty("Non-Condensing","LineColor","red")     
 132       # plot MCS1
 133       self.pW3.changePlotProperty("Condensing","LineWidth",1)
 134       self.pW3.changePlotProperty("Condensing","LineColor","green")
 135 
 136       
 137       self.pW3.addGrid()
 138       #adding automatically generated legend
 139       # default possition is at the bottom of the plot but here we put it at the top
 140       self.pW3.addAutoLegend("top")
 141 
 142       self.pW4=CompuCellSetup.viewManager.plotManager.getNewPlotWindow()
 143       if not self.pW4:
 144           return
 145       #Plot Title - properties           
 146       self.pW4.setTitle("Average Surface Area")
 147       self.pW4.setTitleSize(12)
 148       self.pW4.setTitleColor("Green")
 149         
 150       #plot background
 151       self.pW4.setPlotBackgroundColor("orange")
 152         
 153       # properties of x axis
 154       self.pW4.setXAxisTitle("MonteCarlo Step (MCS)")
 155       self.pW4.setXAxisTitleSize(10)      
 156       self.pW4.setXAxisTitleColor("blue")              
 157         
 158       # properties of y axis
 159       self.pW4.setYAxisTitle("Surface Area")        
 160       #self.pW.setYAxisLogScale()
 161       self.pW4.setYAxisTitleSize(10)        
 162       self.pW4.setYAxisTitleColor("red")                      
 163         
 164       self.pW4.addPlot("Non-Condensing")
 165       self.pW4.addPlot("Condensing")
 166       # plot MCS
 167       self.pW4.changePlotProperty("Non-Condensing","LineWidth",1)
 168       self.pW4.changePlotProperty("Non-Condensing","LineColor","red")     
 169       # plot MCS1
 170       self.pW4.changePlotProperty("Condensing","LineWidth",1)
 171       self.pW4.changePlotProperty("Condensing","LineColor","green")
 172 
 173       
 174       self.pW4.addGrid()
 175       #adding automatically generated legend
 176       # default possition is at the bottom of the plot but here we put it at the top
 177       self.pW4.addAutoLegend("top")
 178 
 179 
 180 
 181    def step(self,mcs):
 182       self.Potts=self.simulator.getPotts()
 183       cell_counter1=0
 184       cell_counter2=0
 185       d2_CON=0
 186       d2_NONCON=0
 187       d_CON=0
 188       d_NONCON=0
 189       t1_volume=0
 190       t2_volume=0
 191       t1_surface=0
 192       t2_surface=0
 193 
 194 	  
 195       for cell in self.cellList:
 196 	if cell.type == 1:
 197 	    list_attrib=CompuCell.getPyAttrib(cell)
 198 	    cell_counter1+=1;
 199 	    ptx=float(cell.xCM/float(cell.volume)) 
 200 	    pty=float(cell.yCM/float(cell.volume)) 
 201 	    pt2x=list_attrib[0] 
 202 	    pt2y=list_attrib[1] 
 203 	    dx2=(ptx-pt2x)**2
 204 	    dy2=(pty-pt2y)**2
 205 	    d2_CON+=(dx2+dy2)
 206 	    d_CON+=(dx2+dy2)**(0.5)
 207 	    list_attrib[0]=ptx
 208 	    list_attrib[1]=pty
 209 	    t1_volume += cell.volume
 210 	    t1_surface += cell.surface
 211 
 212 	if cell.type == 2:
 213 	    list_attrib=CompuCell.getPyAttrib(cell)
 214 	    cell_counter2+=1;
 215 	    ptx=float(cell.xCM/float(cell.volume)) 
 216 	    pty=float(cell.yCM/float(cell.volume)) 
 217 	    pt2x=list_attrib[0]
 218 	    pt2y=list_attrib[1]
 219 	    dx2=(ptx-pt2x)**2
 220 	    dy2=(pty-pt2y)**2
 221 	    d2_NONCON+=(dx2+dy2)
 222 	    d_NONCON+=(dx2+dy2)**(0.5)
 223 	    list_attrib[0]=ptx
 224 	    list_attrib[1]=pty
 225 	    t2_volume += cell.volume
 226 	    t2_surface += cell.surface
 227 
 228 
 229 
 230       AVE_d2_CON=d2_CON/cell_counter1/self.frequ
 231       AVE_d2_NONCON=d2_NONCON/cell_counter2/self.frequ
 232       AVE_d_CON=d_CON/cell_counter1/self.frequ
 233       AVE_d_NONCON=d_NONCON/cell_counter2/self.frequ
 234       if mcs%50==0:
 235 	self.pW.addDataPoint("Condensing",mcs,AVE_d2_CON/4)
 236 	self.pW.addDataPoint("Non-Condensing",mcs,AVE_d2_NONCON/4)
 237 	self.pW.showAllPlots()
 238 	self.pW2.addDataPoint("Condensing",mcs,AVE_d_CON)
 239 	self.pW2.addDataPoint("Non-Condensing",mcs,AVE_d_NONCON)
 240 	self.pW2.showAllPlots()
 241 	self.pW3.addDataPoint("Condensing",mcs,t1_volume/cell_counter1)
 242 	self.pW3.addDataPoint("Non-Condensing",mcs,t2_volume/cell_counter2)
 243 	self.pW3.showAllPlots()
 244 	self.pW4.addDataPoint("Condensing",mcs,t1_surface/cell_counter1)
 245 	self.pW4.addDataPoint("Non-Condensing",mcs,t2_surface/cell_counter2)
 246 	self.pW4.showAllPlots()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-08-17 14:42:10, 320.0 KB) [[attachment:Adhesion Parameter Values.doc]]
  • [get | view] (2011-08-17 14:46:22, 9560.3 KB) [[attachment:CNV-P-T1-T2 .pptx]]
  • [get | view] (2011-08-17 14:36:43, 8.4 KB) [[attachment:CellDiffusionCalculatorSteppable.py]]
  • [get | view] (2011-09-10 20:31:09, 2273.1 KB) [[attachment:CellDraw_1.5.0_presentation_2011.pdf]]
  • [get | view] (2011-08-08 22:09:40, 6.5 KB) [[attachment:Heiko3_O2_ps.zip]]
  • [get | view] (2011-08-18 17:51:04, 57547.3 KB) [[attachment:MergingCC3DandSBWSBML.pdf]]
  • [get | view] (2011-08-18 17:51:42, 2724.4 KB) [[attachment:MergingCC3DandSBWSBML.pptx]]
  • [get | view] (2011-08-18 17:52:58, 43497.5 KB) [[attachment:MergingCC3DandSBWSBML.zip]]
  • [get | view] (2011-08-17 20:57:30, 3.4 KB) [[attachment:RountreeInitializerPresentation.py]]
  • [get | view] (2011-08-17 20:57:05, 8.2 KB) [[attachment:RountreeSteppablePresentation.py]]
  • [get | view] (2011-08-18 17:57:53, 0.2 KB) [[attachment:SimpleOscillator.jan]]
  • [get | view] (2011-08-18 17:58:00, 4.0 KB) [[attachment:SimpleOscillator.sbml]]
  • [get | view] (2011-08-17 14:36:27, 3.7 KB) [[attachment:cellsort2D_negative_J.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.