pyiron_atomistics.calphy.job.Calphy

Contents

pyiron_atomistics.calphy.job.Calphy#

class pyiron_atomistics.calphy.job.Calphy(project, job_name)[source]#

Bases: GenericJob, HasStructure

Class to set up and run calphy jobs for calculation of free energies using LAMMPS.

An input structure (structure) and interatomic potential (potential) are necessary input options. The additional input options such as the temperature and pressure are specified in the calc_free_energy() method. Depending on the input parameters, a corresponding calculation mode is selected. Further input options can be accessed through input.md and input.tolerance.

An example which calculates the free energy of Cu using an interatomic potential:

`python job.structure = pr.create.structure.ase.bulk('Cu', cubic=True).repeat(5) job.potential = "2001--Mishin-Y--Cu-1--LAMMPS--ipr1" job.calc_free_energy(temperature=1100, pressure=0, reference_phase="solid") job.run() `

In order to calculate the free energy of the liquid phase, the reference_phase should be set to liquid.

The different modes can be selected as follows:

For free energy at a given temperature and pressure:

`python job.calc_free_energy(temperature=1100, pressure=0, reference_phase="solid") `

Alternatively, calc_mode_fe() can be used.

To obtain the free energy between a given temperature range (temperature scaling):

`python job.calc_free_energy(temperature=[1100, 1400], pressure=0, reference_phase="solid") `

Alternatively, calc_mode_ts() can be used.

For free energy between a given pressure range (pressure scaling)

`python job.calc_free_energy(temperature=1000, pressure=[0, 100000], reference_phase="solid") `

Alternatively, calc_mode_pscale() can be used.

To obtain the free energy difference between two interatomic potentials (alchemy/upsampling)

`python job.potential = ["2001--Mishin-Y--Cu-1--LAMMPS--ipr1", "1986--Foiles-S-M--Cu--LAMMPS--ipr1"] job.calc_free_energy(temperature=1100, pressure=0, reference_phase="solid") job.run() `

Alternatively, calc_mode_alchemy() can be used.

The way pressure is specified determines how the barostat affects the system. For isotropic pressure control:

`python job.calc_free_energy(temperature=[1100, 1400], pressure=0, reference_phase="solid") `

For anisotropic pressure control:

`python job.calc_free_energy(temperature=[1100, 1400], pressure=[0, 0, 0], reference_phase="solid") `

To constrain the lattice:

`python job.calc_free_energy(temperature=[1100, 1400], pressure=None, reference_phase="solid") `

In addition the boolean option input.npt can be used to determine the MD ensemble. If True, temperature integration and alchemy/upsampling are carried out in the NPT ensemble. If False, the NVT ensemble is employed.

After the calculation is over, the various output options can be accessed through job.output.

Specialised output depending on the selected mode is also available. For example the energy difference between the system of interest and the reference system for mode fe (free energy calculation), is available under job.output.fe. Similarly other output corresponding to modes such as temperature scaling and pressure scaling can be found under job.output.ts and job.output.ps.

__init__(project, job_name)[source]#

Methods

__init__(project, job_name)

animate_structures([spacefill, show_cell, ...])

Animate a series of atomic structures.

calc_free_energy([temperature, pressure, ...])

Calculate free energy at given conditions

calc_mode_alchemy([temperature, pressure, ...])

Perform upsampling/alchemy between two interatomic potentials

calc_mode_fe([temperature, pressure, ...])

Calculate free energy at given conditions

calc_mode_pscale([temperature, pressure, ...])

Calculate free energy between two given pressures

calc_mode_ts([temperature, pressure, ...])

Calculate free energy between given temperatures

check_if_job_exists([job_name, project])

Check if a job already exists in an specific project.

check_setup()

Checks whether certain parameters (such as plane wave cutoff radius in DFT) are changed from the pyiron standard values to allow for a physically meaningful results.

clear_job()

Convenience function to clear job info after suspend.

collect_general_output()

Collect the output from calphy

collect_logfiles()

Collect the log files of the external executable and store the information in the HDF5 file.

collect_output()

Collect the output files of the external executable and store the information in the HDF5 file.

collect_structures([filter_function])

Collects a copy of all structures in a compact StructureStorage.

compress([files_to_compress, files_to_remove])

Compress the output files of a job object.

convergence_check()

Validate the convergence of the calculation.

copy()

Copy the GenericJob object which links to the job and its HDF5 file

copy_file_to_working_directory(file)

Copy a specific file to the working directory before the job is executed.

copy_template([project, new_job_name])

Copy the content of the job including the HDF5 file but without the output data to a new location

copy_to([project, new_job_name, input_only, ...])

Copy the content of the job including the HDF5 file to a new location.

create_job(job_type, job_name[, ...])

Create one of the following jobs: - 'StructureContainer’: - ‘StructurePipeline’: - ‘AtomisticExampleJob’: example job just generating random number - ‘ExampleJob’: example job just generating random number - ‘Lammps’: - ‘KMC’: - ‘Sphinx’: - ‘Vasp’: - ‘GenericMaster’: - ‘ParallelMaster’: series of jobs run in parallel - ‘KmcMaster’: - ‘ThermoLambdaMaster’: - ‘RandomSeedMaster’: - ‘MeamFit’: - ‘Murnaghan’: - ‘MinimizeMurnaghan’: - ‘ElasticMatrix’: - ‘ConvergenceEncutParallel’: - ‘ConvergenceKpointParallel’: - ’PhonopyMaster’: - ‘DefectFormationEnergy’: - ‘LammpsASE’: - ‘PipelineMaster’: - ’TransformationPath’: - ‘ThermoIntEamQh’: - ‘ThermoIntDftEam’: - ‘ScriptJob’: Python script or jupyter notebook job container - ‘ListMaster': list of jobs

db_entry()

Generate the initial database entry :returns: db_dict :rtype: (dict)

decompress()

Decompress the output files of a compressed job object.

drop_status_to_aborted()

Change the job status to aborted when the job was intercepted.

from_dict(obj_dict[, version])

Populate the object from the serialized object.

from_hdf([hdf, group_name])

Restore the GenericJob from an HDF5 file

from_hdf_args(hdf)

Read arguments for instance creation from HDF5 file

get(name[, default])

Internal wrapper function for __getitem__() - self[name]

get_calculate_function()

Generate calculate() function

get_from_table(path, name)

Get a specific value from a pandas.Dataframe

get_input_parameter_dict()

Get an hierarchical dictionary of input files.

get_job_id([job_specifier])

get the job_id for job named job_name in the local project path from database

get_output_parameter_dict()

get_potentials()

Return the interatomic potentials

get_structure([frame, wrap_atoms, ...])

Retrieve structure from object.

inspect(job_specifier)

Inspect an existing pyiron object - most commonly a job - from the database

instantiate(obj_dict[, version])

Create a blank instance of this class.

interactive_close()

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable.

interactive_fetch()

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable.

interactive_flush([path, include_last_step])

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable.

is_compressed()

Check if the job is already compressed or not.

is_master_id(job_id)

Check if the job ID job_id is the master ID for any child job

is_self_archived()

Check if the HDF5 file of the Job is compressed as tar-archive

iter_structures([wrap_atoms])

Iterate over all structures in this object.

job_file_name(file_name[, cwd])

combine the file name file_name with the path of the current working directory

kill()

Kill the job.

list_all()

Returns dictionary of :method:`.list_groups()` and :method:`.list_nodes()`.

list_childs()

List child jobs as JobPath objects - not loading the full GenericJob objects for each child

list_files()

List files inside the working directory

list_groups()

Return a list of names of all nested groups.

list_nodes()

Return a list of names of all nested nodes.

list_potentials()

List of interatomic potentials suitable for the current atomic structure.

load(job_specifier[, convert_to_object])

Load an existing pyiron object - most commonly a job - from the database

move_to(project)

Move the content of the job including the HDF5 file to a new location

refresh_job_status()

Refresh job status by updating the job status with the status from the database if a job ID is available.

relocate_hdf5([h5_path])

Relocate the hdf file.

remove([_protect_childs])

Remove the job - this removes the HDF5 file, all data stored in the HDF5 file an the corresponding database entry.

remove_and_reset_id([_protect_childs])

Remove the job and reset its ID.

remove_child()

internal function to remove command that removes also child jobs.

rename(new_job_name)

Rename the job - by changing the job name

reset_job_id([job_id])

Reset the job id sets the job_id to None in the GenericJob as well as all connected modules like JobStatus.

restart([job_name, job_type])

Create an restart calculation from the current calculation - in the GenericJob this is the same as create_job().

run([delete_existing_job, repair, debug, ...])

This is the main run function, depending on the job status ['initialized', 'created', 'submitted', 'running', 'collect','finished', 'refresh', 'suspended'] the corresponding run mode is chosen.

run_if_interactive()

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable.

run_if_interactive_non_modal()

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable.

run_if_modal()

The run if modal function is called by run to execute the simulation, while waiting for the output.

run_if_refresh()

Internal helper function the run if refresh function is called when the job status is 'refresh'.

run_if_scheduler()

The run if queue function is called by run if the user decides to submit the job to and queing system.

run_static()

The run static function is called by run to execute the simulation.

run_time_to_db()

Internal helper function to store the run_time in the database

save()

Save the object, by writing the content to the HDF5 file and storing an entry in the database.

save_output([output_dict, shell_output])

Store output of the calculate function in the HDF5 file.

self_archive()

Compress HDF5 file of the job object to tar-archive

self_unarchive()

Decompress HDF5 file of the job object from tar-archive

set_input_to_read_only()

This function enforces read-only mode for the input classes, but it has to be implemented in the individual classes.

set_potentials(potential_filenames)

Set the interatomic potential from a given name

show_hdf()

Iterating over the HDF5 datastructure and generating a human readable graph.

signal_intercept(sig)

Abort the job and log signal that caused it.

suspend()

Suspend the job by storing the object and its state persistently in HDF5 file and exit it.

to_dict()

Reduce the object to a dictionary.

to_hdf([hdf, group_name])

Store the GenericJob in an HDF5 file

to_object([object_type])

Load the full pyiron object from an HDF5 file

transfer_from_remote()

Transfer the job from a remote location to the local machine.

transform_structures(modify)

Return a modified object by applying a function to each object lazily.

update_master([force_update])

After a job is finished it checks whether it is linked to any metajob - meaning the master ID is pointing to this jobs job ID.

validate_ready_to_run()

Validate that the calculation is ready to be executed.

view_potentials()

View a list of available interatomic potentials

write_input()

Write input for calphy calculation

write_structure(structure, file_name, ...)

Write structure to file

Attributes

calculate_kwargs

Generate keyword arguments for the calculate() function.

child_ids

list of child job ids - only meta jobs have child jobs - jobs which list the meta job as their master

content

database_entry

exclude_groups_hdf

Get the list of groups which are excluded from storing in the hdf5 file

exclude_nodes_hdf

Get the list of nodes which are excluded from storing in the hdf5 file

executable

Get the executable used to run the job - usually the path to an external executable.

executor_type

files

Allows to browse the files in a job directory.

files_to_compress

files_to_remove

id

Unique id to identify the job in the pyiron database - use self.job_id instead

job_id

Unique id to identify the job in the pyiron database

job_info_str

Short string to describe the job by it is job_name and job ID - mainly used for logging

job_name

Get name of the job, which has to be unique within the project

job_type

['ExampleJob', 'ParallelMaster', 'ScriptJob',

logger

Get the logger object to monitor the external execution and internal pyiron warnings.

master_id

Get job id of the master job - a meta job which groups a series of jobs, which are executed either in parallel or in serial.

name

Get name of the job, which has to be unique within the project

number_of_structures

maximum iteration_step + 1 that can be passed to get_structure().

output

parent_id

Get job id of the predecessor job - the job which was executed before the current one in the current job series

path

Absolute path of the HDF5 group starting from the system root - combination of the absolute system path plus the absolute path inside the HDF5 file starting from the root group.

potential

project

Project instance the jobs is located in

project_hdf5

Get the ProjectHDFio instance which points to the HDF5 file the job is stored in

publication

queue_id

Get the queue ID, the ID returned from the queuing system - it is most likely not the same as the job ID.

restart_file_dict

A dictionary of the new name of the copied restart files

restart_file_list

Get the list of files which are used to restart the calculation from these files.

server

Get the server object to handle the execution environment for the job.

status

Execution status of the job, can be one of the following [initialized, appended, created, submitted, running,

structure

version

Get the version of the hamiltonian, which is also the version of the executable unless a custom executable is used.

working_directory

Get the working directory of the job is executed in - outside the HDF5 file. The working directory equals the path but it is represented by the filesystem: /absolute/path/to/the/file.h5/path/inside/the/hdf5/file becomes: /absolute/path/to/the/file_hdf5/path/inside/the/hdf5/file.

animate_structures(spacefill: bool = True, show_cell: bool = True, center_of_mass: bool = False, particle_size: float = 0.5, camera: str = 'orthographic')#

Animate a series of atomic structures.

Parameters:
  • spacefill (bool) – If True, then atoms are visualized in spacefill stype

  • show_cell (bool) – True if the cell boundaries of the structure is to be shown

  • particle_size (float) – Scaling factor for the spheres representing the atoms. (The radius is determined by the atomic number)

  • center_of_mass (bool) – False (default) if the specified positions are w.r.t. the origin

  • camera (str) – camera perspective, choose from “orthographic” or “perspective”

Returns:

nglview IPython widget

Return type:

animation

calc_free_energy(temperature: float = None, pressure: list | float | None = None, reference_phase: str = None, n_equilibration_steps: int = 15000, n_switching_steps: int = 25000, n_print_steps: int = 0, n_iterations: int = 1)[source]#

Calculate free energy at given conditions

Parameters:

None

Returns:

None

calc_mode_alchemy(temperature: float = None, pressure: list | float | None = None, reference_phase: str = None, n_equilibration_steps: int = 15000, n_switching_steps: int = 25000, n_print_steps: int = 0, n_iterations: int = 1)[source]#

Perform upsampling/alchemy between two interatomic potentials

Parameters:

None

Returns:

None

calc_mode_fe(temperature: float = None, pressure: list | float | None = None, reference_phase: str = None, n_equilibration_steps: int = 15000, n_switching_steps: int = 25000, n_print_steps: int = 0, n_iterations: int = 1)[source]#

Calculate free energy at given conditions

Parameters:

None

Returns:

None

calc_mode_pscale(temperature: float = None, pressure: list | float | None = None, reference_phase: str = None, n_equilibration_steps: int = 15000, n_switching_steps: int = 25000, n_print_steps: int = 0, n_iterations: int = 1)[source]#

Calculate free energy between two given pressures

Parameters:

None

Returns:

None

calc_mode_ts(temperature: float = None, pressure: list | float | None = None, reference_phase: str = None, n_equilibration_steps: int = 15000, n_switching_steps: int = 25000, n_print_steps: int = 0, n_iterations: int = 1)[source]#

Calculate free energy between given temperatures

Parameters:

None

Returns:

None

property calculate_kwargs: dict#

Generate keyword arguments for the calculate() function. A new simulation code only has to extend the get_input_parameter_dict() function which by default specifies an hierarchical dictionary with files_to_write and files_to_copy.

Example:

>>> calculate_function = job.get_calculate_function()
>>> shell_output, parsed_output, job_crashed = calculate_function(**job.calculate_kwargs)
>>> job.save_output(output_dict=parsed_output, shell_output=shell_output)
Returns:

keyword arguments for the calculate() function

Return type:

dict

check_if_job_exists(job_name: str | None = None, project: ProjectHDFio | pyiron_base.project.generic.Project | None = None)#

Check if a job already exists in an specific project.

Parameters:
  • job_name (str) – Job name (optional)

  • project (ProjectHDFio, Project) – Project path (optional)

Returns:

True / False

Return type:

(bool)

check_setup() None#

Checks whether certain parameters (such as plane wave cutoff radius in DFT) are changed from the pyiron standard values to allow for a physically meaningful results. This function is called manually or only when the job is submitted to the queueing system.

property child_ids: list#

list of child job ids - only meta jobs have child jobs - jobs which list the meta job as their master

Returns:

list of child job ids

Return type:

list

clear_job() None#

Convenience function to clear job info after suspend. Mimics deletion of all the job info after suspend in a local test environment.

collect_general_output()[source]#

Collect the output from calphy

Parameters:

None

Returns:

None

collect_logfiles() None#

Collect the log files of the external executable and store the information in the HDF5 file. This method has to be implemented in the individual hamiltonians.

collect_output()[source]#

Collect the output files of the external executable and store the information in the HDF5 file. This method has to be implemented in the individual hamiltonians.

collect_structures(filter_function=None) StructureStorage#

Collects a copy of all structures in a compact StructureStorage.

This can be used to force lazily applied modifications with transform_structures() or simply to obtain a known object type from a generic HasStructure object.

Parameters:

filter_function (function) – include structure only if this function returns True for it

Returns:

a copy of all (filtered) structures

Return type:

StructureStorage

compress(files_to_compress: List[str] | None = None, files_to_remove: List[str] | None = None) None#

Compress the output files of a job object.

Parameters:

files_to_compress (list)

convergence_check() bool#

Validate the convergence of the calculation.

Returns:

If the calculation is converged

Return type:

(bool)

copy() GenericJob#

Copy the GenericJob object which links to the job and its HDF5 file

Returns:

New GenericJob object pointing to the same job

Return type:

GenericJob

copy_file_to_working_directory(file: str) None#

Copy a specific file to the working directory before the job is executed.

Parameters:

file (str) – path of the file to be copied.

copy_template(project: ProjectHDFio | JobCore | None = None, new_job_name: None = None) GenericJob#

Copy the content of the job including the HDF5 file but without the output data to a new location

Parameters:
  • project (JobCore/ProjectHDFio/Project/None) – The project to copy the job to. (Default is None, use the same project.)

  • new_job_name (str) – The new name to assign the duplicate job. Required if the project is None or the same project as the copied job. (Default is None, try to keep the same name.)

Returns:

GenericJob object pointing to the new location.

Return type:

GenericJob

copy_to(project: ProjectHDFio | JobCore | None = None, new_job_name: str | None = None, input_only: bool = False, new_database_entry: bool = True, delete_existing_job: bool = False, copy_files: bool = True)#

Copy the content of the job including the HDF5 file to a new location.

Parameters:
  • project (JobCore/ProjectHDFio/Project/None) – The project to copy the job to. (Default is None, use the same project.)

  • new_job_name (str) – The new name to assign the duplicate job. Required if the project is None or the same project as the copied job. (Default is None, try to keep the same name.)

  • input_only (bool) – [True/False] Whether to copy only the input. (Default is False.)

  • new_database_entry (bool) – [True/False] Whether to create a new database entry. If input_only is True then new_database_entry is False. (Default is True.)

  • delete_existing_job (bool) – [True/False] Delete existing job in case it exists already (Default is False.)

  • copy_files (bool) – If True copy all files the working directory of the job, too

Returns:

GenericJob object pointing to the new location.

Return type:

GenericJob

create_job(job_type: str, job_name: str, delete_existing_job: bool = False) GenericJob#

Create one of the following jobs: - ‘StructureContainer’: - ‘StructurePipeline’: - ‘AtomisticExampleJob’: example job just generating random number - ‘ExampleJob’: example job just generating random number - ‘Lammps’: - ‘KMC’: - ‘Sphinx’: - ‘Vasp’: - ‘GenericMaster’: - ‘ParallelMaster’: series of jobs run in parallel - ‘KmcMaster’: - ‘ThermoLambdaMaster’: - ‘RandomSeedMaster’: - ‘MeamFit’: - ‘Murnaghan’: - ‘MinimizeMurnaghan’: - ‘ElasticMatrix’: - ‘ConvergenceEncutParallel’: - ‘ConvergenceKpointParallel’: - ’PhonopyMaster’: - ‘DefectFormationEnergy’: - ‘LammpsASE’: - ‘PipelineMaster’: - ’TransformationPath’: - ‘ThermoIntEamQh’: - ‘ThermoIntDftEam’: - ‘ScriptJob’: Python script or jupyter notebook job container - ‘ListMaster’: list of jobs

Parameters:
  • job_type (str) – job type can be [‘StructureContainer’, ‘StructurePipeline’, ‘AtomisticExampleJob’, ‘ExampleJob’, ‘Lammps’, ‘KMC’, ‘Sphinx’, ‘Vasp’, ‘GenericMaster’, ‘ParallelMaster’, ‘KmcMaster’, ‘ThermoLambdaMaster’, ‘RandomSeedMaster’, ‘MeamFit’, ‘Murnaghan’, ‘MinimizeMurnaghan’, ‘ElasticMatrix’, ‘ConvergenceEncutParallel’, ‘ConvergenceKpointParallel’, ’PhonopyMaster’, ‘DefectFormationEnergy’, ‘LammpsASE’, ‘PipelineMaster’, ’TransformationPath’, ‘ThermoIntEamQh’, ‘ThermoIntDftEam’, ‘ScriptJob’, ‘ListMaster’]

  • job_name (str) – name of the job

  • delete_existing_job (bool) – delete an existing job - default false

Returns:

job object depending on the job_type selected

Return type:

GenericJob

db_entry()[source]#

Generate the initial database entry :returns: db_dict :rtype: (dict)

decompress() None#

Decompress the output files of a compressed job object.

drop_status_to_aborted() None#

Change the job status to aborted when the job was intercepted.

property exclude_groups_hdf: list#

Get the list of groups which are excluded from storing in the hdf5 file

Returns:

groups(list)

property exclude_nodes_hdf: list#

Get the list of nodes which are excluded from storing in the hdf5 file

Returns:

nodes(list)

property executable: Executable#

Get the executable used to run the job - usually the path to an external executable.

Returns:

exectuable path

Return type:

(str/pyiron_base.job.executable.Executable)

property files: FileBrowser#

Allows to browse the files in a job directory.

By default this object prints itself as a listing of the job directory and the files inside.

>>> job.files
/path/to/my/job:
    pyiron.log
    error.out

Access to the names of files is provided with list()

>>> job.files.list()
['pyiron.log', 'error.out', 'INCAR']

Access to the contents of files is provided by indexing into this object, which returns a list of lines in the file

>>> job.files['error.out']
["Oh no

“, “Something went wrong! “]

The tail() method prints the last lines of a file to stdout

>>> job.files.tail('error.out', lines=1)
Something went wrong!

For files that have valid python variable names can also be accessed by attribute notation

>>> job.files.INCAR 
File('INCAR')
from_dict(obj_dict: dict, version: str = None)#

Populate the object from the serialized object.

Parameters:
  • obj_dict (dict) – data previously returned from to_dict()

  • version (str) – version tag written together with the data

from_hdf(hdf=None, group_name=None)[source]#

Restore the GenericJob from an HDF5 file

Parameters:
  • hdf (ProjectHDFio) – HDF5 group object - optional

  • group_name (str) – HDF5 subgroup name - optional

classmethod from_hdf_args(hdf: ProjectHDFio) dict#

Read arguments for instance creation from HDF5 file

Parameters:

hdf (ProjectHDFio) – HDF5 group object

get(name: str, default: Any | None = None) Any#

Internal wrapper function for __getitem__() - self[name]

Parameters:
  • key (str, slice) – path to the data or key of the data object

  • default (any, optional) – return this if key cannot be found

Returns:

data or data object

Return type:

dict, list, float, int

Raises:

ValueError – key cannot be found and default is not given

get_calculate_function() callable#

Generate calculate() function

Example:

>>> calculate_function = job.get_calculate_function()
>>> shell_output, parsed_output, job_crashed = calculate_function(**job.calculate_kwargs)
>>> job.save_output(output_dict=parsed_output, shell_output=shell_output)
Returns:

calculate() functione

Return type:

callable

get_from_table(path: str, name: str) dict | list | float | int#

Get a specific value from a pandas.Dataframe

Parameters:
  • path (str) – relative path to the data object

  • name (str) – parameter key

Returns:

the value associated to the specific parameter key

Return type:

dict, list, float, int

get_input_parameter_dict() dict#

Get an hierarchical dictionary of input files. On the first level the dictionary is divided in file_to_create and files_to_copy. Both are dictionaries use the file names as keys. In file_to_create the values are strings which represent the content which is going to be written to the corresponding file. In files_to_copy the values are the paths to the source files to be copied.

Returns:

hierarchical dictionary of input files

Return type:

dict

get_job_id(job_specifier: int | str | None = None) int | None#

get the job_id for job named job_name in the local project path from database

Parameters:

job_specifier (str, int) – name of the job or job ID

Returns:

job ID of the job

Return type:

int

get_potentials() List[str][source]#

Return the interatomic potentials

Parameters:

None

Returns:

list of interatomic potentials

Return type:

list of str

get_structure(frame=-1, wrap_atoms=True, iteration_step=None)#

Retrieve structure from object. The number of available structures depends on the job and what kind of calculation has been run on it, see number_of_structures.

Parameters:

frame (int, object) – index of the structure requested, if negative count from the back; if

:param _translate_frame() is overridden: :param frame will pass through it: :param iteration_step: deprecated alias for frame :type iteration_step: int :param wrap_atoms: True if the atoms are to be wrapped back into the unit cell :type wrap_atoms: bool

Returns:

the requested structure

Return type:

pyiron_atomistics.atomistics.structure.atoms.Atoms

Raises:

IndexError – if not -number_of_structures <= iteration_step < number_of_structures

property id: int#

Unique id to identify the job in the pyiron database - use self.job_id instead

Returns:

job id

Return type:

int

inspect(job_specifier: str | int) JobCore#

Inspect an existing pyiron object - most commonly a job - from the database

Parameters:

job_specifier (str, int) – name of the job or job ID

Returns:

Access to the HDF5 object - not a GenericJob object - use load() instead.

Return type:

JobCore

classmethod instantiate(obj_dict: dict, version: str = None) Self#

Create a blank instance of this class.

This can be used when some values are already necessary for the objects __init__.

Parameters:
  • obj_dict (dict) – data previously returned from to_dict()

  • version (str) – version tag written together with the data

Returns:

a blank instance of the object that is sufficiently initialized to call _from_dict() on it

Return type:

object

interactive_close() None#

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable. This is usually faster than a single core python job. After the interactive execution, the job can be closed using the interactive_close function.

interactive_fetch() None#

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable. This is usually faster than a single core python job. To access the output data during the execution the interactive_fetch function is used.

interactive_flush(path: str = 'generic', include_last_step: bool = True) None#

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable. This is usually faster than a single core python job. To write the interactive cache to the HDF5 file the interactive flush function is used.

is_compressed() bool#

Check if the job is already compressed or not.

Returns:

[True/False]

Return type:

bool

is_master_id(job_id: int) bool#

Check if the job ID job_id is the master ID for any child job

Parameters:

job_id (int) – job ID of the master job

Returns:

[True/False]

Return type:

bool

is_self_archived() bool#

Check if the HDF5 file of the Job is compressed as tar-archive

Returns:

[True/False]

Return type:

bool

iter_structures(wrap_atoms=True)#

Iterate over all structures in this object.

Parameters:

wrap_atoms (bool) – True if the atoms are to be wrapped back into the unit cell; passed to get_structure()

Yields:

pyiron_atomistics.atomistitcs.structure.atoms.Atoms – every structure attached to the object

job_file_name(file_name: str, cwd: str | None = None) str#

combine the file name file_name with the path of the current working directory

Parameters:
  • file_name (str) – name of the file

  • cwd (str) – current working directory - this overwrites self.project_hdf5.working_directory - optional

Returns:

absolute path to the file in the current working directory

Return type:

str

property job_id: int#

Unique id to identify the job in the pyiron database

Returns:

job id

Return type:

int

property job_info_str: str#

Short string to describe the job by it is job_name and job ID - mainly used for logging

Returns:

job info string

Return type:

str

property job_name: str#

Get name of the job, which has to be unique within the project

Returns:

job name

Return type:

str

property job_type: str#
[‘ExampleJob’, ‘ParallelMaster’, ‘ScriptJob’,

‘ListMaster’]

Returns:

Job type object

Return type:

JobTypeChoice

Type:

Job type object with all the available job types

kill() None#

Kill the job.

This function is used to terminate the execution of the job. It checks if the job is currently running or submitted, and if so, it removes and resets the job ID. If the job is not running or submitted, a ValueError is raised.

Returns:

None

list_all()#

Returns dictionary of :method:`.list_groups()` and :method:`.list_nodes()`.

Returns:

results of :method:`.list_groups() under the key "groups"; results of :method:`.list_nodes()` und the

key “nodes”

Return type:

dict

list_childs() list#

List child jobs as JobPath objects - not loading the full GenericJob objects for each child

Returns:

list of child jobs

Return type:

list

list_files() list#

List files inside the working directory

Parameters:

extension (str) – filter by a specific extension

Returns:

list of file names

Return type:

list

list_groups()#

Return a list of names of all nested groups.

Returns:

group names

Return type:

list of str

list_nodes()#

Return a list of names of all nested nodes.

Returns:

node names

Return type:

list of str

list_potentials()[source]#

List of interatomic potentials suitable for the current atomic structure.

use self.potentials_view() to get more details.

Parameters:

None

Returns:

potential names

Return type:

list

load(job_specifier: str | int, convert_to_object: bool = True) pyiron_base.job.generic.GenericJob | JobCore#

Load an existing pyiron object - most commonly a job - from the database

Parameters:
  • job_specifier (str, int) – name of the job or job ID

  • convert_to_object (bool) – convert the object to an pyiron object or only access the HDF5 file - default=True accessing only the HDF5 file is about an order of magnitude faster, but only provides limited functionality. Compare the GenericJob object to JobCore object.

Returns:

Either the full GenericJob object or just a reduced JobCore object

Return type:

GenericJob, JobCore

property logger#

Get the logger object to monitor the external execution and internal pyiron warnings.

Returns:

logger object

Return type:

logging.getLogger()

property master_id: int#

Get job id of the master job - a meta job which groups a series of jobs, which are executed either in parallel or in serial.

Returns:

master id

Return type:

int

move_to(project: ProjectHDFio) None#

Move the content of the job including the HDF5 file to a new location

Parameters:

project (ProjectHDFio) – project to move the job to

property name: str#

Get name of the job, which has to be unique within the project

Returns:

job name

Return type:

str

property number_of_structures#

maximum iteration_step + 1 that can be passed to get_structure().

Type:

int

property parent_id: int#

Get job id of the predecessor job - the job which was executed before the current one in the current job series

Returns:

parent id

Return type:

int

property path: str#

Absolute path of the HDF5 group starting from the system root - combination of the absolute system path plus the absolute path inside the HDF5 file starting from the root group.

Returns:

absolute path

Return type:

str

property project: pyiron_base.project.generic.Project#

Project instance the jobs is located in

Returns:

project the job is located in

Return type:

Project

property project_hdf5: ProjectHDFio#

Get the ProjectHDFio instance which points to the HDF5 file the job is stored in

Returns:

HDF5 project

Return type:

ProjectHDFio

property queue_id: int#

Get the queue ID, the ID returned from the queuing system - it is most likely not the same as the job ID.

Returns:

queue ID

Return type:

int

refresh_job_status() None#

Refresh job status by updating the job status with the status from the database if a job ID is available.

relocate_hdf5(h5_path: str | None = None)#

Relocate the hdf file. This function is needed when the child job is spawned by a parent job (cf. pyiron_base.jobs.master.generic)

remove(_protect_childs: bool = True) None#

Remove the job - this removes the HDF5 file, all data stored in the HDF5 file an the corresponding database entry.

Parameters:

_protect_childs (bool) – [True/False] by default child jobs can not be deleted, to maintain the consistency - default=True

remove_and_reset_id(_protect_childs: bool = True) None#

Remove the job and reset its ID.

Parameters:

_protect_childs (bool) – Flag indicating whether to protect child jobs (default is True).

Returns:

None

remove_child() None#

internal function to remove command that removes also child jobs. Do never use this command, since it will destroy the integrity of your project.

rename(new_job_name: str) None#

Rename the job - by changing the job name

Parameters:

new_job_name (str) – new job name

reset_job_id(job_id: int | None = None) None#

Reset the job id sets the job_id to None in the GenericJob as well as all connected modules like JobStatus.

restart(job_name: str | None = None, job_type: str | None = None) GenericJob#

Create an restart calculation from the current calculation - in the GenericJob this is the same as create_job(). A restart is only possible after the current job has finished. If you want to run the same job again with different input parameters use job.run(delete_existing_job=True) instead.

Parameters:
  • job_name (str) – job name of the new calculation - default=<job_name>_restart

  • job_type (str) – job type of the new calculation - default is the same type as the exeisting calculation

Returns:

property restart_file_dict: dict#

A dictionary of the new name of the copied restart files

property restart_file_list: list#

Get the list of files which are used to restart the calculation from these files.

Returns:

list of files

Return type:

list

run(delete_existing_job: bool = False, repair: bool = False, debug: bool = False, run_mode: str | None = None, run_again: bool = False) None#

This is the main run function, depending on the job status [‘initialized’, ‘created’, ‘submitted’, ‘running’, ‘collect’,’finished’, ‘refresh’, ‘suspended’] the corresponding run mode is chosen.

Parameters:
  • delete_existing_job (bool) – Delete the existing job and run the simulation again.

  • repair (bool) – Set the job status to created and run the simulation again.

  • debug (bool) – Debug Mode - defines the log level of the subprocess the job is executed in.

  • run_mode (str) – [‘modal’, ‘non_modal’, ‘queue’, ‘manual’] overwrites self.server.run_mode

  • run_again (bool) – Same as delete_existing_job (deprecated)

run_if_interactive() None#

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable. This is usually faster than a single core python job.

run_if_interactive_non_modal() None#

For jobs which executables are available as Python library, those can also be executed with a library call instead of calling an external executable. This is usually faster than a single core python job.

run_if_modal() None#

The run if modal function is called by run to execute the simulation, while waiting for the output. For this we use subprocess.check_output()

run_if_refresh() None#

Internal helper function the run if refresh function is called when the job status is ‘refresh’. If the job was suspended previously, the job is going to be started again, to be continued.

run_if_scheduler() None | int#

The run if queue function is called by run if the user decides to submit the job to and queing system. The job is submitted to the queuing system using subprocess.Popen() :returns: Returns the queue ID for the job. :rtype: int

run_static()[source]#

The run static function is called by run to execute the simulation.

run_time_to_db() None#

Internal helper function to store the run_time in the database

save() None#

Save the object, by writing the content to the HDF5 file and storing an entry in the database.

Returns:

Job ID stored in the database

Return type:

(int)

save_output(output_dict: dict | None = None, shell_output: str | None = None) None#

Store output of the calculate function in the HDF5 file.

Parameters:
  • output_dict (dict) – hierarchical output dictionary to be stored in the HDF5 file.

  • shell_output (str) – shell output from calling the external executable to be stored in the HDF5 file.

self_archive() None#

Compress HDF5 file of the job object to tar-archive

self_unarchive() None#

Decompress HDF5 file of the job object from tar-archive

property server: Server#

Get the server object to handle the execution environment for the job.

Returns:

server object

Return type:

Server

set_input_to_read_only() None#

This function enforces read-only mode for the input classes, but it has to be implemented in the individual classes.

set_potentials(potential_filenames: list | str)[source]#

Set the interatomic potential from a given name

Parameters:

potential_filenames (list, str) – list of filenames

Returns:

None

show_hdf() None#

Iterating over the HDF5 datastructure and generating a human readable graph.

signal_intercept(sig) None#

Abort the job and log signal that caused it.

Expected to be called from pyiron_base.state.signal.catch_signals().

Parameters:

sig (int) – the signal that triggered the abort

property status: str#
Execution status of the job, can be one of the following [initialized, appended, created, submitted, running,

aborted, collect, suspended, refresh, busy, finished]

Returns:

status

Return type:

(str/pyiron_base.job.jobstatus.JobStatus)

suspend() None#

Suspend the job by storing the object and its state persistently in HDF5 file and exit it.

to_dict() dict#

Reduce the object to a dictionary.

Returns:

serialized state of this object

Return type:

dict

to_hdf(hdf=None, group_name=None)[source]#

Store the GenericJob in an HDF5 file

Parameters:
  • hdf (ProjectHDFio) – HDF5 group object - optional

  • group_name (str) – HDF5 subgroup name - optional

to_object(object_type: str | None = None, **qwargs) pyiron_base.job.generic.GenericJob#

Load the full pyiron object from an HDF5 file

Parameters:
  • object_type – if the ‘TYPE’ node is not available in the HDF5 file a manual object type can be set - optional

  • **qwargs – optional parameters [‘job_name’, ‘project’] - to specify the location of the HDF5 path

Returns:

pyiron object

Return type:

GenericJob

transfer_from_remote() None#

Transfer the job from a remote location to the local machine.

This method transfers the job from a remote location to the local machine. It performs the following steps: 1. Retrieves the job from the remote location using the queue adapter. 2. Transfers the job file to the remote location, with the option to delete the file on the remote location after transfer. 3. Updates the project database if it is disabled, otherwise updates the file table in the database with the job information.

Parameters:

None

Returns:

None

transform_structures(modify) TransformStructure#

Return a modified object by applying a function to each object lazily.

Parameters:

modify (function) – applied to each structure, has to return the modified structure

Returns:

a container with the modified structures

Return type:

TransformStructure

update_master(force_update: bool = False) None#

After a job is finished it checks whether it is linked to any metajob - meaning the master ID is pointing to this jobs job ID. If this is the case and the master job is in status suspended - the child wakes up the master job, sets the status to refresh and execute run on the master job. During the execution the master job is set to status refresh. If another child calls update_master, while the master is in refresh the status of the master is set to busy and if the master is in status busy at the end of the update_master process another update is triggered.

Parameters:

force_update (bool) – Whether to check run mode for updating master

validate_ready_to_run() None#

Validate that the calculation is ready to be executed. By default no generic checks are performed, but one could check that the input information is complete or validate the consistency of the input at this point.

Raises:

ValueError – if ready check is unsuccessful

property version: str#

Get the version of the hamiltonian, which is also the version of the executable unless a custom executable is used.

Returns:

version number

Return type:

str

view_potentials() List[source]#

View a list of available interatomic potentials

Parameters:

None

Returns:

list of available potentials

Return type:

list

property working_directory: str#

Get the working directory of the job is executed in - outside the HDF5 file. The working directory equals the path but it is represented by the filesystem:

/absolute/path/to/the/file.h5/path/inside/the/hdf5/file

becomes:

/absolute/path/to/the/file_hdf5/path/inside/the/hdf5/file

Returns:

absolute path to the working directory

Return type:

str

write_input()[source]#

Write input for calphy calculation

Parameters:

None

Returns:

None

write_structure(structure, file_name: str, working_directory: str)[source]#

Write structure to file

Parameters:
  • structure – input structure

  • file_name (str) – output file name

  • working_directory (str) – output working directory

Returns:

None