def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":100,"y":100,"z":1}) potts.ElementCC3D("Steps",{},1000000) potts.ElementCC3D("Anneal",{},10) potts.ElementCC3D("Temperature",{},10) potts.ElementCC3D("Flip2DimRatio",{},1) potts.ElementCC3D("NeighborOrder",{},2) cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"Condensing", "TypeId":"1"}) cellType.ElementCC3D("CellType", {"TypeName":"NonCondensing", "TypeId":"2"}) volume=cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) volume.ElementCC3D("TargetVolume",{},25) volume.ElementCC3D("LambdaVolume",{},5.0) volume=cc3d.ElementCC3D("Plugin",{"Name":"Surface"}) volume.ElementCC3D("TargetSurface",{},25) volume.ElementCC3D("LambdaSurface",{},5.0) centerOfMass=cc3d.ElementCC3D("Plugin",{"Name":"CenterOfMass"}) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"NonCondensing", "Type2":"NonCondensing"},-3) contact.ElementCC3D("Energy", {"Type1":"Condensing", "Type2":"Condensing"},-10) contact.ElementCC3D("Energy",{"Type1":"NonCondensing", "Type2":"Condensing"},-2) contact.ElementCC3D("Energy", {"Type1":"NonCondensing", "Type2":"Medium"},1) contact.ElementCC3D("Energy", {"Type1":"Condensing", "Type2":"Medium"},1) contact.ElementCC3D("NeighborOrder", {}, 2) chemotaxis=cc3d.ElementCC3D("Plugin",{"Name":"Chemotaxis"}) chemicalField=chemotaxis.ElementCC3D("ChemicalField", {"Source":"FlexibleDiffusionSolverFE", "Name":"FGF"}) chemicalField.ElementCC3D("ChemotaxisByType", {"Type":"Condensing" ,"Lambda":3}) flexDiffSolver=cc3d.ElementCC3D("Steppable",{"Type":"FlexibleDiffusionSolverFE"}) diffusionField=flexDiffSolver.ElementCC3D("DiffusionField") diffusionData=diffusionField.ElementCC3D("DiffusionData") diffusionData.ElementCC3D("FieldName",{},"FGF") diffusionData.ElementCC3D("DiffusionConstant",{},0.2) diffusionData.ElementCC3D("DecayConstant",{},0.01) secretionData=diffusionField.ElementCC3D("SecretionData") secretionData.ElementCC3D("Secretion",{"Type":"Condensing"},0.0) uniform = cc3d.ElementCC3D("Steppable",{"Type":"UniformInitializer"}) region = uniform.ElementCC3D("Region") region.ElementCC3D("BoxMin",{"x":0, "y":0, "z":0}) region.ElementCC3D("BoxMax",{"x":100, "y":100, "z":1}) region.ElementCC3D("Types",{}, "NonCondensing,Condensing") region.ElementCC3D("Width", {}, 5) CompuCellSetup.setSimulationXMLDescription(cc3d)
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d = ElementCC3D("CompuCell3D") potts = cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions", {"x": 55, "y": 55, "z": 1}) potts.ElementCC3D("Steps", {}, 1000) potts.ElementCC3D("Temperature", {}, 0) potts.ElementCC3D("Flip2DimRatio", {}, 0.0) cellType = cc3d.ElementCC3D("Plugin", {"Name": "CellType"}) cellType.ElementCC3D("CellType", {"TypeName": "Medium", "TypeId": "0"}) flexDiffSolver = cc3d.ElementCC3D("Steppable", {"Type": "DiffusionSolverFE"}) diffusionField = flexDiffSolver.ElementCC3D("DiffusionField") diffusionData = diffusionField.ElementCC3D("DiffusionData") diffusionData.ElementCC3D("FieldName", {}, "FGF") diffusionData.ElementCC3D("DiffusionConstant", {}, 0.10) diffusionData.ElementCC3D("DecayConstant", {}, 0.0) diffusionData.ElementCC3D("ConcentrationFileName", {}, "Simulation/diffusion_2D.pulse.txt") CompuCellSetup.setSimulationXMLDescription(cc3d)
def start(self): # avg volumes self.pWVol = CompuCellSetup.addNewPlotWindow( _title='Average Volume', _xAxisTitle='MonteCarlo Step (MCS)', _yAxisTitle='Average Volume') self.pWVol.addPlot(_plotName='MVol', _style='Dots', _color='red', _size=5) # number of cells self.pWNum = CompuCellSetup.addNewPlotWindow( _title='Number of Cells', _xAxisTitle='MonteCarlo Step (MCS)', _yAxisTitle='Number') self.pWNum.addPlot(_plotName='Cancer', _color='green') self.pWNum.addPlot(_plotName='Normal', _color='blue') self.pWNum.addPlot(_plotName='Total', _color='red') # proportions self.pWProp = CompuCellSetup.addNewPlotWindow( _title='Proportions of Cancer vs Normal Cells', _xAxisTitle='MonteCarlo Step (MCS)', _yAxisTitle='%') self.pWProp.addPlot(_plotName='Cancer', _color='green') self.pWProp.addPlot(_plotName='Normal', _color='blue')
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D dim=300 cc3d=ElementCC3D("CompuCell3D") metadata=cc3d.ElementCC3D("Metadata") metadata.ElementCC3D("VirtualProcessingUnits",{"ThreadsPerVPU":1},4) potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":dim,"y":dim,"z":dim}) potts.ElementCC3D("Steps",{},100) potts.ElementCC3D("Temperature",{},0) potts.ElementCC3D("Flip2DimRatio",{},0.0) cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) flexDiffSolver=cc3d.ElementCC3D("Steppable",{"Type":"FlexibleDiffusionSolverFE"}) diffusionField=flexDiffSolver.ElementCC3D("DiffusionField") diffusionData=diffusionField.ElementCC3D("DiffusionData") diffusionData.ElementCC3D("FieldName",{},"FGF") diffusionData.ElementCC3D("DiffusionConstant",{},0.10) diffusionData.ElementCC3D("DecayConstant",{},0.0) diffusionData.ElementCC3D("ConcentrationFileName",{},"Simulation/diffusion_3D.pulse.txt") CompuCellSetup.setSimulationXMLDescription(cc3d)
def __init__(self, _simulator, _frequency=1): SteppableBasePy.__init__(self, _simulator, _frequency) self.scalarFieldDelta = CompuCellSetup.createScalarFieldCellLevelPy( "Delta") self.scalarFieldNotch = CompuCellSetup.createScalarFieldCellLevelPy( "Notch")
def step(self, mcs): print 'lambda_vol=', self.get_steering_param('lambda_vol') print CompuCellSetup.steering_param_dict out_fname = 'd:\CC3DProjects\steering_panel.json' CompuCellSetup.serialize_steering_panel(fname=out_fname)
def writeXMLDescriptionFile(self,_fileName=""): from os.path import join """ This function will write XML description of the stored fields. It has to be called after initialization of theCMLFieldHandler is completed """ import CompuCellSetup latticeTypeStr = CompuCellSetup.ExtractLatticeType() if latticeTypeStr=="": latticeTypeStr = "Square" typeIdTypeNameDict = CompuCellSetup.ExtractTypeNamesAndIds() print "typeIdTypeNameDict",typeIdTypeNameDict from XMLUtils import ElementCC3D dim = self.sim.getPotts().getCellFieldG().getDim() numberOfSteps = self.sim.getNumSteps() latticeDataXMLElement=ElementCC3D("CompuCell3DLatticeData",{"Version":"1.0"}) latticeDataXMLElement.ElementCC3D("Dimensions",{"x":str(dim.x),"y":str(dim.y),"z":str(dim.z)}) latticeDataXMLElement.ElementCC3D("Lattice",{"Type":latticeTypeStr}) latticeDataXMLElement.ElementCC3D("Output",{"Frequency":str(self.outputFrequency),"NumberOfSteps":str(numberOfSteps),"CoreFileName":self.outputFileCoreName,"Directory":self.outputDirName}) #output information about cell type names and cell ids. It is necessary during generation of the PIF files from VTK output for typeId in typeIdTypeNameDict.keys(): latticeDataXMLElement.ElementCC3D("CellType",{"TypeName":str(typeIdTypeNameDict[typeId]),"TypeId":str(typeId)}) fieldsXMLElement=latticeDataXMLElement.ElementCC3D("Fields") for fieldName in self.fieldTypes.keys(): fieldsXMLElement.ElementCC3D("Field",{"Name":fieldName,"Type":self.fieldTypes[fieldName]}) # writing XML description to the disk if _fileName!="": latticeDataXMLElement.CC3DXMLElement.saveXML(str(_fileName)) else: latticeDataFileName = join(self.outputDirName,self.outputFileCoreName+"LDF.dml") latticeDataXMLElement.CC3DXMLElement.saveXML(str(latticeDataFileName))
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":100,"y":100,"z":1}) potts.ElementCC3D("Steps",{},10000) potts.ElementCC3D("Temperature",{},5) potts.ElementCC3D("NeighborOrder",{},2) potts.ElementCC3D("Boundary_x",{},"Periodic") cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"Body1", "TypeId":"1"}) cellType.ElementCC3D("CellType", {"TypeName":"Body2", "TypeId":"2"}) cellType.ElementCC3D("CellType", {"TypeName":"Body3", "TypeId":"3"}) volume=cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) volume.ElementCC3D("TargetVolume",{},25) volume.ElementCC3D("LambdaVolume",{},4.0) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"Body1", "Type2":"Body1"},16) contact.ElementCC3D("Energy", {"Type1":"Body1", "Type2":"Medium"},4) contact.ElementCC3D("Energy",{"Type1":"Body2", "Type2":"Body2"},16) contact.ElementCC3D("Energy", {"Type1":"Body2", "Type2":"Medium"},4) contact.ElementCC3D("Energy", {"Type1":"Body3", "Type2":"Body3"},16) contact.ElementCC3D("Energy", {"Type1":"Body3", "Type2":"Medium"},4) contact.ElementCC3D("Energy", {"Type1":"Body1", "Type2":"Body2"},16) contact.ElementCC3D("Energy", {"Type1":"Body1", "Type2":"Body3"},16) contact.ElementCC3D("Energy", {"Type1":"Body2", "Type2":"Body3"},16) contact.ElementCC3D("neighborOrder" , {} , 2) centerOfMass=cc3d.ElementCC3D("Plugin",{"Name":"CenterOfMass"}) elasticityTracker=cc3d.ElementCC3D("Plugin",{"Name":"ElasticityTracker"}) elasticityTracker.ElementCC3D("IncludeType",{},"Body1") elasticityTracker.ElementCC3D("IncludeType",{},"Body2") elasticityTracker.ElementCC3D("IncludeType",{},"Body3") elasticityEnergy=cc3d.ElementCC3D("Plugin",{"Name":"ElasticityEnergy"}) elasticityEnergy.ElementCC3D("Local",{}) # elasticityEnergy.ElementCC3D("LambdaElasticity",{},200.0) # elasticityEnergy.ElementCC3D("TargetLengthElasticity",{},6) externalPotential=cc3d.ElementCC3D("Plugin",{"Name":"ExternalPotential"}) externalPotential.ElementCC3D("Lambda",{"x":-10,"y":0, "z":0}) pifInitializer=cc3d.ElementCC3D("Steppable",{"Type":"PIFInitializer"}) pifInitializer.ElementCC3D("PIFName",{},"Simulation/elasticitytest.piff") CompuCellSetup.setSimulationXMLDescription(cc3d)
def configureSimulation(sim): import CompuCellSetup,time from XMLUtils import ElementCC3D C1 = 1 C2 = 1 C3 = 1 C4 = 1 J0 = 16 cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":50,"y":50,"z":1}) potts.ElementCC3D("Steps",{},1000) potts.ElementCC3D("Temperature",{},10) potts.ElementCC3D("NeighborOrder",{},2) cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"Condensing", "TypeId":"1"}) cellType.ElementCC3D("CellType", {"TypeName":"NonCondensing", "TypeId":"2"}) volume=cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) volume.ElementCC3D("TargetVolume",{},25) volume.ElementCC3D("LambdaVolume",{},2.0) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"NonCondensing", "Type2":"NonCondensing"},16) contact.ElementCC3D("Energy", {"Type1":"Condensing", "Type2":"Condensing"},2) contact.ElementCC3D("Energy",{"Type1":"NonCondensing", "Type2":"Condensing"},11) contact.ElementCC3D("Energy", {"Type1":"NonCondensing", "Type2":"Medium"},16) contact.ElementCC3D("Energy", {"Type1":"Condensing", "Type2":"Medium"},16) uniform = cc3d.ElementCC3D("Steppable",{"Type":"UniformInitializer"}) region = uniform.ElementCC3D("Region") region.ElementCC3D("BoxMin",{"x":20, "y":20, "z":0}) region.ElementCC3D("BoxMax",{"x":25, "y":25, "z":1}) region.ElementCC3D("Types",{}, "Condensing") region.ElementCC3D("Width", {}, 5) region1 = uniform.ElementCC3D("Region") region1.ElementCC3D("BoxMin",{"x":20, "y":25, "z":0}) region1.ElementCC3D("BoxMax",{"x":25, "y":30, "z":1}) region1.ElementCC3D("Types",{}, "NonCondensing") region1.ElementCC3D("Width", {}, 5) region1 = uniform.ElementCC3D("Region") region1.ElementCC3D("BoxMin",{"x":25, "y":25, "z":0}) region1.ElementCC3D("BoxMax",{"x":30, "y":30, "z":1}) region1.ElementCC3D("Types",{}, "Condensing") region1.ElementCC3D("Width", {}, 5) templateSteppable = cc3d.ElementCC3D("Steppable",{"Type":"TemplateSteppable"}) templateSteppable.ElementCC3D("PIFName",{},"happy") CompuCellSetup.setSimulationXMLDescription(cc3d)
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":100,"y":100,"z":1}) potts.ElementCC3D("Steps",{},10000) potts.ElementCC3D("Temperature",{},15) potts.ElementCC3D("NeighborOrder",{},2) cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"Bacterium", "TypeId":"1"}) cellType.ElementCC3D("CellType", {"TypeName":"Macrophage", "TypeId":"2"}) cellType.ElementCC3D("CellType", {"TypeName":"Wall", "TypeId":"3" , "Freeze":""}) volume=cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) volume.ElementCC3D("TargetVolume",{},25) volume.ElementCC3D("LambdaVolume",{},15.0) surface=cc3d.ElementCC3D("Plugin",{"Name":"Surface"}) surface.ElementCC3D("TargetSurface",{},20) surface.ElementCC3D("LambdaSurface",{},4.0) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"Macrophage", "Type2":"Macrophage"},15) contact.ElementCC3D("Energy", {"Type1":"Macrophage", "Type2":"Medium"},8) contact.ElementCC3D("Energy",{"Type1":"Bacterium", "Type2":"Bacterium"},15) contact.ElementCC3D("Energy", {"Type1":"Bacterium", "Type2":"Macrophage"},15) contact.ElementCC3D("Energy", {"Type1":"Bacterium", "Type2":"Medium"},8) contact.ElementCC3D("Energy", {"Type1":"Wall", "Type2":"Wall"},0) contact.ElementCC3D("Energy", {"Type1":"Wall", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"Wall", "Type2":"Bacterium"},50) contact.ElementCC3D("Energy", {"Type1":"Wall", "Type2":"Macrophage"},50) chemotaxis=cc3d.ElementCC3D("Plugin",{"Name":"Chemotaxis"}) chemicalField=chemotaxis.ElementCC3D("ChemicalField", {"Source":"FlexibleDiffusionSolverFE", "Name":"ATTR"}) chemicalField.ElementCC3D("ChemotaxisByType", {"Type":"Macrophage" ,"Lambda":200}) flexDiffSolver=cc3d.ElementCC3D("Steppable",{"Type":"FlexibleDiffusionSolverFE"}) diffusionField=flexDiffSolver.ElementCC3D("DiffusionField") diffusionData=diffusionField.ElementCC3D("DiffusionData") diffusionData.ElementCC3D("FieldName",{},"ATTR") diffusionData.ElementCC3D("DiffusionConstant",{},0.10) diffusionData.ElementCC3D("DecayConstant",{},0.0) diffusionData.ElementCC3D("DoNotDiffuseTo",{},"Wall") secretionData=diffusionField.ElementCC3D("SecretionData") secretionData.ElementCC3D("Secretion", {"Type":"Bacterium"},200) pifInitializer=cc3d.ElementCC3D("Steppable",{"Type":"PIFInitializer"}) pifInitializer.ElementCC3D("PIFName",{},"Simulation/bacterium_macrophage_2D_wall.piff") CompuCellSetup.setSimulationXMLDescription(cc3d)
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d = ElementCC3D("CompuCell3D") potts = cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions", {"x": 100, "y": 100, "z": 1}) potts.ElementCC3D("Steps", {}, 10000) potts.ElementCC3D("Temperature", {}, 5) potts.ElementCC3D("NeighborOrder", {}, 2) potts.ElementCC3D("Boundary_x", {}, "Periodic") cellType = cc3d.ElementCC3D("Plugin", {"Name": "CellType"}) cellType.ElementCC3D("CellType", {"TypeName": "Medium", "TypeId": "0"}) cellType.ElementCC3D("CellType", {"TypeName": "Body1", "TypeId": "1"}) cellType.ElementCC3D("CellType", {"TypeName": "Body2", "TypeId": "2"}) cellType.ElementCC3D("CellType", {"TypeName": "Body3", "TypeId": "3"}) volume = cc3d.ElementCC3D("Plugin", {"Name": "Volume"}) volume.ElementCC3D("TargetVolume", {}, 25) volume.ElementCC3D("LambdaVolume", {}, 4.0) contact = cc3d.ElementCC3D("Plugin", {"Name": "Contact"}) contact.ElementCC3D("Energy", {"Type1": "Medium", "Type2": "Medium"}, 0) contact.ElementCC3D("Energy", {"Type1": "Body1", "Type2": "Body1"}, 16) contact.ElementCC3D("Energy", {"Type1": "Body1", "Type2": "Medium"}, 4) contact.ElementCC3D("Energy", {"Type1": "Body2", "Type2": "Body2"}, 16) contact.ElementCC3D("Energy", {"Type1": "Body2", "Type2": "Medium"}, 4) contact.ElementCC3D("Energy", {"Type1": "Body3", "Type2": "Body3"}, 16) contact.ElementCC3D("Energy", {"Type1": "Body3", "Type2": "Medium"}, 4) contact.ElementCC3D("Energy", {"Type1": "Body1", "Type2": "Body2"}, 16) contact.ElementCC3D("Energy", {"Type1": "Body1", "Type2": "Body3"}, 16) contact.ElementCC3D("Energy", {"Type1": "Body2", "Type2": "Body3"}, 16) contact.ElementCC3D("neighborOrder", {}, 2) centerOfMass = cc3d.ElementCC3D("Plugin", {"Name": "CenterOfMass"}) elasticityTracker = cc3d.ElementCC3D("Plugin", {"Name": "ElasticityTracker"}) elasticityTracker.ElementCC3D("IncludeType", {}, "Body1") elasticityTracker.ElementCC3D("IncludeType", {}, "Body2") elasticityTracker.ElementCC3D("IncludeType", {}, "Body3") elasticityEnergy = cc3d.ElementCC3D("Plugin", {"Name": "ElasticityEnergy"}) elasticityEnergy.ElementCC3D("Local", {}) # elasticityEnergy.ElementCC3D("LambdaElasticity",{},200.0) # elasticityEnergy.ElementCC3D("TargetLengthElasticity",{},6) externalPotential = cc3d.ElementCC3D("Plugin", {"Name": "ExternalPotential"}) externalPotential.ElementCC3D("Lambda", {"x": -10, "y": 0, "z": 0}) pifInitializer = cc3d.ElementCC3D("Steppable", {"Type": "PIFInitializer"}) pifInitializer.ElementCC3D("PIFName", {}, "Simulation/elasticitytest.piff") CompuCellSetup.setSimulationXMLDescription(cc3d)
def start(self): self.pWVol = CompuCellSetup.addNewPlotWindow( _title="Average Volume", _xAxisTitle="MonteCarlo Step (MCS)", _yAxisTitle="Average Volume" ) self.pWVol.addPlot(_plotName="MVol", _style="Dots", _color="red", _size=5) self.pWSur = CompuCellSetup.addNewPlotWindow( _title="Average Surface", _xAxisTitle="MonteCarlo Step (MCS)", _yAxisTitle="Average Surface" ) self.pWSur.addPlot(_plotName="MSur")
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D CompuCell3DElmnt=ElementCC3D("CompuCell3D",{"Revision":"20140724","Version":"3.7.2"}) PottsElmnt=CompuCell3DElmnt.ElementCC3D("Potts") # Basic properties of CPM (GGH) algorithm PottsElmnt.ElementCC3D("Dimensions",{"x":"320","y":"480","z":"1"}) PottsElmnt.ElementCC3D("Steps",{},"2001") PottsElmnt.ElementCC3D("Temperature",{},"10.0") PottsElmnt.ElementCC3D("NeighborOrder",{},"1") PluginElmnt=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"CellType"}) # Listing all cell types in the simulation PluginElmnt.ElementCC3D("CellType",{"TypeId":"0","TypeName":"Medium"}) PluginElmnt.ElementCC3D("CellType",{"TypeId":"1","TypeName":"AnteriorLobe"}) PluginElmnt.ElementCC3D("CellType",{"TypeId":"2","TypeName":"EN"}) PluginElmnt.ElementCC3D("CellType",{"TypeId":"3","TypeName":"GZ"}) PluginElmnt_1=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Volume"}) # Cell property trackers and manipulators PluginElmnt_2=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Surface"}) extPotential=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"ExternalPotential"}) PluginElmnt_4=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"CenterOfMass"}) PluginElmnt_6=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"NeighborTracker"}) PluginElmnt_6=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Secretion"}) PluginElmnt_5=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Contact"}) # Specification of adhesion energies PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"Medium"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"AnteriorLobe"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"EN"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"GZ"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"AnteriorLobe","Type2":"AnteriorLobe"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"AnteriorLobe","Type2":"EN"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"AnteriorLobe","Type2":"GZ"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"EN","Type2":"EN"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"EN","Type2":"GZ"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"GZ","Type2":"GZ"},"10.0") PluginElmnt_5.ElementCC3D("NeighborOrder",{},"1") ## ***** Define the properties of the Engrailed gene product ***** ## SteppableElmnt=CompuCell3DElmnt.ElementCC3D("Steppable",{"Type":"DiffusionSolverFE"}) DiffusionFieldElmnt=SteppableElmnt.ElementCC3D("DiffusionField",{"Name":"EN_GENE_PRODUCT"}) DiffusionDataElmnt=DiffusionFieldElmnt.ElementCC3D("DiffusionData") DiffusionDataElmnt.ElementCC3D("FieldName",{},"EN_GENE_PRODUCT") DiffusionDataElmnt.ElementCC3D("GlobalDiffusionConstant",{},"10.0") # 0.05 for anterior retardation; 0.5 for bidirectional retardation DiffusionDataElmnt.ElementCC3D("GlobalDecayConstant",{},"0.05") # 0.005 for anterior retardation; 0.05 for bidirectional retardation ## ***** ## SteppableElmnt=CompuCell3DElmnt.ElementCC3D("Steppable",{"Type":"PIFInitializer"}) # Initial layout of cells using PIFF file. Piff files can be generated using PIFGEnerator SteppableElmnt.ElementCC3D("PIFName",{},"Simulation/Dec2014.piff") CompuCellSetup.setSimulationXMLDescription(CompuCell3DElmnt)
def prepareSimulation(self): import CompuCellSetup # CompuCellSetup.setSimulationXMLFileName(self.xmlFileName) (self.sim, self.simthread) = CompuCellSetup.getCoreSimulationObjects() import CompuCell CompuCellSetup.initializeSimulationObjects(self.sim, self.simthread) CompuCellSetup.extraInitSimulationObjects(self.sim, self.simthread) self.simulationInitialized=True self.callingWidget.sim=self.sim
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d = ElementCC3D("CompuCell3D") potts = cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions", {"x": 100, "y": 100, "z": 1}) potts.ElementCC3D("Steps", {}, 1000) potts.ElementCC3D("Temperature", {}, 10) potts.ElementCC3D("NeighborOrder", {}, 2) cellType = cc3d.ElementCC3D("Plugin", {"Name": "CellType"}) cellType.ElementCC3D("CellType", {"TypeName": "Medium", "TypeId": "0"}) cellType.ElementCC3D("CellType", {"TypeName": "Condensing", "TypeId": "1"}) cellType.ElementCC3D("CellType", { "TypeName": "NonCondensing", "TypeId": "2" }) volume = cc3d.ElementCC3D("Plugin", {"Name": "Volume"}) volume.ElementCC3D("TargetVolume", {}, 25) volume.ElementCC3D("LambdaVolume", {}, 2.0) contact = cc3d.ElementCC3D("Plugin", {"Name": "Contact"}) contact.ElementCC3D("Energy", {"Type1": "Medium", "Type2": "Medium"}, 0) contact.ElementCC3D("Energy", { "Type1": "NonCondensing", "Type2": "NonCondensing" }, 16) contact.ElementCC3D("Energy", { "Type1": "Condensing", "Type2": "Condensing" }, 2) contact.ElementCC3D("Energy", { "Type1": "NonCondensing", "Type2": "Condensing" }, 11) contact.ElementCC3D("Energy", { "Type1": "NonCondensing", "Type2": "Medium" }, 16) contact.ElementCC3D("Energy", { "Type1": "Condensing", "Type2": "Medium" }, 16) blobInitializer = cc3d.ElementCC3D("Steppable", {"Type": "BlobInitializer"}) blobInitializer.ElementCC3D("Gap", {}, 0) blobInitializer.ElementCC3D("Width", {}, 5) blobInitializer.ElementCC3D("CellSortInit", {}, "yes") blobInitializer.ElementCC3D("Radius", {}, 40) CompuCellSetup.setSimulationXMLDescription(cc3d)
def prepareSimulation(self): import CompuCellSetup # CompuCellSetup.setSimulationXMLFileName(self.xmlFileName) (self.sim, self.simthread) = CompuCellSetup.getCoreSimulationObjects() import CompuCell CompuCellSetup.initializeSimulationObjects(self.sim, self.simthread) CompuCellSetup.extraInitSimulationObjects(self.sim, self.simthread) self.simulationInitialized = True self.callingWidget.sim = self.sim
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":55,"y":55,"z":1}) potts.ElementCC3D("Steps",{},1000) potts.ElementCC3D("Temperature",{},15) potts.ElementCC3D("Boundary_y",{},"Periodic") cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"Amoeba", "TypeId":"1"}) cellType.ElementCC3D("CellType", {"TypeName":"Bacteria", "TypeId":"2"}) volume=cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) volume.ElementCC3D("TargetVolume",{},25) volume.ElementCC3D("LambdaVolume",{},15.0) surface=cc3d.ElementCC3D("Plugin",{"Name":"Surface"}) surface.ElementCC3D("TargetSurface",{},25) surface.ElementCC3D("LambdaSurface",{},2.0) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"Amoeba", "Type2":"Amoeba"},15) contact.ElementCC3D("Energy", {"Type1":"Amoeba", "Type2":"Medium"},8) contact.ElementCC3D("Energy", {"Type1":"Bacteria", "Type2":"Bacteria"},15) contact.ElementCC3D("Energy", {"Type1":"Bacteria", "Type2":"Amoeba"},15) contact.ElementCC3D("Energy", {"Type1":"Bacteria", "Type2":"Medium"},8) contact.ElementCC3D("NeighborOrder", {},2) chemotaxis=cc3d.ElementCC3D("Plugin",{"Name":"Chemotaxis"}) chemicalField=chemotaxis.ElementCC3D("ChemicalField", {"Source":"DiffusionSolverFE", "Name":"FGF"}) chemicalField.ElementCC3D("ChemotaxisByType", {"Type":"Amoeba" ,"Lambda":3}) chemicalField.ElementCC3D("ChemotaxisByType", {"Type":"Bacteria" ,"Lambda":2}) flexDiffSolver=cc3d.ElementCC3D("Steppable",{"Type":"DiffusionSolverFE"}) diffusionField=flexDiffSolver.ElementCC3D("DiffusionField") diffusionData=diffusionField.ElementCC3D("DiffusionData") diffusionData.ElementCC3D("FieldName",{},"FGF") diffusionData.ElementCC3D("DiffusionConstant",{},0.0) diffusionData.ElementCC3D("DecayConstant",{},0.0) diffusionData.ElementCC3D("ConcentrationFileName",{},"Simulation/amoebaConcentrationField_2D.txt") pifInitializer=cc3d.ElementCC3D("Steppable",{"Type":"PIFInitializer"}) pifInitializer.ElementCC3D("PIFName",{},"Simulation/amoebae_2D.piff") CompuCellSetup.setSimulationXMLDescription(cc3d)
class GraphVTKVisSteppable(SteppableBasePy): def __init__(self, _simulator, _frequency=10): SteppableBasePy.__init__(self, _simulator, _frequency) def start(self): try: import networkx except ImportError, e: return self.visData = CompuCellSetup.createCustomVisPy("CustomGraph") self.visData.registerVisCallbackFunction(self.visualize) self.visData.addActor("glyph", "vtkActor") self.visData.addActor("profile", "vtkActor") self.visData.addActor("nodeColorBar", "vtkScalarBarActor") self.visData.addActor("nodeSizeText", "vtkTextActor") self.visData.addActor("edgeColorBar", "vtkScalarBarActor") self.visData.addActor("edgeSizeText", "vtkTextActor") self.cellIdDict = {} self.cellPosDict = {} self.cellContactNetwork = nx.Graph() self.updateCellIdDict() self.makeContactNetwork(self.cellContactNetwork, fillDegrees=True)
def __savePlotAsPNG(self, _fileName, _sizeX, _sizeY, _mutex): fileName = str(_fileName) # pixmap=QPixmap(_sizeX,_sizeY) # worked on Windows, but not Linux/OSX # pixmap.fill(QColor("white")) imgmap = QImage(_sizeX, _sizeY, QImage.Format_ARGB32) #imgmap.fill(Qt.white) imgmap.fill( qRgba(255, 255, 255, 255) ) # solid white background (should probably depend on user-chosen colors though) self.pW.print_(imgmap) # following seems pretty crude, but keep in mind user can change Prefs anytime during sim # # # if Configuration.getSetting("OutputToProjectOn"): # # # outDir = str(Configuration.getSetting("ProjectLocation")) # # # else: # # # outDir = str(Configuration.getSetting("OutputLocation")) import CompuCellSetup outDir = CompuCellSetup.getSimulationOutputDir() outfile = os.path.join(outDir, fileName) # print '--------- savePlotAsPNG: outfile=',outfile imgmap.save(outfile, "PNG") _mutex.unlock()
def savePlotAsData(self,_fileName): # # # if Configuration.getSetting("OutputToProjectOn"): # # # outDir = str(Configuration.getSetting("ProjectLocation")) # # # else: # # # outDir = str(Configuration.getSetting("OutputLocation")) # may to dump into image/lattice output dir instead import CompuCellSetup outDir=CompuCellSetup.getSimulationOutputDir() outfile = os.path.join(outDir,_fileName) print MODULENAME,' savePlotAsData(): outfile=',outfile fpout = open(outfile, "w") # print MODULENAME,' self.plotData= ',self.plotData for idx in range(len(self.plotData)): # print MODULENAME,' savePlotAsData(): ------- idx,name=',idx, self.plotData.keys()[idx] fpout.write(self.plotData.keys()[idx] + '\n') xvals = self.plotData.values()[idx][0] yvals = self.plotData.values()[idx][1] # print MODULENAME,' savePlotAsData(): xvals=',xvals # print MODULENAME,' savePlotAsData(): yvals=',yvals for jdx in range(len(xvals)): xyStr = "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) # if (not _plotName in self.plotData.keys() ) or (not _plotName in self.plotDrawingObjects.keys() ): fpout.close()
def optimization_step(self, mcs): """ THis function implements houklsekeeping associated with running optimization algorithm in a steppable :param mcs {int}: current mcs :return: None """ if not mcs % self.sim_length_mcs: if self.optim.stop(): self.stopSimulation() print('termination by', self.optim.stop()) print('best f-value =', self.optim.result()[1]) print('best solution =', self.optim.result()[0]) if not len(self.X_vec): self.X_vec = self.optim.ask() if len(self.f_vec): # print 'self.X_vec_check=', self.X_vec_check # print 'self.f_vec=', self.f_vec self.optim.tell( self.X_vec_check, self.f_vec) # do all the real "update" work self.optim.disp(20) # display info every 20th iteration self.optim.logger.add() # log another "data line" self.f_vec = [] self.num_fcn_evals = len(self.X_vec) self.X_vec_check = deepcopy(self.X_vec) self.X_current = self.X_vec[0] if len(self.X_vec_check) != self.num_fcn_evals: fcn_target = self.minimized_fcn() self.f_vec.append(fcn_target) self.X_vec.pop(0) self.num_fcn_evals -= 1 CompuCellSetup.reset_current_step(0) self.simulator.setStep(0) self.clean_cell_field(reset_inventory=True) self.initial_condition_fcn(self.X_current)
def setSimulationResultStorageDirectory(_dir=''): if _dir != '' and _dir != None: CompuCellSetup.simulationPaths.setSimulationResultStorageDirectory(_dir, False) else: outputDir = getRootOutputDir() simulationResultsDirectoryName, baseFileNameForDirectory = CompuCellSetup.getNameForSimDir(fileName, outputDir) CompuCellSetup.simulationPaths.setSimulationResultStorageDirectoryDirect(simulationResultsDirectoryName)
def start(self): self.pW = CompuCellSetup.addNewPlotWindow( _title="Average Volume And Surface", _xAxisTitle="MonteCarlo Step (MCS)", _yAxisTitle="Variables" ) self.pW.addPlot("MVol", _style="Dots", _color="red", _size=5) self.pW.addPlot("MSur", _style="Steps", _size=1) self.pW.setYAxisLogScale()
def savePlotAsData(self, _fileName, _outputFormat=LEGACY_FORMAT): # PLOT_TYPE_POSITION=3 # (XYPLOT,HISTOGRAM,BARPLOT)=range(0,3) import CompuCellSetup outDir = CompuCellSetup.getSimulationOutputDir() outfile = os.path.join(outDir, _fileName) # print MODULENAME,' savePlotAsData(): outfile=',outfile fpout = open(outfile, "w") # print MODULENAME,' self.plotData= ',self.plotData for plotName, plotData in self.plotData.iteritems(): # fpout.write(plotName+ '\n') fieldSize = self.writeOutHeader(_file=fpout, _plotName=plotName, _outputFormat=_outputFormat) xvals = plotData[0] yvals = plotData[1] # print MODULENAME,' savePlotAsData(): xvals=',xvals # print MODULENAME,' savePlotAsData(): yvals=',yvals if _outputFormat == LEGACY_FORMAT: if plotData[PLOT_TYPE_POSITION] == XYPLOT or plotData[ PLOT_TYPE_POSITION] == BARPLOT: for jdx in range(len(xvals)): xyStr = "%f %f\n" % (xvals[jdx], yvals[jdx]) fpout.write(xyStr) elif plotData[PLOT_TYPE_POSITION] == HISTOGRAM: for jdx in range(len(xvals) - 1): xyStr = "%f %f\n" % (xvals[jdx], yvals[jdx]) fpout.write(xyStr) elif _outputFormat == CSV_FORMAT: fmt = '' fmt += '{0:>' + str(fieldSize) + '},' fmt += '{1:>' + str(fieldSize) + '}\n' if plotData[PLOT_TYPE_POSITION] == XYPLOT or plotData[ PLOT_TYPE_POSITION] == BARPLOT: for jdx in range(len(xvals)): xyStr = fmt.format(xvals[jdx], yvals[jdx]) # "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) elif plotData[PLOT_TYPE_POSITION] == HISTOGRAM: for jdx in range(len(xvals) - 1): xyStr = fmt.format(xvals[jdx], yvals[jdx]) # xyStr = "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) else: raise LookupError(MODULENAME + " savePlotAsData :" + "Requested output format: " + outputFormat + " does not exist") fpout.write('\n') #separating data series by a line fpout.close()
def optimization_step(self, mcs): """ THis function implements houklsekeeping associated with running optimization algorithm in a steppable :param mcs {int}: current mcs :return: None """ if not mcs % self.sim_length_mcs: if self.optim.stop(): self.stopSimulation() print('termination by', self.optim.stop()) print('best f-value =', self.optim.result()[1]) print('best solution =', self.optim.result()[0]) if not len(self.X_vec): self.X_vec = self.optim.ask() if len(self.f_vec): # print 'self.X_vec_check=', self.X_vec_check # print 'self.f_vec=', self.f_vec self.optim.tell(self.X_vec_check, self.f_vec) # do all the real "update" work self.optim.disp(20) # display info every 20th iteration self.optim.logger.add() # log another "data line" self.f_vec = [] self.num_fcn_evals = len(self.X_vec) self.X_vec_check = deepcopy(self.X_vec) self.X_current = self.X_vec[0] if len(self.X_vec_check) != self.num_fcn_evals: fcn_target = self.minimized_fcn() self.f_vec.append(fcn_target) self.X_vec.pop(0) self.num_fcn_evals -= 1 CompuCellSetup.reset_current_step(0) self.simulator.setStep(0) self.clean_cell_field(reset_inventory=True) self.initial_condition_fcn(self.X_current)
def finish(self): global mcsOut global c_value self.f = open( CompuCellSetup.getScreenshotDirectoryName() + "\cvalue.txt", "w+") self.f.write("%d\r\n\n" % mcsOut) for ck in c_value: self.f.write("%d\r" % ck) self.f.close()
def _openFile(self): try: import CompuCellSetup fileHandle, fullFileName = CompuCellSetup.openFileInSimulationOutputDirectory(self._fileName, "a") except IOError: print "Could not open file ", self._fileName, " for writing. Check if you have necessary permissions." return fileHandle
def setSimulationResultStorageDirectory(_dir=''): if _dir != '': CompuCellSetup.simulationPaths.setSimulationResultStorageDirectory(_dir,False) else: outputDir = str(Configuration.getSetting('OutputLocation')) simulationResultsDirectoryName , baseFileNameForDirectory = CompuCellSetup.getNameForSimDir(fileName,outputDir) CompuCellSetup.simulationPaths.setSimulationResultStorageDirectoryDirect(simulationResultsDirectoryName) print 'simulationResultsDirectoryName , baseFileNameForDirectory=',(simulationResultsDirectoryName , baseFileNameForDirectory)
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D CompuCell3DElmnt=ElementCC3D("CompuCell3D",{"Revision":"20140724","Version":"3.7.2"}) PottsElmnt=CompuCell3DElmnt.ElementCC3D("Potts") # Basic properties of CPM (GGH) algorithm PottsElmnt.ElementCC3D("Dimensions",{"x":"320","y":"480","z":"1"}) PottsElmnt.ElementCC3D("Steps",{},"900") PottsElmnt.ElementCC3D("Temperature",{},"10.0") PottsElmnt.ElementCC3D("NeighborOrder",{},"1") PluginElmnt=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"CellType"}) # Listing all cell types in the simulation PluginElmnt.ElementCC3D("CellType",{"TypeId":"0","TypeName":"Medium"}) PluginElmnt.ElementCC3D("CellType",{"TypeId":"1","TypeName":"AnteriorLobe"}) PluginElmnt.ElementCC3D("CellType",{"TypeId":"2","TypeName":"Segment"}) PluginElmnt.ElementCC3D("CellType",{"TypeId":"3","TypeName":"GZ"}) PluginElmnt_1=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Volume"}) # Cell property trackers and manipulators PluginElmnt_2=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Surface"}) extPotential=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"ExternalPotential"}) PluginElmnt_4=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"CenterOfMass"}) PluginElmnt_5=CompuCell3DElmnt.ElementCC3D("Plugin",{"Name":"Contact"}) # Specification of adhesion energies PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"Medium"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"AnteriorLobe"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"Segment"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Medium","Type2":"GZ"},"100.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"AnteriorLobe","Type2":"AnteriorLobe"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"AnteriorLobe","Type2":"Segment"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"AnteriorLobe","Type2":"GZ"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Segment","Type2":"Segment"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"Segment","Type2":"GZ"},"10.0") PluginElmnt_5.ElementCC3D("Energy",{"Type1":"GZ","Type2":"GZ"},"10.0") PluginElmnt_5.ElementCC3D("NeighborOrder",{},"1") SteppableElmnt=CompuCell3DElmnt.ElementCC3D("Steppable",{"Type":"PIFInitializer"}) # Initial layout of cells using PIFF file. Piff files can be generated using PIFGEnerator SteppableElmnt.ElementCC3D("PIFName",{},"Simulation/newStart.piff") CompuCellSetup.setSimulationXMLDescription(CompuCell3DElmnt)
def start(self): # avg volumes self.pWVol=CompuCellSetup.addNewPlotWindow(_title='Average Volume',_xAxisTitle='MonteCarlo Step (MCS)',_yAxisTitle='Average Volume') self.pWVol.addPlot(_plotName='MVol',_style='Dots',_color='red',_size=5) self.pWVol.addPlot(_plotName='N_TVol',_style='Dots',_color='green',_size=5) # number of cells self.pWNum=CompuCellSetup.addNewPlotWindow(_title='Number of Cells',_xAxisTitle='MonteCarlo Step (MCS)',_yAxisTitle='Number') self.pWNum.addPlot(_plotName='Normal',_color='green',_size=2) self.pWNum.addPlot(_plotName='PROL',_color='blue',_size=2) self.pWNum.addPlot(_plotName='MIGR',_color='red', _style='Dots',_size=2) self.pWNum.addPlot(_plotName='NECR',_color='black', _style='Dots',_size=2) self.pWNum.addPlot(_plotName='Total',_color='red',_size=2) # proportions self.pWProp=CompuCellSetup.addNewPlotWindow(_title='Proportions of Cancer vs Normal Cells',_xAxisTitle='MonteCarlo Step (MCS)',_yAxisTitle='%') self.pWProp.addPlot(_plotName='Cancer',_color='green') self.pWProp.addPlot(_plotName='Normal',_color='blue')
def finish(self): # Finish Function gets called after the last MCS # CompuCellSetup.set_simulation_return_value(322.0) temperature_access_path = [['Potts'], ['Temperature']] temp = float(self.getXMLElementValue(*temperature_access_path)) access_path = [['Plugin', 'Name', 'Contact'], ['Energy', 'Type1', 'A', 'Type2', 'B']] contact_energy = float(self.getXMLElementValue(*access_path)) print 'temp,contact_energy=', (temp, contact_energy) x = [temp, contact_energy] target_val = self.fcn(x) # target_val = self.fcn(x)+3***2 target_val = float(int(self.fcn(x))) CompuCellSetup.set_simulation_return_value(target_val)
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") Globals=cc3d.ElementCC3D("Globals") for key in sorted(globals(), key=str.lower): if key not in Old: Globals.ElementCC3D(key,{},globals()[key]) keys.append(key) md=cc3d.ElementCC3D("Metadata") md.ElementCC3D("VirtualProcessingUnits",{"ThreadsPerVPU":2},2) md.ElementCC3D("DebugOutputFrequency",{},0) potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":Lx,"y":Ly,"z":Lz}) potts.ElementCC3D("Steps",{},Time) potts.ElementCC3D("Temperature",{},int(T)) potts.ElementCC3D("NeighborOrder",{},2) #CELL TYPES: cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium","TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"cyto", "TypeId":"1"}) #CELL COLORS: playSet=cc3d.ElementCC3D("Plugin",{"Name":"PlayerSettings"}) playSet.ElementCC3D("Cell", {"Type":"0", "Color":"#000000"}) #black playSet.ElementCC3D("Cell", {"Type":"1", "Color":"#FFFFFF"}) #white #CONTACT ENERGIES: contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"cyto" },10) # contact.ElementCC3D("Energy", {"Type1":"cyto", "Type2":"cyto"},10) #-neighbor order contact.ElementCC3D("NeighborOrder",{},nOrder) CompuCellSetup.setSimulationXMLDescription(cc3d)
def savePlotAsData(self,_fileName,_outputFormat=LEGACY_FORMAT): # PLOT_TYPE_POSITION=3 # (XYPLOT,HISTOGRAM,BARPLOT)=range(0,3) import CompuCellSetup outDir=CompuCellSetup.getSimulationOutputDir() outfile = os.path.join(outDir,_fileName) # print MODULENAME,' savePlotAsData(): outfile=',outfile fpout = open(outfile, "w") # print MODULENAME,' self.plotData= ',self.plotData for plotName,plotData in self.plotData.iteritems(): # fpout.write(plotName+ '\n') fieldSize=self.writeOutHeader( _file=fpout,_plotName=plotName, _outputFormat=_outputFormat) xvals = plotData[0] yvals = plotData[1] # print MODULENAME,' savePlotAsData(): xvals=',xvals # print MODULENAME,' savePlotAsData(): yvals=',yvals if _outputFormat==LEGACY_FORMAT: if plotData[PLOT_TYPE_POSITION]==XYPLOT or plotData[PLOT_TYPE_POSITION]==BARPLOT: for jdx in range(len(xvals)): xyStr = "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) elif plotData[PLOT_TYPE_POSITION]==HISTOGRAM: for jdx in range(len(xvals)-1): xyStr = "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) elif _outputFormat==CSV_FORMAT: fmt='' fmt+='{0:>'+str(fieldSize)+'},' fmt+='{1:>'+str(fieldSize)+'}\n' if plotData[PLOT_TYPE_POSITION]==XYPLOT or plotData[PLOT_TYPE_POSITION]==BARPLOT: for jdx in range(len(xvals)): xyStr = fmt.format(xvals[jdx],yvals[jdx]) # "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) elif plotData[PLOT_TYPE_POSITION]==HISTOGRAM: for jdx in range(len(xvals)-1): xyStr = fmt.format(xvals[jdx],yvals[jdx]) # xyStr = "%f %f\n" % (xvals[jdx],yvals[jdx]) fpout.write(xyStr) else: raise LookupError(MODULENAME+" savePlotAsData :"+"Requested output format: "+outputFormat+" does not exist") fpout.write('\n') #separating data series by a line fpout.close()
def finish(self): # Finish Function gets called after the last MCS # CompuCellSetup.set_simulation_return_value(322.0) temperature_access_path = [['Potts'], ['Temperature']] temp = float(self.getXMLElementValue(*temperature_access_path)) access_path = [['Plugin', 'Name', 'Contact'], ['Energy', 'Type1', 'A','Type2','B']] contact_energy = float(self.getXMLElementValue(*access_path)) print 'temp,contact_energy=',(temp, contact_energy) x = [temp, contact_energy] target_val = self.fcn(x) # target_val = self.fcn(x)+3***2 target_val = float(int(self.fcn(x))) CompuCellSetup.set_simulation_return_value(target_val)
def step(self,mcs): print "This function is called every 10 MCS" for cell in self.cellList: print "CELL ID=",cell.id, " CELL TYPE=",cell.type," volume=",cell.volume if not ( mcs % 20 ): counter=0 for cell in self.cellListByType(self.CONDENSING): print "BY TYPE CELL ID=",cell.id, " CELL TYPE=",cell.type," volume=",cell.volume counter+=1 for cell in self.cellListByType(self.NONCONDENSING): print "BY TYPE CELL ID=",cell.id, " CELL TYPE=",cell.type," volume=",cell.volume counter+=1 for cell in self.cellListByType(self.CONDENSING,self.NONCONDENSING): print "MULTI TYPE LIST - CELL ID=",cell.id, " CELL TYPE=",cell.type," volume=",cell.volume print "number of cells in typeInventory=",len(self.cellListByType) print "number of cells in the entire cell inventory=",len(self.cellList) if mcs>500: CompuCellSetup.stopSimulation()
def finish(self): global mcsOut global c_value # saving number of cells getting deleted at lattice boundary at each mcs self.f = open( CompuCellSetup.getScreenshotDirectoryName() + "\cvalue.txt", "w+") self.f.write( "%d\r\n\n" % mcsOut) #saving the number of MCS when cells start getting deleted for ck in c_value: self.f.write("%d\r" % ck) self.f.close()
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":100,"y":100,"z":1}) potts.ElementCC3D("Steps",{},1000) potts.ElementCC3D("Anneal",{},10) potts.ElementCC3D("Temperature",{},10) potts.ElementCC3D("Flip2DimRatio",{},1) potts.ElementCC3D("NeighborOrder",{},2) cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium", "TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"Condensing", "TypeId":"1"}) cellType.ElementCC3D("CellType", {"TypeName":"NonCondensing", "TypeId":"2"}) volume=cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) volume.ElementCC3D("TargetVolume",{},25) volume.ElementCC3D("LambdaVolume",{},2.0) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"NonCondensing", "Type2":"NonCondensing"},16) contact.ElementCC3D("Energy", {"Type1":"Condensing", "Type2":"Condensing"},2) contact.ElementCC3D("Energy",{"Type1":"NonCondensing", "Type2":"Condensing"},11) contact.ElementCC3D("Energy", {"Type1":"NonCondensing", "Type2":"Medium"},16) contact.ElementCC3D("Energy", {"Type1":"Condensing", "Type2":"Medium"},16) contact.ElementCC3D("NeighborOrder", {}, 2) blobInitializer=cc3d.ElementCC3D("Steppable",{"Type":"BlobInitializer"}) blobInitializer.ElementCC3D("Gap",{},0) blobInitializer.ElementCC3D("Width",{},5) blobInitializer.ElementCC3D("CellSortInit",{},"yes") blobInitializer.ElementCC3D("Radius",{},40) CompuCellSetup.setSimulationXMLDescription(cc3d)
def init_lattice_type(self): """ Initializes lattice type and lattice type enum :return: None """ self.lattice_type_str = CompuCellSetup.ExtractLatticeType() if self.lattice_type_str in Configuration.LATTICE_TYPES.keys(): self.lattice_type = Configuration.LATTICE_TYPES[ self.lattice_type_str] else: # default choice self.lattice_type = Configuration.LATTICE_TYPES["Square"]
def __openParameterfile(self, filename): """ Writes all parameters to a file. :param filename: :return: """ #TODO: change from pure text file to xml? try: import CompuCellSetup self.__fileHandle, self.__fullFileName = CompuCellSetup.openFileInSimulationOutputDirectory(filename, "a") except IOError: print "Could not open file ", filename, \ " for writing. Check if you have necessary permissions."
def step(self, mcs): print "This function is called every 10 MCS" for cell in self.cellList: print "CELL ID=", cell.id, " CELL TYPE=", cell.type, " volume=", cell.volume if not (mcs % 20): counter = 0 for cell in self.cellListByType(self.CONDENSING): print "BY TYPE CELL ID=", cell.id, " CELL TYPE=", cell.type, " volume=", cell.volume counter += 1 for cell in self.cellListByType(self.NONCONDENSING): print "BY TYPE CELL ID=", cell.id, " CELL TYPE=", cell.type, " volume=", cell.volume counter += 1 for cell in self.cellListByType(self.CONDENSING, self.NONCONDENSING): print "MULTI TYPE LIST - CELL ID=", cell.id, " CELL TYPE=", cell.type, " volume=", cell.volume print "number of cells in typeInventory=", len(self.cellListByType) print "number of cells in the entire cell inventory=", len( self.cellList) if mcs > 500: CompuCellSetup.stopSimulation()
def copyFilesToOutputDirectory(self): import CompuCellSetup screenshotDirectoryName=CompuCellSetup.getScreenshotDirectoryName() import shutil import os if screenshotDirectoryName=="": return for fileName in self.fileNamesList: fileName=CompuCellSetup.simulationPaths.normalizePath(fileName) sourceFileName=os.path.abspath(fileName) destinationFileName=os.path.join(screenshotDirectoryName,os.path.basename(sourceFileName)) shutil.copy(sourceFileName,destinationFileName)
def step(self,mcs): fileName="diffusion_output/FGF_"+str(mcs)+".dat" field=CompuCell.getConcentrationField(self.simulator,"FGF") if field: try: import CompuCellSetup fileHandle,fullFileName=CompuCellSetup.openFileInSimulationOutputDirectory(fileName,"w") except IOError: print "Could not open file ", fileName," for writing. Check if you have necessary permissions" for i,j,k in self.everyPixel(): fileHandle.write("%d\t%d\t%d\t%f\n"%(i,j,k,field[i,j,k])) fileHandle.close()
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d = ElementCC3D("CompuCell3D") potts = cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions", {"x": 42, "y": 42, "z": 1}) potts.ElementCC3D("Steps", {}, 10000) potts.ElementCC3D("Anneal", {}, 10) potts.ElementCC3D("Temperature", {}, 10) potts.ElementCC3D("NeighborOrder", {}, 2) potts.ElementCC3D("Boundary_x", {}, "Periodic") potts.ElementCC3D("Boundary_y", {}, "Periodic") cellType = cc3d.ElementCC3D("Plugin", {"Name": "CellType"}) cellType.ElementCC3D("CellType", {"TypeName": "Medium", "TypeId": "0"}) cellType.ElementCC3D("CellType", {"TypeName": "TypeA", "TypeId": "1"}) contact = cc3d.ElementCC3D("Plugin", {"Name": "Contact"}) contact.ElementCC3D("Energy", {"Type1": "Medium", "Type2": "Medium"}, 0) contact.ElementCC3D("Energy", {"Type1": "Medium", "Type2": "TypeA"}, 5) contact.ElementCC3D("Energy", {"Type1": "TypeA", "Type2": "TypeA"}, 5) contact.ElementCC3D("NeighborOrder", {}, 4) vp = cc3d.ElementCC3D("Plugin", {"Name": "Volume"}) vp.ElementCC3D("TargetVolume", {}, 49) vp.ElementCC3D("LambdaVolume", {}, 5) ntp = cc3d.ElementCC3D("Plugin", {"Name": "NeighborTracker"}) uipd = cc3d.ElementCC3D("Steppable", {"Type": "UniformInitializer"}) region = uipd.ElementCC3D("Region") region.ElementCC3D("BoxMin", {"x": 0, "y": 0, "z": 0}) region.ElementCC3D("BoxMax", {"x": 42, "y": 42, "z": 1}) region.ElementCC3D("Types", {}, "TypeA") region.ElementCC3D("Width", {}, 7) CompuCellSetup.setSimulationXMLDescription(cc3d)
def configureSimulation(sim): import CompuCellSetup from XMLUtils import ElementCC3D cc3d=ElementCC3D("CompuCell3D") potts=cc3d.ElementCC3D("Potts") potts.ElementCC3D("Dimensions",{"x":42,"y":42,"z":1}) potts.ElementCC3D("Steps",{},10000) potts.ElementCC3D("Anneal",{},10) potts.ElementCC3D("Temperature",{},10) potts.ElementCC3D("NeighborOrder",{},2) potts.ElementCC3D("Boundary_x",{},"Periodic") potts.ElementCC3D("Boundary_y",{},"Periodic") cellType=cc3d.ElementCC3D("Plugin",{"Name":"CellType"}) cellType.ElementCC3D("CellType", {"TypeName":"Medium","TypeId":"0"}) cellType.ElementCC3D("CellType", {"TypeName":"TypeA" ,"TypeId":"1"}) contact=cc3d.ElementCC3D("Plugin",{"Name":"Contact"}) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"Medium"},0) contact.ElementCC3D("Energy", {"Type1":"Medium", "Type2":"TypeA"},5) contact.ElementCC3D("Energy", {"Type1":"TypeA", "Type2":"TypeA"},5) contact.ElementCC3D("NeighborOrder",{},4) vp = cc3d.ElementCC3D("Plugin",{"Name":"Volume"}) vp.ElementCC3D("TargetVolume",{},49) vp.ElementCC3D("LambdaVolume",{},5) ntp = cc3d.ElementCC3D("Plugin",{"Name":"NeighborTracker"}) uipd = cc3d.ElementCC3D("Steppable",{"Type":"UniformInitializer"}) region = uipd.ElementCC3D("Region") region.ElementCC3D("BoxMin",{"x":0, "y":0, "z":0}) region.ElementCC3D("BoxMax",{"x":42, "y":42, "z":1}) region.ElementCC3D("Types",{},"TypeA") region.ElementCC3D("Width", {},7) CompuCellSetup.setSimulationXMLDescription(cc3d)
def _run(self): """ Start the simulation. """ self.execConfig.parameterStore.addObj(self) for cellType in self.cellTypes: self.execConfig.parameterStore.addObj(cellType) CompuCellSetup.setSimulationXMLDescription(self._configureSimulation()) CompuCellSetup.initializeSimulationObjects(self.sim, self.simthread) pyAttributeDictionaryAdder, dictAdder = CompuCellSetup.attachDictionaryToCells(self.sim) # Add Python steppables here: steppableRegistry = CompuCellSetup.getSteppableRegistry() for steppable in self._getSteppables(): steppableRegistry.registerSteppable(steppable) CompuCellSetup.mainLoop(self.sim, self.simthread, steppableRegistry)
def start(self): # #################### Create SBML models ###################### sbmlModelName = "DeltaNotchModel" sbmlModelKey = "DN" sbmlModelPath = "Simulation/MinimalDeltaNotch.sbml" timeStepOfIntegration = 0.1 bionetAPI.loadSBMLModel(sbmlModelName, sbmlModelPath, sbmlModelKey, timeStepOfIntegration) # ################ Add SBML models to cell types ################## bionetAPI.addSBMLModelToTemplateLibrary("DeltaNotchModel", "LowDelta") bionetAPI.addSBMLModelToTemplateLibrary("DeltaNotchModel", "HighDelta") ## Include this for a test bionetAPI.addSBMLModelToTemplateLibrary("DeltaNotchModel", "External") # ####### Set initial conditions for SBML properties ######### bionetAPI.setBionetworkInitialCondition("LowDelta", "DN_di", 0.2) bionetAPI.setBionetworkInitialCondition("HighDelta", "DN_di", 0.8) for cell in self.cellList: cell.targetVolume = 32.0 cell.lambdaVolume = 1.0 cell.targetSurface = 32.0 cell.lambdaSurface = 1.0 # ######## Create bionetworks and initialize their states ########## bionetAPI.initializeBionetworks() # ######## Set cell initial conditions by individual cell ########## for cell in self.cellList: dictionaryAttrib = CompuCell.getPyAttrib(cell) dictionaryAttrib["InitialVolume"] = cell.volume dictionaryAttrib["DivideVolume"] = 2. * cell.volume self.initialNumberOfCells = len(self.cellList) print "\n\nNumber of cells: %s\n\n" % self.initialNumberOfCells import CompuCellSetup self.cellTypeMap = CompuCellSetup.ExtractTypeNamesAndIds() del (self.cellTypeMap[0])
def start(self): # #################### Load SBML models ###################### ## Create a bionetwork SBML model named "DeltaNotchModel" sbmlModelName = "DeltaNotchModel" sbmlModelKey = "DN" sbmlModelPath = "Simulation/MinimalDeltaNotch.sbml" timeStepOfIntegration = 0.1 bionetAPI.loadSBMLModel(sbmlModelName, sbmlModelPath, sbmlModelKey, timeStepOfIntegration) # ################ Add SBML models to celltype-specific bionetwork template libraries ################## bionetAPI.addSBMLModelToTemplateLibrary("DeltaNotchModel", "LowDelta") bionetAPI.addSBMLModelToTemplateLibrary("DeltaNotchModel", "HighDelta") ## Include this for a test bionetAPI.addSBMLModelToTemplateLibrary("DeltaNotchModel", "External") # ####### Set initial conditions for SBML properties ######### bionetAPI.setBionetworkInitialCondition("LowDelta", "DN_di", 0.2) bionetAPI.setBionetworkInitialCondition("HighDelta", "DN_di", 0.8) # ######## Create bionetworks and initialize their states ########## bionetAPI.initializeBionetworks() # ######## Set cell initial conditions by individual cell ########## for cell in self.cellList: cell.dict["InitialVolume"] = cell.volume cell.dict["DivideVolume"] = 2. * cell.volume cell.targetVolume = 32.0 cell.lambdaVolume = 1.0 import CompuCellSetup self.cellTypeMap = CompuCellSetup.ExtractTypeNamesAndIds() del (self.cellTypeMap[0])
def __savePlotAsPNG(self,_fileName,_sizeX,_sizeY,_mutex): fileName=str(_fileName) # pixmap=QPixmap(_sizeX,_sizeY) # worked on Windows, but not Linux/OSX # pixmap.fill(QColor("white")) imgmap = QImage(_sizeX, _sizeY, QImage.Format_ARGB32) #imgmap.fill(Qt.white) imgmap.fill(qRgba(255, 255, 255, 255)) # solid white background (should probably depend on user-chosen colors though) self.pW.print_(imgmap) # following seems pretty crude, but keep in mind user can change Prefs anytime during sim # # # if Configuration.getSetting("OutputToProjectOn"): # # # outDir = str(Configuration.getSetting("ProjectLocation")) # # # else: # # # outDir = str(Configuration.getSetting("OutputLocation")) import CompuCellSetup outDir=CompuCellSetup.getSimulationOutputDir() outfile = os.path.join(outDir,fileName) # print '--------- savePlotAsPNG: outfile=',outfile imgmap.save(outfile,"PNG") _mutex.unlock()
def createScalarFieldCellLevelPy(self,_fieldName): import CompuCellSetup return CompuCellSetup.createScalarFieldCellLevelPy(_fieldName)
def createFloatFieldPy(self, _dim,_fieldName): import CompuCellSetup return CompuCellSetup.createFloatFieldPy(_dim,_fieldName)
import sys from os import environ from os import getcwd import string from PySteppablesExamples import SimulationFileStorage sys.path.append(environ["PYTHON_MODULE_PATH"]) import CompuCellSetup sim, simthread = CompuCellSetup.getCoreSimulationObjects() # Create extra player fields here or add attributes CompuCellSetup.initializeSimulationObjects(sim, simthread) # Add Python steppables here steppableRegistry = CompuCellSetup.getSteppableRegistry() from helpfile_steppables_CellDraw import HelpfileCellDrawSteppable theHelpfileCellDrawSteppable = HelpfileCellDrawSteppable(_simulator=sim, _frequency=100) steppableRegistry.registerSteppable(theHelpfileCellDrawSteppable) # sfs=SimulationFileStorage(_simulator=sim,_frequency=10) # sfs.addFileNameToStore("examples_PythonTutorial/cellsort_2D_info_printer/cellsort_2D.xml") # sfs.addFileNameToStore("examples_PythonTutorial/cellsort_2D_info_printer/cellsort_2D_info_printer.py") # sfs.addFileNameToStore("examples_PythonTutorial/cellsort_2D_info_printer/cellsort_2D_steppables_info_printer.py") # steppableRegistry.registerSteppable(sfs)
import sys from os import environ import string python_module_path=os.environ["PYTHON_MODULE_PATH"] appended=sys.path.count(python_module_path) if not appended: sys.path.append(python_module_path) # sys.path.append(environ["PYTHON_MODULE_PATH"]) import CompuCellSetup if not CompuCellSetup.simulationFileName=="": CompuCellSetup.setSimulationXMLFileName(CompuCellSetup.simulationFileName) sim,simthread = CompuCellSetup.getCoreSimulationObjects() import CompuCell #notice importing CompuCell to main script has to be done after call to getCoreSimulationObjects() #Create extra player fields here or add attributes or plugin: #PUT YOUR CODE HERE #PUT YOUR CODE HERE #PUT YOUR CODE HERE import XMLUtils steppableList=CompuCellSetup.cc3dXML2ObjConverter.root.getElements("Plugin") steppableListPy=XMLUtils.CC3DXMLListPy(steppableList) for element in steppableListPy: print "Element",element.name # ," name", element.getNumberOfChildren()
import sys from os import environ import string sys.path.append(environ["PYTHON_MODULE_PATH"]) import CompuCellSetup CompuCellSetup.setSimulationXMLFileName("Simulation/ConnectivityTest.xml") sim,simthread = CompuCellSetup.getCoreSimulationObjects() CompuCellSetup.initializeSimulationObjects(sim,simthread) from PySteppables import SteppableRegistry steppableRegistry=SteppableRegistry() from ConnectivityElongationSteppable import ConnectivityElongationSteppable connectivityElongationSteppable=ConnectivityElongationSteppable(_simulator=sim,_frequency=50) steppableRegistry.registerSteppable(connectivityElongationSteppable) CompuCellSetup.mainLoop(sim,simthread,steppableRegistry)
# CompuCellSetup.setSimulationXMLDescription(CompuCell3DElmnt) # INCORPORATE XML DATA SPECIFICATION FILE import sys from os import environ from os import getcwd import string sys.path.append(environ["PYTHON_MODULE_PATH"]) import CompuCellSetup # path for Win (path for Mac may need full path) CompuCellSetup.setSimulationXMLFileName("Simulation/BlHet.xml") #add additional sim, simthread = CompuCellSetup.getCoreSimulationObjects() #add additional attributes # add extra attributes here pyAttributeDictionaryAdder, dictAdder = CompuCellSetup.attachDictionaryToCells( sim) CompuCellSetup.initializeSimulationObjects(sim, simthread) #notice importing CompuCell to main script has to be done after call to getCoreSimulationObjects() import CompuCell #add lattice monitors here
import sys from os import environ from os import getcwd import string sys.path.append(environ["PYTHON_MODULE_PATH"]) import CompuCellSetup sim, simthread = CompuCellSetup.getCoreSimulationObjects() # add extra attributes here pyAttributeDictionaryAdder, dictAdder = CompuCellSetup.attachDictionaryToCells( sim) CompuCellSetup.initializeSimulationObjects(sim, simthread) # Definitions of additional Python-managed fields go here #Add Python steppables here steppableRegistry = CompuCellSetup.getSteppableRegistry() from bistabSwitch2Steppables import EMT_switch1Steppable steppableInstance = EMT_switch1Steppable(sim, _frequency=100) steppableRegistry.registerSteppable(steppableInstance) CompuCellSetup.mainLoop(sim, simthread, steppableRegistry)