#include <qe.hpp>
Inheritance diagram for q3::QEInputParser:Public Member Functions | |
| InputData | parse (const std::string &filename) const override |
Public Member Functions inherited from q3::InputParser | |
| virtual | ~InputParser ()=default |
|
inlineoverridevirtual |
Parse the given input file and return the populated InputData.
A pw.x deck runs on pw.x's wavefunction grid, sized for 4 x ecutwfc. pw.x has no switch for it, so neither does this reader. See InputData::use_exact_wavefunction_grid.
pw.x mixes with mixing_mode = 'plain' unless the deck says otherwise, and 'plain' is Broyden with no preconditioning. Q3's own default ("default") adds Kerker whenever smearing is on, which is a different mixer: on a metallic slab it damps exactly the long-wavelength charge that converges slowest, and a Ni(111) slab that pw.x converges in 24 iterations took Q3 85. A deck that names TF or local-TF still gets its preconditioner below.
Raw 1-based starting_ns_eigenvalue (m, ispin, ityp, f), resolved to symbols post-parse.
CELL_PARAMETERS card state (applied after the whole file is read, because celldm(1) may appear before or after the card). The units string is empty for a card that names none; what that means depends on whether a lattice parameter is given, so it is resolved then too.
A/B/C/cosAB/cosAC/cosBC state, converted to celldm after the file is read (which celldm each cosine becomes depends on ibrav).
ATOMIC_POSITIONS units option. The rows are stored as read and converted after the whole file is read, because the cell they may be Cartesian in can be given after the card.
Whether the deck states the two DFT-D3 sub-options itself. pw.x's defaults for them are not what Q3 implements, so a D3 deck that leaves either one out is refused once the whole file is read – QE does not require them to follow vdw_corr. A stated value Q3 does not implement is refused where it is read.
Drop trailing comments before anything reads the line: a key scan that sees celldm(1) = 10.2 ! a = 5 in the old cell would find a key a in the prose.
Namelist headers. Every &name is matched, not only the ones Q3 reads: an unrecognized header used to leave section pointing at the previous namelist, so &IONS's keys were scanned as &ELECTRONS's and silently found nothing.
Fortran lets assignments share the header's line, and the closing / too: &ELECTRONS conv_thr = 1.0d-10, mixing_beta = 0.3 /. The rest of the line therefore goes on below as an ordinary namelist line. It used to be thrown away with the header, so a deck written that way ran on Q3's defaults for every key on those lines.
The / that closes a namelist need not stand alone either: it may follow the line's last assignment (ecutwfc = 30.0 /). Left in place, it became part of that value – 30.0 /, or ‘'relax’ /` for a string key. It is cut off here, and the namelist closes at the bottom of the loop, once the assignments before it are read.
QE's remaining cards.
They must be recognized even when unsupported: an unrecognized card header leaves section pointing at whatever came before, and the card's body is then parsed as that section's data. A HUBBARD card following K_POINTS was silently dropped — a PAW+U input ran and returned the no-U energy.
A card header never contains '='. Without that guard the occupations key in &SYSTEM matches the OCCUPATIONS card and a perfectly ordinary input is refused.
HUBBARD (atomic) / (ortho-atomic). QE's other projector flavours (wf, pseudo, norm-atomic) have no Q3 equivalent and are refused rather than silently substituted.
Classify every key on the line before any of it is applied, so a refusal names the offending key rather than failing later on a missing value.
QE's own vocabulary, mapped to Q3's flavor names. Passing it through verbatim meant a real QE input file failed on its very first field with "unsupported calculation type 'scf'" — the parser could read the file but not run it.
QE's six spellings collapse onto Q3's two, along the same line QE itself draws: 'high' and 'debug' raise iverbosity above zero, the other four leave it there. Read rather than ignored, so a deck that asked pw.x for the detailed output gets the detailed output here too.
QE-vocabulary exception: 'npool' mirrors QE's own flag name so QE-style inputs stay portable. QE itself only accepts -npool on the command line; accepting it in &control is a Q3 extension. Everywhere else use the full name: number_of_kpoint_pools.
QE's default, stated explicitly in most real inputs. Only 'from_scratch' means anything here — Q3 cannot resume a QE run's saved state.
Relaxation controls. They are inert for ‘calculation='scf’`, so they are applied unconditionally rather than deferred until the calculation type is known — which QE does not require to appear first.
celldm(2..6) carry the axial ratios and cell angles. Dropping them left every non-cubic Bravais index — hexagonal, tetragonal, orthorhombic, monoclinic, triclinic — being built with c/a = 0, i.e. a collapsed cell.
QE's alternative crystallographic form. Recorded raw and converted after the file is read, because the celldm(4..6) each cosine maps onto depends on ibrav, which may appear later in the namelist.
YAML-manifest vocabulary exception: mirrors nspin's own guard above (the YAML parser rejects 'nspin' with a message pointing back here) – reject the manifest key here so a mistyped namelist input cannot silently fall through and run unpolarized.
Per-species: starting_magnetization(i) = m. An unindexed occurrence means species 1 (Fortran scalar-assignment rule).
starting_ns_eigenvalue(m,ispin,ityp) = f.
Scanned for every occurrence on the line rather than via extract_key_value, which returns only the first match: a seeding deck naturally packs several directives onto one namelist line, and silently keeping just one of them would steer the SCF into a minimum the user did not ask for – the precise failure seeding exists to rule out.
All three indices are required. The Fortran scalar shorthand would leave which eigenvalue of which species to guesswork, and a seed aimed at the wrong manifold selects a different solution, not a slightly-off number. Species resolution to a symbol happens post-parse, since ntyp and ATOMIC_SPECIES may follow this line.
Only the Becke-Johnson-damped two-body term is implemented – what D3BJDispersionCalculator computes, and what pw.x runs for dftd3_version = 4, dftd3_threebody = .false.. Neither is pw.x's default, so the deck has to state both; see refuse_dftd3_defaults_q3_does_not_implement().
pw.x's DFT-D2, Tkatchenko-Scheffler, MBD and XDM. These used to fall through silently and run with no dispersion correction at all.
The two D3 sub-options Q3's implementation pins. They used to be ignored, which meant ‘vdw_corr='dft-d3’` silently produced the BJ-damped two-body energy whatever the file asked for.
QE's spelling of the corrections Q3 has; its remaining options ('esm', '2D') are different physics, not aliases.
Q3 relaxes with ASE's BFGS. QE's other ion_dynamics values are molecular dynamics or damped dynamics, which follow a different trajectory and stop somewhere else.
pw.x's two starts: overlapping atoms, or the saved density.
QE's vocabulary, translated the way calculation is. plain is QE's default and appears in most real inputs; storing it verbatim meant Q3 died in the mixer factory with "Unknown mixer mode: 'plain'" on files QE runs without comment. It keeps the unpreconditioned default set at the top of parse().
TF/local-TF are Thomas-Fermi preconditioners on the same Broyden mixing, and Q3 now has both: TF is the average (global) Thomas-Fermi screening, which is exactly what Kerker is, and local-TF builds the screening from the local density. Both map onto Broyden with the matching preconditioner rather than onto a different fixed point.
QE's default is .true.; .false. asks it to carry on with an unconverged density, which Q3 has no equivalent for and must not silently upgrade to a converged run.
Parsed through the same tolerant numeric path as every other value in this reader: a bare std::stoi throws std::invalid_argument without naming the key, which is the one thing this parser exists not to do.
QE's iterative solvers select an algorithm, not physics: both converge to the same fixed point. cg is mapped to Davidson with a notice rather than refused, because every QE PAW reference has to be generated with cg (its Davidson aborts in cegterg on PAW datasets), and refusing it would make exactly those inputs unreadable.
U <species>-<shell> <value in eV>, e.g. U Ni-3d 4.0. Only the U term: QE's J, V and B parameters describe interactions Q3's Dudarev implementation does not have, so they are refused rather than dropped.
Read the value only once the line is known to be a U entry: QE's V takes two targets, so extracting a number here first would report the second target as "not a number" and bury the accurate refusal above.
A/B/C are resolved before CELL_PARAMETERS, because the alat that an (alat) card is expressed in may have been given in that form.
starting_magnetization(i) indices were only bounds-checked to be >= 1 while streaming (ntyp may appear after them in the namelist); validate against the species count now that the whole file is read.
starting_ns_eigenvalue species indices, resolvable only now that ATOMIC_SPECIES is read: convert 1-based (m, ispin, ityp) to the symbol-keyed, 0-based form the SCF consumes. ityp beyond ntyp is a hard error like any other out-of-range species reference.
Implements q3::InputParser.
Definition at line 316 of file qe.hpp.
References q3::InputData::atoms, q3::InputData::bravais_lattice_index, q3::InputData::calculation, q3::InputData::cell_dimension_1, q3::InputData::cell_dimension_2, q3::InputData::cell_dimension_3, q3::InputData::cell_dimension_4, q3::InputData::cell_dimension_5, q3::InputData::cell_dimension_6, q3::InputData::charge_density_energy_cutoff, q3::InputData::convergence_threshold, q3::InputData::diagonalization_method, q3::InputData::disable_symmetry, q3::InputData::dispersion_correction, q3::InputData::exchange_correlation_functional, q3::constants::HARTREE_TO_EV, q3::qe_input::honoured_keys_by_namelist(), q3::InputData::hubbard, q3::InputData::hubbard_fixed_occupation_iterations, q3::InputData::hubbard_projector_type, q3::InputData::hubbard_starting_eigenvalues, q3::log::info(), q3::InputData::isolated_system_correction, q3::InputData::kpoint_grid_dimension_1, q3::InputData::kpoint_grid_dimension_2, q3::InputData::kpoint_grid_dimension_3, q3::InputData::kpoint_grid_shift_1, q3::InputData::kpoint_grid_shift_2, q3::InputData::kpoint_grid_shift_3, q3::make_hubbard_starting_eigenvalue(), q3::AtomSpecies::mass, q3::InputData::maximum_iterations, q3::InputData::mixing_beta, q3::InputData::mixing_history_size, q3::InputData::mixing_mode, q3::InputData::mixing_preconditioning, q3::Atom::movable_components, q3::InputData::number_of_atoms, q3::InputData::number_of_bands, q3::InputData::number_of_kpoint_pools, q3::InputData::number_of_species, q3::InputData::number_of_spin_components, q3::InputData::output_directory, q3::Atom::position, q3::InputData::prefix, q3::InputData::pseudopotential_directory, q3::AtomSpecies::pseudopotential_file, q3::InputData::relax_energy_threshold, q3::InputData::relax_force_threshold, q3::InputData::relax_maximum_steps, q3::InputData::smearing, q3::InputData::smearing_width, q3::InputData::species, q3::Atom::species_index, q3::InputData::start_from_saved_charge_density, q3::InputData::starting_magnetization, q3::AtomSpecies::symbol, q3::InputData::total_charge, q3::InputData::use_exact_wavefunction_grid, q3::InputData::verbosity, and q3::InputData::wavefunction_energy_cutoff.