Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML
<script type="text/javascript">
    
 AJS.toInit(function() {
 // unbind directly-embedded images
 AJS.$("img.confluence-embedded-image").unbind("click.fb");
 });
 </script>

scrollbar

Create a new region in the script for this section of the tutorial.

The best fit will be considered to be that one that gives fit giving the smallest deviation from the measured data will be considered the best one. A loop over the previously created variable listCalibration will provide this information. PreviouslyTo begin with, the variables indicating the different properties around of the best fit will be initialized to values that will certainly will be overwritten. Remember that the initial model set up could provide a better fit than any of the multiple calibration simulations. So this case should also be included in the check loop (we will start the loop at index 1, the second item in the list, the . The first item, number 0, is the measured data). If the deviation of a case is smaller than the current one devBestFit, then that case should replace the current one (index, boundary condition used, roughness used, and deviation from the data).

Code Block
languagepy
titleFind out which is the best fit
indexBestFit = -1
bcBestFit = 1e100
roughnessBestFit = 1e100
devBestFit = 1e100
for i in range(len(listCalibration)):
    case = listCalibration[i]
    if case[2] < devBestFit:
        indexBestFit = i
        bcBestFit = case[0]
        roughnessBestFit = case[1]
        devBestFit = case[2]

Once the best fit has been found, you can print the corresponding values to the Messages console.

Code Block
languagepy
titlePrint to messages console
print "selected bc: " + str(bcBestFit) + "m3/s"
print "selected roughness " + str(roughnessBestFit) + "m^(1/3) s^-1"

Finally, the line corresponding to this best fit can be added to the chart using distinctive line color and width, and series name.

Code Block
languagepy
titleHighlight the best fit in the chart
lineResultsBestFit = CreateLineSeries(timeSeriesToCompare[indexBestFit+1]) # +1 to skip measured data
lineResultsBestFit.Color = Color.Blue
lineResultsBestFit.Width = 2
lineResultsBestFit.Title = "Best fit"
lineResultsBestFit.ShowInLegend = True
lineResultsBestFit.PointerVisible = False
chartCalibration.Series.Add(lineResultsBestFit)

 

 

Or more in detail, if you zoom in (manually or with scripting):

 

 

Create a separate region for the the code of this section to keep your work tidy.

 

Panel

Export (calibration) results: Graphs, data and report

 

scrollbar