memento
BalanceEngineCaretaker
BalanceEngineCaretaker(engine: BalanceEngine)
Dedicated class responsible for saving and restoring BalanceEngine state.
Implements the Caretaker role of the Memento pattern. The engine itself (the Originator) is not modified — all snapshot logic lives here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BalanceEngine
|
The balance engine whose state is managed. |
required |
Source code in src/mechaphlowers/core/models/balance/memento.py
71 72 | |
restore
restore(memento: BalanceEngineMemento) -> None
Restore the engine's mutable state from a previously saved memento.
After restoration all internal caches (span geometry, deformation snapshots, node projections, moments) are refreshed so the engine is immediately ready for a new solve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BalanceEngineMemento
|
Snapshot previously returned by
|
required |
Source code in src/mechaphlowers/core/models/balance/memento.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
save
save() -> BalanceEngineMemento
Create an immutable snapshot of the engine's current mutable state.
Returns:
| Name | Type | Description |
|---|---|---|
BalanceEngineMemento |
BalanceEngineMemento
|
Independent copy of every mutable array. |
Source code in src/mechaphlowers/core/models/balance/memento.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
BalanceEngineMemento
dataclass
BalanceEngineMemento(
dxdydz: ndarray,
parameter: ndarray,
sagging_temperature: ndarray,
adjustment: bool,
Th: ndarray,
Tv_d: ndarray,
Tv_g: ndarray,
a: ndarray,
b: ndarray,
span_sagging_parameter: ndarray,
span_span_length: ndarray,
span_elevation_difference: ndarray,
span_load_coefficient: ndarray,
wind_pressure: ndarray,
ice_thickness: ndarray,
deformation_current_temperature: ndarray,
deformation_tension_mean: ndarray,
deformation_cable_length: ndarray,
L_ref: Optional[ndarray],
)
Immutable snapshot of a BalanceEngine's mutable state.
Every numpy array stored here is an independent copy (via .copy())
so mutating the originals after saving will not affect the memento.