--- myst: substitutions: macro: python: 1-5,18-53,56-62,65-66,68-73,75-84 cpp: 7-9,15-48,51-57,60-61,64-69,72-79 bloc1: python: 30-31 cpp: 25-26 bloc2: python: 36-45 cpp: 31-40 bloc3: python: 47-53,56-57 cpp: 42-48,51-52 bloc4: python: 59-62,65-66,68-73,75-84 cpp: 54-57,60-61,64-69,72-79 console: python: 2-49,52-61 cpp: 6-53,56-65 --- (use_cases_macro_calibration_minimisation_vizir)= # Macro "**calibrationMinimisationFlowrate2DVizir.{{extension}}**" ## Objective The goal here is to calibrate the parameters $H_u$ and $H_l$ within the `flowrateCalib2D` model (a two-dimensional version of the `flowrate` model), while varying only two inputs ($r_{\omega}$ and $L$). The remaining variables are fixed to the following values: $r=25050$, $T_u=89335$, $T_l=89.55$, $K_{\omega}=10950$. The context of this example has already been presented in [](#calibration_classes_functions_observations_use_case), including the model (implemented here as a C++ function) and the initial lines defining the {{tds}} objects. In addition to what has been presented in [](#use_cases_macro_calibration_minimisation), this macro introduces two new elements: - the use of **Vizir** instead of a simpler `TNloptSolver`-inheriting instance; - the discussion of problem identifiability, as introduced in {{metho}}. ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/calibration/use_cases/" + language + "/calibrationMinimisationFlowrate2DVizir." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + macro[language] + "\n" + "```" }} Much of this code has already been covered in the previous section [](#use_cases_macro_calibration_minimisation) (up to the sequential run). The main difference here is that the input parameter is now defined as a `TAttribute` with boundaries specifying the space in which the algorithm will search. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/calibration/use_cases/" + language + "/calibrationMinimisationFlowrate2DVizir." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} The model is defined (from a `TCIntEval` instance with the three input variables discussed above, in the **correct order**) along with the computation distribution method (sequential). {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/calibration/use_cases/" + language + "/calibrationMinimisationFlowrate2DVizir." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} Once this setup is complete, the calibration object (`TMinimisation`) is created. As explained in [](#calibration_classes_functions_observations_data_and_distance_recommended_distance), the first step is to define the distance function (here the relative least squares distance) using `setDistance`. This method also specifies the {{tds}} containing the reference data, the names of the reference inputs, and the reference variable against which the model output is compared. Finally, the optimisation algorithm is defined by creating an instance of `TVizirGenetic`, and the parameters are then estimated. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/calibration/use_cases/" + language + "/calibrationMinimisationFlowrate2DVizir." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + "```" }} The final part demonstrates how to display the results. Since this method produces a point estimate, only a single value is obtained, which is always shown on the screen, as illustrated in [](#use_cases_macro_calibration_minimisation_vizir_console). Another important aspect is to examine the residuals, as discussed in {{metho}}. This is illustrated in {numref}`usecases_calibrationMinimisationFlowrate2DVizir_Res`, which shows the residuals of the *a posteriori* estimates, typically following a normal distribution. Finally, the parameter graph ({numref}`usecases_calibrationMinimisationFlowrate2DVizir_Par`) reveals a wide variety of possible solutions. This highlights a problem of identifiability, since infinitely many parameter combinations can lead to the same results, as further confirmed by the correlation matrix shown in [](#use_cases_macro_calibration_minimisation_vizir_console). {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/calibration/use_cases/" + language + "/calibrationMinimisationFlowrate2DVizir." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + "```" }} (use_cases_macro_calibration_minimisation_vizir_console)= ## Console {{ "```{literalinclude} " + parent_dir + "/roottest/build/uranie/doc/calibration/use_cases/" + language + "/calibrationMinimisationFlowrate2DVizir_clean.log" + "\n" + ":language: none\n" + ":lines: " + console[language] + "\n" + "```" }} ## Graphs {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/calibration/use_cases/" + language + "/minimisation_vizir/calibrationMinimisationFlowrate2DVizir_Res.png\n" ":align: center\n" ":name: usecases_calibrationMinimisationFlowrate2DVizir_Res\n" + figure_scale + "\n" "\n" "Residuals graph of the macro **\"calibrationMinimisationFlowrate2DVizir." + extension + "\"**\n" "```" }} {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/calibration/use_cases/" + language + "/minimisation_vizir/calibrationMinimisationFlowrate2DVizir_Par.png\n" ":align: center\n" ":name: usecases_calibrationMinimisationFlowrate2DVizir_Par\n" + figure_scale + "\n" "\n" "Parameter graph of the macro **\"calibrationMinimisationFlowrate2DVizir." + extension + "\"**\n" "```" }}