We are now ready to build the main loop corresponding to the model calibration. If you want to see how the calibration parameters (BC at Boxbergen and roughnesss of the section type main) are modified by the script, you can look at the corresponding items on the project explorer view (only for the BC). Additionally, you can double click on the items on the project explorer to open their corresponding editor view.

The possible values that the calibration parameters may have can be indicated in different ways, for example, through their respective statistical distributions. However, as indicated before and for the sake of simplicity, in this tutorial, let’s assume that only a limited amount of values is possible for each of them, and that the possible combinations of those cases are equally likely.

The kernel of the calibration algorithm is then a double loop with which we will iterate along all possible combinations of the parameters used in the procedure, BC at Boxbergen and roughness Strickler coefficient ks for the default value of the Main type of cross section roughness. When the parameters have been updated, the model should be run. Then, the model results at the gauging station will be retrieved, and the deviation of these results with respect to the measured data will be calculated. The list containing the calibration parameters values and the goodness of the corresponding fit will be added to listCalibration. Finally, the entire time series of the results will also be added to the corresponding list timeSeriesToCompare. This last variable can be used, for example, in case we decide to change the threshold for which the model is considered to be warming up, and therefore, the time step results which can be neglected, without having to run all the simulations again (since this process can be very time-consuming).

 

Main calibration loop
# Main calibration loop

for bcValue in rangeBC:

    # Adjust boundary condition value
    bcCalibration.Flow = bcValue

    for roughnessValue in rangeRoughness:

        # Adjust default roughness value for roughness section Main     

        roughnessMain.DefaultValue = roughnessValue

        RunModel(flowModel, showDialog=True)

        # Add deviation of results of current run with respect to measurements
        calibResults = GetTimeSeriesFromWaterFlowModel(flowModel, calculationPoint, "Water level")
        deviation = GetAverageDeviation(measuredTimeSeries, calibResults, startAt = warmUpTimeSteps)
        listCalibration.append([bcValue, roughnessValue, deviation])


        # Add timeseries to timeSeriesToCompare list

        timeSeriesToCompare.append(calibResults)


 

  • No labels