RMG Analyzer#
- nexus.rmg_analyzer.as_float(text)[source]#
Convert a finite RMG-formatted number to a float when possible.
- nexus.rmg_analyzer.line_numbers(line)[source]#
Return all finite, whitespace-delimited RMG numbers in a line.
- class nexus.rmg_analyzer.RmgOutData(filepath, input=None)[source]#
Bases:
DevBaseNexusRead an RMG output file and collect results appropriate to its run mode.
- Parameters:
- filepath
stroros.PathLike Path to the RMG log output file.
- filepath
- Attributes:
- path
str Directory containing the output file.
- abspath
str Absolute path to the output directory.
- outfile_name
str Name of the RMG output file.
- input
RmgInputorNone Parsed control input when the referenced input file is available.
- setup_info
obj Parsed setup sections and derived setup data. Derived members include
run_mode, the initialstructure,cellvolume information, and crystal and Cartesiank_pointswith optional weights.- run_mode
str,tuple,orNone Short RMG calculation mode:
"scf","nscf","band","exx","relax","md_VE","md_TE","tddft","stm", or"neb". Input/output disagreement is represented by(input_mode, output_mode).- input_run_mode, output_run_mode
strorNone Calculation modes independently identified from the referenced input and the output log.
- reader_mode
strorNone Mode used to select the structured reader stack. Output-log data take precedence over referenced-input data for this purpose.
- run_mode_detectedbool
Whether a mode was available to select the structured reader stack.
- convergence
objorNone Electronic and ionic convergence indicators and event counts.
- timing
objorNone Total, per-step, and section-resolved timing data in seconds.
- energies
objorNone Energy data with
history,units,final,final_units,direct, anddirect_unitsmembers.- electronic
objorNone Fermi energies, band edges, gaps, k-points, eigenvalues, and occupations, charge, magnetization, force, volume, and per-atom energy data when reported.
- scf
objorNone SCF energy components, iteration indices, residuals, and timing data.
- ions
objorNone Detailed ionic
steps; cell, position, force, charge, magnetization, and maximum-force histories; associated units; and astructure_historyconstructed with the cell reported for each step.- stress
objorNone Stress-tensor and hydrostatic-pressure histories, their units, and the final pressure.
- bands
objorNone Spin-indexed band-path distances and band energies read from companion band-structure files.
- md
objorNone Molecular-dynamics step, energy, temperature, and displacement arrays.
- md_stats
objorNone Statistical summaries for the molecular-dynamics arrays.
- tddft
objorNone Time-dependent energy changes and spin-resolved dipole histories read from companion files.
- neb
objorNone NEB controller and parallel settings, input and final path structures, reaction coordinate, image energies and barriers, and local-image histories.
final_imagescontains ordered final structures, positions, cells, atoms, units, and source files when available.- produced_files
objorNone Paths to recognized QMCPACK restart, EXX integral, or STM files.
- path
Methods
copy()Read spin-resolved band structures from companion data files.
read_cell_events(lines[, initial_structure])Return line-indexed lattice cells reported in an RMG output.
read_convergence(lines)Read electronic and ionic convergence messages.
read_electronic(lines)Parse electronic quantities exposed by
RmgAnalyzer.read_energies(lines)Read eigenvalue-sum and direct total-energy histories.
read_ion_records(lines[, initial_structure])Return ionic records and structures without binding analyzer data.
read_ions(lines)Read ionic records, cells, and trajectory-level structures.
read_md(lines)Read molecular-dynamics records and compute summary statistics.
read_neb(lines)Read NEB controller, path, energy, and final-image data.
Locate recognized files produced by EXX, STM, and SCF runs.
read_scf(lines)Read SCF energy components, iteration indices, residuals, and times.
read_setup_info(lines)Read setup sections, the run mode, and the initial structure.
read_stress(lines)Parse stress tensors and derive hydrostatic pressures.
Read TDDFT energy and spin-resolved dipole time series.
read_timing(lines)Read total, per-step, and section-resolved timing information.
save([filepath])clear
error
items
keys
load
nxs_print
update
values
warn
- Raises:
TypeErrorIf
filepathis not a string or path-like object.FileNotFoundErrorIf
filepathdoes not exist.IsADirectoryErrorIf
filepathdoes not identify a regular file.
Notes
All result members are initialized to
None.convergenceandtimingapply to all supported modes.energies,scf,ions, andstressapply to SCF, NSCF, relaxation, molecular dynamics, TDDFT, and NEB modes.electronicalso applies to band mode.bands,mdandmd_stats,tddft, andnebare specific to their corresponding modes.produced_filesapplies to SCF, EXX, and STM. A member remainsNonewhen its data cannot be obtained. History arrays are ordered as they occur in the output. When no run mode can be detected, all readers are attempted permissively. When a mode is detected, only the corresponding structured reader stack is attempted. Readers skip absent or malformed records they recognize, but unexpected reader exceptions are not suppressed.Independently identified input and output modes are normally stored as a single string. A disagreement is retained as
(input_mode, output_mode)rather than terminating parsing. The expected SCF input associated with an NEB image calculation is represented as"neb".- number_pattern = '[-+]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[EeDd][-+]?\\d+)?'#
- read_setup_info(lines)[source]#
Read setup sections, the run mode, and the initial structure.
Binds
setup_infoto anobjcontaining normalized setup blocks and derived grid, lattice, ion, k-point, and structure data. When the referenced control file is available, also bindsinput.
- read_convergence(lines)[source]#
Read electronic and ionic convergence messages.
Binds
convergenceto anobjcontaining nullable status values and electronic success and failure counts.
- read_timing(lines)[source]#
Read total, per-step, and section-resolved timing information.
Binds
timingto anobjmeasured in seconds, with individual timing rows stored undertiming.sections.
- read_energies(lines)[source]#
Read eigenvalue-sum and direct total-energy histories.
Binds
energiesto anobjcontaining the history arrays and their units, as well as the final eigenvalue-sum energy and its units.
- read_scf(lines)[source]#
Read SCF energy components, iteration indices, residuals, and times.
Binds
scfto anobjcontaining NumPy histories. Energies are in Hartree and times are in seconds.
- read_stress(lines)[source]#
Parse stress tensors and derive hydrostatic pressures.
Binds
stressto anobjcontaining tensor and pressure histories, their shared unit label, and the final hydrostatic pressure.
- read_electronic(lines)[source]#
Parse electronic quantities exposed by
RmgAnalyzer.Binds
electronicto anobjcontaining Fermi energies, band edges, gaps, charge and magnetization values, summed forces, per-atom volume and energy, k-point-major eigenvalues and occupations, and k-points.
- read_neb(lines)[source]#
Read NEB controller, path, energy, and final-image data.
Final reported image geometries are collected in
final_imagesin path order. Its position and cell arrays are in bohr and remainNoneunless every image supplies compatible data.
- read_produced_files()[source]#
Locate recognized files produced by EXX, STM, and SCF runs.
Binds
produced_filesto anobjcontaining the QMCPACK restart path when the file exists.
- class nexus.rmg_analyzer.RmgAnalyzer(input=None, outfile=None, *, analyze=False, path=None, strict=True, required=None)[source]#
Bases:
SimulationAnalyzerAnalyze an RMG simulation or log output file.
- Parameters:
- input
Simulation,RmgInput,str,os.PathLike,orNone, optional RMG simulation, parsed input, input-file path, or directory in which an input can be discovered.
- outfile
str,os.PathLike,orNone, optional Path to RMG log output. Relative paths are resolved below
path.- analyzebool, default=False
If
True, parse the RMG output during initialization.- path
str,os.PathLike,orNone, optional Base directory for relative paths and log-output discovery.
- strictbool, default=True
Require the configured log output to be a regular file when analysis begins. Top-level run types discovered from the referenced input and output log must also agree. If
False, a missing or non-file path completes analysis with empty results and run-type disagreement is retained as a tuple.- required
str, iterableofstr,orNone, optional Query quantities whose absence should raise
RuntimeErrorinstead of returningNone.
- input
- Attributes:
- path
strorNone Directory containing the RMG log output file.
- abspath
strorNone Absolute path to the output directory.
- outfile_name
strorNone Name of the RMG log output file.
- info
obj General analyzer metadata.
- input
RmgInputorNone RMG input reconstructed from the referenced control file when it is available.
- run_mode
str,tuple,orNone Short RMG calculation mode determined during analysis:
"scf","nscf","band","exx","relax","md_VE","md_TE","tddft","stm", or"neb". Disagreement between a referenced input and output log is represented by(input_mode, output_mode).- results
RmgOutData,obj,orNone Parsed setup and mode-specific RMG output data, an empty result object after permissive missing-file analysis, or
Nonebefore analysis.- required
setofstr Validated query quantities subject to required-data behavior.
- analysis_state{‘not_analyzed’, ‘analyzing’, ‘analyzed’}
Current analysis lifecycle state.
- source_status
obj Diagnostic referenced-input and output-log states.
- path
Methods
initial_structure(units=’A’)
(Structure or None) Input atomic structure in Angstrom (
'A') or bohr ('B').energy(units=’Ha’)
(float or None) Final eigenvalue-sum energy in
'eV','Ha', or'Ry'. Available for electronic, ionic, molecular-dynamics, TDDFT, and NEB calculations, but not band, EXX, or STM calculations.kpoints(units=’B’)
(numpy.ndarray or None) Cartesian k-points in inverse Angstrom or inverse bohr with shape
(nkpoints, 3). The unit argument is'A'or'B'. Electronic output data are preferred over setup data when both are available.kweights()
(numpy.ndarray or None) Dimensionless k-point weights with shape
(nkpoints,).eigenvalues(units=’eV’)
(numpy.ndarray or None) Kohn–Sham eigenvalues in
'eV','Ha', or'Ry'. The leading dimension has lengthnkpoints; remaining dimensions represent spin, when present, and bands. Band calculations are read from their spin-resolved companion files.occupations()
(numpy.ndarray or None) Dimensionless Kohn–Sham occupations. The leading dimension has length
nkpoints; remaining dimensions represent spin, when present, and bands.Ef(units=’eV’)
(float or None) Final Fermi energy in
'eV','Ha', or'Ry'.Evbm(units=’eV’)
(float or None) Final reported valence-band maximum in selected energy units.
Ecbm(units=’eV’)
(float or None) Final reported conduction-band minimum in selected energy units.
band_gap(units=’eV’)
(float or None) Final reported electronic band gap in selected energy units.
fractional_occs(tol=1e-3)
(bool or None) Whether any occupation is farther than
tolfrom both empty and full occupation.relaxed_structure(units=’A’)
(Structure or None) Final structure from the ionic history of a relaxation or local NEB image, in Angstrom (
'A') or bohr ('B').forces(units=’eV/A’)
(numpy.ndarray or None) Final ionic forces with shape
(natoms, 3). Available units are'eV/A','Ry/B', and'Ha/B'.stress(units=’GPa’)
(numpy.ndarray or None) Final stress tensor with shape
(3, 3). Available units are'Pa','bar','kbar','Mbar','GPa','atm','eV/A^3','Ha/Bohr^3', and'Ry/Bohr^3'.pressure(units=’GPa’)
(float or None) Final hydrostatic pressure in the units accepted by
stress.require(*quantities)
Add query quantities to the required-data policy without parsing.
available(*quantities)
(bool) Report whether every named quantity is currently queryable.
- Raises:
TypeErrorIf an input or path argument has an unsupported type.
FileNotFoundErrorDuring strict analysis, if the configured output path does not exist.
IsADirectoryErrorDuring strict analysis, if the configured output path is not a file.
ValueErrorIf a query receives unsupported units or a quantity name is invalid.
Notes
Initial structures and setup k-points are queryable for every supported mode. Eigenvalues additionally support band mode. Energy, occupations, band-edge quantities, forces, stress, and pressure apply to SCF, NSCF, relaxation, molecular-dynamics, TDDFT, and NEB modes. Relaxed structures apply to relaxation and NEB modes. Parsed data are returned even when unusual for the identified mode. Otherwise, a query returns
Nonewhen applicable data were not parsed unless the quantity is required. Calling a query before analysis or for a definitively unsupported mode raisesRuntimeError. Supplying unsupported units raisesValueError.- all_modes = frozenset({'band', 'exx', 'md_TE', 'md_VE', 'neb', 'nscf', 'relax', 'scf', 'stm', 'tddft'})#
- electronic_modes = frozenset({'md_TE', 'md_VE', 'neb', 'nscf', 'relax', 'scf', 'tddft'})#
- eigenvalue_modes = frozenset({'band', 'md_TE', 'md_VE', 'neb', 'nscf', 'relax', 'scf', 'tddft'})#
- relaxation_modes = frozenset({'neb', 'relax'})#
- quantity_names = frozenset({'Ecbm', 'Ef', 'Evbm', 'band_gap', 'eigenvalues', 'energy', 'forces', 'fractional_occs', 'initial_structure', 'kpoints', 'kweights', 'occupations', 'pressure', 'relaxed_structure', 'stress'})#
- pressure_units = mappingproxy({'Pa': 100000000.0, 'bar': 1000.0, 'kbar': 1.0, 'Mbar': 0.001, 'GPa': 0.1, 'atm': 986.9232667160128, 'eV/A^3': 0.0006241509752302815, 'Ha/Bohr^3': 3.398931451903016e-06, 'Ry/Bohr^3': 6.797862903806032e-06})#
- require(*quantities)[source]#
Add query quantities to the required-data policy.
- Parameters:
- *quantities
str Case-sensitive names from
quantity_names.
- *quantities
- Returns:
Notes
This method only updates
required. It does not parse files, reanalyze existing results, or check current availability.
- available(*quantities)[source]#
Return whether all named query quantities are available.
- Parameters:
- *quantities
str Case-sensitive names from
quantity_names.
- *quantities
- Returns:
- bool
Trueonly when every named query returns a value other thanNone. With no names, returnsTrue.
- Raises:
RuntimeErrorIf analysis has not completed.
ValueErrorIf any quantity name is invalid.
Notes
Required-data and run-mode-applicability errors are suppressed for this check. The method never parses or reanalyzes data.
- initial_structure(units='A')[source]#
Return the initial structure.
- Parameters:
- units{‘A’, ‘B’}, default=’A’
Requested length unit: Angstrom or bohr.
- Returns:
StructureorNoneStructure with axes
(3, 3)and positions(natoms, 3), orNone.
- kpoints(units='B')[source]#
Return Cartesian k-points.
- Parameters:
- units{‘A’, ‘B’}, default=’B’
Reciprocal length unit, inverse Angstrom or inverse bohr.
- Returns:
numpy.ndarrayorNoneFloat array of shape
(nkpoints, 3), orNone.
- kweights()[source]#
Return k-point integration weights.
- Returns:
numpy.ndarrayorNoneOne-dimensional float array with shape
(nkpoints,), orNone.
- eigenvalues(units='eV')[source]#
Return Kohn–Sham eigenvalues.
- Parameters:
- units{‘eV’, ‘Ha’, ‘Ry’}, default=’eV’
Requested energy unit.
- Returns:
numpy.ndarrayorNoneFloat array shaped
(nkpoints, nbands)or(nkpoints, 2, nbands)for collinear spin, orNone.
- occupations()[source]#
Return Kohn–Sham occupations.
- Returns:
numpy.ndarrayorNoneDimensionless float array with the shape returned by
eigenvalues, orNone.
- relaxed_structure(units='A')[source]#
Return the final ionic structure.
- Parameters:
- units{‘A’, ‘B’}, default=’A’
Requested length unit: Angstrom or bohr.
- Returns:
StructureorNoneFinal structure with axes
(3, 3)and positions(natoms, 3), orNone.
- forces(units='eV/A')[source]#
Return final ionic forces.
- Parameters:
- units{‘eV/A’, ‘Ry/B’, ‘Ha/B’}, default=’eV/A’
Requested energy-per-length unit.
- Returns:
numpy.ndarrayorNoneFloat array of shape
(natoms, 3), orNone.
- stress(units='GPa')[source]#
Return the final stress tensor.
- Parameters:
- units{‘Pa’, ‘bar’, ‘kbar’, ‘Mbar’, ‘GPa’, ‘atm’, ‘eV/A^3’, ‘Ha/Bohr^3’, ‘Ry/Bohr^3’}, default=’GPa’
Requested pressure or energy-density unit.
- Returns:
numpy.ndarrayorNoneFloat array of shape
(3, 3), orNone.