PythonPhysicalModel¶
- 
class persalys.PythonPhysicalModel(*args)¶
- Create a physical model defined by Python code. - Parameters
 - Notes - The code string must contain a function named ‘_exec’ that takes float arguments and return a float or a sequence of floats. - Examples - >>> import openturns as ot >>> import persalys - Create the model: - >>> R = persalys.Input('R', 0., ot.LogNormalMuSigma(300., 30., 0.).getDistribution(), 'Yield strength') >>> F = persalys.Input('F', 0., ot.Normal(75000., 5000.), 'Traction load') >>> G = persalys.Output('G', 'deviation') >>> code = 'from math import pi\n\ndef _exec(R, F):\n G = R-F/(pi*100.0)\n return G\n' >>> model = persalys.PythonPhysicalModel('myPhysicalModel', [R, F], [G], code) >>> y = model.getFunction()([300.0,75000.0]) - Attributes
- thisown
- The membership flag 
 
 - Methods - addInput(input)- Add an input variable. - addOutput(output)- Add an output variable. - Remove all the input variables. - Remove all the output variables. - Accessor to the object’s name. - getCode()- Code accessor. - Copula accessor. - Distribution accessor. - getFunction(*args)- Accessor to the underlying function. - getId()- Accessor to the object’s id. - getInputByName(*args)- Input variable accessor. - Number of input variables accessor. - Input variable names accessor. - Input random vector accessor. - Input variables accessor. - Mesh model accessor. - getName()- Accessor to the object’s name. - getOutputByName(*args)- Output variable accessor. - Number of output variables accessor. - Output variable names accessor. - getOutputRandomVector(outputNames)- Output random vector accessor. - Output variables accessor. - getPointToFieldFunction(*args)- Accessor to the underlying function. - Number of concurrent processes. - Python script accessor. - getRestrictedFunction(*args)- Accessor to the function restricted to its stochastic inputs. - getRestrictedPointToFieldFunction(outputNames)- Accessor to the field function restricted to its stochastic inputs. - Accessor to the selected outputs names. - Accessor to the object’s shadowed id. - Accessor to the names of the stochastic input variables. - Accessor to the object’s visibility state. - hasInputNamed(inputName)- Check if an input has the given name. - hasMesh()- Whether the model has a mesh. - hasName()- Test if the object is named. - hasOutputNamed(outputName)- Check if an output has the given name. - Whether it contains stochastic variables. - Test if the object has a distinguishable name. - Whether the evaluations of the model are parallelized. - isValid()- Whether it is valid. - removeInput(inputName)- Remove an input variable. - removeOutput(outputName)- Remove an output variable. - selectOutput(outputName, selected)- Select output. - setCode(code)- Code accessor. - setCopula(inputNames, copula)- Copula accessor. - setDistribution(inputName, distribution)- Input distribution accessor. - setDistributionParametersType(inputName, …)- Input distribution parameter type accessor. - setFiniteDifferenceStep(inputName, step)- Finite difference step accessor. - setInputDescription(inputName, description)- Input description accessor. - setInputName(inputName, newName)- Input variable name accessor. - setInputStochastic(inputName, stoch)- Whether the input variable is stochastic. - setInputValue(inputName, value)- Input variable value accessor. - setInputs(inputs)- Input variables accessor. - setMeshModel(meshModel)- Mesh model accessor. - setName(name)- Accessor to the object’s name. - setOutputDescription(outputName, description)- Output description accessor. - setOutputName(outputName, newName)- Output variable name accessor. - setOutputValue(outputName, value)- Output variable name accessor. - setOutputs(outputs)- Output variables accessor. - setParallel(flag)- Whether the evaluations of the model are parallelized. - setProcessNumber(processNumber)- Number of concurrent processes. - setShadowedId(id)- Accessor to the object’s shadowed id. - setVisibility(visible)- Accessor to the object’s visibility state. - getEvalTime - setEvalTime - 
__init__(*args)¶
- Initialize self. See help(type(self)) for accurate signature. 
 - 
clearInputs()¶
- Remove all the input variables. 
 - 
clearOutputs()¶
- Remove all the output variables. 
 - 
getClassName()¶
- Accessor to the object’s name. - Returns
- class_namestr
- The object class name (object.__class__.__name__). 
 
 
 - 
getCode()¶
- Code accessor. - Returns
- codestr
- Code text 
 
 
 - 
getCopula()¶
- Copula accessor. - Parameters
- copulaopenturns.Copula
- The copula 
 
- copula
 
 - 
getDistribution()¶
- Distribution accessor. - Parameters
- Distributionopenturns.ComposedDistribution
- The composed distribution (marginals and dependence) 
 
- Distribution
 
 - 
getFunction(*args)¶
- Accessor to the underlying function. - Parameters
- outputNamessequence of str
- Names of the outputs to be evaluated (optional) 
 
- Returns
- functionopenturns.Function
- Function evaluating the outputs 
 
- function
 
 - 
getId()¶
- Accessor to the object’s id. - Returns
- idint
- Internal unique identifier. 
 
 
 - 
getInputByName(*args)¶
- Input variable accessor. - Parameters
- namestr
- Variable name 
 
- Returns
- inputInput
- Input variable 
 
- input
 
 - 
getInputDimension()¶
- Number of input variables accessor. - Returns
- dimensionint
- Number of input variables 
 
 
 - 
getInputNames()¶
- Input variable names accessor. - Returns
- namesopenturns.Description
- Input variable names 
 
- names
 
 - 
getInputRandomVector()¶
- Input random vector accessor. - Returns
- namesopenturns.RandomVector
- Input random vector 
 
- names
 
 - 
getName()¶
- Accessor to the object’s name. - Returns
- namestr
- The name of the object. 
 
 
 - 
getOutputByName(*args)¶
- Output variable accessor. - Parameters
- namestr
- Variable name 
 
- Returns
- inputOutput
- Output variable 
 
- input
 
 - 
getOutputDimension()¶
- Number of output variables accessor. - Returns
- dimensionint
- Number of output variables 
 
 
 - 
getOutputNames()¶
- Output variable names accessor. - Returns
- namesopenturns.Description
- Ouput variable names 
 
- names
 
 - 
getOutputRandomVector(outputNames)¶
- Output random vector accessor. - Returns
- namesopenturns.RandomVector
- Output random vector 
 
- names
 
 - 
getPointToFieldFunction(*args)¶
- Accessor to the underlying function. - Parameters
- outputNamessequence of str
- Names of the outputs to be evaluated (optional) 
 
- Returns
- functionopenturns.PointToFieldFunction
- Function evaluating the outputs along the mesh nodes 
 
- function
 
 - 
getProcessNumber()¶
- Number of concurrent processes. - Returns
- process_numberint
- Maximum number of processes 
 
 
 - 
getPythonScript()¶
- Python script accessor. - Returns
- scriptstr
- Python script to replay the model 
 
 
 - 
getRestrictedFunction(*args)¶
- Accessor to the function restricted to its stochastic inputs. - Parameters
- outputNamessequence of str
- Output variables (optional) 
 
- Returns
- restrictedopenturns.Function
- Stochastic function 
 
- restricted
 
 - 
getRestrictedPointToFieldFunction(outputNames)¶
- Accessor to the field function restricted to its stochastic inputs. - Parameters
- outputNamessequence of str
- Output variables (optional) 
 
- Returns
- restrictedopenturns.PointToFieldFunction
- Stochastic field function (for model with mesh) 
 
- restricted
 
 - 
getSelectedOutputsNames()¶
- Accessor to the selected outputs names. - Returns
- namesopenturns.Description
- Selected outputs names 
 
- names
 
 - 
getShadowedId()¶
- Accessor to the object’s shadowed id. - Returns
- idint
- Internal unique identifier. 
 
 
 - 
getStochasticInputNames()¶
- Accessor to the names of the stochastic input variables. - Returns
- namesopenturns.Description
- Names of the stochastic input variables 
 
- names
 
 - 
getVisibility()¶
- Accessor to the object’s visibility state. - Returns
- visiblebool
- Visibility flag. 
 
 
 - 
hasInputNamed(inputName)¶
- Check if an input has the given name. - Parameters
- namestr
- Variable name 
 
- Returns
- hasbool
- Whether an input has the given name 
 
 
 - 
hasMesh()¶
- Whether the model has a mesh. - Returns
- hasMeshbool
- Whether the model has a mesh 
 
 
 - 
hasName()¶
- Test if the object is named. - Returns
- hasNamebool
- True if the name is not empty. 
 
 
 - 
hasOutputNamed(outputName)¶
- Check if an output has the given name. - Parameters
- namestr
- Variable name 
 
- Returns
- hasbool
- Whether an output has the given name 
 
 
 - 
hasStochasticInputs()¶
- Whether it contains stochastic variables. - Returns
- hasbool
- Whether it contains stochastic variables 
 
 
 - 
hasVisibleName()¶
- Test if the object has a distinguishable name. - Returns
- hasVisibleNamebool
- True if the name is not empty and not the default one. 
 
 
 - 
isParallel()¶
- Whether the evaluations of the model are parallelized. - Returns
- isParallelbool
- Whether the evaluations of the model are parallelized (available only for the Python model) 
 
 
 - 
isValid()¶
- Whether it is valid. - Returns
- isValidbool
- Whether it is valid 
 
 
 - 
removeInput(inputName)¶
- Remove an input variable. - Parameters
- namestr
- Variable name 
 
 
 - 
removeOutput(outputName)¶
- Remove an output variable. - Parameters
- namestr
- Variable name 
 
 
 - 
selectOutput(outputName, selected)¶
- Select output. - Parameters
- namestr
- Output name 
- isSelectedbool
- Whether it is selected 
 
 
 - 
setCode(code)¶
- Code accessor. - Parameters
- codestr
- Code text 
 
 
 - 
setCopula(inputNames, copula)¶
- Copula accessor. - Parameters
- copulaopenturns.Copula
- The copula 
 
- copula
 
 - 
setDistribution(inputName, distribution)¶
- Input distribution accessor. - Parameters
- namestr
- Variable name 
- distributionopenturns.Distribution
- Variable distribution 
 
 
 - 
setDistributionParametersType(inputName, distributionParametersType)¶
- Input distribution parameter type accessor. - Parameters
- namestr
- Variable name 
- parametersTypeint
- Distribution parameter type accessor 
 
 
 - 
setFiniteDifferenceStep(inputName, step)¶
- Finite difference step accessor. - Parameters
- namestr
- Variable name 
- stepfloat
- Finite difference step used to define the gradient of the model’s function 
 
 
 - 
setInputDescription(inputName, description)¶
- Input description accessor. - Parameters
- namestr
- Variable name 
- descriptionstr
- Description text 
 
 
 - 
setInputName(inputName, newName)¶
- Input variable name accessor. - Parameters
- namestr
- Variable name 
- newNamestr
- New name 
 
 
 - 
setInputStochastic(inputName, stoch)¶
- Whether the input variable is stochastic. - Parameters
- namestr
- Variable name 
- isStochasticbool
- Whether the input variable is stochastic 
 
 
 - 
setInputValue(inputName, value)¶
- Input variable value accessor. - Parameters
- namestr
- Variable name 
- valuefloat
- New value 
 
 
 - 
setName(name)¶
- Accessor to the object’s name. - Parameters
- namestr
- The name of the object. 
 
 
 - 
setOutputDescription(outputName, description)¶
- Output description accessor. - Parameters
- namestr
- Variable name 
- descriptionstr
- Description text 
 
 
 - 
setOutputName(outputName, newName)¶
- Output variable name accessor. - Parameters
- namestr
- Variable name 
- newNamestr
- New name 
 
 
 - 
setOutputValue(outputName, value)¶
- Output variable name accessor. - Parameters
- namestr
- Variable name 
- valuefloat
- New value 
 
 
 - 
setOutputs(outputs)¶
- Output variables accessor. - Parameters
- outputssequence of Output
- Output variables 
 
- outputssequence of 
 
 - 
setParallel(flag)¶
- Whether the evaluations of the model are parallelized. - Parameters
- isParallelbool
- Whether the evaluations of the model are parallelized (available only for the Python model) 
 
 
 - 
setProcessNumber(processNumber)¶
- Number of concurrent processes. - Parameters
- process_numberint
- Maximum number of processes 
 
 
 - 
setShadowedId(id)¶
- Accessor to the object’s shadowed id. - Parameters
- idint
- Internal unique identifier. 
 
 
 - 
setVisibility(visible)¶
- Accessor to the object’s visibility state. - Parameters
- visiblebool
- Visibility flag. 
 
 
 - 
property thisown¶
- The membership flag 
 
