smash.Model.set_serr_mu_parameters#

Model.set_serr_mu_parameters(key, value)[source]#

Set the values of a Model structural error mu parameter.

This method performs an in-place operation on the Model object.

Parameters:
keystr

The name of the structural error mu parameter.

valuefloat or numpy.ndarray

The value(s) to set to the structural error mu parameter. If the value is a numpy.ndarray, its shape must be broadcastable into the structural error mu parameter shape.

See also

Model.get_serr_mu_parameters

Get the values of a Model structural error mu parameter.

Model.serr_mu_parameters

Model structural error mu parameters.

Examples

>>> from smash.factory import load_dataset
>>> setup, mesh = load_dataset("cance")

Set the structural error mu mapping to 'Linear' (see Model). Default value in the Cance dataset is 'Zero' (equivalent to no mu mapping)

>>> setup["serr_mu_mapping"] = "Linear"
>>> model = smash.Model(setup, mesh)

Set a specific value to a structural error mu parameter vector

>>> model.set_serr_mu_parameters("mg0", 10)

Access its value

>>> model.get_serr_mu_parameters("mg0")
array([10., 10., 10.], dtype=float32)

Set a vector with a shape equivalent to the structural error mu parameter

Get the structural error mu parameter size (equivalent to the number of gauge model.mesh.ng)

>>> size = model.get_serr_mu_parameters("mg0").size
>>> size
3

Generate the vector

>>> vec = np.arange(1, size + 1)
>>> vec
array([1, 2, 3])

Set to the structural error mu parameter the vector

>>> model.set_serr_mu_parameters("mg0", vec)
>>> model.get_serr_mu_parameters("mg0")
array([1., 2., 3.], dtype=float32)

Note

This method is equivalent to directly slicing the serr_mu_parameters.values array (as shown below) and change the values but is simpler and safer to use.

Access the structual error mu parameter keys

>>> model.serr_mu_parameters.keys
array(['mg0', 'mg1'], dtype='<U3')

Get the index of the structural error mu parameter 'mg0'

>>> ind = np.argwhere(model.serr_mu_parameters.keys == "mg0").item()
>>> ind
0

Slice the serr_mu_parameters.values array on the last axis and change its values

>>> model.serr_mu_parameters.values[..., ind] = 24
>>> model.serr_mu_parameters.values[..., ind]
array([[24., 24., 24.]], dtype=float32)

Warning

In that case, there’s no problem to set the value 24 to the structural error mu parameter 'mg0', but each structural error mu parameter has a feasibility domain, and that outside this domain, the model cannot run. For example, the feasibility domain of 'mg0' is \(]-\inf, +\inf[\) so in this case, you should not have any problems.