Batch API¶
Parallel simulation execution with thread-pool parallelism.
simulate_batch¶
idfkit.simulation.batch.simulate_batch(jobs, *, energyplus=None, max_workers=None, cache=None, progress=None, fs=None, on_progress=None)
¶
Run multiple EnergyPlus simulations in parallel.
Uses ThreadPoolExecutor to dispatch simulations concurrently. Individual job failures are captured as failed SimulationResult entries -- the batch never raises due to a single job failing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobs
|
Sequence[SimulationJob]
|
Sequence of simulation jobs to execute. |
required |
energyplus
|
EnergyPlusConfig | None
|
Shared EnergyPlus configuration (auto-discovered if
|
None
|
max_workers
|
int | None
|
Maximum number of concurrent simulations. Defaults
to |
None
|
cache
|
SimulationCache | None
|
Optional simulation cache for content-hash lookups. |
None
|
progress
|
Callable[..., None] | None
|
Optional callback invoked after each job completes.
Called as |
None
|
fs
|
FileSystem | None
|
Optional file system backend passed through to each simulate call. |
None
|
on_progress
|
Callable[[SimulationProgress], None] | None
|
Optional callback invoked with
SimulationProgress events
during each individual simulation. Events include
|
None
|
Returns:
| Type | Description |
|---|---|
BatchResult
|
A BatchResult with results in the same order as jobs. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If jobs is empty. |
Source code in idfkit/simulation/batch.py
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 | |
SimulationJob¶
idfkit.simulation.batch.SimulationJob
dataclass
¶
Specification for a single simulation within a batch.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
object
|
The EnergyPlus model to simulate. |
weather |
str | Path
|
Path to the weather file. |
label |
str
|
Human-readable label for progress reporting. |
output_dir |
str | Path | None
|
Directory for output files (default: auto temp dir). |
expand_objects |
bool
|
Run ExpandObjects before simulation. |
annual |
bool
|
Run annual simulation. |
design_day |
bool
|
Run design-day-only simulation. |
output_prefix |
str
|
Prefix for output files. |
output_suffix |
Literal['C', 'L', 'D']
|
Output file naming suffix ( |
readvars |
bool
|
Run ReadVarsESO after simulation. |
timeout |
float
|
Maximum runtime in seconds for the main EnergyPlus subprocess. |
preprocessor_timeout |
float | None
|
Per-subprocess timeout (seconds) applied
individually to ExpandObjects, Slab, and Basement when they
run automatically. |
extra_args |
tuple[str, ...] | None
|
Additional command-line arguments. |
Source code in idfkit/simulation/batch.py
annual = False
class-attribute
instance-attribute
¶
design_day = False
class-attribute
instance-attribute
¶
expand_objects = True
class-attribute
instance-attribute
¶
extra_args = None
class-attribute
instance-attribute
¶
label = ''
class-attribute
instance-attribute
¶
model
instance-attribute
¶
output_dir = None
class-attribute
instance-attribute
¶
output_prefix = 'eplus'
class-attribute
instance-attribute
¶
output_suffix = 'C'
class-attribute
instance-attribute
¶
preprocessor_timeout = None
class-attribute
instance-attribute
¶
readvars = False
class-attribute
instance-attribute
¶
timeout = 3600.0
class-attribute
instance-attribute
¶
weather
instance-attribute
¶
BatchResult¶
idfkit.simulation.batch.BatchResult
dataclass
¶
Bases: Sequence[SimulationResult]
Aggregated results from a batch simulation run.
A real Sequence of the results, in job order, so
for result in batch, enumerate(batch), batch[0], len(batch),
reversed(batch) and result in batch all work and all type-check.
It behaved that way at runtime long before it type-checked. __len__ and
__getitem__ alone make an object iterable through the legacy sequence
protocol, so for result in batch ran fine and every static checker rejected
it, which pushed seven documented examples into writing batch.results
instead. Documenting a workaround for a call that already worked is worse than
either fixing it or removing it, so the base class is declared.
Attributes:
| Name | Type | Description |
|---|---|---|
results |
tuple[SimulationResult, ...]
|
Simulation results in the same order as the input jobs. |
total_runtime_seconds |
float
|
Wall-clock time for the entire batch. |