CSR Initialization

From VLECK
Jump to: navigation, search

context

The model engine is the highest level driver of the process. The simulation is invoked by the user calling ModelEngine.run():

 
def Run(cls, userModel):
    engine = cls(userModel)
    engine.setUpTechnicalEnvironment()
    engine.InitialiseModel()
    engine.RunModel()
    engine.FinaliseModel()
    engine.tearDownTechnicalEnvironment()



The run-method is called with a Model as argument, so Model.__init__() is called first. Model.__init__() only prints welcome text. The interesting part starts on calling engine.setUpTechnicalEnvironment() which in turn invokes Model.setUp().

sequence

In Model.setUp() first the invariable parts of any model (i.e. ModelSystem, ModelArea, and Patch(es)) are created. To determine the number of patches, a datafile with he geographical layout must be consulted. Then, triggered by ModelSystem.build(), the patches are populated with cohorts and their soils initialized (from soil data files).

• initializing model engine ...

 
model.setUp()
    ModelComponent.running = False
    ###class_registration 
    # building and populating ...
    ModelSystem.__init__()
        ModelArea.__init__()
        ### read area map
        Weather.__init__()
 
    ModelComponent.running = True
 
    ModelSystem.build()
        ModelArea.build()
            ModelArea._defaultInitArea()
                ModelArea.populatePatches()
                    ###read polulation file
                    Patch.populate()
                        ###create cohort from typefile
                        cohort.__init__()
                        ###read initialisation files to cohort
                Patch.createSoil()
                ###read soil maps [non netCDF-files]
 
    runner.doSetUpComplete(self._system)



In Model.initial() time enters. First every ModelComponent executes its initializeAtT0(); then a sequence of final checks is run to make sure the whole system is ready to take off.

• model engine set-up complete; starting initialization.

 
model.initial()     
    ModelSystem.integration_beforeSimulation()        
        ModelArea.integration_beforeSimulation()
            Patch.integration_beforeSimulation()
 
    ### print run parameters (time)
 
    ModelSystem.integration_startSimulation()
        ModelSystem.initializeAtT0()
            ModelSystem._getParameters()
        ModelArea.integration_startSimulation()
            ModelArea.initializeAtT0()
                ModelArea._getParameters()
 
            Patch(es).integration_startSimulation()
                Patch.initializeAtT0()
                    Patch._getParameters()
                    ###add soil and light model to plant cohorts#
                    ###add weather to environment
                # now for soil, all plants, animals and components:
                (recursive) *.integration_startSimulation() 
                    *.initializeAtT0()
 
    ModelSystem.integration_finalCheckBeforeSimulation()                                
        (recursive) *.preRunChecks()
 
    runner.doInitialized(self._system)



execution log

Model.__init__()


Model.initial()


see also

CSR Run