PAOFLOW.elphon.coupling_cache#

Disk cache of the doubly real-space vertex g(R_e, R_p) between runs.

Building g(R_e, R_p) (prepare_dense_vertex()) depends only on the coarse coupling, the grids, the masses and the PAO basis, not on the dense grids, temperatures or properties computed afterwards. With cache_dir the array is written once (g_ReRp_<key>.npy plus a <key>.json provenance file) and later runs fill the shared window from disk. The key hashes the coupling files (names and sizes), the grids, the masses, the shape of the projections and a caller-supplied cache_tag that identifies the PAO basis (basis_tag()); the values of the projections are not hashed because they are not reproducible across machines at the rounding level.

Functions#

basis_tag(data_controller[, pthr])

Signature of the PAO basis of a DataController (for cache_tag).

dense_vertex_cache_key(coupling_dir, source, ...)

Key of a g(R_e, R_p) cache entry.

cache_paths(cache_dir, key)

(array file, provenance file) of a key.

load_dense_vertex(cache_dir, key, g_ReRp)

Fill g_ReRp from the cache (row by row, to bound the memory).

store_dense_vertex(cache_dir, key, g_ReRp, provenance)

Write g_ReRp and its provenance atomically; returns the array path.

Module Contents#

PAOFLOW.elphon.coupling_cache.basis_tag(data_controller, pthr=None)[source]#

Signature of the PAO basis of a DataController (for cache_tag).

Parameters:
  • data_controller (DataController) – After projections (arrays['basis']) and projectability.

  • pthr (float, optional) – Projectability threshold used, appended to the tag.

Returns:

"<n orbitals>:<species and shells>:<nbnd>[:pthr]".

Return type:

str

PAOFLOW.elphon.coupling_cache.dense_vertex_cache_key(coupling_dir, source, qgrid_coarse, ng, masses_amu, projection_shape, cache_tag)[source]#

Key of a g(R_e, R_p) cache entry.

Parameters:
  • coupling_dir (str) – EPW directory or ph.x outputs.

  • source (str) – 'epw' or 'dfpt'.

  • qgrid_coarse (sequence of int)

  • ng (sequence of int)

  • masses_amu (array_like)

  • projection_shape (sequence of int) – A.shape (nbnd, nawf, nk).

  • cache_tag (str or None) – Identity of the PAO basis (see basis_tag()).

Returns:

A 16-character hexadecimal digest.

Return type:

str

PAOFLOW.elphon.coupling_cache.cache_paths(cache_dir, key)[source]#

(array file, provenance file) of a key.

PAOFLOW.elphon.coupling_cache.load_dense_vertex(cache_dir, key, g_ReRp)[source]#

Fill g_ReRp from the cache (row by row, to bound the memory).

Parameters:
  • cache_dir (str)

  • key (str)

  • g_ReRp (ndarray) – The (shared) destination array.

Returns:

False when no entry exists.

Return type:

bool

Raises:

ValueError – If the cached shape differs from g_ReRp.shape.

PAOFLOW.elphon.coupling_cache.store_dense_vertex(cache_dir, key, g_ReRp, provenance)[source]#

Write g_ReRp and its provenance atomically; returns the array path.