PhonopyWorkChain (phonopy.phonopy)#

workchainaiida_phonopy.workflows.phonopy.PhonopyWorkChain

Abstract workflow for automated frozen phonons. Phonopy is used to produce structures with displacements, while the forces are calculated with a quantum engine of choice. This workchain is meant to be used as a base for other specific force calculato plugin workchains, or as an example on how to set a possible workchain/workflow. For this reason, the outline of this class is not defined, while it provides the inputs and a `setup` method, which can be used in a specific workflow outline. Ideally, the workflow would look like: 1. Setup the preprocess data. This is already provided in this class. It setups a `PreProcessData` node, from where supercell, primitive cell and supercells with displacements can be easily extracted using the methods of the nodes. This node can be taken from `self.ctx.preprocess_data`, and used during the outline of the workflow. 2. Run supercells using the selected quantum engine/force calculator code. In specific code implementations, a force calculation on supercells needs to be run. To get these supercells, one need simply to run: ```self.ctx.preprocess_data.calcfunctions.get_supercells_with_displacements()``` This will return a dictionary with all the supercells as StructureData to run for the phonon calculation. The keys of this dictionary are of the type `supercell_{number}`, where `number` is an integer. These numbers are essentials since the `phonopy` force sets is generated following these numbers, in order to make sure to refer to the correct displacement. Thus, it is required to keep track of them. Moreover,a calculation over the pristine supercell structure should be run before hand as reference. This structure can instead be gotten via: ```self.ctx.preprocess_data.calcfunctions.get_supercell()``` This will return a StructureData without any label. For an example of implementation, refer to aiidateam/aiida-common-worfklows. * Note: some type of force calculation needs to map some variables from the unitcell to the supercell (and in certain case even the primitive cell), e.g. the atomic spin in VASP. Since this is code dependent, you will need to map these parameters before launching the force calculation of a certain supercell with displacement. This information can be gotten via: ```self.ctx.preprocess_data.get_cells_mappings()``` Moreover, consider that cells in phonopy will always (re)fold the atoms in order to have positive coordinates. 3. Inspect all runs and expose the forces and energies (not mandatory) outputs. * Suggested: when the calculation on each supercell has finished (correctly) expose the output forces (and energies) in the dynamical `supercells_forces(energies)` namespace(s). Provide each supercell forces as an `ArrayData` with the forces stored as `forces` (e.g. if your code plugin stores the forces in `TrajectoryData`, extract them with a `calcfunction`). Expose each `ArrayData` choosing a **common prefix**, while as **suffix use _{number}**, with `{number}` referring to the correspective supercell label suffix (that you are supposed to keep track somewhere, e.g. in the label of the code calculation/workchain). Now you can gather all the information in one data noe, i.e. in a `PhonopyData` node. To do so, you can simple run: ```self.ctx.preprocess_data.calcfunctions.generate_phonopy_data(**self.outputs.supercells_forces)``` and then expose it as output in the `output_phonopy_data` namespace. * Alternatively: instead of exposing the supercell forces as outputs, you can directly gather all the forces in a dictionary and run directly to the `generate_phonopy_data` method using this dictionary (always using the double *). See the implementation in aiidateam/aiida-common-workflows for an example. 4. (optional) Run the non-analytical constants on the primitive cell. Non-analytical constants should be run for polar insulators. These require usually a linear response code or a finite difference approach (e.g. using the electric enthalpy). Since this is usually the most expensive part, you should run them on the primitive cell. To get it, use: ```self.ctx.preprocess_data.calcfunctions.get_primitive_cell()``` If you compute also these, collect the dielectric tensor and the effectic born charges in an ArrayData, with the arraynames `dielectric` and `born_charges` (in Cartesian coordinates!). Then, gather all the information of nac and forces in a unique `PhonopyData` via: ``` self.ctx.preprocess_data.calcfunctions.generate_phonopy_data( nac_parameters=nac_paramters, **self.outputs.supercells_forces ) ``` and expose the output. * Note: we require in the input for generating the full phonopy data, to give the nac in the primitive cell. The primitive cell of phonopy will just rotate the lattice vectors, thus mantaining the Cartasian coordinate system. It can happen, though, that the unitcell is not the primitive cell of the system, meaning that the primitive cell will contain less atoms. We expect in input the nac computed on this number of atoms. If you want, for some reason, compute the nac on the unitcell, you will need to get the reduced nac. To do so, you can consider using a built-in function in phonopy, namely: :py:func:`phonopy.structure.symmetry.elaborate_borns_and_epsilon`

Inputs:

  • clean_workdir, Bool, optional – If True, work directories of all called calculation will be cleaned at the end of execution.
  • displacement_generator, (Dict, NoneType), optional –
    Info for displacements generation. The following flags are allowed:

    distance is_plusminus is_diagonal is_trigonal number_of_snapshots random_seed temperature cutoff_frequency

  • fc_options, (Dict, NoneType), optional –
    Options for force constants calculation (optional). The following flags are allowed:

    calculate_full_force_constants fc_calculator fc_calculator_options

  • is_symmetry, (Bool, NoneType), optional – Whether using or not the space group symmetries.
  • metadata, Namespace
    • call_link_label, str, optional, is_metadata – The label to use for the CALL link if the process is called by another process.
    • description, (str, NoneType), optional, is_metadata – Description to set on the process node.
    • disable_cache, (bool, NoneType), optional, is_metadata – Do not consider the cache for this process, ignoring all other caching configuration rules.
    • label, (str, NoneType), optional, is_metadata – Label to set on the process node.
    • store_provenance, bool, optional, is_metadata – If set to False provenance will not be stored in the database.
  • nac_parameters, (ArrayData, NoneType), optional – Non-analytical parameters.
  • phonopy, Namespace – Inputs for the PhonopyCalculation that willbe used to calculate the inter-atomic force constants, or for post-processing.
    • code, (AbstractCode, NoneType), optional – The Code to use for this job. This input is required, unless the remote_folder input is specified, which means an existing job is being imported and no code will actually be run.
    • metadata, Namespace
      • call_link_label, str, optional, is_metadata – The label to use for the CALL link if the process is called by another process.
      • computer, (Computer, NoneType), optional, is_metadata – When using a “local” code, set the computer on which the calculation should be run.
      • description, (str, NoneType), optional, is_metadata – Description to set on the process node.
      • disable_cache, (bool, NoneType), optional, is_metadata – Do not consider the cache for this process, ignoring all other caching configuration rules.
      • dry_run, bool, optional, is_metadata – When set to True will prepare the calculation job for submission but not actually launch it.
      • label, (str, NoneType), optional, is_metadata – Label to set on the process node.
      • options, Namespace
        • account, (str, NoneType), optional, is_metadata – Set the account to use in for the queue on the remote computer
        • additional_retrieve_list, (list, tuple, NoneType), optional, is_metadata – List of relative file paths that should be retrieved in addition to what the plugin specifies.
        • append_text, str, optional, is_metadata – Set the calculation-specific append text, which is going to be appended in the scheduler-job script, just after the code execution
        • custom_scheduler_commands, str, optional, is_metadata – Set a (possibly multiline) string with the commands that the user wants to manually set for the scheduler. The difference of this option with respect to the prepend_text is the position in the scheduler submission file where such text is inserted: with this option, the string is inserted before any non-scheduler command
        • environment_variables, dict, optional, is_metadata – Set a dictionary of custom environment variables for this calculation
        • environment_variables_double_quotes, bool, optional, is_metadata – If set to True, use double quotes instead of single quotes to escape the environment variables specified in environment_variables.
        • import_sys_environment, bool, optional, is_metadata – If set to true, the submission script will load the system environment variables
        • input_filename, str, optional, is_metadata
        • max_memory_kb, (int, NoneType), optional, is_metadata – Set the maximum memory (in KiloBytes) to be asked to the scheduler
        • max_wallclock_seconds, (int, NoneType), optional, is_metadata – Set the wallclock in seconds asked to the scheduler
        • mpirun_extra_params, (list, tuple), optional, is_metadata – Set the extra params to pass to the mpirun (or equivalent) command after the one provided in computer.mpirun_command. Example: mpirun -np 8 extra_params[0] extra_params[1] … exec.x
        • output_filename, str, optional, is_metadata
        • parser_name, str, optional, is_metadata
        • prepend_text, str, optional, is_metadata – Set the calculation-specific prepend text, which is going to be prepended in the scheduler-job script, just before the code execution
        • priority, (str, NoneType), optional, is_metadata – Set the priority of the job to be queued
        • qos, (str, NoneType), optional, is_metadata – Set the quality of service to use in for the queue on the remote computer
        • queue_name, (str, NoneType), optional, is_metadata – Set the name of the queue on the remote computer
        • rerunnable, (bool, NoneType), optional, is_metadata – Determines if the calculation can be requeued / rerun.
        • resources, dict, required, is_metadata – Set the dictionary of resources to be used by the scheduler plugin, like the number of nodes, cpus etc. This dictionary is scheduler-plugin dependent. Look at the documentation of the scheduler for more details.
        • scheduler_stderr, str, optional, is_metadata – Filename to which the content of stderr of the scheduler is written.
        • scheduler_stdout, str, optional, is_metadata – Filename to which the content of stdout of the scheduler is written.
        • stash, Namespace – Optional directives to stash files after the calculation job has completed.
          • dereference, (bool, NoneType), optional, is_metadata – Whether to follow symlinks while stashing or not, specific to StashMode.COMPRESS_* enums
          • fail_on_missing, (bool, NoneType), optional, is_metadata – If True, all files must be specified explicitly (no patterns) and all must exist, otherwise it results in calcjob failure. If False (default), patterns are allowed and missing files are skipped. Only affects copy and compress modes.
          • source_list, (tuple, list, NoneType), optional, is_metadata – Sequence of relative filepaths representing files in the remote directory that should be stashed.
          • stash_mode, (str, NoneType), optional, is_metadata – Mode with which to perform the stashing, should be value of aiida.common.datastructures.StashMode.
          • target_base, (str, NoneType), optional, is_metadata – The base location to where the files should be stashd. For example, for the copy stash mode, this should be an absolute filepath on the remote computer.
        • submit_script_filename, str, optional, is_metadata – Filename to which the job submission script is written.
        • unstash, Namespace – Optional directives to unstash files after upload.
          • source_list, (tuple, list, NoneType), optional, is_metadata – Sequence of relative filepaths representing files in the remote directory that should be unstashed.
          • unstash_target_mode, (str, NoneType), optional, is_metadata – Mode with which to perform the unstashing, should be value of aiida.common.datastructures.UnstashTargetMode.
        • withmpi, bool, optional, is_metadata
      • store_provenance, bool, optional, is_metadata – If set to False provenance will not be stored in the database.
    • monitors, Namespace – Add monitoring functions that can inspect output files while the job is running and decide to prematurely terminate the job.
    • parameters, Dict, required – Phonopy parameters (setting tags) for post processing. The following tags, along their type, are allowed: PRIMITIVE_AXES PRIMITIVE_AXIS EIGENVECTORS BAND BAND_PATHS BAND_POINTS BAND_LABELS BAND_CONNECTION BAND_INDICES MESH MP MESH_NUMBERS MP_SHIFT GAMMA_CENTER WRITE_MESH DOS DOS_RANGE FMIN FMAX FPITCH PDOS PROJECTION_DIRECTION XYZ_DIRECTION SIGMA DEBYE_MODEL MOMEMT MOMENT_ORDER TPROP TMIN TMAX TSTEP PRETEND_REAL CUTOFF_FREQUENCY TDISP TDISPMAT TDISPMAT_CIF QPOINTS WRITEDM NAC_METHOD Q_DIRECTION GROUP_VELOCITY GV_DELTA_Q SYMMETRY_TOLERANCE SYMMETRY MESH_SYMMETRY FC_SYMMETRY FULL_FORCE_CONSTANTS WRITE_FORCE_CONSTANTS ANIME_TYPE ANIME MODULATION IRREPS SHOW_IRREPS LITTLE_COGROUP
    • remote_folder, (RemoteData, NoneType), optional – Remote directory containing the results of an already completed calculation job without AiiDA. The inputs should be passed to the CalcJob as normal but instead of launching the actual job, the engine will recreate the input files and then proceed straight to the retrieve step where the files of this RemoteData will be retrieved as if it had been actually launched through AiiDA. If a parser is defined in the inputs, the results are parsed and attached as output nodes as usual.
    • settings, (Dict, NoneType), optional – Settings for phonopy calculation.
  • preprocess_data, (PhonopyData, PreProcessData, NoneType), optional – The preprocess data for frozen phonon calcualtion.
  • primitive_matrix, (List, NoneType), optional – The matrix used to generate the primitive cell from the input structure in the List format. Allowed shapes are 3x1 and 3x3 lists.
  • settings, Namespace – Settings for how to run the workflow.
    • run_parallel_nac_forces, (bool, NoneType), optional, non_db – Whether running nac parameters and forces calculations in parallel.
  • structure, (StructureData, NoneType), optional – The structure at equilibrium volume.
  • supercell_matrix, (List, NoneType), optional – The matrix used to generate the supercell from the input structure in the List format. Allowed shapes are 3x1 and 3x3 lists.
  • symmetry_tolerance, (Float, NoneType), optional – Symmetry tolerance for space group analysis on the input structure.

Outputs:

  • force_constants, ForceConstantsData, optional – The matrix of force constants computed with finite displacements.
  • output_phonopy, Namespace
    • irreducible_representations, Dict, optional – Irreducible representation output.
    • modulation, Dict, optional – Modulation information.
    • output_force_constants, ArrayData, optional – Calculated force constants.
    • output_parameters, Dict, optional – Sum up info of phonopy calculation.
    • phonon_bands, BandsData, optional – Calculated phonon band structure.
    • projected_phonon_dos, XyData, optional – Calculated projected DOS.
    • qpoints, BandsData, optional – Calculated qpoints.
    • qpoints_mesh, BandsData, optional – Calculated qpoint mesh.
    • remote_folder, RemoteData, required – Input files necessary to run the process will be stored in this folder node.
    • remote_stash, RemoteStashData, optional – Contents of the stash.source_list option are stored in this remote folder after job completion.
    • retrieved, FolderData, required – Files that are retrieved by the daemon will be stored in this node. By default the stdout and stderr of the scheduler will be added, but one can add more by specifying them in CalcInfo.retrieve_list.
    • thermal_displacement_matrices, Dict, optional – Calculated thermal displacements matrices.
    • thermal_displacements, Dict, optional – Calculated thermal displacements.
    • thermal_properties, XyData, optional – Calculated thermal properties.
    • total_phonon_dos, XyData, optional – Calculated total DOS.
  • phonopy_data, PhonopyData, optional – The phonopy data with supercells displacements, forces and (optionally)nac parameters to use in the post-processing calculation.
  • supercells, Namespace – The supercells with displacements.
  • supercells_energies, Namespace – The total energy of each supercell.
  • supercells_forces, Namespace – The forces acting on the atoms of each supercell.

Outline:

setup(Set up the workflow generating the PreProcessData.)
run_supercells(Run supercell with displacements.)
run_forces(Run the forces for each supercell.)
inspect_forces(Inspect the calculation of forces for each supercell.)
run_results(Gather the supercell forces and output the results.)
if(should_run_phonopy)
    run_phonopy(Run a `PhonopyCalculation` to get the force constants.)
    inspect_phonopy(Inspect that the `PhonopyCalculation` finished successfully.)