Before we start running the model, we need to configure the model times.

Set model times
SetModelTimes(fmModel, startTime, endTime, time(0,20,0))

This sets the model start time, end time and time-step to the times used in our time series.

Now, we can run the model by using the RunModel statement :

Run the model
RunModel(fmModel, showDialog = True)

This will run the whole model from start to end time time, what may take some time.

An alternative way to run a your model can be used by decomposing the run action into its different steps.

Run model with your own control flow
numberOfTimeSteps = int((fmModel.StopTime - fmModel.StartTime).TotalSeconds  / fmModel.TimeStep.TotalSeconds)

fmModel.Initialize()

for i in range(numberOfTimeSteps):
    fmModel.Execute()

fmModel.Finish()
fmModel.Cleanup()

In this manner, you can control the run and, if you want, add some additional script code to be run at every time step.

 

  • No labels