PALEOS-API cache resolver
On-disk cache for PALEOS-API:* tables under $ZALMOXIS_ROOT/data/EOS_PALEOS_API/. Converts a (material, GridSpec) cache key into a concrete .dat path, regenerating via paleos_api.py on cache miss. Cache key is (PALEOS_SHA, BUILD_KEY, GridSpec.hash_short()), all in the file name and the first two stamped into the file header, so a missing file, a SHA mismatch (upstream PALEOS upgraded) or a build key mismatch (RTpress, the AQUA table, numpy, scipy or sympy changed) triggers regeneration. The SHA guard is the backstop for upstream PALEOS changes: renaming _phase_eos_map or a boundary function on upstream produces a different SHA and invalidates the disk file even if the path still exists.
paleos_api_cache
Cache resolver for PALEOS-API:* live-tabulated tables.
Converts a (material, GridSpec) or (GridSpec,) cache key to an
on-disk .dat path, regenerating via paleos_api.py on cache miss.
Cache layout under $ZALMOXIS_ROOT/data/EOS_PALEOS_API/::
unified_<material>_<sha10>_<build>_<gridhash>.dat
2phase_solid_<sha10>_<build>_<gridhash>.dat
2phase_liquid_<sha10>_<build>_<gridhash>.dat
<sha10> is the first 10 characters of the PALEOS commit, followed by
-dirty-<8 hex> for an allowed checkout whose package code differs from that
commit; each such state keeps its own files, which invalidate_cache removes.
<build> is :func:~zalmoxis.eos.paleos_api.build_key: RTpress, the AQUA
table md5 (H2O) and the numpy, scipy and sympy versions.
Cache key is (PALEOS_SHA, BUILD_KEY, GridSpec.hash_short()). All are stamped in
the generated file's header, so:
- A missing file → regenerate.
- An existing file whose header SHA or build key does not match the currently
installed PALEOS and its inputs → regenerate (caught by
_header_sha_matches).
The SHA guard is the backstop for upstream PALEOS changes:
renaming _phase_eos_map or a boundary function on upstream will
produce a different SHA even if the on-disk file still exists.
resolve_paleos_api_unified(material, grid, *, h2o_table_path=None, force=False, n_workers=-1)
Return the path to a cached unified PALEOS-API table, regenerating if stale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
('iron', 'mgsio3', 'h2o')
|
|
'iron'
|
grid
|
GridSpec
|
|
required |
h2o_table_path
|
str or None
|
AQUA table path, passed through to the generator when |
None
|
force
|
bool
|
If True, regenerate even if a valid cached file exists. Intended for debugging / explicit cache-invalidation commands. |
False
|
n_workers
|
int
|
Parallelism for the generator on cache-miss. Default |
-1
|
Source code in src/zalmoxis/eos/paleos_api_cache.py
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 | |
resolve_paleos_api_2phase_mgsio3(grid, *, force=False, n_workers=-1)
Return (solid_path, liquid_path) for cached 2-phase MgSiO3 tables.
Regenerates both files as a pair (same SHA + grid_hash) to ensure they are always from the same PALEOS commit. If only one side is stale, we still regenerate both — the generation cost is O(few min) and pairing them guarantees consistency for downstream mushy-zone mixing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
GridSpec
|
|
required |
force
|
bool
|
Regenerate even when cached files look valid. |
False
|
n_workers
|
int
|
Parallelism for the generator on cache-miss. Default |
-1
|
Source code in src/zalmoxis/eos/paleos_api_cache.py
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 | |
resolve_registry_entry(material_dict)
Materialise PALEOS-API:* / PALEOS-API-2phase:* registry entries in place.
Registry entries for the live-tabulated EoS carry grid + material metadata
but no file path. This helper detects format=='paleos_api' or
format=='paleos_api_2phase' in either the top-level dict (unified
materials) or in the solid_mantle / melted_mantle sub-dicts
(2-phase materials), calls the appropriate cache resolver, writes the
resolved on-disk path into eos_file, and switches format to the
matching downstream format (paleos_unified or paleos). Subsequent
dispatch goes through the normal code path unchanged.
Rewriting in place (rather than returning a copy) is intentional: the registry entry is a mutable dict that downstream consumers hold a reference to. Once resolved, further lookups on the same entry are O(1) (plain dict access).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material_dict
|
dict
|
A registry entry. For unified materials the dict itself has
|
required |
Returns:
| Type | Description |
|---|---|
dict
|
The same |
Source code in src/zalmoxis/eos/paleos_api_cache.py
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 | |
invalidate_cache(material=None)
Remove cache files for material (or all if None).
Returns the number of files removed. Intended for CLI / debugging use.
Source code in src/zalmoxis/eos/paleos_api_cache.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |