I/O¶
save_hdf5(results, path)
¶
Save simulation results to an HDF5 file.
File structure::
results.h5
├── metadata/
│ ├── version (attribute)
│ └── config_json (attribute)
├── T=2.269/
│ ├── configurations (n_samples x L x L, int8)
│ ├── energy (n_samples, float64)
│ ├── magnetization (n_samples, float64)
│ ├── correlation_function (n_distances, float64) [optional]
│ ├── correlation_distances (n_distances, float64) [optional]
│ └── correlation_length (n_samples, float64) [optional]
└── ...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
SimulationResults
|
The simulation results to save. |
required |
path
|
str or Path
|
Output file path (should end in .h5 or .hdf5). |
required |
load_hdf5(path)
¶
Load simulation results from an HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Input file path. |
required |
Returns:
| Type | Description |
|---|---|
SimulationResults
|
The loaded simulation results. |
save_json_summary(results, path)
¶
Save a JSON summary of simulation results (no large arrays).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
SimulationResults
|
The simulation results to summarize. |
required |
path
|
str or Path
|
Output file path. |
required |
checkpoint_run(sim, path, *, show_progress=True, resume=False, checkpoint_interval=1)
¶
Run a simulation with periodic HDF5 checkpointing.
After every checkpoint_interval temperatures complete, results
are appended to the checkpoint file. If the process is interrupted,
already-completed temperatures are preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sim
|
Simulation
|
Configured simulation instance. |
required |
path
|
str or Path
|
HDF5 checkpoint file path. |
required |
show_progress
|
bool
|
Whether to display progress bars. |
True
|
resume
|
bool
|
If True and the file exists, skip already-completed temperatures. |
False
|
checkpoint_interval
|
int
|
Save checkpoint every N completed temperatures. Default is 1 (save after every temperature). Use higher values for speed at the cost of less frequent saves. |
1
|
Returns:
| Type | Description |
|---|---|
SimulationResults
|
Complete simulation results (including resumed data). |