3 from module_generator import *
5 # This example shows how to create a component used as a calculation code for OpenTURNS
6 # with YACSGEN tool. This example is very basic. See YACSGEN documentation and DEVIATION
7 # component for more advanced features.
9 # edit those values to reflect your environment:
10 prerequisites_script_path = "/path/to/prerequisites.sh"
11 kernel_path = "/path/to/KERNEL_install"
12 openturns_module_path = "/path/to/OPENTURNS_install"
14 c1 = PYComponent("EXAMPLE_COMPONENT",
17 inport=[("studyID", "long"),
18 ("detCaseEntry", "string")],
20 # Those values should be initialized from the deterministic case in the study
21 # (see component DEVIATION for an example)
22 self.deterministicValues = {'E' : 210.e9,
29 inport=[("paramInput", "SALOME_TYPES/ParametricInput"),],
30 outport=[("paramOutput", "SALOME_TYPES/ParametricOutput")],
31 defs = "import SALOME_TYPES",
33 # This section creates the point to evaluate "evalPoint"
34 evalPoint = self.deterministicValues
35 for i in range(len(paramInput.inputVarList)):
36 evalPoint[paramInput.inputVarList[i]] = paramInput.inputValues[i][0][0]
38 # This section should be modified according to your needs (it's the evaluation itself)
39 if evalPoint["L"] <= 0: # Test for an invalid parameter and return an error in this case
40 paramOutput = SALOME_TYPES.ParametricOutput(
42 specificOutputInfos = [],
44 errorMessage = "Invalid value: L must be positive")
47 resDict["dev"] = (evalPoint["F"] * evalPoint["L"] * evalPoint["L"] * evalPoint["L"]) / \
48 (3. * evalPoint["E"] * evalPoint["I"])
50 # This section builds the returned object
52 for outputVar in paramInput.outputVarList:
53 outputValues.append([[resDict[outputVar]]])
54 paramOutput = SALOME_TYPES.ParametricOutput(outputValues,
55 specificOutputInfos = [],
64 m = Module("EXAMPLE_MODULE",components=[c1],prefix="./EXAMPLE_MODULE_INSTALL")
67 "prerequisites":prerequisites_script_path,
70 g=Generator(m,context)
76 g.make_appli("example_appli",
77 altmodules={"OPENTURNS":openturns_module_path})