Progress¶
Event-based progress tracking for simulations: the SimulationProgress event
passed to on_progress callbacks, and the ProgressParser that turns raw
EnergyPlus stdout into those events.
Simulation progress tracking.
Provides a dataclass for progress events and a parser that extracts structured progress information from EnergyPlus stdout output.
ProgressParser
¶
Parse EnergyPlus stdout lines into SimulationProgress events.
Maintains internal state to track the current environment, warmup iteration count, and simulation day for percentage estimation.
Recent EnergyPlus releases (26.1, for one) print Starting Simulation at
01/01/2013 for RUN PERIOD 1 without the period's end date, so the parser cannot learn
the length of the period from stdout alone. Pass environment_days
(see environment_days) so it
can still report percent and sim_total_days. EnergyPlus prints
EnergyPlus Completed Successfully to stderr: feed stderr lines to
parse_line too to
get the "complete" event, which is emitted at most once.
A new instance should be created for each simulation run. The parser
is designed to be defensive — unrecognised lines return None and
never raise.
Examples:
parser = ProgressParser()
for line in energyplus_stdout_lines:
event = parser.parse_line(line)
if event is not None:
print(event.phase, event.percent)
Source code in idfkit/simulation/progress.py
61 62 63 64 65 66 67 68 69 70 71 72 73 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 105 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
parse_line(line)
¶
Parse a single stdout line into a progress event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
A single line from EnergyPlus stdout. |
required |
Returns:
| Type | Description |
|---|---|
SimulationProgress | None
|
A SimulationProgress event, or |
SimulationProgress | None
|
does not contain progress information. |
Source code in idfkit/simulation/progress.py
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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
SimulationProgress
dataclass
¶
Progress event emitted during a single EnergyPlus simulation.
This dataclass represents a progress update parsed from EnergyPlus
stdout output. It is passed to user-supplied on_progress callbacks
on simulate and
async_simulate.
Attributes:
| Name | Type | Description |
|---|---|---|
phase |
Literal['preprocessing', 'initializing', 'warmup', 'simulating', 'postprocessing', 'complete']
|
Current simulation phase. |
message |
str
|
Raw EnergyPlus stdout line (stripped). |
percent |
float | None
|
Estimated completion percentage (0.0-100.0), or |
environment |
str | None
|
Name of the current simulation environment, if known. |
warmup_day |
int | None
|
Current warmup iteration (1-based), only set during
the |
sim_day |
int | None
|
Current simulation day-of-year (1-based), only set during
the |
sim_total_days |
int | None
|
Total number of simulation days, only set when the simulation period is known. |
job_index |
int | None
|
Index of this job in a batch, or |
job_label |
str | None
|
Label of this job in a batch, or |
Source code in idfkit/simulation/progress.py
environment = None
class-attribute
instance-attribute
¶
job_index = None
class-attribute
instance-attribute
¶
job_label = None
class-attribute
instance-attribute
¶
message
instance-attribute
¶
percent = None
class-attribute
instance-attribute
¶
phase
instance-attribute
¶
sim_day = None
class-attribute
instance-attribute
¶
sim_total_days = None
class-attribute
instance-attribute
¶
warmup_day = None
class-attribute
instance-attribute
¶
environment_days(model)
¶
Return the length in days of each simulation environment model defines.
Covers RunPeriod (from its begin and end month/day, ignoring years),
SizingPeriod:DesignDay (one day each) and
SizingPeriod:WeatherFileDays. The result is meant for
ProgressParser, which
simulate builds with it so progress
events carry percent on EnergyPlus versions that do not print the
period's date range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
AnyIDFDocument
|
The model about to be simulated. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
Days per environment name, in upper case with single spaces, as |
dict[str, int]
|
EnergyPlus prints it. |