salome.kernel.parametric – Package for parametric studies

study_exchange_vars – Handle Exchange Variables

This module provides classes and functions to handle “Exchange Variables”, i.e. description of variables to be exchanged between a supervision code and a computation code. These Exchange Variables can be stored in a SObject in Salome study.

class salome.kernel.parametric.study_exchange_vars.ExchangeVariables(inputVarList=[], outputVarList=[], refEntry=None)

This class describes “Exchange Variables”, i.e. a structure containing all the necessary information to exchange variables between a supervision code and a computation code.

inputVarList

This instance attribute is a list of Variable objects, describing the input variables for the computation code.

outputVarList

This instance attribute is a list of Variable objects, describing the output variables for the computation code.

refEntry

This instance attribute is optional and can be used to store a reference to a Salome entry containing an “Exchange Variable” SObject that was used to build this one (when the current object has been built by selecting variables of interest in a list of potential variables).

class salome.kernel.parametric.study_exchange_vars.Variable(name, dimension=[], minValue=None, maxValue=None, initialValue=None)

This class describes a single variable. For now, it is only described by its name. Other attributes are reserved for future use.

salome.kernel.parametric.study_exchange_vars.createSObjectForExchangeVariables(fatherSobj, exchangeVariables, name='Variables', icon=None, typeId=None)

Create a SObject to store an ExchangeVariables instance.

Parameters:
  • fatherSobj (SObject) – parent of the SObject to create.
  • exchangeVariables (ExchangeVariables) – ExchangeVariables instance to store in Salome study.
  • name (string) – name of the SObject to create.
  • icon (string) – icon of the SObject to create.
  • typeId (integer) – type of the SObject to create.
Returns:

the newly created SObject.

salome.kernel.parametric.study_exchange_vars.getExchangeVariablesFromSObject(sobj)

Get an ExchangeVariables instance from a SObject that stores it.

Parameters:sobj (SObject) – the SObject from which to read the ExchangeVariables instance.
Returns:the newly created ExchangeVariables instance.
salome.kernel.parametric.study_exchange_vars.updateSObjectForExchangeVariables(sobj, exchangeVariables, name='Variables', icon=None, typeId=None)

Update an existing SObject storing an ExchangeVariables instance.

Parameters:sobj (SObject) – the SObject to update.

See createSObjectForExchangeVariables() for the description of the other parameters.

compo_utils – Useful functions for SALOME components used in parametric studies

This module provides utility functions for the computation codes intended for use in parametric studies. The computation codes must be implemented as SALOME components to use these functions. If the computation code is implemented as a Python script or function, use module salome.kernel.parametric.pyscript_utils instead.

salome.kernel.parametric.compo_utils.create_error_parametric_output(error_message)

This function returns a structure describing the output of the computation code in parametric studies in case of error.

Parameters:error_message (string) – the error message.
Returns:a structure of type SALOME_TYPES/ParametricOutput describing the error.
salome.kernel.parametric.compo_utils.create_input_dict(deterministic_dict, parametric_input)

This function returns a dictionary containing the input values to be used in the computation code.

Parameters:
  • deterministic_dict (dict) – dictionary containing the fixed values (i.e. non-parametric). This dictionary can be empty if all variables are parametric.
  • parametric_input (SALOME_TYPES/ParametricInput) – structure containing the description and values of the parametric variables.
Returns:

a dictionary containing the input values for the computation code.

salome.kernel.parametric.compo_utils.create_normal_parametric_output(output_dict, parametric_input)

This function returns a structure describing the output of the computation code in parametric studies.

Parameters:
  • output_dict (dict) – dictionary containing the output values of the computation code (the keys are the variable names, the values are the variable values).
  • parametric_input (SALOME_TYPES/ParametricInput) – structure containing the description and values of the parametric variables.
Returns:

a structure of type SALOME_TYPES/ParametricOutput containing the output of the computation code.

pyscript_utils – Useful functions for Python scripts used in parametric studies

This module provides utility functions for the computation codes intended for use in parametric studies. The computation codes must be implemented as a Python script or function to use these functions. If the computation code is implemented as a SALOME component, use module salome.kernel.parametric.compo_utils instead.

salome.kernel.parametric.pyscript_utils.create_error_parametric_output(error_message)

This function returns a dictionary describing the output of the computation code in parametric studies in case of error.

Parameters:error_message (string) – the error message.
Returns:a dictionary describing the error.
salome.kernel.parametric.pyscript_utils.create_input_dict(deterministic_dict, parametric_input)

This function returns a dictionary containing the input values to be used in the computation code.

Parameters:
  • deterministic_dict (dict) – dictionary containing the fixed values (i.e. non-parametric). This dictionary can be empty if all variables are parametric.
  • parametric_input (dict) – dictionary containing the description and values of the parametric variables.
Returns:

a dictionary containing the input values for the computation code.

salome.kernel.parametric.pyscript_utils.create_normal_parametric_output(output_dict, parametric_input)

This function returns a dictionary describing the output of the computation code in parametric studies.

Parameters:
  • output_dict (dict) – dictionary containing the output values of the computation code (the keys are the variable names, the values are the variable values).
  • parametric_input (dict) – dictionary containing the description and values of the parametric variables.
Returns:

a dictionary containing the representation of the output of the computation code.