Skip to content
Snippets Groups Projects
Commit 422dee6f authored by Franck Pérignon's avatar Franck Pérignon
Browse files

Add missing file ...

parent 500a3ada
No related branches found
No related tags found
No related merge requests found
"""
@file simulation.py
Description of the simulation parameters (time, iteration ...)
"""
from parmepy.mpi import main_rank
class Simulation(object):
"""
Setup for simulation parameters.
"""
def __init__(self, tinit=0.0, tend=1.0, nbiter=10):
"""
Creates a Timer.
@param t_end : Simulation final time.
@param dt : Time step.
@param t_init : Simulation starting time.
"""
## Simulation final time
self.end = tend
## Starting time
self.start = tinit
## Simulation current time
self.time = tinit
## Is simulation is terminated
self.isOver = False
## Iteration counter
self.currentIteration = 0
## Number of iteration
self.nbiter = nbiter
## Simulation time step
self.timeStep = (self.end - self.start) / float(self.nbiter)
def advance(self):
"""
Proceed to next time
"""
if self.currentIteration < self.nbiter:
self.currentIteration += 1
self.time += self.timeStep
else:
self.isOver = True
def printState(self):
"""
print current state
"""
if main_rank == 0:
print "==== Iteration : {0:3d} t={1:6.3f} ====".format(
self.currentIteration, self.time)
def __str__(self):
s = "Simulation parameters : "
s += "start from " + str(self.start) + ' to ' + str(self.end)
s += ', time step = ' + str(self.timeStep)
s += ', current time : ' + str(self.time) + ' iteration number :'
s += str(self.currentIteration)
return s
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment