Beam wrapper

Warning

In construction…

class Wrapper(tmpdir=None, sleep=0.0)

Wrapper of a C++ code that computes the deviation of a beam.

The C++ code computes the deviation with the given formula:

\[y = \frac{FL^{3}}{3EI}\]

with :

  • \(F\) : Load

  • \(E\) : Young modulus

  • \(L\) : Length

  • \(I\) : Inertia

The wrapped code is an executable that is run from the shell as follows :

$ beam -x beam.xml

where beam.xml is the input file containing the four parameters \(F, E, L, I\).

The output of the code is an xml output file _beam_outputs_.xml containing the deviation and its derivates.

Methods

__call__(X)

Call self as a function.

getInputDescription()

Input description accessor.

getInputDimension()

Input dimension accessor.

getOutputDescription()

Output description accessor.

getOutputDimension()

Output dimension accessor.

setInputDescription(descIn)

Input description accessor.

setOutputDescription(descOut)

Output description accessor.

__init__(tmpdir=None, sleep=0.0)
Parameters:
tmpdirstring

The root directory on which temporary working directories will be created for each independent simulation.

sleepfloat (Optional)

Intentional delay (in seconds) to demonstrate the effect of parallelizing.

_exec(X)

Run the model in the shell for a given point \(X\).

This is the default OpenTURNS method that executes the function on a given point. It has to be overloaded so that it executes/wraps your code. Semantically speaking, the function is divided on three parts :

The three steps are executed on a temporary working directory using the context manager otwrapy.TempWorkDir

Parameters:
X1D array (e.g. ot.Point or a 1D np.array)

Input vector of size \(n\) on which the model will be evaluated

Returns:
Ylist

Output vector of the model. Univariate in this case.

_create_input_file(X)

Create the input file required by the code.

Replace the values of the vector \(X\) to their corresponding tokens on the beam_input_template.xml and create the input file beam.xml on the current working directory.

Parameters:
X1D array (e.g. ot.Point or a 1D np.array)

Input vector of size \(n\) on which the model will be evaluated

_call()

Execute code on the shell and return the runtime

Returns:
runtimefloat

Total runtime (wall time and not cpu time)

_parse_output()

Parse the XML output given by the code and get the value of deviation

Returns:
Ylist

Output vector of the model. Univariate in this case.

getInputDescription()

Input description accessor.

getInputDimension()

Input dimension accessor.

getOutputDescription()

Output description accessor.

getOutputDimension()

Output dimension accessor.

setInputDescription(descIn)

Input description accessor.

setOutputDescription(descOut)

Output description accessor.