pymead.core.param.LengthParam#

class LengthParam(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)[source]#

Bases: Param

Length-type parameter in pymead. Adds unit functionality and prevents negative values except in the case of points.

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 with unit_type="length".

__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)[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

get_dict_rep()

Gets a dictionary representation of the pymead object.

set_lower(lower[, force])

Sets the lower bound for the design variable.

set_unit([unit, old_unit, modify_value])

This method sets the length unit to be used, called the first time when adding a parameter via GeometryCollection.add_pymead_obj_by_ref.

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

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

unit()

The value of this parameter's length unit.

Attributes

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).

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_unit(unit: str | None = None, old_unit: str | None = None, modify_value: bool = True) float[source]#

This method sets the length unit to be used, called the first time when adding a parameter via GeometryCollection.add_pymead_obj_by_ref.

Parameters:
  • unit (str or None) – The new unit to switch to. If None, the current length unit will be used. Default: None

  • old_unit (str or None) – The old unit to switch from. If None, no changes will be made to the bounds or value of the param. Default: None

  • modify_value (bool) – Whether to scale the parameter value based on the conversion to the new unit. Default: True

Returns:

If old_unit==None, None will be returned. Otherwise, the value of the parameter is returned

Return type:

float or None

set_value(value: float, bounds_normalized: bool = False, force: bool = False, param_graph_update: bool = False, from_request_move: bool = False, direct_user_request: bool = True)[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

unit() str[source]#

The value of this parameter’s length unit.

Returns:

None if the unit should be the default, str otherwise.

Return type:

str or None