pymead.core.param.Param#

class Param(value: float, name: str, lower: float | None = None, upper: float | None = None, sub_container: str = 'params', setting_from_geo_col: bool = False, point=None, root=None, rotation_handle=None, enabled: bool = True, equation_str: str | None = None, geo_col=None, bspline=None)[source]#

Bases: PymeadObj

Base-level parameter in pymead. Sub-classed by DesVar (design variable). Provides operator overloading and getter/setter methods.

Note

Instances of this class should never be created directly. Instead, parameters can be created by creating a GeometryCollection and calling its add_param method.

__init__(value: float, name: str, lower: float | None = None, upper: float | None = None, sub_container: str = 'params', setting_from_geo_col: bool = False, point=None, root=None, rotation_handle=None, enabled: bool = True, equation_str: str | None = None, geo_col=None, bspline=None)[source]#
Parameters:
  • value (float or int) – Starting value for the parameter.

  • name (str) – Name of the parameter

  • lower (float) – Lower bound for the parameter

  • upper (float) – Upper bound for the parameter

Methods

enabled()

Whether this parameter is enabled (whether it can change)

evaluate_equation()

Evaluates this parameter's equation, taking into account other parameter values.

get_dict_rep()

Gets a dictionary representation of the pymead object.

lower()

Returns the lower bound for the design variable

set_enabled(enabled)

Sets this parameter to be enabled or disabled

set_from_dict_rep(d)

set_lower(lower[, force])

Sets the lower bound for the design variable.

set_upper(upper[, force])

Sets the upper bound for the design variable.

set_value(value[, bounds_normalized, force, ...])

Sets the design variable value, adjusting the value to fit inside the bounds if necessary.

update_equation([equation_str])

Updates the equation defining the value of this parameter.

upper()

Returns the upper bound for the design variable

value([bounds_normalized])

Returns the design variable value.

Attributes

enabled() bool[source]#

Whether this parameter is enabled (whether it can change)

Returns:

Whether this parameter is enabled

Return type:

bool

evaluate_equation()[source]#

Evaluates this parameter’s equation, taking into account other parameter values. Raises an EquationCompileError if the equation cannot be compiled due to a naming or syntax error.

get_dict_rep()[source]#

Gets a dictionary representation of the pymead object. In general, this dictionary should consist of only the required arguments for object instantiation. For example, the dictionary representation of a point looks something like this: {"x": 0.3, "y": 0.5}. If the argument requires a reference to a PymeadObj rather than a string or float value, the name() method should be the value that is stored. For an example, see the overridden value of this method in pymead.core.airfoil.Airfoil. All subclasses of PymeadObj must implement this method, since it is the way pymead objects are stored in saved instances of a GeometryCollection (.jmea files).

lower() float[source]#

Returns the lower bound for the design variable

Returns:

DV lower bound

Return type:

float

set_enabled(enabled: bool)[source]#

Sets this parameter to be enabled or disabled

Parameters:

enabled (bool) – True if this parameter should be enabled, False otherwise

set_lower(lower: float, force: bool = False)[source]#

Sets the lower bound for the design variable. If called from outside DesVar.__init__(), adjust the design variable value to fit inside the bounds if necessary.

Parameters:
  • lower (float) – Lower bound for the design variable

  • force (bool) – Setting this argument to True ignores the check for lower bound greater than value. Default: False

set_upper(upper: float, force: bool = False)[source]#

Sets the upper bound for the design variable. If called from outside DesVar.__init__(), adjust the design variable value to fit inside the bounds if necessary.

Parameters:
  • upper (float) – Upper bound for the design variable

  • force (bool) – Setting this argument to True ignores the check for upper bound less than value. Default: False

set_value(value: float, bounds_normalized: bool = False, force: bool = False, param_graph_update: bool = False, from_request_move: bool = False)[source]#

Sets the design variable value, adjusting the value to fit inside the bounds if necessary.

Parameters:
  • value (float or int) – Design variable value

  • bounds_normalized (bool) – Whether the specified value is normalized by the bounds (e.g., 0 if the value is equal to the lower bound, 1 if the value is equal to the upper bound, or a float between 0.0 and 1.0 if the value is somewhere between the bounds). Default: False

  • force (bool) – Whether to force the change in value. This keyword argument should never be set to True when using the API. Default: False

  • param_graph_update (bool) – Whether this value is being set as part of a parameter graph update. Used to prevent the parameter graph from triggering multiple updates for the same parameter. This keyword argument should never be set to True when using the API. Default: False

  • from_request_move (bool) – Whether this method was called from Point.request_move. Default: False

update_equation(equation_str: str | None = None)[source]#

Updates the equation defining the value of this parameter.

Parameters:

equation_str (str or None) – The equation to assign to the parameter. If None, the parameter will no longer be defined by an equation and the value is free to change independently of all other parameters. Default: None

upper() float[source]#

Returns the upper bound for the design variable

Returns:

DV upper bound

Return type:

float

value(bounds_normalized: bool = False)[source]#

Returns the design variable value.

Parameters:

bounds_normalized (bool) – Whether to return the value as normalized by the set bounds. If the value is at the lower bound, 0.0 will be returned. If the value is at the upper bound, 1.0 will be returned. Otherwise, a number between 0.0 and 1.0 will be returned. Default: False.

Returns:

The design variable value

Return type:

float