iprPy package

Module contents

class Library(host=None, username=None, password=None, certification=None, localpath=None, verbose=False, local=True, remote=True, load=False, status='active')

Bases: atomman.library.Database.Database

Class for interacting with potential records hosted from potentials.nist.gov

download_mp_crystals(elements, api_key=None, localpath=None, format='json', indent=4)

Accesses Materials Project and downloads crystal structures containing the given elements. The structures are saved to the iprPy library as reference_crystal records.

Parameters
  • elements (list) – A list of element symbols.

  • api_key (str, optional) – The user’s Materials Project API key. If not given, will use “MAPI_KEY” environment variable

download_oqmd_crystals(elements, localpath=None, format='json', indent=4)

Accesses OQMD and downloads crystal structures containing the given elements. The structures are saved to the iprPy library as reference_crystal records.

Parameters

elements (list) – A list of element symbols.

download_refs(style=None, status='active', format='json', indent=4, verbose=False)

Downloads reference records from potentials.nist.gov to the library. Note: this will overwrite any local copies of records with matching names. If you made changes to library files, be sure to save them with a different name.

Parameters
  • style (str or list, optional) – The reference style(s) to download. If not given, all reference style will be downloaded.

  • status (str, list or None, optional) – Only the potential_LAMMPS records with the given status(es) will be downloaded. Allowed values are ‘active’ (default), ‘superseded’, and ‘retracted’. If set to None, all hosted potential_LAMMPS will be downloaded.

  • format (str, optional) – Indicates the file format to save the refs as: ‘json’ or ‘xml’. Default is ‘json’.

  • indent (int or None, optional) – If a number, then the saved content will be indented making it easier to read but larger files. If None, the files will be compact. Default value is 4.

  • verbose (bool, optional) – If True, informative messages will be printed.

get_ref(style, name, verbose=False, asrecord=True)

Gets a reference file from the iprPy library or by downloading from potentials.nist.gov if a local copy is not found.

Parameters
  • style (str) – The reference record’s style.

  • name (str) – The name of the record.

  • verbose (bool, optional) – If True, informative print statements will be used.

  • asrecord (bool, optional) – If True (default) then the content will be returned as an iprPy Record if a subclass has been defined for the style.

Returns

  • iprPy.Record – The content as an iprPy Record object. Returned if asrecord is True and iprPy has a subclass for the record’s style.

  • DataModelDict.DataModelDict – The content as a DataModelDict. Returned if asrecord is False or iprPy does not have a subclass for the record’s style.

class Settings

Bases: potentials.Settings.Settings

Class for handling saved settings.

property databases

The pre-defined database settings organized by name

Type

dict

property list_databases

The names of the pre-defined database names

Type

list

property list_run_directories

The names of the pre-defined database names

Type

list

property run_directories

The pre-defined run_directory paths organized by name

Type

dict

property runner_log_directory

Path to the directory where runner logs are saved to.

Type

pathlib.Path

set_database(name=None, style=None, host=None, **kwargs)

Allows for database information to be defined in the settings file. Screen prompts will be given to allow any necessary database parameters to be entered.

Parameters
  • name (str, optional) – The name to assign to the database. If not given, the user will be prompted to enter one.

  • style (str, optional) – The database style associated with the database. If not given, the user will be prompted to enter one.

  • host (str, optional) – The database host (directory path or url) where the database is located. If not given, the user will be prompted to enter one.

  • **kwargs (any, optional) – Any other database style-specific parameter settings required to properly access the database.

set_run_directory(name=None, path=None)

Allows for run_directory information to be defined in the settings file.

Parameters
  • name (str, optional) – The name to assign to the run_directory. If not given, the user will be prompted to enter one.

  • path (str, optional) – The directory path for the run_directory. If not given, the user will be prompted to enter one.

set_runner_log_directory(path=None)

Sets the runner log directory to a different location.

Parameters

path (str or Path) – The path to the new runner log directory where log files generated by runners are saved to. If not given, will be asked for in a prompt.

unset_database(name=None)

Deletes the settings for a pre-defined database from the settings file.

Parameters

name (str) – The name assigned to a pre-defined database.

unset_run_directory(name=None)

Deletes the settings for a pre-defined run_directory from the settings file.

Parameters

name (str) – The name assigned to a pre-defined run_directory.

unset_runner_log_directory()

Resets the saved runner log directory information back to the default <Settings.directory>/runner-logs/ location.

check_modules()

Prints lists of the calculation, record, and database styles that were successfully and unsuccessfully loaded when iprPy was initialized.

command_line()
load_calculation(style)

Loads a Calculation subclass associated with a given calculation style

Parameters

style (str) – The calculation style

Returns

A Calculation object for the style

Return type

subclass of iprPy.calculation.Calculation

load_database(name=None, style=None, host=None, **kwargs)

Loads a database object. Can be either loaded from stored settings or by defining all needed access information.

Parameters
  • name (str, optional) – The name assigned to a pre-defined database. If given, can be the only parameter.

  • style (str, optional) – The database style to use.

  • host (str, optional) – The URL/file path where the database is hosted.

  • kwargs (dict, optional) – Any other keyword parameters defining necessary access information. Allowed keywords are database style-specific.

Returns

The database object.

Return type

Subclass of iprPy.Database

load_record(style, name=None, content=None)

Loads a Record subclass associated with a given record style

Parameters
  • style (str) – The record style

  • name (str) – The name to give to the specific record

  • content – The record’s data model content

Returns

A Record object for the style

Return type

subclass of iprPy.record.Record