common¶
Value objects and helpers shared across the library, belonging to no single model package.
FluidState— A fluid at a thermodynamic state point: fluid name, pressure, temperature, and density. What a feed system hands the injector, so neither package has to import the other.DryMassProperties— Mass, center of gravity, and inertia tensor of a device's dry structure.- Array manipulation helpers and a
@timingdecorator for profiling.
machwave.common.fluid_state
¶
FluidState
dataclass
¶
A fluid at a thermodynamic state point.
Attributes:
| Name | Type | Description |
|---|---|---|
fluid_name |
str
|
Name of the fluid in the CoolProp database. |
pressure |
float
|
Pressure [Pa]. |
temperature |
float
|
Temperature [K]. |
density |
float
|
Density [kg/m^3]. |
Source code in machwave/common/fluid_state.py
machwave.common.mass_properties
¶
DryMassProperties
dataclass
¶
Properties common to devices that contain dry mass.
Attributes:
| Name | Type | Description |
|---|---|---|
dry_mass |
float
|
Dry mass scalar [kg]. |
center_of_gravity_coordinate |
tuple[float, float, float]
|
Dry mass center of gravity position measured from
the nozzle exit |
moment_of_inertia |
tuple[float, float, float]
|
Dry mass principal moments of inertia |
Source code in machwave/common/mass_properties.py
__post_init__()
¶
Validate and normalize the dry mass properties.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dry mass is non-positive or non-finite, either triple is malformed, or a moment of inertia is negative or non-finite. |
Source code in machwave/common/mass_properties.py
machwave.common.arrays
¶
replace_array_values(arr, to_replace, value)
¶
Replaces values in a NumPy array with another value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
NDArray[number]
|
The array in which to replace values. |
required |
to_replace
|
int | float
|
The value to be replaced. |
required |
value
|
int | float
|
The value to replace with. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[number]
|
A new array with the values replaced. |
Source code in machwave/common/arrays.py
machwave.common.decorators
¶
timing(f)
¶
Decorator to print the execution time of a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
F
|
The function to be timed. |
required |
Returns:
| Type | Description |
|---|---|
F
|
The wrapped function with added timing functionality. |
Source code in machwave/common/decorators.py
machwave.common.objects
¶
get_object_dict(obj)
¶
Extract the attribute dictionary from an object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
Any Python object to inspect. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary mapping attribute names to their values, or an empty dictionary |
dict[str, Any]
|
if the object has no dict. |
Examples:
>>> class Example:
... def __init__(self):
... self.x = 1
... self.y = 2
>>> get_object_dict(Example())
{'x': 1, 'y': 2}