Skip to content

Variables

This module contains definitions of LUME-model variables for use with lume tools. The variables are divided into input and outputs, each with different minimal requirements. Initiating any variable without the minimum requirements will result in an error.

For now, only scalar variables (floats) are supported.

Variable

Bases: BaseModel, Generic[Value]

Minimum requirements for a variable.

Attributes:

Name Type Description
name str

Name of the variable.

value Optional[Value]

Value assigned to the variable.

precision Optional[int]

Precision to use for the value.

Source code in lume_model/variables.py
19
20
21
22
23
24
25
26
27
28
29
30
class Variable(BaseModel, Generic[Value]):
    """
    Minimum requirements for a variable.

    Attributes:
        name: Name of the variable.
        value: Value assigned to the variable.
        precision: Precision to use for the value.
    """
    name: str
    value: Optional[Value] = None
    precision: Optional[int] = None

ScalarVariable

Bases: BaseModel

Base class used for constructing a scalar variable.

Attributes:

Name Type Description
variable_type str

Indicates scalar variable.

units Optional[str]

Units associated with scalar value.

parent_variable str

Variable for which this is an attribute.

Source code in lume_model/variables.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class ScalarVariable(BaseModel):
    """
    Base class used for constructing a scalar variable.

    Attributes:
        variable_type: Indicates scalar variable.
        units: Units associated with scalar value.
        parent_variable: Variable for which this is an attribute.
    """
    variable_type: str = "scalar"
    units: Optional[str] = None  # required for some output displays
    parent_variable: str = (
        None  # indicates that this variable is an attribute of another
    )

InputVariable

Bases: Variable, Generic[Value]

Base class for input variables.

Attributes:

Name Type Description
default Value

Default value assigned to the variable.

is_constant bool

Indicates whether the variable is constant.

Source code in lume_model/variables.py
49
50
51
52
53
54
55
56
57
58
class InputVariable(Variable, Generic[Value]):
    """
    Base class for input variables.

    Attributes:
        default: Default value assigned to the variable.
        is_constant: Indicates whether the variable is constant.
    """
    default: Value  # required default
    is_constant: bool = Field(False)

OutputVariable

Bases: Variable, Generic[Value]

Base class for output variables. Value and range assignment are optional.

Attributes:

Name Type Description
default Optional[Value]

Default value assigned to the variable.

value_range Optional[list]

Acceptable range for value.

Source code in lume_model/variables.py
61
62
63
64
65
66
67
68
69
70
class OutputVariable(Variable, Generic[Value]):
    """
    Base class for output variables. Value and range assignment are optional.

    Attributes:
        default: Default value assigned to the variable.
        value_range: Acceptable range for value.
    """
    default: Optional[Value] = None
    value_range: Optional[list] = Field(None, alias="range")

ScalarInputVariable

Bases: InputVariable[float], ScalarVariable

Variable used for representing a scalar input. Scalar variables hold float values. Initialization requires name, default, and value_range.

Attributes:

Name Type Description
value_range list[float]

Acceptable range for value.

Example
variable = ScalarInputVariable(name="example_input", default=0.1, value_range=[0.0, 1.0])
Source code in lume_model/variables.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class ScalarInputVariable(InputVariable[float], ScalarVariable):
    """
    Variable used for representing a scalar input. Scalar variables hold float values.
    Initialization requires name, default, and value_range.

    Attributes:
        value_range: Acceptable range for value.

    Example:
        ```
        variable = ScalarInputVariable(name="example_input", default=0.1, value_range=[0.0, 1.0])
        ```
    """
    value_range: list[float]

ScalarOutputVariable

Bases: OutputVariable[float], ScalarVariable

Variable used for representing a scalar output. Scalar variables hold float values. Initialization requires name.

Example
variable = ScalarOutputVariable(name="example_output")
Source code in lume_model/variables.py
89
90
91
92
93
94
95
96
97
98
99
class ScalarOutputVariable(OutputVariable[float], ScalarVariable):
    """
    Variable used for representing a scalar output. Scalar variables hold float values.
    Initialization requires name.

    Example:
        ```
        variable = ScalarOutputVariable(name="example_output")
        ```
    """
    pass