matador.workflows.castep package

The workflows.castep submodule contains any workflows that rely on CASTEP-specific implementation, for example electronic spectropscopy or phonons.

matador.workflows.castep.castep_full_phonon(computer, calc_doc, seed, **kwargs)[source]

Perform a “full” phonon calculation on a system, i.e. first perform a relaxation in a standardised unit cell, then compute the dynamical matrix, then finally interpolate that dynamical matrix into dispersion curves and DOS. This function is a wrapper for the CastepPhononWorkflow class.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

matador.workflows.castep.castep_full_spectral(computer, calc_doc, seed, **kwargs)[source]

Perform a “full” spectral calculation on a system, i.e. first perform an SCF then interpolate to different kpoint paths/grids to form DOS and dispersions. Optionally use OptaDOS for post-processing of DOS.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

matador.workflows.castep.castep_elastic(computer, calc_doc, seed, **kwargs)[source]

Perform a calculation of the elastic tensor on a system. Currently only calculation of the bulk modulus is implemented.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

matador.workflows.castep.castep_full_magres(computer, calc_doc, seed, final_elec_energy_tol=1e-11, **kwargs)[source]

Perform a “full” magres calculation on a system, i.e. first perform a relaxation, then do a high quality SCF and compute NMR properties in the same step.

This function is a wrapper for the CastepMagresWorkflow class.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

Submodules

matador.workflows.castep.common module

This submodule implements some common workflow steps for use in more complicated workflows.

matador.workflows.castep.common.castep_prerelax(computer, calc_doc, seed, write_checkpoint='all', required_keys=None, forbidden_keys=None)[source]

Run a self-consistent (i.e. restarted) geometry optimisation. Optionally write a check file containing the final structure and density.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

Keyword Arguments
  • write_checkpoint (bool or str) – keyword to pass to CASTEP’s write_checkpoint parameter. If True (False), CASTEP parameter set to ALL (NONE).

  • required_keys (list of str) – list of keys required in calc doc to perform the calculation.

  • forbidden_keys (list of str) – list of keys to scrub from calc doc to perform the calculation.

Returns

whether or not the relaxation was successful.

Return type

bool

matador.workflows.castep.common.castep_scf(computer, calc_doc, seed, elec_energy_tol=None, write_checkpoint='ALL', required_keys=None, forbidden_keys=None)[source]

Run a singleshot SCF calculation.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

Keyword Arguments
  • elec_energy_tol (float or str) – keyword to pass to elec_energy_tol.

  • write_checkpoint (bool or str) – keyword to pass to CASTEP’s write_checkpoint parameter. If True (False), CASTEP parameter set to ALL (NONE).

  • required_keys (list of str) – list of keys required in calc doc to perform the calculation.

  • forbidden_keys (list of str) – list of keys to scrub from calc doc to perform the calculation.

Returns

whether or not the SCF was successful.

Return type

bool

matador.workflows.castep.elastic module

This module implements the CastepElasticWorkflow, which performs elastic tensor calculations with CASTEP. So far, only bulk modulus calculations (i.e. varying volume from equilibrium) have been implemented.

matador.workflows.castep.elastic.castep_elastic(computer, calc_doc, seed, **kwargs)[source]

Perform a calculation of the elastic tensor on a system. Currently only calculation of the bulk modulus is implemented.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

class matador.workflows.castep.elastic.CastepElasticWorkflow(computer, calc_doc, seed, **workflow_kwargs)[source]

Bases: matador.workflows.workflows.Workflow

Perform a “full” spectral calculation on a system, i.e. first perform an SCF then interpolate to different kpoint paths/grids to form DOS and dispersions. Optionally use OptaDOS for post-processing of DOS.

computer

the object that calls CASTEP.

Type

ComputeTask

calc_doc

the interim dictionary of structural and calculation parameters.

Type

dict

seed

the root seed for the calculation.

Type

str

volume_rescale

a list of floats containing the amounts by which to rescale volumes when performing bulk modulus calculation.

Type

list

success

the status of the Workflow: only set to True after post-processing method completes.

Type

bool

Initialise the Workflow object from a matador.compute.ComputeTask, calculation parameters and the seed name.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be running the computation.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

preprocess()[source]

Decide which parts of the Workflow need to be performed, and set the appropriate CASTEP parameters.

postprocess()[source]

Fit some equations of state, then save a plot and a datafile.

matador.workflows.castep.elastic.castep_rescaled_volume_scf(computer, calc_doc, seed, rescale=1)[source]

Run a singleshot SCF calculation.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

Keyword Arguments

rescale (float) – amount to rescale volume by.

matador.workflows.castep.elastic.castep_elastic_prerelax(computer, calc_doc, seed)[source]

Run a geometry optimisation before re-scaling volumes SCF-style calculation.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.magres module

This module implements the CastepMagresWorkflow class, which performs magres calculations with CASTEP in multiple steps (only when necessary):

  1. Try to pre-relax structure (skipped if check file is already present).

  2. Perform an SCF with lower electronic tolerances.

  3. Calculate NMR properties, e.g. shielding and EFG.

matador.workflows.castep.magres.castep_full_magres(computer, calc_doc, seed, final_elec_energy_tol=1e-11, **kwargs)[source]

Perform a “full” magres calculation on a system, i.e. first perform a relaxation, then do a high quality SCF and compute NMR properties in the same step.

This function is a wrapper for the CastepMagresWorkflow class.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

class matador.workflows.castep.magres.CastepMagresWorkflow(computer, calc_doc, seed, **workflow_kwargs)[source]

Bases: matador.workflows.workflows.Workflow

Perform a “full” magres calculation on a system, i.e. first perform a relaxation in a standardised unit cell, then do a high quality SCF, then compute NMR properties.

computer

the object that calls CASTEP.

Type

ComputeTask

calc_doc

the interim dictionary of structural and calculation parameters.

Type

dict

seed

the root seed for the calculation.

Type

str

success

the status of the Workflow: only set to True after post-processing method completes.

Type

bool

final_elec_energy_tol

the electronic energy tolerance to use in the high-quality SCF calculation.

Type

float

Initialise the Workflow object from a matador.compute.ComputeTask, calculation parameters and the seed name.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be running the computation.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

preprocess()[source]

Decide which parts of the Workflow need to be performed, and set the appropriate CASTEP parameters.

matador.workflows.castep.magres.castep_magres_scf(computer, calc_doc, seed, elec_energy_tol=1e-11)[source]

Run a singleshot SCF calculation with a high elec_energy_tol.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

Returns

whether or not the SCF was successful.

Return type

bool

matador.workflows.castep.magres.castep_magres(computer, calc_doc, seed, elec_energy_tol=1e-11)[source]

Runs a NMR properties calculation on top of a completed SCF calculation.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.phonons module

This module implements the CastepPhononWorkflow class, which performs phonon calculations with CASTEP in multiple steps (only when necessary):

  1. Try to pre-relax structure (skipped if check file

    is already present).

  2. Calculate dynamical matrix.

  3. If phonon_fine_kpoint_mp_spacing keyword is found, interpolate dynamical matrix to form phonon DOS.

  4. If phonon_fine_kpoint_path_spacing key word is found, interpolate dynamical matrix to form phonon dispersion on the path given by seekpath.

  5. If task=thermodynamics, perform a CASTEP thermodynamics calculation for the temperature-dependence of the free energy.

matador.workflows.castep.phonons.castep_full_phonon(computer, calc_doc, seed, **kwargs)[source]

Perform a “full” phonon calculation on a system, i.e. first perform a relaxation in a standardised unit cell, then compute the dynamical matrix, then finally interpolate that dynamical matrix into dispersion curves and DOS. This function is a wrapper for the CastepPhononWorkflow class.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

class matador.workflows.castep.phonons.CastepPhononWorkflow(computer, calc_doc, seed, **workflow_kwargs)[source]

Bases: matador.workflows.workflows.Workflow

Perform a “full” phonon calculation on a system, i.e. first perform a relaxation in a standardised unit cell, then compute the dynamical matrix, then finally interpolate that dynamical matrix into dispersion curves and DOS.

computer

the object that calls CASTEP.

Type

ComputeTask

calc_doc

the interim dictionary of structural and calculation parameters.

Type

dict

seed

the root seed for the calculation.

Type

str

success

the status of the Workflow: only set to True after post-processing method completes.

Type

bool

Initialise the Workflow object from a matador.compute.ComputeTask, calculation parameters and the seed name.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be running the computation.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

preprocess()[source]

Decide which parts of the Workflow need to be performed, and set the appropriate CASTEP parameters.

matador.workflows.castep.phonons.castep_phonon_prerelax(computer, calc_doc, seed)[source]

Run a singleshot geometry optimisation before an SCF-style calculation. This is typically used to ensure phonon calculations start successfully. The phonon calculation will then be restarted from the .check file produced here.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.phonons.castep_phonon_dynmat(computer, calc_doc, seed)[source]

Runs a singleshot phonon dynmat calculation, with no “fine_method” interpolation.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.phonons.castep_phonon_dos(computer, calc_doc, seed)[source]

Runs a DOS interpolation on top of a completed phonon calculation.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.phonons.castep_phonon_dispersion(computer, calc_doc, seed)[source]

Runs a dispersion interpolation on top of a completed phonon calculation.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.phonons.castep_phonon_thermodynamics(computer, calc_doc, seed)[source]

Runs a “thermodynamics” interpolation on top of a completed phonon calculation, using the phonon_fine_kpoint_mp_grid.

Parameters
  • computer (ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.spectral module

This module implements the CastepSpectralWorkflow, which performs spectral calculations with CASTEP in multiple steps:

  1. Performs a singlepoint calculation (if check file is not found).

  2. If the spectral_kpoints_mp_spacing keyword is found, interpolate wavefunction to DOS grid. - If an OptaDOS input file (.odi) with the root seedname

    is found, run OptaDOS on the resulting density of states.

  3. If spectral_kpoints_path_spacing keyword is present, create a bandstructure on the SeeK-path generated path.

matador.workflows.castep.spectral.castep_full_spectral(computer, calc_doc, seed, **kwargs)[source]

Perform a “full” spectral calculation on a system, i.e. first perform an SCF then interpolate to different kpoint paths/grids to form DOS and dispersions. Optionally use OptaDOS for post-processing of DOS.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

Returns

True if Workflow completed successfully, or False otherwise.

Return type

bool

class matador.workflows.castep.spectral.CastepSpectralWorkflow(computer, calc_doc, seed, **workflow_kwargs)[source]

Bases: matador.workflows.workflows.Workflow

Perform a “full” spectral calculation on a system, i.e. first perform an SCF then interpolate to different kpoint paths/grids to form DOS and dispersions. Optionally use OptaDOS for post-processing of DOS.

computer

the object that calls CASTEP.

Type

matador.compute.ComputeTask

calc_doc

the interim dictionary of structural and calculation parameters.

Type

dict

seed

the root seed for the calculation.

Type

str

success

the status of the Workflow: only set to True after post-processing method completes.

Type

bool

Initialise the Workflow object from a matador.compute.ComputeTask, calculation parameters and the seed name.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be running the computation.

  • calc_doc (dict) – dictionary of structure and calculation parameters.

  • seed (str) – root seed for the calculation.

Raises

RuntimeError – if any part of the calculation fails.

preprocess()[source]

Decide which parts of the Workflow need to be performed, and set the appropriate CASTEP parameters.

matador.workflows.castep.spectral.castep_spectral_scf(computer, calc_doc, seed)[source]

Run a singleshot SCF calculation.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.spectral.castep_spectral_dos(computer, calc_doc, seed)[source]

Runs a DOS interpolation on top of a completed SCF. If a single .odi file is found, run OptaDOS on the resulting DOS.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.spectral.castep_spectral_dispersion(computer, calc_doc, seed)[source]

Runs a dispersion interpolation on top of a completed SCF calculation, optionally running orbitals2bands and OptaDOS projected dispersion.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling CASTEP.

  • calc_doc (dict) – the structure to run on.

  • seed (str) – root filename of structure.

matador.workflows.castep.spectral.optados_pdos(computer, _, seed)[source]

Run an OptaDOS projected-DOS.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling OptaDOS.

  • _ – second parameter is required but ignored.

  • seed (str) – root filename of structure.

matador.workflows.castep.spectral.optados_dos_broadening(computer, _, seed)[source]

Run an OptaDOS total DOS broadening.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling OptaDOS.

  • _ – second parameter is required but ignored.

  • seed (str) – root filename of structure.

matador.workflows.castep.spectral.optados_pdispersion(computer, _, seed)[source]

Runs an OptaDOS projected dispersion calculation.

Parameters
  • computer (matador.compute.ComputeTask) – the object that will be calling OptaDOS.

  • _ – second parameter is required but ignored.

  • seed (str) – root filename of structure.