def startSimulation(self, amountOfParticles, initiallyInfected, riskOfInfection, rateOfDeath, riskOfQuarantine, avgInfectedTime, avgImmuneTime, infectionRadius, modifierDeflect, modifierHealth, modifierVaccine, socialDistanceRadius, vaccineDays, healthCareCapacity, deathRateMultiplier): self.isSimulationRunning = True self.simulation = Simulation(amountOfParticles, initiallyInfected, riskOfInfection, rateOfDeath, riskOfQuarantine, avgInfectedTime, avgImmuneTime, infectionRadius, modifierDeflect, modifierHealth, modifierVaccine, socialDistanceRadius, vaccineDays, healthCareCapacity, deathRateMultiplier) self.ui.startSimulation()
def test(self): if not self.lock.locked(): self.lock.acquire() self.__clear_map() simulation = Simulation(self.scenarios[self.scenario], self.test_iteration_finished, 1) if self.last_model: simulation.model = self.last_model simulation.start(self) self.lock.release() else: print("Cannot run tests - Test results are showing now")
def startSimulation(self, xBorder, yBorder, percentageImmune, minImmuneDuration, maxImmuneDuration, countParticles, infectionRate, infectionRadius, initiallyInfected, deathRate, minDaysInfected, maxDaysInfected, quarantinePercentage, vaccinationActivated, vaccinationBegin, vaccinationSpeed, vaccinateHealthyFirst): """this function is used to initiate a simulation. It starts the simulation with the given arguments Args: xBorder: the maximum x-coordinate particles are allowed to move to the right yBorder: the maximum y-coordinate particles are allowed to move down percentageImmune: the percentage of being immune after recovery minImmuneDuration: the minimum duration of being immune maxImmuneDuration: the maximum duration of being immune countParticles: the number of particles the simulation should hold infectionRate: the initially set infection rate which with particles can infect each other infectionRadius: the initially set infection radius, which is used to detect collisions of the particles initiallyInfected: the initial number of particles that are infected by the start of the simulation deathRate: the initially set death rate within the simulation minDaysInfected: the minimum of days particles have to be infected maxDaysInfected the maximum of days particles can be infected quarantinePercentage: the percentage of particles being in quarantine when infected vaccinationActivated: whether vaccination is activated in the current simulation vaccinationBegin: the start of vaccination in days vaccinationSpeed: the count of particles being able to be vaccinated in one day vaccinateHealthyFirst: whether the first one getting vaccinated are the healthy ones """ if countParticles < initiallyInfected: self.ui.showAlert(constants.PARTICLES_ALERT) elif minDaysInfected > maxDaysInfected: self.ui.showAlert(constants.INFECTION_MIN_OVER_MAX_ALERT) elif minImmuneDuration > maxImmuneDuration: self.ui.showAlert(constants.IMMUNE_MIN_OVER_MAX_ALERT) else: if self.isSimulationPaused: self.resetSimulation() self.isSimulationRunning = True self.simulation = Simulation( xBorder, yBorder, percentageImmune, minImmuneDuration, maxImmuneDuration, countParticles, infectionRate, infectionRadius, initiallyInfected, deathRate, minDaysInfected, maxDaysInfected, quarantinePercentage, vaccinationActivated, vaccinationBegin, vaccinationSpeed, vaccinateHealthyFirst) self.ui.startSimulation() self.ui.resumeSimulation()
def run(self): self._init() # Run simulation: for each service to evaluate, create a simulation and delegate to the loader objects # the decision about the environment to load based on the alternatives services = self._parser.get_services() for service in services: # For each alternative of this service, create a simulation for alternative in service.get_alternatives(): ''' Creating overlay and adding it to the topology object. ''' self._log.info(self.__class__.__name__, 'Creating overlay for alternative %s.', alternative.get_name()) # Creating the overlay for current alternative overlay = alternative.create_overlay(self._topology.get_topology_from_graphml()) self._log.info(self.__class__.__name__, 'Adding overlay %s for alternative %s to the topology.', overlay.get_name(), alternative.get_name()) self._topology.add_overlay(overlay) ''' Loading environment, creating the simulation and running it. ''' self._log.info(self.__class__.__name__, 'Loading the environment for the alternative %s.', alternative) # Load an environment for the current alternative of this service environment = self._loader.load(alternative.get_environment()) # Create the simulation simulation = Simulation(self._topology, service, environment, alternative) self._log.info( self.__class__.__name__, 'A new simulation has been created for service %s and alternative %s.', service.get_name(), alternative) # Run the simulation simulation.start() simulation.join() self._log.info(self.__class__.__name__, 'All alternatives for service %s have been successfully tested.', service.get_name()) self._log.info(self.__class__.__name__, 'All services have been successfully tested; framework will stop.')
def __run_simulation( self, networks_groups: Mapping[str, List[NeuralNetwork]] ) -> Generator[None, T_CONTEXT, SimState]: simulation = Simulation(self._track, networks_groups) frame_time = 0.0 any_active = True state: T_STATE = self._initialize() while any_active: context: T_CONTEXT = (yield) frame_time += FIXED_DELTA_TIME frame_time, cars = simulation.update(frame_time) any_active = False # TODO: differentiate cars on group_id for group_id, car_group in cars.items(): for car_state in car_group: if car_state.active: any_active = True self._process_car_step(state, context, group_id, car_state) state = self._finalize_iteration(state, context) return cars
def startMultipleSimulations(self, simCount, simDuration, countParticles, initiallyInfected, infectionRate, infectionRadius, deathRate, minDaysInfected, maxDaysInfected, percentageImmune, minImmuneDuration, maxImmuneDuration, distanceRadius, quarantinePercentage, vaccinationActivated, vaccinationDate, vaccinationSpeed, vaccinateHealthyFirst, dialog, xBorder=0, yBorder=195): """this function is used to initiate multiple simulations. It starts all of the simulations with the given arguments Args: simCount: the count of simulations running simultaneously simDuration: the count of days the simulations will be running countParticles: the number of particles the simulation should hold initiallyInfected: the initial number of particles that are infected by the start of the simulation infectionRate: the initially set infection rate which with particles can infect each other infectionRadius: the initially set infection radius, which is used to detect collisions of the particles deathRate: the initially set death rate within the simulation minDaysInfected: the minimum of days particles have to be infected maxDaysInfected the maximum of days particles can be infected percentageImmune: the percentage of being immune after recovery minImmuneDuration: the minimum duration of being immune maxImmuneDuration: the maximum duration of being immune distanceRadius: the radius particles hold to each other to be on distance quarantinePercentage: the percentage of particles being in quarantine when infected vaccinationActivated: whether vaccination is activated in the current simulation vaccinationDate: the start of vaccination in days vaccinationSpeed: the count of particles being able to be vaccinated in one day vaccinateHealthyFirst: whether the first one getting vaccinated are the healthy ones dialog: the dialog for the presenter from where the call came xBorder: the maximum x-coordinate particles are allowed to move to the right (default: 0) yBorder: the maximum y-coordinate particles are allowed to move down (default: 195) """ self.simulations = [] self.dialog = dialog for i in range(0, simCount): s = Simulation(xBorder, yBorder, percentageImmune, minImmuneDuration, maxImmuneDuration, countParticles, infectionRate, infectionRadius, initiallyInfected, deathRate, minDaysInfected, maxDaysInfected, quarantinePercentage, vaccinationActivated, vaccinationDate, vaccinationSpeed, vaccinateHealthyFirst) s.changeParticleRadius(distanceRadius) self.simulations.append(s) for i in range(0, simDuration * FPS): data = [] for j in range(0, len(self.simulations)): self.simulations[j].performStep() data.append(self.simulations[j].getData()) self.dialog.updateData(data)
class Presenter(QtCore.QObject): """The presenter acts upon the model and the view. It retrieves data from the model (simulation), and formats it to display it in the view.""" def __init__(self): super(Presenter, self).__init__() # create main window self.ui = View() self.dialog = None self.simulation = None self.isSimulationRunning = False self.isSimulationPaused = False # create timer that will call the mainLoop every 1000/FPS milliseconds self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.mainLoop) self.timer.start((1000 / FPS)) self.framecounter = 0 self._connectUIElements() def mainLoop(self): """this function is used to process the steps as long as the simulation is running. It performs the steps and it retrieves the data from the model and updates the data in the view""" if self.isSimulationRunning: self.simulation.performStep() self.ui.updateParticles(self.simulation.getParticles(), self.simulation.getData()) def startSimulation(self, xBorder, yBorder, percentageImmune, minImmuneDuration, maxImmuneDuration, countParticles, infectionRate, infectionRadius, initiallyInfected, deathRate, minDaysInfected, maxDaysInfected, quarantinePercentage, vaccinationActivated, vaccinationBegin, vaccinationSpeed, vaccinateHealthyFirst): """this function is used to initiate a simulation. It starts the simulation with the given arguments Args: xBorder: the maximum x-coordinate particles are allowed to move to the right yBorder: the maximum y-coordinate particles are allowed to move down percentageImmune: the percentage of being immune after recovery minImmuneDuration: the minimum duration of being immune maxImmuneDuration: the maximum duration of being immune countParticles: the number of particles the simulation should hold infectionRate: the initially set infection rate which with particles can infect each other infectionRadius: the initially set infection radius, which is used to detect collisions of the particles initiallyInfected: the initial number of particles that are infected by the start of the simulation deathRate: the initially set death rate within the simulation minDaysInfected: the minimum of days particles have to be infected maxDaysInfected the maximum of days particles can be infected quarantinePercentage: the percentage of particles being in quarantine when infected vaccinationActivated: whether vaccination is activated in the current simulation vaccinationBegin: the start of vaccination in days vaccinationSpeed: the count of particles being able to be vaccinated in one day vaccinateHealthyFirst: whether the first one getting vaccinated are the healthy ones """ if countParticles < initiallyInfected: self.ui.showAlert(constants.PARTICLES_ALERT) elif minDaysInfected > maxDaysInfected: self.ui.showAlert(constants.INFECTION_MIN_OVER_MAX_ALERT) elif minImmuneDuration > maxImmuneDuration: self.ui.showAlert(constants.IMMUNE_MIN_OVER_MAX_ALERT) else: if self.isSimulationPaused: self.resetSimulation() self.isSimulationRunning = True self.simulation = Simulation( xBorder, yBorder, percentageImmune, minImmuneDuration, maxImmuneDuration, countParticles, infectionRate, infectionRadius, initiallyInfected, deathRate, minDaysInfected, maxDaysInfected, quarantinePercentage, vaccinationActivated, vaccinationBegin, vaccinationSpeed, vaccinateHealthyFirst) self.ui.startSimulation() self.ui.resumeSimulation() def pauseResumeSimulation(self): """this function is used to pause or to resume the current simulation""" if self.simulation != None: if (self.isSimulationPaused == False): self.isSimulationRunning = False self.isSimulationPaused = True self.ui.pauseSimulation() else: self.isSimulationRunning = True self.isSimulationPaused = False self.ui.resumeSimulation() else: self.ui.resumeSimulation() def resetSimulation(self): """this function is used to stop and reset the current simulation""" self.isSimulationRunning = False self.isSimulationPaused = False self.simulation = None self.ui.resetSimulation() self.ui.resumeSimulation() def speedSimulation(self, value): """this function is used to change the current speed of the simulation Args: value: the new value by which factor to normal (1) the simulation has to be speed up """ self.timer.setInterval((1 / value * 1000) / FPS) def changeInfectionRate(self, infectionRate): """this function changes the infection rate of the current simulation Args: infectionRate: the new infection rate """ if self.isSimulationRunning: self.simulation.setInfectionRate(infectionRate) def changeDeathRate(self, deathRate): """this function changes the death rate of the current simulation Args: deathRate: the new death rate """ if self.isSimulationRunning: self.simulation.setDeathRate(deathRate) # changes the particles infectionRadius def changeinfectionRadius(self, infectionRadius): """this function changes the infection radius of the current simulation Args: infectionRadius: the new infection radius """ if (self.simulation != None): self.simulation.setInfectionRadius(infectionRadius) def export_csv(self): """this function checks whether the simulation is running or has never started. If not it is allowing the view to show its exportDialog. """ if (self.isSimulationPaused == True): self.ui.ask_granularity() else: if self.simulation: self.ui.showAlert( constants.EXPORT_CSV_SIMULATION_RUNNING_ALERT) else: self.ui.showAlert(constants.EXPORT_CSV_NO_SIMULATION_ALERT) def changeStayAtHome(self): """this fucntion changes the current behaviour of simulating people are staying at home""" if self.isSimulationRunning: self.simulation.changePeopleStayAtHome() def changeParticleRadius(self, radius): """this function changes the particles radii in the current simulation""" if self.simulation: self.simulation.changeParticleRadius(radius) def changeMinDaysInfected(self, minDaysInfected): """this function changes the minimum days particles have to be infected in the current simulation Args: minDaysInfected: the minimum days particles have to be infected """ if self.simulation: if self.simulation.maxDaysInfected >= minDaysInfected: self.simulation.setMinDaysInfected(minDaysInfected) else: self.ui.showAlert(constants.INFECTION_MIN_OVER_MAX_ALERT) def changeMaxDaysInfected(self, maxDaysInfected): """this function changes the maximum days particles are able to be infected in the current simulation Args: maxDaysInfected: the maximum days particles are able to be infected """ if self.simulation: if self.simulation.minDaysInfected <= maxDaysInfected: self.simulation.setMaxDaysInfected(maxDaysInfected) else: self.ui.showAlert(constants.INFECTION_MAX_UNDER_MIN_ALERT) def changePercentageImmune(self, percentage): """this function changes the percentage of particles to be immune in the current simulation Args: percentage: the new percentage of particles being immune afterwards """ self.simulation.setPercentageImmune(percentage) def changeMaxImmuneDuration(self, duration): """this function changes the maximum duration particles are allow to be immune in the current simulation Args: duration: the new maximum duration to be immune """ if self.simulation: if self.simulation.minImmuneDuration <= duration: self.simulation.setMaxImmuneDuration(duration) else: self.ui.showAlert(constants.IMMUNE_MAX_UNDER_MIN_ALERT) def changeMinImmuneDuration(self, duration): """this function changes the minimum duration particles are allow to be immune in the current simulation Args: duration: the new minimum duration to be immune """ if self.simulation: if self.simulation.maxImmuneDuration >= duration: self.simulation.setMinImmuneDuration(duration) else: self.ui.showAlert(constants.IMMUNE_MIN_OVER_MAX_ALERT) def changeQuarantinePercentage(self, percentage): """this function changes the percentage of particles that are in quarantine while being infected Args: percentage: the new percentage of quarantining particles """ if self.simulation: self.simulation.setQuarantinePercentage(percentage) def startMultipleSimulations(self, simCount, simDuration, countParticles, initiallyInfected, infectionRate, infectionRadius, deathRate, minDaysInfected, maxDaysInfected, percentageImmune, minImmuneDuration, maxImmuneDuration, distanceRadius, quarantinePercentage, vaccinationActivated, vaccinationDate, vaccinationSpeed, vaccinateHealthyFirst, dialog, xBorder=0, yBorder=195): """this function is used to initiate multiple simulations. It starts all of the simulations with the given arguments Args: simCount: the count of simulations running simultaneously simDuration: the count of days the simulations will be running countParticles: the number of particles the simulation should hold initiallyInfected: the initial number of particles that are infected by the start of the simulation infectionRate: the initially set infection rate which with particles can infect each other infectionRadius: the initially set infection radius, which is used to detect collisions of the particles deathRate: the initially set death rate within the simulation minDaysInfected: the minimum of days particles have to be infected maxDaysInfected the maximum of days particles can be infected percentageImmune: the percentage of being immune after recovery minImmuneDuration: the minimum duration of being immune maxImmuneDuration: the maximum duration of being immune distanceRadius: the radius particles hold to each other to be on distance quarantinePercentage: the percentage of particles being in quarantine when infected vaccinationActivated: whether vaccination is activated in the current simulation vaccinationDate: the start of vaccination in days vaccinationSpeed: the count of particles being able to be vaccinated in one day vaccinateHealthyFirst: whether the first one getting vaccinated are the healthy ones dialog: the dialog for the presenter from where the call came xBorder: the maximum x-coordinate particles are allowed to move to the right (default: 0) yBorder: the maximum y-coordinate particles are allowed to move down (default: 195) """ self.simulations = [] self.dialog = dialog for i in range(0, simCount): s = Simulation(xBorder, yBorder, percentageImmune, minImmuneDuration, maxImmuneDuration, countParticles, infectionRate, infectionRadius, initiallyInfected, deathRate, minDaysInfected, maxDaysInfected, quarantinePercentage, vaccinationActivated, vaccinationDate, vaccinationSpeed, vaccinateHealthyFirst) s.changeParticleRadius(distanceRadius) self.simulations.append(s) for i in range(0, simDuration * FPS): data = [] for j in range(0, len(self.simulations)): self.simulations[j].performStep() data.append(self.simulations[j].getData()) self.dialog.updateData(data) def startSIRD(self, population, initiallyInfected, infectionRate, healthyRate, deathRate, days, dialog): """this function start the sird model calculation and sends it to the dialog which started the process Args: population: the amount of particles for the simulation initiallyInfected: the amount of initially infected particles from the population infectionRate: the infection rate healthyRate: the rate of being immune deathRate: the rate of being dead after infection days: the amount of days the simulation should process dialog: the dialog that initiated the calculation """ self.dialog = dialog if initiallyInfected > population: self.dialog.showAlert(constants.PARTICLES_ALERT) else: sird = SIRD(population, initiallyInfected, infectionRate, healthyRate, deathRate, days) dialog.updateData(sird.getData()) def _connectUIElements(self) -> None: """this function is used to connect all of the signals between the view and the presenter""" # elements of the main window self.ui.startSimulationSignal.connect(self.startSimulation) self.ui.pauseResumeSimulationSignal.connect(self.pauseResumeSimulation) self.ui.resetSimulationSignal.connect(self.resetSimulation) self.ui.speedSimulationSignal.connect(self.speedSimulation) self.ui.infectionRateSignal.connect(self.changeInfectionRate) self.ui.deathRateSignal.connect(self.changeDeathRate) self.ui.infectionRadiusChangedSignal.connect( self.changeinfectionRadius) self.ui.export_csvSignal.connect(self.export_csv) self.ui.stayAtHomeSignal.connect(self.changeStayAtHome) self.ui.particleRadiusChangedSignal.connect(self.changeParticleRadius) self.ui.minDaysInfectedSignal.connect(self.changeMinDaysInfected) self.ui.maxDaysInfectedSignal.connect(self.changeMaxDaysInfected) self.ui.percentageImmuneSignal.connect(self.changePercentageImmune) self.ui.maxImmuneDurationSignal.connect(self.changeMaxImmuneDuration) self.ui.minImmuneDurationSignal.connect(self.changeMinImmuneDuration) self.ui.quarantinePercentageSignal.connect( self.changeQuarantinePercentage) self.ui.multipleSimulationSignal.connect(self.startMultipleSimulations) self.ui.sirdSignal.connect(self.startSIRD)
def run_simulation(): sim = Simulation() plot_func.timecourse(sim)
import time from model.simulation import Simulation from examples.Scenario2 import Scenario2 start = time.clock() class App: def iteration_finished(self,a,b): pass print(time.clock() - start) app = App() sim = Simulation(Scenario2) sim.start(app)
class Presenter(QtCore.QObject): def __init__(self): super(Presenter, self).__init__() # create main window self.ui = View() self.simulation = None self.isSimulationRunning = False # create timer that will call the mainLoop every 1000/FPS milliseconds self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.mainLoop) self.timer.start(int(1000 / constVariables.FPS)) self.framecounter = 0 # create a second window self.endWindow = ViewEndWindow() self.endWindow.hide() self.endWindowGotClosed = False # create granularity window self.granularityWindow = ViewGranularityWindow() self.granularityWindow.hide() self._connectUIElements() # perform the steps and draw the items on the scene for each step while the simulation is running def mainLoop(self): if self.isSimulationRunning: self.simulation.performStep() self.ui.drawItems(self.simulation.getParticleList()) self.ui.updateScene() self.ui.updateElements(self.simulation.getDays(), self.simulation.getQuantityList()) # track if the simulation is finished if self.simulation.getIsFinished() and not self.endWindowGotClosed: # pause the "main window" self.ui.pauseSimulationClicked() # update and show the "end window" self.endWindow.updateElements(self.simulation.getQuantityList(), self.simulation.getHealthCareModifier(), self.simulation.getCapacity()) self.endWindow.show() # ensures that the end window will not pop up again, even if user resumes the simulation self.endWindowGotClosed = True # create the simulation and hand it all the predetermined values def startSimulation(self, amountOfParticles, initiallyInfected, riskOfInfection, rateOfDeath, riskOfQuarantine, avgInfectedTime, avgImmuneTime, infectionRadius, modifierDeflect, modifierHealth, modifierVaccine, socialDistanceRadius, vaccineDays, healthCareCapacity, deathRateMultiplier): self.isSimulationRunning = True self.simulation = Simulation(amountOfParticles, initiallyInfected, riskOfInfection, rateOfDeath, riskOfQuarantine, avgInfectedTime, avgImmuneTime, infectionRadius, modifierDeflect, modifierHealth, modifierVaccine, socialDistanceRadius, vaccineDays, healthCareCapacity, deathRateMultiplier) self.ui.startSimulation() # pause the simulation def pauseSimulation(self): self.isSimulationRunning = False # resume the simulation def resumeSiumlation(self): self.isSimulationRunning = True # reset the simulation def resetSimulation(self): self.isSimulationRunning = False # clean up the scene, enable showing "end window" and close the current "end window" self.ui.scene.clear() self.endWindowGotClosed = False self.endWindow.close() self.simulation = None # show the granularity window def showGranularityWindow(self): self.granularityWindow.exec_() # hand the given parameters with the quantityList to the write-Operation def exportCsv(self, granularity): path, filetype = self.ui.getExportParameters() if path and granularity: self.writeInCsv(path, filetype, granularity, self.simulation.getQuantityList()) else: print("Something went wrong.") # writes to the csv def writeInCsv(self, path, filetype, granularity, quantityList): with open(path, mode='w', newline='') as self.f: self.writer = csv.writer(self.f) fieldnames = ["Step", "Healthy", "Infected", "Immune", "Deceased", "Alive"] self.writer.writerow(fieldnames) self.writer.writerow(quantityList[0]) for i in range(granularity, len(quantityList), granularity): self.writer.writerow(quantityList[i]) self.f.close() # set of methods that connect with the parameters in the simulation class if a value is changed # if simulation has been created,... # ...change the risk of infection in the simulation def changeRiskOfI(self, risk): if self.simulation: self.simulation.changeRiskOfInfectionS(risk) # ...change rate of death def changeRate(self, rate): if self.simulation: self.simulation.changeRateOfDeathS(rate) # ...change risk of being quarantined def changeRiskOfQ(self, risk): if self.simulation: self.simulation.changeRiskOfQuarantineS(risk) # ...change average infected time def changeAvgInfectedTime(self, time): if self.simulation: self.simulation.changeAvgInfectedTimeS(time) # ...change average immune time def changeAvgImmuneTime(self, time): if self.simulation: self.simulation.changeAvgImmuneTimeS(time) # ...change infection radius def changeInfectionRadius(self, radius): if self.simulation: self.simulation.changeInfectionRadiusS(radius) # change the speed of the simulation def changeSpeedOfSim(self, newSpeed): self.timer.start(int(1000/newSpeed)) # connect elements of the view def _connectUIElements(self) -> None: # elements of the main window self.ui.startSimulationSignal.connect(self.startSimulation) self.ui.pauseSimulationSignal.connect(self.pauseSimulation) self.ui.resumeSimulationSignal.connect(self.resumeSiumlation) self.ui.resetSimulationSignal.connect(self.resetSimulation) self.ui.exportCsvSignal.connect(self.showGranularityWindow) self.ui.riskOfInfectionSignal.connect(self.changeRiskOfI) self.ui.rateOfDeathSignal.connect(self.changeRate) self.ui.riskOfQuarantineSignal.connect(self.changeRiskOfQ) self.ui.avgInfectionTimeSignal.connect(self.changeAvgInfectedTime) self.ui.avgImmuneTimeSignal.connect(self.changeAvgImmuneTime) self.ui.infectionRadiusSignal.connect(self.changeInfectionRadius) self.ui.speedOfSimSignal.connect(self.changeSpeedOfSim) self.granularityWindow.granularitySelectedSignal.connect(self.exportCsv)
def train(self): simulation = Simulation(self.scenarios[self.scenario], self.training_iteration_finished, self.iterations) simulation.start(self) self.last_model = simulation.model
def generate(self): simulation = Simulation(self.scenarios[self.scenario], n_iterations=1) self.fields = simulation.get_map() self.__generate_graphics() return simulation