Package esys :: Package escript :: Module modelframe :: Class Simulation
[hide private]
[frames] | no frames]

Class Simulation

    object --+            
             |            
LinkableObject --+        
                 |        
      ParameterSet --+    
                     |    
                 Model --+
                         |
                        Simulation

A Simulation object is a special Model which runs a sequence of Models.

The methods doInitialization, finalize, getSafeTimeStepSize, doStepPreprocessing, terminateIteration, doStepPostprocessing, doFinalization execute the corresponding methods of the models in the simulation.

Instance Methods [hide private]
 
__getitem__(self, i)
Returns the i-th model.
 
__init__(self, models=[], **kwargs)
Initiates a simulation from a list of models.
 
__len__(self)
Returns the number of models.
 
__repr__(self)
Returns a string representation of the Simulation.
 
__setitem__(self, i, value)
Sets the i-th model.
 
__str__(self)
Returns Simulation as a string.
 
checkModels(self, models, hash)
Returns a list of (model, parameter, target model) if the parameter of model is linking to the target_model which is not in the list of models.
 
doFinalization(self)
Finalises the time stepping for all models.
 
doInitialPostprocessing(self)
Finalises the initialization iteration process for all models.
 
doInitialStep(self)
Performs an iteration step in the initialization step for all models.
 
doInitialization(self)
Initializes all models.
 
doStep(self, dt)
Executes the iteration step at a time step for all models:
 
doStepPostprocessing(self, dt)
Finalises the iteration process for all models.
 
doStepPreprocessing(self, dt)
Initializes the time step for all models.
 
finalize(self)
Returns True if any of the models is to be finalized.
 
getAllModels(self)
Returns a list of all models used in the Simulation including subsimulations.
 
getSafeTimeStepSize(self, dt)
Returns a time step size which can be safely used by all models.
 
iterModels(self)
Returns an iterator over the models.
 
run(self, check_pointing=None)
Runs the simulation by performing essentially:
 
setUp(self)
Performs the setup for all models.
 
terminateInitialIteration(self)
Returns True if all initial iterations for all models are terminated.
 
terminateIteration(self)
Returns True if all iterations for all models are terminated.
 
toDom(self, esysxml, node)
toDom method of Simulation class.

Inherited from ParameterSet: __delattr__, __iter__, checkLinkTargets, declareParameter, declareParameters, releaseParameters, showParameters, writeXML

Inherited from ParameterSet (private): _parametersToDom

Inherited from LinkableObject: __getattr__, __setattr__, getAttributeObject, hasAttribute, trace

Inherited from object: __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__

Class Methods [hide private]
 
fromDom(cls, esysxml, node)
Class Variables [hide private]
  FAILED_TIME_STEPS_MAX = 20
  MAX_CHANGE_OF_DT = 2.0
  MAX_ITER_STEPS = 50

Inherited from Model: UNDEF_DT

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, models=[], **kwargs)
(Constructor)

 

Initiates a simulation from a list of models.

Overrides: object.__init__

__repr__(self)
(Representation operator)

 

Returns a string representation of the Simulation.

Overrides: object.__repr__

__str__(self)
(Informal representation operator)

 

Returns Simulation as a string.

Overrides: object.__str__

doFinalization(self)

 

Finalises the time stepping for all models.

Overrides: Model.doFinalization

doInitialPostprocessing(self)

 

Finalises the initialization iteration process for all models.

Overrides: Model.doInitialPostprocessing

doInitialStep(self)

 

Performs an iteration step in the initialization step for all models.

Overrides: Model.doInitialStep

doInitialization(self)

 

Initializes all models.

Overrides: Model.doInitialization

doStep(self, dt)

 

Executes the iteration step at a time step for all models:

   self.doStepPreprocessing(dt)
   while not self.terminateIteration():
       for all models:
       self.doStep(dt)
       self.doStepPostprocessing(dt)
Overrides: Model.doStep

doStepPostprocessing(self, dt)

 

Finalises the iteration process for all models.

Overrides: Model.doStepPostprocessing

doStepPreprocessing(self, dt)

 

Initializes the time step for all models.

Overrides: Model.doStepPreprocessing

finalize(self)

 

Returns True if any of the models is to be finalized.

Overrides: Model.finalize

fromDom(cls, esysxml, node)
Class Method

 
Overrides: ParameterSet.fromDom

getSafeTimeStepSize(self, dt)

 

Returns a time step size which can be safely used by all models.

This is the minimum over the time step sizes of all models.

Overrides: Model.getSafeTimeStepSize

run(self, check_pointing=None)

 

Runs the simulation by performing essentially:

   self.setUp()
   if not restart:
       self.doInitialization()
       while not self.terminateInitialIteration(): self.doInitialStep()
       self.doInitialPostprocessing()
   while not self.finalize():
       dt=self.getSafeTimeStepSize()
       self.doStepPreprocessing(dt_new)
       self.doStep(dt_new)
       self.doStepPostprocessing(dt_new)
   self.doFinalization()

If one of the models throws a FailedTimeStepError exception a new time step size is computed through getSafeTimeStepSize() and the time step is repeated.

If one of the models throws a IterationDivergenceError exception the time step size is halved and the time step is repeated.

In both cases the time integration is given up after Simulation.FAILED_TIME_STEPS_MAX attempts.

setUp(self)

 

Performs the setup for all models.

Overrides: Model.setUp

terminateInitialIteration(self)

 

Returns True if all initial iterations for all models are terminated.

Overrides: Model.terminateInitialIteration

terminateIteration(self)

 

Returns True if all iterations for all models are terminated.

Overrides: Model.terminateIteration

toDom(self, esysxml, node)

 

toDom method of Simulation class.

Overrides: ParameterSet.toDom