mag4.analysis.wien2k

Extract converged magnetic moments from WIEN2k .scf files.

Layer: WIEN2k-specific (backs the mag4-moments CLI).

Functions

build_table(cases, atom_indices[, ...])

Textual table of moments for each case + statistics + a target check.

extract_moments_from_scf(scf_path, atom_indices)

Parse a WIEN2k .scf file and return the converged :MMIxxx: values.

extract_total_moment(scf_path)

Return the last :MMTOT: total magnetic moment in cell.

find_cases([base_dir, scf_basename, code])

Auto-detect config subdirectories with results for code (sorted).

find_report([base_dir])

Locate a *_report.dat in base_dir (prefers four_state_report).

parse_report_target_moment(report_path)

Read the intended per-site |MAGMOM| = 2·S from a mag4 report.

mag4.analysis.wien2k.parse_report_target_moment(report_path)[source]

Read the intended per-site |MAGMOM| = 2·S from a mag4 report.

Returns the target moment (μ_B) or None if the report has no MAGMOM (S = …, |MAGMOM| = 2·S = …) header (older/other reports).

Return type:

Optional[float]

Parameters:

report_path (str)

mag4.analysis.wien2k.find_report(base_dir='.')[source]

Locate a *_report.dat in base_dir (prefers four_state_report).

Return type:

Optional[str]

Parameters:

base_dir (str)

mag4.analysis.wien2k.find_cases(base_dir='.', scf_basename=None, code='wien2k')[source]

Auto-detect config subdirectories with results for code (sorted).

code='wien2k' → directories with a .scf file (or exactly <scf_basename>.scf when given); code='vasp' → directories with an OUTCAR.

Return type:

List[str]

Parameters:
  • base_dir (str)

  • scf_basename (str | None)

  • code (str)

mag4.analysis.wien2k.extract_moments_from_scf(scf_path, atom_indices)[source]

Parse a WIEN2k .scf file and return the converged :MMIxxx: values.

Line format:

:MMI009: MAGNETIC MOMENT IN SPHERE  9 =  2.85000

The last occurrence of each tag (i.e. the converged value) is kept.

Returns:

{atom_index: float or None}.

Return type:

dict

Parameters:
mag4.analysis.wien2k.extract_total_moment(scf_path)[source]

Return the last :MMTOT: total magnetic moment in cell.

Return type:

Optional[float]

Parameters:

scf_path (str)

mag4.analysis.wien2k.build_table(cases, atom_indices, scf_basename=None, target=None, tol=0.5, code='wien2k')[source]

Textual table of moments for each case + statistics + a target check.

code selects the parser: 'wien2k' reads per-sphere :MMI: values from <dir>/<scf_basename>.scf; 'vasp' reads the per-ion tot column of the last magnetization (x) block in <dir>/OUTCAR (needs LORBIT=10/11). For VASP the indices are 1-based POSCAR ion numbers (mag4 writes the magnetic atoms first, so they are 1 n_mag).

Returns (lines, summary) where summary carries n_data (configs with a readable SCF), n_missing (SCF not found), failures (list of (case, reason) where a site did not reach the target moment within tol, or collapsed to ~0), and target.

target is the expected per-site |μ| (e.g. 2·S = the generated |MAGMOM|). When None the check only flags collapsed moments (|μ| < 0.1 μ_B), which usually mean the config fell into a non-magnetic solution rather than the intended spin state.

Return type:

Tuple[List[str], dict]

Parameters: