pymatgen.io.jdftx package

Submodules

pymatgen.io.jdftx.generic_tags module

Module for class objects for containing JDFTx tags.

This module contains class objects for containing JDFTx tags. These class objects are used to validate the type of the value for the tag, read the value string for the tag, write the tag and its value as a string, and get the token length of the tag.

@mkhorton - This file is ready to review.

class AbstractTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False)[source]

Bases: ClassPrintFormatter, ABC

Abstract base class for all tags.

allow_list_representation: bool = False[source]
can_repeat: bool = False[source]
defer_until_struc: bool = False[source]
get_dict_representation(tag: str, value: Any) dict | list[dict][source]

Convert the value to a dict representation.

Parameters:
  • tag (str) – The tag to convert the value to a dict representation for.

  • value (Any) – The value to convert to a dict representation.

Returns:

The value converted to a dict representation.

Return type:

dict | list[dict]

get_list_representation(tag: str, value: Any) list | list[list][source]

Convert the value to a list representation.

Parameters:
  • tag (str) – The tag to convert the value to a list representation for.

  • value (Any) – The value to convert to a list representation.

Returns:

The value converted to a list representation.

Return type:

list | list[list]

abstract get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

is_tag_container: bool = False[source]
multiline_tag: bool = False[source]
optional: bool = True[source]
abstract read(tag: str, value_str: str) Any[source]

Read and parse the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value_str (str) – The value string to read.

Returns:

The parsed value.

Return type:

Any

abstract validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value.

  • False. (Defaults to)

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

abstract write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

write_tagname: bool = True[source]
write_value: bool = True[source]
class BoolTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False, _TF_read_options: dict[str, bool] = <factory>, _TF_write_options: dict[bool, str] = <factory>)[source]

Bases: AbstractTag

Tag for boolean values in JDFTx input files.

Tag for boolean values in JDFTx input files.

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

raise_value_error(tag: str, value: str) None[source]

Raise a ValueError for the value string.

Parameters:
  • tag (str) – The tag to raise the ValueError for.

  • value (str) – The value string to raise the ValueError for.

read(tag: str, value: str) bool[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The parsed boolean value.

Return type:

bool

validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value.

  • False. (Defaults to)

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

class BoolTagContainer(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = True, allow_list_representation: bool = False, linebreak_nth_entry: int | None = None, subtags: dict[str, ~pymatgen.io.jdftx.generic_tags.AbstractTag] = <factory>)[source]

Bases: TagContainer

BoolTagContainer class for handling the subtags to the “dump” tag.

This class is used to handle the subtags to the “dump” tag. All subtags are freqs for dump, and all values for these tags are boolean values that are read given the existence of their “var” name.

read(tag: str, value_str: str) dict[source]

Read the value string for this tag.

This method reads the value string for this tag. It is used to parse the value string for the tag and return the parsed value.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value_str (str) – The value string to read.

Returns:

The parsed value.

Return type:

dict

class ClassPrintFormatter[source]

Bases: object

Generic class for printing to command line in readable format.

Generic class for printing to command line in readable format.

class DumpTagContainer(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = True, allow_list_representation: bool = False, linebreak_nth_entry: int | None = None, subtags: dict[str, ~pymatgen.io.jdftx.generic_tags.AbstractTag] = <factory>)[source]

Bases: TagContainer

DumpTagContainer class for handling the “dump” tag.

This class is used to handle the “dump” tag.

read(tag: str, value_str: str) dict[source]

Read the value string for this tag.

This method reads the value string for this tag. It is used to parse the value string for the tag and return the parsed value.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value_str (str) – The value string to read.

Returns:

The parsed value.

Return type:

dict

class FloatTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False, prec: int | None = None)[source]

Bases: AbstractTag

Tag for float values in JDFTx input files.

Tag for float values in JDFTx input files.

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

prec: int | None = None[source]
read(tag: str, value: str) float[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The parsed float value.

Return type:

float

validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value, by default False.

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

class InitMagMomTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False)[source]

Bases: AbstractTag

Tag for initial-magnetic-moments tag in JDFTx input files.

Tag for initial-magnetic-moments tag in JDFTx input files.

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

read(tag: str, value: str) str[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The parsed string value.

Return type:

str

validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value, by default False.

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

class IntTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False)[source]

Bases: AbstractTag

Tag for integer values in JDFTx input files.

Tag for integer values in JDFTx input files.

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

read(tag: str, value: str) int[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The parsed integer value.

Return type:

int

validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value, by default False.

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

class MultiformatTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False, format_options: list[~pymatgen.io.jdftx.generic_tags.AbstractTag] = <factory>)[source]

Bases: AbstractTag

Class for tags with multiple format options.

Class for tags that could have different types of input values given to them or tags where different subtag options directly impact how many expected arguments are provided e.g. the coulomb-truncation or van-der-waals tags.

This class should not be used for tags with simply some combination of mandatory and optional args because the TagContainer class can handle those cases by itself.

format_options: list[AbstractTag][source]
get_format_index_for_str_value(tag: str, value: str) int[source]

Get the format index from string representation of value.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The index of the format option for the value of this tag.

Return type:

int

Raises:

ValueError – If no valid read format is found for the tag.

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

Raises:

NotImplementedError – If the method is called directly on MultiformatTag objects.

raise_invalid_format_option_error(tag: str, i: int) None[source]

Raise an error for an invalid format option.

Parameters:
  • tag (str) – The tag to raise the error for.

  • i (int) – The index of the format option to raise the error for.

Raises:

ValueError – If the format option is invalid.

read(tag: str, value: str) None[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Raises:

RuntimeError – If the method is called directly on MultiformatTag.

validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the value type for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value. Defaults to False.

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

Raises:

RuntimeError – If the method is called directly on MultiformatTag.

class StrTag(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = False, allow_list_representation: bool = False, options: list | None = None)[source]

Bases: AbstractTag

Tag for string values in JDFTx input files.

Tag for string values in JDFTx input files.

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

options: list | None = None[source]
read(tag: str, value: str) str[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The parsed string value.

Return type:

str

validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value. Defaults to False.

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

class TagContainer(multiline_tag: bool = False, can_repeat: bool = False, write_tagname: bool = True, write_value: bool = True, optional: bool = True, defer_until_struc: bool = False, is_tag_container: bool = True, allow_list_representation: bool = False, linebreak_nth_entry: int | None = None, subtags: dict[str, ~pymatgen.io.jdftx.generic_tags.AbstractTag] = <factory>)[source]

Bases: AbstractTag

TagContainer class for handling tags that contain other tags.

This class is used to handle tags that contain other tags. It is used to validate the type of the value for the tag, read the value string for the tag, write the tag and its value as a string, and get the token length of the tag.

Note: When constructing a TagContainer, all subtags must be able to return the correct token length without any information about the value. # TODO: Remove this assumption by changing the signature of get_token_len to take the value as an argument.

get_dict_representation(tag: str, value: list) dict | list[dict][source]

Convert the value to a dict representation.

Parameters:
  • tag (str) – The tag to convert the value to a dict representation for.

  • value (list) – The value to convert to a dict representation.

Returns:

The value converted to a dict representation.

Return type:

dict | list[dict]

get_list_representation(tag: str, value: Any) list[source]

Convert the value to a list representation.

Parameters:
  • tag (str) – The tag to convert the value to a list representation for.

  • value (Any) – The value to convert to a list representation.

Returns:

The value converted to a list representation.

Return type:

list

get_token_len() int[source]

Get the token length of the tag.

Returns:

The token length of the tag.

Return type:

int

is_tag_container: bool = True[source]
linebreak_nth_entry: int | None = None[source]
read(tag: str, value: str) dict[source]

Read the value string for this tag.

Parameters:
  • tag (str) – The tag to read the value string for.

  • value (str) – The value string to read.

Returns:

The parsed value.

Return type:

dict

subtags: dict[str, AbstractTag][source]
validate_value_type(tag: str, value: Any, try_auto_type_fix: bool = False) tuple[str, bool, Any][source]

Validate the type of the value for this tag.

Parameters:
  • tag (str) – The tag to validate the type of the value for.

  • value (Any) – The value to validate the type of.

  • try_auto_type_fix (bool, optional) – Whether to try to automatically fix the type of the value, by default False.

Returns:

The tag, whether the value is of the correct type, and the possibly fixed value.

Return type:

tuple[str, bool, Any]

write(tag: str, value: Any) str[source]

Write the tag and its value as a string.

Parameters:
  • tag (str) – The tag to write.

  • value (Any) – The value to write.

Returns:

The tag and its value as a string.

Return type:

str

pymatgen.io.jdftx.inputs module

Classes for reading/manipulating/writing JDFTx input files.

Classes for reading/manipulating/writing JDFTx input files.

Note: JDFTXInfile will be moved back to its own module once a more broad inputs class is written.

@mkhorton - This file is ready to review.

class JDFTXInfile(params: dict[str, Any] | None = None)[source]

Bases: dict, MSONable

Class for reading/writing JDFtx input files.

JDFTxInfile object for reading and writing JDFTx input files. Essentially a dictionary with some helper functions.

Create a JDFTXInfile object.

Parameters:

params (dict) – Input parameters as a dictionary.

append_tag(tag: str, value: Any) None[source]

Append a value to a tag.

Append a value to a tag. Use this method instead of directly appending the list contained in the tag, such that the value is properly processed.

Parameters:
  • tag (str) – Tag to append to.

  • value (Any) – Value to append.

as_dict(sort_tags: bool = True, skip_module_keys: bool = False) dict[source]

Return JDFTXInfile as MSONable dict.

Parameters:
  • sort_tags (bool, optional) – Whether to sort the tags. Defaults to True.

  • skip_module_keys (bool, optional) – Whether to skip the module keys. Defaults to False.

Returns:

JDFTXInfile as MSONable dict.

Return type:

dict

copy() JDFTXInfile[source]

Return a copy of the JDFTXInfile object.

Returns:

Copy of the JDFTXInfile object.

Return type:

JDFTXInfile

classmethod from_dict(d: dict[str, Any]) JDFTXInfile[source]

Create JDFTXInfile from a dictionary.

Parameters:

d (dict) – Dictionary to create JDFTXInfile from.

Returns:

The created JDFTXInfile object.

Return type:

JDFTXInfile

classmethod from_file(filename: PathLike, dont_require_structure: bool = False, sort_tags: bool = True, assign_path_parent: bool = True) Self[source]

Read a JDFTXInfile object from a file.

Parameters:
  • filename (PathLike) – Filename to read from.

  • dont_require_structure (bool, optional) – Whether to require structure tags. Defaults to False.

  • sort_tags (bool, optional) – Whether to sort the tags. Defaults to True.

  • assign_path_parent (bool, optional) – Whether to assign the parent directory of the input file for include tags. Defaults to True.

Returns:

The created JDFTXInfile object.

Return type:

JDFTXInfile

classmethod from_jdftxstructure(jdftxstructure: JDFTXStructure) JDFTXInfile[source]

Create a JDFTXInfile object from a JDFTXStructure object.

Parameters:

jdftxstructure (JDFTXStructure) – JDFTXStructure object to convert.

Returns:

The created JDFTXInfile object.

Return type:

JDFTXInfile

classmethod from_str(string: str, dont_require_structure: bool = False, sort_tags: bool = True, path_parent: Path | None = None) JDFTXInfile[source]

Read a JDFTXInfile object from a string.

Parameters:
  • string (str) – String to read from.

  • dont_require_structure (bool, optional) – Whether to require structure tags. Defaults to False.

  • sort_tags (bool, optional) – Whether to sort the tags. Defaults to True.

  • path_parent (Path, optional) – Path to the parent directory of the input file for include tags. Defaults to None.

Returns:

The created JDFTXInfile object.

Return type:

JDFTXInfile

classmethod from_structure(structure: Structure, selective_dynamics: ArrayLike | None = None, write_cart_coords: bool = False) JDFTXInfile[source]

Create a JDFTXInfile object from a pymatgen Structure.

Parameters:
  • structure (Structure) – Structure to convert.

  • selective_dynamics (ArrayLike, optional) – Selective dynamics attribute for each site if available. Shape Nx1, by default None.

Returns:

The created JDFTXInfile object.

Return type:

JDFTXInfile

classmethod get_dict_representation(jdftxinfile: JDFTXInfile) JDFTXInfile[source]

Convert JDFTXInfile object properties into dict representation.

Parameters:

jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.

classmethod get_list_representation(jdftxinfile: JDFTXInfile) JDFTXInfile[source]

Convert JDFTXInfile object properties into list representation.

Parameters:

jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.

get_text_list() list[str][source]

Get a list of strings representation of the JDFTXInfile.

Returns:

List of strings representation of the JDFTXInfile.

Return type:

list[str]

path_parent: str | None = None[source]
property structure: Structure[source]

Return a pymatgen Structure object.

Returns:

Pymatgen structure object.

Return type:

Structure

classmethod to_jdftxstructure(jdftxinfile: JDFTXInfile, sort_structure: bool = False) JDFTXStructure[source]

Convert JDFTXInfile to JDFTXStructure object.

Converts JDFTx lattice, lattice-scale, ion tags into JDFTXStructure, with Pymatgen structure as attribute.

Parameters:
  • jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.

  • sort_structure (bool, optional) – Whether to sort the structure. Useful if species are not grouped properly together. Defaults to False.

classmethod to_pmg_structure(jdftxinfile: JDFTXInfile, sort_structure: bool = False) Structure[source]

Convert JDFTXInfile to pymatgen Structure object.

Converts JDFTx lattice, lattice-scale, ion tags into pymatgen Structure.

Parameters:
  • jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.

  • sort_structure (bool, optional) – Whether to sort the structure. Useful if species are not grouped properly together. Defaults to False.

Returns:

The created pymatgen Structure object.

Return type:

Structure

validate_tags(try_auto_type_fix: bool = False, error_on_failed_fix: bool = True, return_list_rep: bool = False) None[source]

Validate the tags in the JDFTXInfile.

Validate the tags in the JDFTXInfile. If try_auto_type_fix is True, will attempt to fix the tags. If error_on_failed_fix is True, will raise an error if the tags cannot be fixed. If return_list_rep is True, will return the tags in list representation.

Parameters:
  • try_auto_type_fix (bool, optional) – Whether to attempt to fix the tags. Defaults to False.

  • error_on_failed_fix (bool, optional) – Whether to raise an error if the tags cannot be fixed. Defaults to True.

  • return_list_rep (bool, optional) – Whether to return the tags in list representation. Defaults to False.

write_file(filename: PathLike) None[source]

Write JDFTXInfile to an in file.

Parameters:

filename (PathLike) – Filename to write to.

class JDFTXStructure(structure: Structure = None, selective_dynamics: ArrayLike | None = None, sort_structure: bool = False, write_cart_coords: bool = False)[source]

Bases: MSONable

Object for representing the data in JDFTXStructure tags.

structure[source]

Associated Structure.

Type:

Structure

selective_dynamics[source]

Selective dynamics attribute for each site if available. Shape Nx1.

Type:

ArrayLike

sort_structure[source]

Whether to sort the structure. Useful if species are not grouped properly together. Defaults to False.

Type:

bool

as_dict() dict[source]

MSONable dict.

Returns:

MSONable dictionary representation of the JDFTXStructure.

Return type:

dict

classmethod from_dict(params: dict) Self[source]

Get JDFTXStructure from dict.

Parameters:

params (dict) – Serialized JDFTXStructure.

Returns:

The created JDFTXStructure object.

Return type:

JDFTXStructure

classmethod from_file(filename: str) JDFTXStructure[source]

Read JDFTXStructure from file.

Parameters:

filename (str) – Filename to read from.

Returns:

The created JDFTXStructure object.

Return type:

JDFTXStructure

classmethod from_jdftxinfile(jdftxinfile: JDFTXInfile, sort_structure: bool = False) JDFTXStructure[source]

Get JDFTXStructure from JDFTXInfile.

Parameters:
  • jdftxinfile (JDFTXInfile) – JDFTXInfile object.

  • sort_structure (bool, optional) – Whether to sort the structure. Useful if species are not grouped properly together as JDFTx output will have species sorted.

Returns:

The created JDFTXStructure object.

Return type:

JDFTXStructure

classmethod from_str(data: str) JDFTXStructure[source]

Read JDFTXStructure from string.

Parameters:

data (str) – String to read from.

Returns:

The created JDFTXStructure object.

Return type:

JDFTXStructure

get_str(in_cart_coords: bool | None = None) str[source]

Return a string to be written as JDFTXInfile tags.

Allows extra options as compared to calling str(JDFTXStructure) directly.

Parameters:

in_cart_coords (bool, optional) – Whether coordinates are output in direct or Cartesian.

Returns:

Representation of JDFTXInfile structure tags.

Return type:

str

property natoms: int[source]

Return number of atoms.

Returns:

Number of sites.

Return type:

int

selective_dynamics: ArrayLike | None = None[source]
sort_structure: bool = False[source]
structure: Structure = None[source]
write_cart_coords: bool = False[source]
write_file(filename: PathLike, **kwargs) None[source]

Write JDFTXStructure to a file.

The supported kwargs are the same as those for the JDFTXStructure.get_str method and are passed through directly.

Parameters:
  • filename (PathLike) – Filename to write to.

  • **kwargs – Kwargs to pass to JDFTXStructure.get_str.

pymatgen.io.jdftx.jdftxinfile_master_format module

Master list of AbstractTag-type objects for JDFTx input file generation.

This module contains; - MASTER_TAG_LIST: a dictionary mapping tag categories to dictionaries mapping

tag names to AbstractTag-type objects.

  • get_tag_object: a function that returns an AbstractTag-type object from

    MASTER_TAG_LIST given a tag name.

@mkhorton - this file is ready to review.

get_dump_tag_container() DumpTagContainer[source]

Initialize a dump tag container.

Returns:

The dump tag container.

Return type:

DumpTagContainer

get_tag_object(tag: str) AbstractTag[source]

Get the tag object for a given tag name.

Parameters:

tag (str) – The tag name.

Returns:

The tag object.

Return type:

AbstractTag

pymatgen.io.jdftx.jdftxinfile_ref_options module

Module for containing reference data for JDFTx tags.

This module contains reference data for JDFTx tags, such as valid options for functionals, pseudopotentials, etc.

@mkhorton - this file is ready to review.

pymatgen.io.jdftx.jdftxoutfileslice module

JDFTx Outfile Slice Class.

This module defines the JDFTxOutfileSlice class, which is used to read and process a JDFTx out file.

class JDFTXOutfileSlice(prefix: str | None = None, jstrucs: JOutStructures | None = None, jsettings_fluid: JMinSettings | None = None, jsettings_electronic: JMinSettings | None = None, jsettings_lattice: JMinSettings | None = None, jsettings_ionic: JMinSettings | None = None, constant_lattice: bool | None = None, xc_func: str | None = None, lattice_initial: np.ndarray | None = None, lattice_final: np.ndarray | None = None, lattice: np.ndarray | None = None, a: float | None = None, b: float | None = None, c: float | None = None, fftgrid: list[int] | None = None, geom_opt: bool | None = None, geom_opt_type: str | None = None, efermi: float | None = None, egap: float | None = None, emin: float | None = None, emax: float | None = None, homo: float | None = None, lumo: float | None = None, homo_filling: float | None = None, lumo_filling: float | None = None, is_metal: bool | None = None, etype: str | None = None, broadening_type: str | None = None, broadening: float | None = None, kgrid: list | None = None, truncation_type: str | None = None, truncation_radius: float | None = None, pwcut: float | None = None, rhocut: float | None = None, pp_type: str | None = None, semicore_electrons: int | None = None, valence_electrons: float | None = None, total_electrons_uncharged: int | None = None, semicore_electrons_uncharged: int | None = None, valence_electrons_uncharged: int | None = None, nbands: int | None = None, atom_elements: list | None = None, atom_elements_int: list | None = None, atom_types: list | None = None, spintype: str | None = None, nspin: int | None = None, nat: int | None = None, atom_coords_initial: list[list[float]] | None = None, atom_coords_final: list[list[float]] | None = None, atom_coords: list[list[float]] | None = None, has_solvation: bool = False, fluid: str | None = None, is_gc: bool | None = None, is_bgw: bool = False, has_eigstats: bool = False, has_parsable_pseudo: bool = False, _total_electrons_backup: int | None = None, total_electrons: float | None = None, _mu_backup: int | None = None, t_s: float | None = None, converged: bool | None = None, structure: Structure | None = None, trajectory: Trajectory | None = None, electronic_output: dict | None = None, eopt_type: str | None = None, elecmindata: JElSteps | None = None, stress: np.ndarray | None = None, strain: np.ndarray | None = None, forces: np.ndarray | None = None, nstep: int | None = None, e: float | None = None, grad_k: float | None = None, alpha: float | None = None, linmin: float | None = None, abs_magneticmoment: float | None = None, tot_magneticmoment: float | None = None, mu: float | None = None, elec_nstep: int | None = None, elec_e: float | None = None, elec_grad_k: float | None = None, elec_alpha: float | None = None, elec_linmin: float | None = None)[source]

Bases: object

A class to read and process a slice of a JDFTx out file.

A class to read and process a slice of a JDFTx out file, where a “slice” is a segment of an out file corresponding to a single call of JDFTx.

from_out_slice(text

list[str]): Read slice of out file into a JDFTXOutfileSlice instance.

prefix[source]

Prefix of dump files for JDFTx calculation.

Type:

str | None

jstrucs[source]

JOutStructures instance containing intermediate structures. Holds a “slices” attribute, which is a list of JOutStructure instances. (A JOutStructure instance functions as a Structure object, along with a JElSteps instance (stored as elecmindata) and other JDFTx-calculation-specific data.)

Type:

JOutStructures | None

jsettings_fluid[source]

JMinSettings instance containing fluid optimization settings.

Type:

JMinSettings | None

jsettings_electronic[source]

JMinSettings instance containing electronic optimization settings.

Type:

JMinSettings | None

jsettings_lattice[source]

JMinSettings instance containing lattice optimization settings.

Type:

JMinSettings | None

jsettings_ionic[source]

JMinSettings instance containing ionic optimization settings.

Type:

JMinSettings | None

xc_func[source]

Exchange-correlation functional used in the calculation.

Type:

str | None

lattice_initial[source]

Initial lattice matrix in Angstroms.

Type:

np.ndarray | None

lattice_final[source]

Final lattice matrix in Angstroms.

Type:

np.ndarray | None

lattice[source]

Current lattice matrix in Angstroms.

Type:

np.ndarray | None

a[source]

Lattice parameter a in Angstroms.

Type:

float | None

b[source]

Lattice parameter b in Angstroms.

Type:

float | None

c[source]

Lattice parameter c in Angstroms.

Type:

float | None

fftgrid[source]

Shape of FFT grid used in calculation (3 integers).

Type:

list[int] | None

geom_opt[source]

True if geometric (lattice or ionic) optimization was performed.

Type:

bool | None

geom_opt_type[source]

Type of geometric optimization performed (lattice or ionic, where lattice implies ionic as well unless geometry was given in direct coordinates).

Type:

str | None

efermi[source]

Fermi energy in eV (may be None if eigstats are not dumped).

Type:

float | None

egap[source]

Band gap in eV (None if eigstats are not dumped).

Type:

float | None

emin[source]

Minimum energy in eV (None if eigstats are not dumped).

Type:

float | None

emax[source]

Maximum energy in eV (None if eigstats are not dumped).

Type:

float | None

homo[source]

Energy of last band-state before Fermi level (acronym for Highest Occupied Molecular Orbital, even though these are not molecular orbitals and this state may not be entirely occupied) (None if eigstats are not dumped).

Type:

float | None

lumo[source]

Energy of first band-state after Fermi level (acronym for Lowest Unoccupied Molecular Orbital, even though these are not molecular orbitals, and this state may not be entirely unoccupied) (None if eigstats are not dumped).

Type:

float | None

homo_filling[source]

Filling of “homo” band-state as calculated within this class object from the homo energy, Fermi level, electronic broadening type and electronic broadening parameter. (None if eigstats are not dumped).

Type:

float | None

lumo_filling[source]

Filling of “lumo” band-state as calculated within this class object from the homo energy, Fermi level, electronic broadening type and electronic broadening parameter. (None if eigstats are not dumped).

Type:

float | None

is_metal[source]

True if fillings of homo and lumo band-states are off-set by 1 and 0 by at least an arbitrary tolerance of 0.01 (ie 1 - 0.015 and 0.012 for homo/lumo fillings would be metallic, while 1-0.001 and 0 would not be). (Only available if eigstats was dumped).

Type:

bool | None

etype[source]

String representation of total energy-type of system. Commonly “G” (grand-canonical potential) for GC calculations, and “F” for canonical (fixed electron count) calculations.

Type:

str | None

broadening_type[source]

Type of broadening for electronic filling about Fermi-level requested. Either “Fermi”, “Cold”, “MP1”, or “Gauss”.

Type:

str

broadening[source]

Magnitude of broadening for electronic filling.

Type:

float

kgrid[source]

Shape of k-point grid used in calculation. (equivalent to k-point folding).

Type:

list[int]

truncation_type[source]

Type of coulomb truncation used to prevent interaction between periodic images along certain directions. “periodic” means no coulomb truncation was used.

Type:

str

truncation_radius[source]

If spherical truncation_type, this is the radius of the coulomb truncation sphere.

Type:

float | None

pwcut[source]

The plane-wave cutoff energy in Hartrees used in the most recent JDFTx call.

Type:

float

rhocut[source]

The density cutoff energy in Hartrees used in the most recent JDFTx call.

Type:

float

pp_type[source]

The pseudopotential library used in the most recent JDFTx call. Currently only “GBRV” and “SG15” are supported by this output parser.

Type:

str

total_electrons[source]

The total number of electrons in the most recent JDFTx call (redundant to nelectrons).

Type:

float

semicore_electrons[source]

The number of semicore electrons in the most recent JDFTx call.

Type:

int

valence_electrons[source]

The number of valence electrons in the most recent JDFTx call.

Type:

float

total_electrons_uncharged[source]

The total number of electrons in the most recent JDFTx call, uncorrected for charge. (ie total_electrons + charge).

Type:

int

semicore_electrons_uncharged[source]

The number of semicore electrons in the most recent JDFTx call, uncorrected for charge. (ie semicore_electrons + charge).

Type:

int

valence_electrons_uncharged[source]

The number of valence electrons in the most recent JDFTx call, uncorrected for charge. (ie valence_electrons + charge).

Type:

int

nbands[source]

The number of bands used in the most recent JDFTx call.

Type:

int

atom_elements[source]

The list of each ion’s element symbol in the most recent JDFTx call.

Type:

list[str]

atom_elements_int[source]

The list of ion’s atomic numbers in the most recent JDFTx call.

Type:

list[int]

atom_types[source]

Non-repeating list of each ion’s element symbol in the most recent JDFTx call.

Type:

list[str]

spintype[source]

The spin type used in the most recent JDFTx call. Options are “none”, “collinear”.

Type:

str

nspin[source]

The number of spins used in the most recent JDFTx call.

Type:

int

nat[source]

The number of atoms in the most recent JDFTx call.

Type:

int

atom_coords_initial[source]

The initial atomic coordinates of the most recent JDFTx call.

Type:

list[list[float]]

atom_coords_final[source]

The final atomic coordinates of the most recent JDFTx call.

Type:

list[list[float]]

atom_coords[source]

The atomic coordinates of the most recent JDFTx call.

Type:

list[list[float]]

has_solvation[source]

True if the most recent JDFTx call included a solvation calculation.

Type:

bool

fluid[source]

The fluid used in the most recent JDFTx call.

Type:

str

is_gc[source]

True if the most recent slice is a grand canonical calculation.

Type:

bool

is_bgw[source]

True if data must be usable for a BerkeleyGW calculation (user-set).

Type:

bool

has_eigstats[source]

True if eigstats were dumped in the most recent JDFTx call.

Type:

bool

has_parsable_pseudo[source]

True if the most recent JDFTx call used a pseudopotential that can be parsed by this output parser. Options are currently “GBRV” and “SG15”.

Type:

bool

Properties:

t_s (float | None): The total time in seconds for the calculation. converged (bool | None): True if calculation converged. trajectory (Trajectory): pymatgen Trajectory object containing intermediate Structure’s of outfile slice

calculation.

electronic_output (dict): Dictionary with all relevant electronic information dumped from an eigstats log. structure (Structure): Calculation result as pymatgen Structure. eopt_type (str | None): eopt_type from most recent JOutStructure. elecmindata (JElSteps): elecmindata from most recent JOutStructure. stress (np.ndarray | None): Stress tensor from most recent JOutStructure in units eV/Ang^3. strain (np.ndarray | None): Strain tensor from most recent JOutStructure (unitless). nstep (int | None): (geometric) nstep from most recent JOutStructure. e (float | None): Energy of system “etype” from most recent JOutStructure. grad_k (float): The final norm of the preconditioned gradient for geometric optimization of the most recent

JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).

alpha (float): The step size of the final geometric step in the most recent JDFTx call. linmin (float): The final normalized projection of the geometric step direction onto the gradient for the most

recent JDFTx call.

abs_magneticmoment (float | None): The absolute magnetic moment of the most recent JDFTx call. tot_magneticmoment (float | None): The total magnetic moment of the most recent JDFTx call. mu (float): The Fermi energy of the most recent JDFTx call. elec_e (float): The final energy of the most recent electronic optimization step. elec_nstep (int): The number of electronic optimization steps in the most recent JDFTx call. elec_grad_k (float): The final norm of the preconditioned gradient for electronic optimization of the most

recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).

elec_alpha (float): The step size of the final electronic step in the most recent JDFTx call. elec_linmin (float): The final normalized projection of the electronic step direction onto the gradient for the

most recent JDFTx call.

Magic Methods:
__getattr__(name: str) -> Any: Overwrite of default __getattr__ method to allow for reference of un-defined

attributes to the “jstrucs” class field. This referring behavior is ideally never used as (currently) all referrable attributes are defined properties, but is included to prevent errors in the case of future changes.

__str__() -> str: Return a string representation of the class instance using pprint module. __repr__() -> str: Create string representation of the class instance. Overwritten from default behavior for

dataclass so that properties are included in the string, and verbose attributes with redundant information are trimmed.

a: float | None = None[source]
abs_magneticmoment: float | None = None[source]
alpha: float | None = None[source]
atom_coords: list[list[float]] | None = None[source]
atom_coords_final: list[list[float]] | None = None[source]
atom_coords_initial: list[list[float]] | None = None[source]
atom_elements: list | None = None[source]
atom_elements_int: list | None = None[source]
atom_types: list | None = None[source]
b: float | None = None[source]
broadening: float | None = None[source]
broadening_type: str | None = None[source]
c: float | None = None[source]
constant_lattice: bool | None = None[source]
converged: bool | None = None[source]
determine_is_metal() bool | None[source]

Determine if the system is a metal based on the fillings of homo and lumo.

Returns:

True if system is metallic.

Return type:

bool

e: float | None = None[source]
efermi: float | None = None[source]
egap: float | None = None[source]
elec_alpha: float | None = None[source]
elec_e: float | None = None[source]
elec_grad_k: float | None = None[source]
elec_linmin: float | None = None[source]
elec_nstep: int | None = None[source]
elecmindata: JElSteps | None = None[source]
electronic_output: dict | None = None[source]
emax: float | None = None[source]
emin: float | None = None[source]
eopt_type: str | None = None[source]
etype: str | None = None[source]
fftgrid: list[int] | None = None[source]
fluid: str | None = None[source]
forces: np.ndarray | None = None[source]
geom_opt: bool | None = None[source]
geom_opt_type: str | None = None[source]
grad_k: float | None = None[source]
has_eigstats: bool = False[source]
has_parsable_pseudo: bool = False[source]
has_solvation: bool = False[source]
homo: float | None = None[source]
homo_filling: float | None = None[source]
is_bgw: bool = False[source]
is_gc: bool | None = None[source]
is_metal: bool | None = None[source]
jsettings_electronic: JMinSettings | None = None[source]
jsettings_fluid: JMinSettings | None = None[source]
jsettings_ionic: JMinSettings | None = None[source]
jsettings_lattice: JMinSettings | None = None[source]
jstrucs: JOutStructures | None = None[source]
kgrid: list | None = None[source]
lattice: np.ndarray | None = None[source]
lattice_final: np.ndarray | None = None[source]
lattice_initial: np.ndarray | None = None[source]
linmin: float | None = None[source]
lumo: float | None = None[source]
lumo_filling: float | None = None[source]
mu: float | None = None[source]
nat: int | None = None[source]
nbands: int | None = None[source]
nspin: int | None = None[source]
nstep: int | None = None[source]
parsable_pseudos: ClassVar[list[str]] = ['GBRV', 'SG15'][source]
pp_type: str | None = None[source]
prefix: str | None = None[source]
pwcut: float | None = None[source]
rhocut: float | None = None[source]
semicore_electrons: int | None = None[source]
semicore_electrons_uncharged: int | None = None[source]
spintype: str | None = None[source]
strain: np.ndarray | None = None[source]
stress: np.ndarray | None = None[source]
structure: Structure | None = None[source]
t_s: float | None = None[source]
to_dict() dict[source]

Convert dataclass to dictionary representation.

Returns:

JDFTXOutfileSlice in dictionary format.

Return type:

dict

tot_magneticmoment: float | None = None[source]
total_electrons: float | None = None[source]
total_electrons_uncharged: int | None = None[source]
trajectory: Trajectory | None = None[source]
truncation_radius: float | None = None[source]
truncation_type: str | None = None[source]
valence_electrons: float | None = None[source]
valence_electrons_uncharged: int | None = None[source]
write() None[source]

Return an error.

Raises:

NotImplementedError – There is no need to write a JDFTx out file.

xc_func: str | None = None[source]
get_pseudo_read_section_bounds(text: list[str]) list[list[int]][source]

Get the boundary line numbers for the pseudopotential read section.

Parameters:

text (list[str]) – Output of read_file for out file.

Returns:

List of line numbers for the pseudopotential read sections.

Return type:

list[list[int]]

pymatgen.io.jdftx.jelstep module

Module for parsing single SCF step from JDFTx.

This module contains the JElStep class for parsing single SCF step from a JDFTx out file.

class JElStep(opt_type: str | None = None, etype: str | None = None, nstep: int | None = None, e: float | None = None, grad_k: float | None = None, alpha: float | None = None, linmin: float | None = None, t_s: float | None = None, mu: float | None = None, nelectrons: float | None = None, abs_magneticmoment: float | None = None, tot_magneticmoment: float | None = None, subspacerotationadjust: float | None = None, converged: bool = False, converged_reason: str | None = None)[source]

Bases: object

Electronic minimization data for a single SCF step.

Class object for storing logged electronic minimization data for a single SCF step.

opt_type[source]

The type of electronic minimization step (almost always ElecMinimize).

Type:

str | None

etype[source]

The type of energy component (G, F, or Etot).

Type:

str | None

nstep[source]

The SCF step number.

Type:

int | None

e[source]

The total electronic energy in eV.

Type:

float | None

grad_k[source]

The gradient of the Kohn-Sham energy (along the line minimization direction).

Type:

float | None

alpha[source]

The step length.

Type:

float | None

linmin[source]

Normalized line minimization direction / energy gradient projection (-1 for perfectly opposite, 1 for perfectly aligned).

Type:

float | None

t_s[source]

Time elapsed from beginning of JDFTx calculation.

Type:

float | None

mu[source]

The chemical potential in eV.

Type:

float | None

nelectrons[source]

The number of electrons.

Type:

float | None

abs_magneticmoment[source]

The absolute magnetic moment.

Type:

float | None

tot_magneticmoment[source]

The total magnetic moment.

Type:

float | None

subspacerotationadjust[source]

The subspace rotation adjustment factor.

Type:

float | None

abs_magneticmoment: float | None = None[source]
alpha: float | None = None[source]
converged: bool = False[source]
converged_reason: str | None = None[source]
e: float | None = None[source]
etype: str | None = None[source]
grad_k: float | None = None[source]
linmin: float | None = None[source]
mu: float | None = None[source]
nelectrons: float | None = None[source]
nstep: int | None = None[source]
opt_type: str | None = None[source]
subspacerotationadjust: float | None = None[source]
t_s: float | None = None[source]
to_dict() dict[source]

Return dictionary representation of JElStep object.

Returns:

Dictionary representation of JElStep object.

Return type:

dict

tot_magneticmoment: float | None = None[source]
class JElSteps(opt_type: str | None = None, etype: str | None = None, iter_flag: str | None = None, converged: bool | None = None, converged_reason: str | None = None, slices: list[~pymatgen.io.jdftx.jelstep.JElStep] = <factory>)[source]

Bases: object

Class object for series of SCF steps.

Class object for collecting and storing a series of SCF steps done between geometric optimization steps.

opt_type[source]

The type of electronic minimization step.

Type:

str | None

etype[source]

The type of energy component.

Type:

str | None

iter_flag[source]

The flag that indicates the start of a log message for a JDFTx optimization step.

Type:

str | None

converged[source]

True if the SCF steps converged.

Type:

bool

converged_reason[source]

The reason for convergence.

Type:

str | None

slices[source]

A list of JElStep objects.

Type:

list[JElStep]

e[source]

The total electronic energy in eV.

Type:

float | None

grad_k[source]

The gradient of the Kohn-Sham energy (along the line minimization direction).

Type:

float | None

alpha[source]

The step length.

Type:

float | None

linmin[source]

Normalized line minimization direction / energy gradient projection (-1 for perfectly opposite, 1 for perfectly aligned).

Type:

float | None

t_s[source]

Time elapsed from beginning of JDFTx calculation.

Type:

float | None

mu[source]

The chemical potential in eV.

Type:

float | None

nelectrons[source]

The number of electrons.

Type:

float | None

abs_magneticmoment[source]

The absolute magnetic moment.

Type:

float | None

tot_magneticmoment[source]

The total magnetic moment.

Type:

float | None

subspacerotationadjust[source]

The subspace rotation adjustment factor.

Type:

float | None

nstep[source]

The SCF step number.

Type:

int | None

abs_magneticmoment: float | None = None[source]
alpha: float | None = None[source]
converged: bool | None = None[source]
converged_reason: str | None = None[source]
e: float | None = None[source]
etype: str | None = None[source]
grad_k: float | None = None[source]
iter_flag: str | None = None[source]
linmin: float | None = None[source]
mu: float | None = None[source]
nelectrons: float | None = None[source]
nstep: int | None = None[source]
opt_type: str | None = None[source]
slices: list[JElStep][source]
subspacerotationadjust: float | None = None[source]
t_s: float | None = None[source]
to_dict() dict[str, Any][source]

Return dictionary representation of JElSteps object.

Returns:

Dictionary representation of JElSteps object.

Return type:

dict

tot_magneticmoment: float | None = None[source]

pymatgen.io.jdftx.jminsettings module

Store generic minimization settings read from a JDFTx out file.

This module contains the JMinSettings class for storing generic minimization and mutants for storing specific minimization settings read from a JDFTx out file.

@mkhorton - this file is ready to review.

class JMinSettings(params: dict[str, Any] | None = None)[source]

Bases: object

Store generic minimization settings read from a JDFTx out file.

Store generic minimization settings read from a JDFTx out file.

Initialize a generic JMinSettings class.

Parameters:

params (dict[str, Any] | None) – A dictionary of minimization settings.

params: dict[str, Any] | None = None[source]
class JMinSettingsElectronic(params: dict[str, Any] | None = None)[source]

Bases: JMinSettings

JMInSettings mutant for electronic minimization settings.

A class for storing electronic minimization settings read from a JDFTx out file.

Initialize a generic JMinSettings class.

Parameters:

params (dict[str, Any] | None) – A dictionary of minimization settings.

start_flag: str = 'electronic-minimize'[source]
class JMinSettingsFluid(params: dict[str, Any] | None = None)[source]

Bases: JMinSettings

JMInSettings mutant for fluid minimization settings.

A class for storing fluid minimization settings read from a JDFTx out file.

Initialize a generic JMinSettings class.

Parameters:

params (dict[str, Any] | None) – A dictionary of minimization settings.

start_flag: str = 'fluid-minimize'[source]
class JMinSettingsIonic(params: dict[str, Any] | None = None)[source]

Bases: JMinSettings

JMInSettings mutant for ionic minimization settings.

A class for storing ionic minimization settings read from a JDFTx out file.

Initialize a generic JMinSettings class.

Parameters:

params (dict[str, Any] | None) – A dictionary of minimization settings.

start_flag: str = 'ionic-minimize'[source]
class JMinSettingsLattice(params: dict[str, Any] | None = None)[source]

Bases: JMinSettings

JMInSettings mutant for lattice minimization settings.

A class for storing lattice minimization settings read from a JDFTx out file.

Initialize a generic JMinSettings class.

Parameters:

params (dict[str, Any] | None) – A dictionary of minimization settings.

start_flag: str = 'lattice-minimize'[source]

pymatgen.io.jdftx.joutstructure module

Class object for storing a single JDFTx geometric optimization step.

A mutant of the pymatgen Structure class for flexibility in holding JDFTx.

class JOutStructure(lattice: ndarray, species: list[str], coords: list[ndarray], site_properties: dict[str, list], **kwargs)[source]

Bases: Structure

Class object for storing a single JDFTx optimization step.

A mutant of the pymatgen Structure class for flexibility in holding JDFTx optimization data.

Properties:

charges (np.ndarray | None): The Lowdin charges of the atoms in the system. magnetic_moments (np.ndarray | None): The magnetic moments of the atoms in the system.

opt_type[source]

The type of optimization step.

Type:

str | None

etype[source]

The type of energy from the electronic minimization data.

Type:

str | None

eopt_type[source]

The type of electronic minimization step.

Type:

str | None

emin_flag[source]

The flag that indicates the start of a log message for a JDFTx optimization step.

Type:

str | None

ecomponents[source]

The energy components of the system.

Type:

dict | None

elecmindata[source]

The electronic minimization data.

Type:

JElSteps | None

stress[source]

The stress tensor.

Type:

np.ndarray | None

strain[source]

The strain tensor.

Type:

np.ndarray | None

nstep[source]

The most recent step number.

Type:

int | None

e[source]

The total energy of the system.

Type:

float | None

grad_k[source]

The gradient of the electronic density along the most recent line minimization.

Type:

float | None

alpha[source]

The step size of the most recent SCF step along the line minimization.

Type:

float | None

linmin[source]

The normalized alignment projection of the electronic energy gradient to the line minimization direction.

Type:

float | None

t_s[source]

The time in seconds for the optimization step.

Type:

float | None

geom_converged[source]

Whether the geometry optimization has converged.

Type:

bool

geom_converged_reason[source]

The reason for geometry optimization convergence.

Type:

str | None

line_types[source]

The types of lines in a JDFTx out file.

Type:

ClassVar[list[str]]

selective_dynamics[source]

The selective dynamics flags for the atoms in the system.

Type:

list[int] | None

mu[source]

The chemical potential (Fermi level) in eV.

Type:

float | None

nelectrons[source]

The total number of electrons in the electron density.

Type:

float | None

abs_magneticmoment[source]

The absolute magnetic moment of the electron density.

Type:

float | None

tot_magneticmoment[source]

The total magnetic moment of the electron density.

Type:

float | None

elec_nstep[source]

The most recent electronic step number.

Type:

int | None

elec_e[source]

The most recent electronic energy.

Type:

float | None

elec_grad_k[source]

The most recent electronic grad_k.

Type:

float | None

elec_alpha[source]

The most recent electronic alpha.

Type:

float | None

elec_linmin[source]

The most recent electronic linmin.

Type:

float | None

structure[source]

The Structure object of the system. (helpful for uses where the JOutStructure metadata causes issues)

Type:

Structure | None

Create a periodic structure.

Parameters:
  • lattice – The lattice, either as a pymatgen.core.Lattice or simply as any 2D array. Each row should correspond to a lattice vector. e.g. [[10,0,0], [20,10,0], [0,0,30]] specifies a lattice with lattice vectors [10,0,0], [20,10,0] and [0,0,30].

  • species

    List of species on each site. Can take in flexible input, including:

    1. A sequence of element / species specified either as string symbols, e.g. [“Li”, “Fe2+”, “P”, …] or atomic numbers, e.g. (3, 56, …) or actual Element or Species objects.

    2. List of dict of elements/species and occupancies, e.g. [{“Fe” : 0.5, “Mn”:0.5}, …]. This allows the setup of disordered structures.

  • coords (Nx3 array) – list of fractional/cartesian coordinates of each species.

  • charge (float) – overall charge of the structure. Defaults to behavior in SiteCollection where total charge is the sum of the oxidation states.

  • validate_proximity (bool) – Whether to check if there are sites that are less than 0.01 Ang apart. Defaults to False.

  • to_unit_cell (bool) – Whether to map all sites into the unit cell, i.e., fractional coords between 0 and 1. Defaults to False.

  • coords_are_cartesian (bool) – Set to True if you are providing coordinates in Cartesian coordinates. Defaults to False.

  • site_properties (dict) – Properties associated with the sites as a dict of sequences, e.g. {“magmom”:[5,5,5,5]}. The sequences have to be the same length as the atomic species and fractional_coords. Defaults to None for no properties.

  • labels (list[str]) – Labels associated with the sites as a list of strings, e.g. [‘Li1’, ‘Li2’]. Must have the same length as the species and fractional coords. Defaults to None for no labels.

  • properties (dict) – Properties associated with the whole structure. Will be serialized when writing the structure to JSON or YAML but is lost when converting to other formats.

abs_magneticmoment: float | None = None[source]
alpha: float | None = None[source]
property charges: ndarray | None[source]

Return the Lowdin charges.

Returns:

The Lowdin charges of the atoms in the system.

Return type:

np.ndarray

e: float | None = None[source]
ecomponents: dict | None = None[source]
elec_alpha: float | None = None[source]
elec_e: float | None = None[source]
elec_grad_k: float | None = None[source]
elec_linmin: float | None = None[source]
elec_nstep: int | None = None[source]
elecmindata: JElSteps | None = None[source]
emin_flag: str | None = None[source]
eopt_type: str | None = None[source]
etype: str | None = None[source]
forces: np.ndarray | None = None[source]
geom_converged: bool = False[source]
geom_converged_reason: str | None = None[source]
grad_k: float | None = None[source]
line_types: ClassVar[list[str]] = ['emin', 'lattice', 'strain', 'stress', 'posns', 'forces', 'ecomp', 'lowdin', 'opt'][source]
linmin: float | None = None[source]
property magnetic_moments: ndarray | None[source]

Return the magnetic moments.

Returns:

The magnetic moments of the atoms in the system.

Return type:

np.ndarray

mu: float | None = None[source]
nelectrons: float | None = None[source]
nstep: int | None = None[source]
opt_type: str | None = None[source]
selective_dynamics: list[int] | None = None[source]
strain: np.ndarray | None = None[source]
stress: np.ndarray | None = None[source]
structure: Structure | None = None[source]
t_s: float | None = None[source]
to_dict() dict[source]

Convert the JOutStructure object to a dictionary.

Returns:

A dictionary representation of the JOutStructure object.

Return type:

dict

tot_magneticmoment: float | None = None[source]

pymatgen.io.jdftx.joutstructures module

Module for JOutStructures class.

This module contains the JOutStructures class for storing a series of JOutStructure.

class JOutStructures(opt_type: str | None = None, geom_converged: bool = False, geom_converged_reason: str | None = None, elec_converged: bool = False, elec_converged_reason: str | None = None, _t_s: float | None = None, slices: list[JOutStructure] = <factory>, eopt_type: str | None = None, etype: str | None = None, emin_flag: str | None = None, ecomponents: list[str] | None = None, elecmindata: JElSteps = None, stress: np.ndarray | None = None, strain: np.ndarray | None = None, forces: np.ndarray | None = None, nstep: int | None = None, e: float | None = None, grad_k: float | None = None, alpha: float | None = None, linmin: float | None = None, nelectrons: float | None = None, abs_magneticmoment: float | None = None, tot_magneticmoment: float | None = None, mu: float | None = None, elec_nstep: int | None = None, elec_e: float | None = None, elec_grad_k: float | None = None, elec_alpha: float | None = None, elec_linmin: float | None = None, charges: np.ndarray[float] | None = None, magnetic_moments: np.ndarray[float] | None = None, selective_dynamics: list[int] | None = None, structure: Structure | None = None)[source]

Bases: object

Class for storing a series of JStructure objects.

A class for storing a series of JStructure objects.

out_slice_start_flag[source]

The string that marks the beginning of the portion of an out file slice that contains data for a JOutStructures object.

Type:

str

opt_type[source]

The type of optimization performed on the structures in the JOutStructures object.

Type:

str | None

geom_converged[source]

Whether the geometry of the last structure in the list has converged.

Type:

bool

geom_converged_reason[source]

The reason the geometry of the last structure in the list has converged.

Type:

str | None

elec_converged[source]

Whether the electronic density of the last structure in the list has converged.

Type:

bool

elec_converged_reason[source]

The reason the electronic density of the last structure in the list has converged.

Type:

str | None

slices[source]

A list of JOutStructure objects.

Type:

list[JOutStructure]

eopt_type[source]

The type of electronic optimization performed on the last structure in the list.

Type:

str | None

etype[source]

String representation of total energy-type of system. Commonly “G”

Type:

str | None

(grand-canonical potential) for GC calculations, and "F" for canonical
Type:

fixed electron count

emin_flag[source]

The flag for the electronic minimization.

Type:

str | None

ecomponents[source]

The components of the electronic minimization.

Type:

list[str] | None

elecmindata[source]

The electronic minimization data.

Type:

JElSteps

stress[source]

The stress tensor.

Type:

np.ndarray | None

strain[source]

The strain tensor.

Type:

np.ndarray | None

nstep[source]

The number of steps in the optimization.

Type:

int | None

e[source]

The total energy.

Type:

float | None

grad_k[source]

The final norm of the preconditioned gradient for geometric optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).

Type:

float | None

alpha[source]

The step size of the final geometric step in the most recent JDFTx call.

Type:

float | None

linmin[source]

The final normalized projection of the geometric step direction onto the gradient for the most recent JDFTx call.

Type:

float | None

abs_magneticmoment[source]

The absolute magnetic moment of the most recent JDFTx call.

Type:

float | None

tot_magneticmoment[source]

The total magnetic moment of the most recent JDFTx call.

Type:

float | None

mu[source]

The Fermi energy of the most recent JDFTx call.

Type:

float | None

elec_e[source]

The final energy of the most recent electronic optimization step.

Type:

float

elec_nstep[source]

The number of electronic optimization steps in the most recent JDFTx call.

Type:

int

elec_grad_k[source]

The final norm of the preconditioned gradient for electronic optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).

Type:

float | None

elec_alpha[source]

The step size of the final electronic step in the most recent JDFTx call.

Type:

float

elec_linmin[source]

The final normalized projection of the electronic step direction onto the gradient for the most recent JDFTx call.

Type:

float | None

charges[source]

The most recent Lowdin-charges.

Type:

np.ndarray[float] | None

magnetic_moments[source]

The most recent Lowdin-magnetic moments.

Type:

np.ndarray[float] | None

selective_dynamics[source]

The selective dynamics flags for the most recent JDFTx call.

Type:

list[int] | None

structure[source]

Cleaned pymatgen Structure object of final JOutStructure

Type:

Structure | None

abs_magneticmoment: float | None = None[source]
alpha: float | None = None[source]
charges: np.ndarray[float] | None = None[source]
e: float | None = None[source]
ecomponents: list[str] | None = None[source]
elec_alpha: float | None = None[source]
elec_converged: bool = False[source]
elec_converged_reason: str | None = None[source]
elec_e: float | None = None[source]
elec_grad_k: float | None = None[source]
elec_linmin: float | None = None[source]
elec_nstep: int | None = None[source]
elecmindata: JElSteps = None[source]
emin_flag: str | None = None[source]
eopt_type: str | None = None[source]
etype: str | None = None[source]
forces: np.ndarray | None = None[source]
geom_converged: bool = False[source]
geom_converged_reason: str | None = None[source]
grad_k: float | None = None[source]
linmin: float | None = None[source]
magnetic_moments: np.ndarray[float] | None = None[source]
mu: float | None = None[source]
nelectrons: float | None = None[source]
nstep: int | None = None[source]
opt_type: str | None = None[source]
out_slice_start_flag = '-------- Electronic minimization -----------'[source]
selective_dynamics: list[int] | None = None[source]
slices: list[JOutStructure][source]
strain: np.ndarray | None = None[source]
stress: np.ndarray | None = None[source]
structure: Structure | None = None[source]
to_dict() dict[source]

Convert the JOutStructures object to a dictionary.

Returns:

A dictionary representation of the JOutStructures object.

Return type:

dict

tot_magneticmoment: float | None = None[source]

pymatgen.io.jdftx.outputs module

JDFTx outputs parsing module.

Module for parsing outputs of JDFTx.

Note: JDFTXOutfile will be moved back to its own module once a more broad outputs class is written.

class JDFTXOutfile(slices: list[~pymatgen.io.jdftx.jdftxoutfileslice.JDFTXOutfileSlice] = <factory>)[source]

Bases: object

JDFTx out file parsing class.

A class to read and process a JDFTx out file.

from_file(file_path

str | Path) -> JDFTXOutfile: Return JDFTXOutfile object from the path to a JDFTx out file.

slices[source]

A list of JDFTXOutfileSlice objects. Each slice corresponds to an individual call of the JDFTx executable. Subsequent JDFTx calls within the same directory and prefix will append outputs to the same out file. More than one slice may correspond to restarted calculations, geom + single point calculations, or optimizations done with 3rd-party wrappers like ASE.

Type:

list[JDFTXOutfileSlice]

prefix[source]

The prefix of the most recent JDFTx call.

Type:

str

jstrucs[source]

The JOutStructures object from the most recent JDFTx call. This object contains a series of JOutStructure objects in its ‘slices’ attribute, each corresponding to a single structure (multiple iff performing a geometric optimization) as well as convergence data for the structures as a series.

Type:

JOutStructures

jsettings_fluid[source]

The JMinSettingsFluid object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the fluid optimization.

Type:

JMinSettingsFluid

jsettings_electronic[source]

The JMinSettingsElectronic object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the electronic optimization.

Type:

JMinSettingsElectronic

jsettings_lattice[source]

The JMinSettingsLattice object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the lattice optimization.

Type:

JMinSettingsLattice

jsettings_ionic[source]

The JMinSettingsIonic object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the ionic optimization.

Type:

JMinSettingsIonic

xc_func[source]

The exchange-correlation functional used in the most recent JDFTx call. See documentation for JDFTx online for a list of available exchange-correlation functionals.

Type:

str

lattice_initial[source]

The initial lattice vectors of the most recent JDFTx call as a 3x3 numpy array. In units of Angstroms.

Type:

np.ndarray

lattice_final[source]

The final lattice vectors of the most recent JDFTx call as a 3x3 numpy array. In units of Angstroms.

Type:

np.ndarray

lattice[source]

The lattice vectors of the most recent JDFTx call as a 3x3 numpy array (redundant to lattice_final).

Type:

np.ndarray

a[source]

Length of the first lattice vector. In units of Angstroms.

Type:

float

b[source]

Length of the second lattice vector. In units of Angstroms.

Type:

float

c[source]

Length of the third lattice vector. In units of Angstroms.

Type:

float

fftgrid[source]

The FFT grid shape used in the most recent JDFTx call. Can be used to properly shape densities dumped as binary files.

Type:

list[int]

geom_opt[source]

True if the most recent JDFTx call was a geometry optimization (lattice or ionic).

Type:

bool

geom_opt_type[source]

The type of geometry optimization performed in the most recent JDFTx call. Options are ‘lattice’ or ‘ionic’ if geom_opt, else “single point”. (‘lattice’ optimizations perform ionic optimizations as well unless ion positions are given in direct coordinates).

Type:

str

ecomponents[source]

The components of the total energy in eV of the most recent JDFTx call.

Type:

dict

efermi[source]

The Fermi energy in eV of the most recent JDFTx call. Equivalent to “mu”.

Type:

float

egap[source]

The band gap in eV of the most recent JDFTx call. (Only available if eigstats was dumped).

Type:

float

emin[source]

The minimum energy in eV (smallest Kohn-Sham eigenvalue) of the most recent JDFTx call. (Only available if eigstats was dumped).

Type:

float

emax[source]

The maximum energy in eV (largest Kohn-Sham eigenvalue) of the most recent JDFTx call. (Only available if eigstats was dumped).

Type:

float

homo[source]

The energy in eV of the band-gap lower bound (Highest Occupied Molecular Orbital) (Only available if eigstats was dumped).

Type:

float

lumo[source]

The energy in eV of the band-gap upper bound (Lowest Unoccupied Molecular Orbital) (Only available if eigstats was dumped).

Type:

float

homo_filling[source]

The electron filling at the homo band-state. (Only available if eigstats was dumped).

Type:

float

lumo_filling[source]

The electron filling at the lumo band-state. (Only available if eigstats was dumped).

Type:

float

is_metal[source]

True if fillings of homo and lumo band-states are off-set by 1 and 0 by at least an arbitrary tolerance of 0.01 (ie 1 - 0.015 and 0.012 for homo/lumo fillings would be metallic, while 1-0.001 and 0 would not be). (Only available if eigstats was dumped).

Type:

bool

converged[source]

True if most recent SCF cycle converged (and geom forces converged is calc is geom_opt)

Type:

bool

etype[source]

String representation of total energy-type of system. Commonly “G” (grand-canonical potential) for GC calculations, and “F” for canonical (fixed electron count) calculations.

Type:

str

broadening_type[source]

Type of broadening for electronic filling about Fermi-level requested. Either “Fermi”, “Cold”, “MP1”, or “Gauss”.

Type:

str

broadening[source]

Magnitude of broadening for electronic filling.

Type:

float

kgrid[source]

Shape of k-point grid used in calculation. (equivalent to k-point folding)

Type:

list[int]

truncation_type[source]

Type of coulomb truncation used to prevent interaction between periodic images along certain directions. “periodic” means no coulomb truncation was used.

Type:

str

truncation_radius[source]

If spherical truncation_type, this is the radius of the coulomb truncation sphere.

Type:

float | None

pwcut[source]

The plane-wave cutoff energy in Hartrees used in the most recent JDFTx call.

Type:

float

rhocut[source]

The density cutoff energy in Hartrees used in the most recent JDFTx call.

Type:

float

pp_type[source]

The pseudopotential library used in the most recent JDFTx call. Currently only “GBRV” and “SG15” are supported by this output parser.

Type:

str

total_electrons[source]

The total number of electrons in the most recent JDFTx call (redundant to nelectrons).

Type:

float

semicore_electrons[source]

The number of semicore electrons in the most recent JDFTx call.

Type:

int

valence_electrons[source]

The number of valence electrons in the most recent JDFTx call.

Type:

float

total_electrons_uncharged[source]

The total number of electrons in the most recent JDFTx call, uncorrected for charge. (ie total_electrons + charge)

Type:

int

semicore_electrons_uncharged[source]

The number of semicore electrons in the most recent JDFTx call, uncorrected for charge. (ie semicore_electrons + charge)

Type:

int

valence_electrons_uncharged[source]

The number of valence electrons in the most recent JDFTx call, uncorrected for charge. (ie valence_electrons + charge)

Type:

int

nbands[source]

The number of bands used in the most recent JDFTx call.

Type:

int

atom_elements[source]

The list of each ion’s element symbol in the most recent JDFTx call.

Type:

list[str]

atom_elements_int[source]

The list of ion’s atomic numbers in the most recent JDFTx call.

Type:

list[int]

atom_types[source]

Non-repeating list of each ion’s element symbol in the most recent JDFTx call.

Type:

list[str]

spintype[source]

The spin type used in the most recent JDFTx call. Options are “none”, “collinear”,

Type:

str

nspin[source]

The number of spins used in the most recent JDFTx call.

Type:

int

nat[source]

The number of atoms in the most recent JDFTx call.

Type:

int

atom_coords_initial[source]

The initial atomic coordinates of the most recent JDFTx call.

Type:

list[list[float]]

atom_coords_final[source]

The final atomic coordinates of the most recent JDFTx call.

Type:

list[list[float]]

atom_coords[source]

The atomic coordinates of the most recent JDFTx call.

Type:

list[list[float]]

structure[source]

The updated pymatgen Structure object of the most recent JDFTx call.

Type:

Structure

trajectory[source]

The Trajectory object of the most recent JDFTx call.

Type:

Trajectory

has_solvation[source]

True if the most recent JDFTx call included a solvation calculation.

Type:

bool

fluid[source]

The fluid used in the most recent JDFTx call.

Type:

str

is_gc[source]

True if the most recent slice is a grand canonical calculation.

Type:

bool

eopt_type[source]

The type of energy iteration used in the most recent JDFTx call.

Type:

str

elecmindata[source]

The JElSteps object from the most recent JDFTx call. This object contains a series of JElStep objects in its ‘steps’ attribute, each corresponding to a single energy iteration.

Type:

JElSteps

stress[source]

The stress tensor of the most recent JDFTx call as a 3x3 numpy array. In units of eV/Angstrom^3.

Type:

np.ndarray

strain[source]

The strain tensor of the most recent JDFTx call as a 3x3 numpy array.

Type:

np.ndarray

nstep[source]

The number of geometric optimization steps in the most recent JDFTx call.

Type:

int

e[source]

The final energy in eV of the most recent JDFTx call (equivalent to the call’s etype).

Type:

float

grad_k[source]

The final norm of the preconditioned gradient for geometric optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).

Type:

float

alpha[source]

The step size of the final geometric step in the most recent JDFTx call.

Type:

float

linmin[source]

The final normalized projection of the geometric step direction onto the gradient for the most recent JDFTx call.

Type:

float

abs_magneticmoment[source]

The absolute magnetic moment of the most recent JDFTx call.

Type:

float | None

tot_magneticmoment[source]

The total magnetic moment of the most recent JDFTx call.

Type:

float | None

mu[source]

The Fermi energy in eV of the most recent JDFTx call.

Type:

float

elec_e[source]

The final energy in eV of the most recent electronic optimization step.

Type:

float

elec_nstep[source]

The number of electronic optimization steps in the most recent JDFTx call.

Type:

int

elec_grad_k[source]

The final norm of the preconditioned gradient for electronic optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).

Type:

float

elec_alpha[source]

The step size of the final electronic step in the most recent JDFTx call.

Type:

float

elec_linmin[source]

The final normalized projection of the electronic step direction onto the gradient for the most recent JDFTx call.

Type:

float

Magic Methods:
__getitem__(key: str | int) -> Any: Decides behavior of how JDFTXOutfile objects are indexed. If the key is a

string, it will return the value of the property with the same name. If the key is an integer, it will return the slice of the JDFTXOutfile object at that index.

__len__() -> int: Returns the number of slices in the JDFTXOutfile object. __getattr__(name: str) -> Any: Returns the value of the property with the same name as the input string. __str__() -> str: Returns a string representation of the JDFTXOutfile object.

a: float[source]
abs_magneticmoment: float[source]
alpha: float[source]
atom_coords: list[list[float]][source]
atom_coords_final: list[list[float]][source]
atom_coords_initial: list[list[float]][source]
atom_elements: list[str][source]
atom_elements_int: list[int][source]
atom_types: list[str][source]
b: float[source]
broadening: float[source]
broadening_type: str[source]
c: float[source]
converged: bool[source]
e: float[source]
efermi: float[source]
egap: float[source]
elec_alpha: float[source]
elec_e: float[source]
elec_grad_k: float[source]
elec_linmin: float[source]
elec_nstep: int[source]
elecmindata: JElSteps[source]
electronic_output: float[source]
emax: float[source]
emin: float[source]
eopt_type: str[source]
etype: str[source]
fftgrid: list[int][source]
fluid: str[source]
forces: np.ndarray[source]
classmethod from_calc_dir(calc_dir: str | Path, is_bgw: bool = False, none_slice_on_error: bool = False) JDFTXOutfile[source]

Create a JDFTXOutfile object from a directory containing JDFTx out files.

Parameters:
  • calc_dir (str | Path) – The path to the directory containing the JDFTx out files.

  • is_bgw (bool) – Mark True if data must be usable for BGW calculations. This will change the behavior of the parser to be stricter with certain criteria.

  • none_slice_on_error (bool) – If True, will return None if an error occurs while parsing a slice instead of halting the parsing process. This can be useful for parsing files with multiple slices where some slices may be incomplete or corrupted.

Returns:

The JDFTXOutfile object.

Return type:

JDFTXOutfile

classmethod from_file(file_path: str | Path, is_bgw: bool = False, none_slice_on_error: bool | None = None) JDFTXOutfile[source]

Create a JDFTXOutfile object from a JDFTx out file.

Parameters:
  • file_path (str | Path) – The path to the JDFTx out file.

  • is_bgw (bool) – Mark True if data must be usable for BGW calculations. This will change the behavior of the parser to be stricter with certain criteria.

  • none_slice_on_error (bool | None) – If True, will return None if an error occurs while parsing a slice instead of halting the parsing process. This can be useful for parsing files with multiple slices where some slices may be incomplete or corrupted. If False, all slices may raise errors. If None, only the final slice can raise an error upon parsing (default behavior)

Returns:

The JDFTXOutfile object.

Return type:

JDFTXOutfile

geom_opt: bool[source]
geom_opt_type: str[source]
grad_k: float[source]
has_solvation: bool[source]
homo: float[source]
homo_filling: float[source]
is_gc: bool[source]
is_metal: bool[source]
jsettings_electronic: JMinSettingsElectronic[source]
jsettings_fluid: JMinSettingsFluid[source]
jsettings_ionic: JMinSettingsIonic[source]
jsettings_lattice: JMinSettingsLattice[source]
jstrucs: JOutStructures[source]
kgrid: list[int][source]
lattice: np.ndarray[source]
lattice_final: np.ndarray[source]
lattice_initial: np.ndarray[source]
linmin: float[source]
lumo: float[source]
lumo_filling: float[source]
mu: float[source]
nat: int[source]
nbands: int[source]
nspin: int[source]
nstep: int[source]
pp_type: str[source]
prefix: str[source]
pwcut: float[source]
rhocut: float[source]
semicore_electrons: int[source]
semicore_electrons_uncharged: int[source]
slices: list[JDFTXOutfileSlice][source]
spintype: str[source]
strain: np.ndarray[source]
stress: np.ndarray[source]
structure: Structure[source]
to_dict() dict[source]

Convert the JDFTXOutfile object to a dictionary.

Returns:

A dictionary representation of the JDFTXOutfile object.

Return type:

dict

tot_magneticmoment: float[source]
total_electrons: float[source]
total_electrons_uncharged: int[source]
trajectory: Trajectory[source]
truncation_radius: float[source]
truncation_type: str[source]
valence_electrons: float[source]
valence_electrons_uncharged: int[source]
xc_func: str[source]
class JDFTXOutputs(calc_dir: str | ~pathlib.Path, outfile_name: str | ~pathlib.Path | None, store_vars: list[str] = <factory>)[source]

Bases: object

JDFTx outputs parsing class.

A class to read and process JDFTx outputs.

from_calc_dir(calc_dir

str | Path, store_vars: list[str] = None) -> JDFTXOutputs: Return JDFTXOutputs object from the path to a directory containing JDFTx out files.

calc_dir[source]

The path to the directory containing the JDFTx output files.

Type:

str | Path

store_vars[source]

A list of the names of dump files to read and store.

Type:

list[str]

paths[source]

A dictionary of the paths to the dump files.

Type:

dict[str, Path]

outfile[source]

The JDFTXOutfile object for the out file.

Type:

JDFTXOutfile

bandProjections[source]

The band projections. Stored in shape (nstates, nbands, nproj) where nstates is nspin*nkpts (nkpts may not equal prod(kfolding) if symmetry reduction occurred), nbands is the number of bands, and nproj is the number of projections. This shape is chosen instead of the pymatgen convention of (nspin, nkpt, nbands, nion, nionproj) to save on memory as nonionproj is different depending on the ion type. This array may also be complex if specified in ‘band-projections-params’ in the JDFTx input, allowing for pCOHP analysis.

Type:

np.ndarray

eigenvals[source]

The eigenvalues. Stored in shape (nstates, nbands) where nstates is nspin*nkpts (nkpts may not equal prod(kfolding) if symmetry reduction occurred) and nbands is the number of bands.

Type:

np.ndarray

orb_label_list[source]

A tuple of the orbital labels for the bandProjections file, where the i’th element describes the i’th orbital. Orbital labels are formatted as “<ion>#<ion-number>(<orbital>)”, where <ion> is the element symbol of the ion, <ion-number> is the 1-based index of the ion-type in the structure (ie C#2 would be the second carbon atom, but not necessarily the second ion in the structure), and <orbital> is a string describing “l” and “ml” quantum numbers (ie “p_x” or “d_yz”). Note that while “z” corresponds to the “z” axis, “x” and “y” are arbitrary and may not correspond to the actual x and y axes of the structure. In the case where multiple shells of a given “l” are available within the projections, a 0-based index will appear mimicking a principle quantum number (ie “0px” for first shell and “1px” for second shell). The actual principal quantum number is not stored in the JDFTx output files and must be inferred by the user.

Type:

tuple[str, …]

bandProjections: ndarray | None[source]
calc_dir: str | Path[source]
eigenvals: ndarray | None[source]
classmethod from_calc_dir(calc_dir: str | Path, store_vars: list[str] | None = None, outfile_name: str | Path | None = None) JDFTXOutputs[source]

Create a JDFTXOutputs object from a directory containing JDFTx out files.

Parameters:
  • calc_dir (str | Path) – The path to the directory containing the JDFTx out files.

  • is_bgw (bool) – Mark True if data must be usable for BGW calculations. This will change the behavior of the parser to be stricter with certain criteria.

  • none_slice_on_error (bool) – If True, will return None if an error occurs while parsing a slice instead of halting the parsing process. This can be useful for parsing files with multiple slices where some slices may be incomplete or corrupted.

  • outfile_name (str | Path) – The name of the outfile to use. If None, will search for the outfile in the calc_dir. If provided, will concatenate with calc_dir as the outfile path. Use this if the calc_dir contains multiple files that may be mistaken for the outfile (ie multiple files with the ‘.out’ suffix).

Returns:

The JDFTXOutputs object.

Return type:

JDFTXOutputs

orb_label_list: tuple[str, ...] | None[source]
outfile: JDFTXOutfile[source]
outfile_name: str | Path | None[source]
paths: dict[str, Path][source]
store_vars: list[str][source]