pymatgen.cli package — pymatgen 2025.6.14 documentation

# pymatgen.cli package

This package contains various command line interfaces for common pymatgen functionality such as file conversion, etc. Entry points to these interfaces are defined in [project.scripts] of pyproject.toml.

## Submodules

## pymatgen.cli.feff_plot_cross_section module

Script for plotting cross sections generated by FEFF found in xmu.dat files.

main()

  Main function.

## pymatgen.cli.feff_plot_dos module

Script to plot density of states (DOS) generated by an FEFF run either by site, element, or orbital.

main()

  Main function.

## pymatgen.cli.get_environment module

Command line script to get the chemical environment of a structure.

main() → int

  Main function for get_environment CLI.

## pymatgen.cli.pmg module

A master convenience script with many tools for vasp and structure analysis.

diff_incar(args: Namespace) → int

  Handle diff commands.

  Parameters:

    args – Args from command.

main(argv: list[str] | None = None) → Any

  Entry point for the pmg CLI.

parse_view(args: Namespace) → int

  Handle view commands.

  Parameters:

    args – Args from command.

## pymatgen.cli.pmg_analyze module

Implementation for pmg analyze CLI.

analyze(args: Namespace) → int

  Main function controlling which analysis to call.

  Parameters:

    args (Namespace) – args from argparse.

get_energies(rootdir: str, reanalyze: bool, verbose: bool, quick: bool, sort: bool, fmt: str) → int

  Get energies of all vaspruns in directory (nested).

  Parameters:

    - rootdir (str) – Root directory.

    - reanalyze (bool) – Whether to ignore saved results and reanalyze

    - verbose (bool) – Verbose mode or not.

    - quick (bool) – Whether to perform a quick analysis (using OSZICAR instead of vasprun.xml

    - sort (bool) – Whether to sort the results in ascending order.

    - fmt (str) – tablefmt passed to tabulate.

get_magnetizations(dirc: str, ion_list: list[int]) → int

  Get magnetization info from OUTCARs.

  Parameters:

    - dirc (str) – Directory name

    - ion_list (list[int]) – List of ions to obtain magnetization information for.

  Returns:

    0 if successful.

  Return type:

    int

## pymatgen.cli.pmg_config module

Implementation for pmg config CLI.

add_config_var(tokens: list[str], backup_suffix: str) → None

  Add/update keys in .pmgrc.yaml config file.

build_bader(fortran_command='gfortran') → bool

  Build bader package.

  Parameters:

    fortran_command – The Fortran compiler command.

build_enum(fortran_command: str = 'gfortran') → bool

  Build enum.

  Parameters:

    fortran_command – The Fortran compiler command.

configure_pmg(args: Namespace)

  Handle configure command.

install_software(install: Literal['enumlib', 'bader']) → None

  Install all optional external software.

setup_cp2k_data(cp2k_data_dirs: list[str]) → None

  Setup CP2K basis and potential data directory.

setup_potcars(potcar_dirs: list[str]) → None

  Setup POTCAR directories.

## pymatgen.cli.pmg_plot module

Implementation for pmg plot CLI.

get_chgint_plot(args: Namespace, ax: plt.Axes | None = None) → plt.Axes

  Plot integrated charge from CHGCAR file.

  Parameters:

    - args (Namespace) – args from argparse.

    - ax (plt.Axes) – Matplotlib Axes object for plotting.

  Returns:

    Matplotlib Axes object.

  Return type:

    plt.Axes

get_dos_plot(args: Namespace) → plt.Axes

  Plot DOS from vasprun.xml file.

  Parameters:

    args (Namespace) – Args from argparse.

get_xrd_plot(args: Namespace) → plt.Axes

  Plot XRD from structure.

  Parameters:

    args (Namespace) – Args from argparse

plot(args: Namespace) → None

  Master control function calling other plot functions based on args.

  Parameters:

    args (Namespace) – Args from argparse.

## pymatgen.cli.pmg_potcar module

Implementation for pmg potcar CLI.

gen_potcar(dirname: str, filename: str) → None

  Generate POTCAR from POTCAR.spec in directories.

  Parameters:

    - dirname (str) – Directory name.

    - filename (str) – Filename in directory.

generate_potcar(args: Namespace) → None

  Generate POTCAR.

  Parameters:

    args (Namespace) – Args from argparse.

proc_dir(dirname: str, proc_file_function: Callable) → None

  Process a directory.

  Parameters:

    - dirname (str) – Directory name.

    - proc_file_function (callable) – Callable to execute on directory.

## pymatgen.cli.pmg_structure module

Implementation for pmg structure CLI.

analyze_localenv(args: Namespace) → None

  Analyze local env of structures in files.

  Parameters:

    args (Namespace) – Args for argparse.

analyze_structures(args: Namespace) → None

  Main function to handle which operation to perform.

  Parameters:

    args (Namespace) – Args from argparse.

analyze_symmetry(args: Namespace) → None

  Analyze symmetry of structures in files.

  Parameters:

    args (Namespace) – Args from argparse.

compare_structures(args: Namespace) → None

  Compare structures in files for similarity using structure matcher.

  Parameters:

    args (Namespace) – Args from argparse.

convert_fmt(args: Namespace) → None

  Convert files from one format to another.

  Parameters:

    args (Namespace) – Args from argparse.