PAOFLOW.inputs.lattice_format#
Reconstruct Bravais lattice vectors from Quantum ESPRESSO ibrav.
This module implements the lattice-vector conventions of Quantum
ESPRESSO’s PW/src/latgen.f90 (documented in INPUT_PW). Given a
QE ibrav index and the six celldm parameters it returns the three
primitive lattice vectors (as the rows of a (3, 3) array) in Bohr —
the same layout and units used elsewhere in PAOFLOW
(PAOFLOW.inputs.file_io.struct_from_outputfile_QE()).
The per-ibrav vector definitions are kept in a registry
(_IBRAV_BUILDERS) so the canonical forms can be reused by a future
inverse map (explicit lattice / AFLOW ibrav=0 → canonical QE
ibrav + celldm).
celldm convention#
Following QE, celldm is a length-6 array:
celldm[0]—a(the lattice parameter) in Bohr.celldm[1]—b/a.celldm[2]—c/a.celldm[3]— first cosine (meaning depends onibrav).celldm[4]— second cosine (meaning depends onibrav).celldm[5]— third cosine (meaning depends onibrav).
Public API#
lattice_format_QE()—(ibrav, celldm)→ lattice vectors (Bohr).celldm_from_namelist()— assemblecelldmfrom a parsed QE&systemblock, accepting either thecelldm(i)convention or theA/B/C/cosAB/cosAC/cosBCconvention.
Functions#
|
Return the primitive lattice vectors for a QE |
|
Assemble a length-6 |
|
Return |
|
Map an AFLOW Bravais-lattice symbol to a candidate QE |
|
Classify an explicit lattice as a QE |
Module Contents#
- PAOFLOW.inputs.lattice_format.lattice_format_QE(ibrav, celldm)[source]#
Return the primitive lattice vectors for a QE
ibrav.- Parameters:
ibrav (int) – Quantum ESPRESSO Bravais-lattice index. All non-zero QE values are supported:
1, 2, 3, -3, 4, 5, -5, 6, 7, 8, 9, -9, 91, 10, 11, 12, -12, 13, -13, 14.celldm (array_like) – Length-6 array of QE
celldmparameters.celldm[0]is the lattice parameterain Bohr;celldm[1] = b/a,celldm[2] = c/aandcelldm[3:6]are the cosines whose meaning depends onibrav(see module docstring).
- Returns:
(3, 3)array whose rows are the primitive lattice vectors in Bohr.- Return type:
- Raises:
ValueError – If
ibravis0(explicitCELL_PARAMETERSrequired) or not a recognised QE Bravais-lattice index.
- PAOFLOW.inputs.lattice_format.celldm_from_namelist(system_block, ibrav)[source]#
Assemble a length-6
celldmarray from a parsed QE&systemblock.Accepts either of the two mutually exclusive QE conventions:
celldm(1)..``celldm(6)`` directly; orA,B,C(Ångström) withcosAB,cosAC,cosBC.
The cosine slots are filled following QE’s
cell_basemapping, which depends onibrav:ibrav = 14:celldm[3]=cosBC,celldm[4]=cosAC,celldm[5]=cosAB.ibrav in {-12, -13}(unique axis b):celldm[4]=cosAC.all other
ibravneeding one cosine:celldm[3]=cosAB.
- Parameters:
system_block (dict) – Mapping of lower-case
&systemkeywords to their raw string values, as produced byPAOFLOW.inputs.file_io.struct_from_inputfile_QE().ibrav (int) – QE Bravais-lattice index (controls the cosine mapping above).
- Returns:
Length-6
celldmarray withcelldm[0]in Bohr.- Return type:
- Raises:
ValueError – If neither
celldm(1)norAis present in the block.
- PAOFLOW.inputs.lattice_format.cell_lengths_angles(lattice)[source]#
Return
(a, b, c, alpha, beta, gamma)for a set of cell vectors.- Parameters:
lattice (array_like) –
(3, 3)array whose rows are the cell vectors (any length unit).- Returns:
Lengths
a, b, c(same unit aslattice) and anglesalpha, beta, gammain degrees.alphais the angle between vectors 2 and 3,betabetween 1 and 3,gammabetween 1 and 2.- Return type:
- PAOFLOW.inputs.lattice_format.bravais_to_ibrav(symbol, spacegroup=None)[source]#
Map an AFLOW Bravais-lattice symbol to a candidate QE
ibrav.- Parameters:
symbol (str) – AFLOW Bravais-lattice symbol (e.g.
'FCC','BCC','HEX','ORCC') or Pearson-style two-letter code (e.g.'cF').spacegroup (int, optional) – Space-group number. Currently unused for the base mapping but accepted so callers can pass it through; variant/sign disambiguation is done geometrically.
- Returns:
The candidate
ibrav(the magnitude/base variant), orNoneif the symbol is not recognised.- Return type:
int or None
- PAOFLOW.inputs.lattice_format.qe_ibrav_from_lattice(lattice, bravais_hint=None, spacegroup=None, symprec=0.0001)[source]#
Classify an explicit lattice as a QE
ibrav+celldm.- Parameters:
lattice (array_like) –
(3, 3)primitive cell, rows are the lattice vectors in Bohr.bravais_hint (str, optional) – AFLOW Bravais-lattice symbol (e.g.
'FCC'); when given it narrows the candidateibravand makes classification robust. When omitted, every supportedibravis tried in order of decreasing symmetry.spacegroup (int, optional) – Space-group number (passed through to
bravais_to_ibrav()).symprec (float, optional) – Absolute tolerance (Bohr) for length comparisons; the angular tolerance is derived from it. Defaults to
1e-4.
- Returns:
{'ibrav': int, 'celldm': ndarray, 'M': ndarray}on success, whereMis the integer unimodular matrix mapping the input basis to the QE primitive basis (so fractional coordinates transform asf_qe = f_in @ inv(M)). On failure returns{'ibrav': 0, 'celldm': None, 'M': None}and the caller should keep the explicitCELL_PARAMETERSdescription.- Return type: