--- myst: substitutions: macro: python: 1-5,11-24,29-77 cpp: 6-8,11-22,30-78 bloc1: python: 30-31 cpp: 30-32 bloc2: python: 34,36 cpp: 35,37 bloc3: python: 39-44 cpp: 39-40,42-45 console: python: 2-6,34-54 cpp: 5-9,22-42 --- # Macro "**modelerFlowratePolynChaosIntegration.{{extension}}**" ## Objective The objective of this macro is to build a polynomial chaos expansion in order to get a surrogate model along with a global sensitivity interpretation for the `flowrate` function, whose purpose and behaviour have been already introduced in [](#launcher_introduction_simple_case_problem). The method used here is the regression one, as discussed below. ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowratePolynChaosIntegration." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + macro[language] + "\n" + "```" }} The first part is just creating a {{tds}} and providing the attributes needed to define the problem. From there, a `TNisp` object is created, providing the dataserver that specifies the inputs. This class is used to generate the sample (Petras being a {{doe}} dedicated to integration problem). {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowratePolynChaosIntegration." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} The function is launched through a `TLauncherFunction` instance in order to get the output values that will be needed to train the surrogate model. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowratePolynChaosIntegration." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} Finally, a `TPolynomialChaos` instance is created and the computation of the coefficients is performed by requesting a truncature on the resulting degree of the polynomial expansion (set to 4) and the use of a regression method. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowratePolynChaosIntegration." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + "```" }} The rest of the code is showing how to access the resulting sensitivity indices either one-by-one, or ordered up to a chosen threshold of the output variance. ## Console {{ "```{literalinclude} " + parent_dir + "/roottest/build/uranie/doc/modeler/use_cases/" + language + "/modelerFlowratePolynChaosIntegration_clean.log\n" + ":language: none\n" + ":lines: " + console[language] + "\n" + "```" }}