EPWpy.EPWpy_prepare#

Classes

PyPrepare(prefix, pseudo[, files])

The PyPrepare class handles setup tasks required before running EPW or related first-principles simulations.

class EPWpy.EPWpy_prepare.PyPrepare(prefix, pseudo, files=None)[source]#

Bases: SetDir

The PyPrepare class handles setup tasks required before running EPW or related first-principles simulations. It inherits from SetDir and is mainly responsible for preparing and transferring necessary files (e.g., pseudopotentials, input decks) to the working directory.

This class is typically used internally by PyRun, but it can also be invoked independently for pre-processing or file management tasks.

Attributes#

prefixstr

Name prefix used for input/output files and working directories.

pseudostr

Path to the pseudopotential directory or file.

fileslist of str

List of files to be transferred or linked for the run.

folder_namestr

Name of the folder where files will be prepared (default: 'dummy').

dolinkbool

Whether to create symbolic links instead of copying files (default: False).

decorated_save()[source]#

Saves state

Create a symbolic link from infile to outfile.

This method either writes the ln -sf command to a script if script-writing mode is enabled, or executes it immediately in the shell.

Parameters:
  • infile (str) -- Path to the source file.

  • outfile (str) -- Path where the symbolic link will be created.

Example

>>> link("path/to/source.save", "./epw_run/source.save")
pp()[source]#
prepare_abinit(name='abinit', filename='abi.abi')[source]#

Prepares an Abinit calculation

prepare_bands(name='bs', filename='bands.in')[source]#

Prepare a bandstructure (BANDS) calculation directory.

Copies the BANDS input file into the specified folder.

Parameters:
  • name (str, optional) -- Target directory (default: "bs").

  • filename (str, optional) -- Input file name (default: "bands.in").

Example

>>> prepare_bands(name="bs_run", filename="si.bands.in")
prepare_bs(name='bs', filename='bs.in')[source]#

Prepare a bandstructure (BS) calculation directory.

This method sets up the folder structure and transfers necessary input files for a bandstructure calculation. It uses the same workflow as prepare_post_scf(), ensuring that required SCF outputs are available for the BS run.

Parameters:
  • name (str, optional) -- Name of the directory for the bandstructure calculation (default: "bs").

  • filename (str, optional) -- Name of the bandstructure input file to copy (default: "bs.in").

  • Workflow

  • --------

  • files. (1. Calls prepare_post_scf() to create the directory and transfer)

  • calculation. (2. Ensures SCF outputs and BS input are in place for the)

Notes

  • Assumes that a corresponding SCF calculation has already been completed.

  • This setup is necessary for proper bandstructure analysis.

Example

>>> prepare_bs(name="bs_run", filename="si.bs.in")
prepare_custom(name='custom', filename='custom.in')[source]#

Prepare a custom calculation directory and transfer input files.

This method sets up a folder for a custom calculation and copies the necessary input files to that directory. It can be used for any calculation type where the inputs are not standard SCF/EPW workflows.

Parameters:
  • name (str, optional) -- Name of the directory to create for the custom calculation (default: "custom").

  • filename (str, optional) -- Name of the input file to copy into the custom directory (default: "custom.in").

  • Workflow

  • --------

  • makedir(). (1. Creates a new directory name via)

  • file_transfer=[]. (2. Transfers required files using run_transfer(name); these are provided through)

  • run(). (3. Copies the specified input file into the new directory using)

Notes

  • Useful for setting up calculations that do not follow the standard SCF/EPW workflow.

  • Ensures the folder structure is ready for independent runs.

Example

>>> prepare_custom(name="my_custom_calc", filename="my_input.in")
prepare_dos(name='nscf', filename='dos.in')[source]#

Prepares a dos calculation

prepare_dummy()[source]#

Prepares a dummy run on any type

prepare_dvscf_q2r(name='ph', filename='dvscf_q2r.in')[source]#

Prepare a dvscf_q2r calculation directory.

Copies the dvscf_q2r input file into the specified folder.

Parameters:
  • name (str, optional) -- Target directory (default: "ph").

  • filename (str, optional) -- Input file name (default: "dvscf_q2r.in").

Example

>>> prepare_dvscf_q2r(name="ph_run", filename="si.dvscf_q2r.in")
prepare_dynmat(name='ph', filename='dynmat.in')[source]#

Prepare a dynmat calculation directory.

Copies the dynmat input file into the specified folder.

Parameters:
  • name (str, optional) -- Target directory (default: "ph").

  • filename (str, optional) -- Input file name (default: "dynmat.in").

Example

>>> prepare_dynmat(name="ph_run", filename="si.dynmat.in")
prepare_eps(name='eps', filename='eps.in')[source]#

Prepare an epsilon.x calculation directory for QE.

Transfers the NSCF outputs and wavefunction files required for dielectric function calculations using epsilon.x.

Parameters:
  • name (str, optional) -- Target directory for the epsilon calculation (default: "eps").

  • filename (str, optional) -- Input file for epsilon.x (default: "eps.in").

  • Workflow

  • --------

  • directory. (1. Creates the target)

  • files. (2. Transfers NSCF save folder and wavefunction)

  • file. (3. Copies the epsilon input)

Example

>>> prepare_eps(name="eps_run", filename="si.eps.in")
prepare_epw1(name='epw', filename='epw1.in')[source]#

Prepare EPW coarse-grid (epw1) calculation directory.

Sets up the folder for the first EPW step using coarse k/q grids. Transfers necessary NSCF and phonon outputs, copies the EPW input file, and optionally performs post-processing.

Parameters:
  • name (str, optional) -- Target directory for the EPW calculation (default: "epw").

  • filename (str, optional) -- Input file for EPW step 1 (default: "epw1.in").

  • Workflow

  • --------

  • exist. (1. Creates the directory if it doesn’t)

  • directory (2. Transfers NSCF .save folder and phonon _ph0)

  • dolink=True. (or links them if)

  • folder. (3. Copies dynamical matrices from the PH)

  • file. (4. Copies the EPW input)

  • (pp()). (5. Transfers additional files and runs post-processing)

Example

>>> prepare_epw1(name="epw_run", filename="si.epw1.in")
prepare_epw2(name='epw', filename='epw2.in')[source]#

Prepare EPW second-step (interpolated) calculation directory.

Sets up the EPW coarse-to-fine interpolation step by transferring necessary files from the previous EPW calculation and copying the step 2 input file.

Parameters:
  • name (str, optional) -- Target directory for the EPW calculation (default: "epw").

  • filename (str, optional) -- Input file for EPW step 2 (default: "epw2.in").

  • Workflow

  • --------

  • calculation. (1. Transfers files from the previous EPW)

  • directory. (2. Copies the EPW step 2 input file into the target)

Example

>>> prepare_epw2(name="epw_run", filename="si.epw2.in")
prepare_epw3(name='epw', filename='epw3.in')[source]#

Prepare EPW third-step calculation directory.

Sets up the final EPW calculation step, typically for computing properties on dense k/q grids. Transfers files from the previous EPW step and copies the step 3 input file.

Parameters:
  • name (str, optional) -- Target directory for the EPW calculation (default: "epw").

  • filename (str, optional) -- Input file for EPW step 3 (default: "epw3.in").

  • Workflow

  • --------

  • calculation. (1. Transfers files from the previous EPW)

  • directory. (2. Copies the EPW step 3 input file into the target)

Example

>>> prepare_epw3(name="epw_run", filename="si.epw3.in")
prepare_fbw(name='fbw', filename='fbw.in')[source]#

Prepares FBW calculation

prepare_fbw_mu(name='fbw_mu', filename='fbw_mu.in')[source]#

Prepares fbw mu calculation

prepare_matdyn(name='ph', filename='matdyn.in')[source]#

Prepare a matdyn calculation directory.

Copies the matdyn input file into the specified folder.

Parameters:
  • name (str, optional) -- Target directory (default: "ph").

  • filename (str, optional) -- Input file name (default: "matdyn.in").

Example

>>> prepare_matdyn(name="ph_run", filename="si.matdyn.in")
prepare_nesting(name='nesting', filename='nesting.in')[source]#

Prepares nesting calculation

prepare_nscf(name='nscf', filename='nscf.in')[source]#

Prepare a non-self-consistent field (NSCF) calculation directory.

This method sets up the folder structure and transfers necessary input files for an NSCF calculation. It uses the same workflow as prepare_post_scf(), ensuring that the required SCF outputs are available for the NSCF run.

Parameters:
  • name (str, optional) -- Name of the directory for the NSCF calculation (default: "nscf").

  • filename (str, optional) -- Name of the NSCF input file to copy (default: "nscf.in").

  • Workflow

  • --------

  • files. (1. Calls prepare_post_scf() to create the directory and transfer)

  • calculation. (2. Ensures SCF outputs and NSCF input are in place for the)

Notes

  • Assumes that the corresponding SCF calculation has already been completed.

  • This setup is required for proper NSCF or bandstructure calculations.

Example

>>> prepare_nscf(name="nscf_run", filename="si.nscf.in")
prepare_nscf2supercond(name='nscf', filename='nscf2supercond.in')[source]#

Prepares an nscf2supercond calculation

prepare_nscf_tetra(name='nscf_tetra', filename='nscf.in')[source]#

Prepares a nscf tetragonal calculation

prepare_outerbands(name='epw_outerbands', filename='epw_outerbands.in')[source]#

Prepares outerbands calculation

prepare_pdos(name='nscf', filename='pdos.in')[source]#

Prepares a pdos calculation

prepare_ph(name='ph', filename='ph.in')[source]#

Prepare a phonon (PH) calculation directory.

This method sets up the folder structure and transfers necessary input files for a phonon calculation. It uses the same workflow as prepare_post_scf(), ensuring that required SCF outputs are available for the phonon run.

Parameters:
  • name (str, optional) -- Name of the directory for the phonon calculation (default: "ph").

  • filename (str, optional) -- Name of the phonon input file to copy (default: "ph.in").

  • Workflow

  • --------

  • files. (1. Calls prepare_post_scf() to create the directory and transfer)

  • calculation. (2. Ensures SCF outputs and PH input are in place for the)

Notes

  • Assumes that a corresponding SCF calculation has already been completed.

  • Necessary for running phonon calculations using Quantum ESPRESSO.

Example

>>> prepare_ph(name="ph_run", filename="si.ph.in")
prepare_phdos(name='ph', filename='phdos.in')[source]#

Prepares a phdos calculation

prepare_phselfen(name='phselfen', filename='phselfen.in')[source]#

Prepares phselfen calculation

prepare_post_epw(name, filename)[source]#

Prepares a post epw calculation outside epw folder

prepare_post_epw2(name, filename)[source]#

Prepares a post epw calculation outside epw folder

prepare_post_scf(name, filename)[source]#

Prepare the post-SCF environment for EPW calculations.

This method sets up the necessary folder structure and transfers required files from a completed SCF calculation to a new working directory for subsequent EPW workflows.

Parameters:
  • name (str) -- Name of the target directory where post-SCF files will be prepared.

  • filename (str) -- Name of the input file or folder to be copied for the particular calculation.

  • Workflow

  • --------

  • makedir(). (1. Creates a new directory name via)

  • run_transfer(name). (2. Transfers essential files using)

  • run(). (3. Copies the specified SCF output or folder to the new directory using)

  • directory. (4. Ensures the SCF save folder ({prefix}.save) is available in the post-SCF)

Notes

  • Assumes that a standard SCF calculation has already been completed.

  • This step is necessary to prepare the input files and folder structure for EPW or further post-processing calculations.

Example

>>> prepare_post_scf(name="epw_workdir", filename="si.scf.out")
prepare_postahc(name='ph', filename='postahc.in')[source]#

Prepare a postahc calculation directory.

Copies the postahc input file into the specified folder.

Parameters:
  • name (str, optional) -- Target directory (default: "ph").

  • filename (str, optional) -- Input file name (default: "postahc.in").

Example

>>> prepare_postahc(name="ph_run", filename="si.postahc.in")
prepare_pp(name='pp', filename='pp.in')[source]#

Prepare a post-processing (PP) calculation directory.

Copies the PP input file into the specified directory.

Parameters:
  • name (str, optional) -- Target directory name (default: "pp").

  • filename (str, optional) -- PP input file name (default: "pp.in").

Example

>>> prepare_pp(name="pp_run", filename="si.pp.in")
prepare_q2r(name='ph', filename='q2r.in')[source]#

Prepare a q2r calculation directory.

Copies the q2r input file into the specified folder.

Parameters:
  • name (str, optional) -- Target directory (default: "ph").

  • filename (str, optional) -- Input file name (default: "q2r.in").

Example

>>> prepare_q2r(name="ph_run", filename="si.q2r.in")
prepare_scf(name='scf', filename='scf.in')[source]#

Prepare a self-consistent field (SCF) calculation directory.

This method creates a folder for an SCF calculation and copies the SCF input file into that directory. It ensures the directory structure is ready for running Quantum ESPRESSO SCF calculations.

Parameters:
  • name (str, optional) -- Name of the directory to create for the SCF calculation (default: "scf").

  • filename (str, optional) -- Name of the SCF input file to copy (default: "scf.in").

  • Workflow

  • --------

  • makedir(). (1. Creates the SCF directory using)

  • run(). (2. Copies the specified input file into the SCF directory using)

Notes

  • Assumes the SCF input file exists in the current working directory.

  • This setup is a prerequisite for performing SCF calculations.

Example

>>> prepare_scf(name="scf_run", filename="si.scf.in")
prepare_vasp(name='vasp', filename='INCAR', structure='POSCAR')[source]#

Prepares an Abinit calculation

prepare_vasp_nscf(name='bands', filename='INCAR', name_vasp='vasp', structure='POSCAR')[source]#

Prepares an Abinit calculation

prepare_wannier(name='wannier', filename='')[source]#

Prepares Wannier files

prepare_zg(name='zg', filename='zg.in')[source]#

Prepare a ZG calculation directory.

This method sets up the folder and transfers all necessary input files for a ZG calculation, including SCF outputs, phonon dynamical matrices, force constants, and any additional files required.

Parameters:
  • name (str, optional) -- Target directory for the ZG calculation (default: "zg").

  • filename (str, optional) -- ZG input file name (default: "zg.in").

  • Workflow

  • --------

  • exist. (1. Creates the directory if it doesn't)

  • calculations. (2. Transfers files from previous SCF and PH)

  • file. (3. Copies the specified ZG input)

Example

>>> prepare_zg(name="zg_run", filename="si.zg.in")
run(infile, outfile)[source]#

Execute the main preparation step by copying or linking files.

This method handles the transfer of input files required for a given EPW or Quantum ESPRESSO calculation. Depending on whether symbolic linking is enabled (dolink), the method either copies the files or creates symbolic links.

If script writing is enabled (i.e., self.writer.script_params['write_script'] == True), the corresponding shell command is written to the run script instead of being executed immediately.

Parameters#

infilestr

Path to the input file or directory to be copied or linked.

outfilestr

Destination path or filename for the prepared file.

Behavior#

  • If dolink is False → performs a deep copy using cp -r.

  • If dolink is True → creates a symbolic link in the current working directory.

  • If self.writer.script_params['write_script'] is enabled, the copy/link command is written to the script instead of being executed.

Examples#

>>> prep = PyPrepare(prefix='si', pseudo='Si.pz-vbc.UPF')
>>> prep.run('scf.in', 'workdir/scf.in')

This copies scf.in into the working directory.

run_transfer(name)[source]#

Transfer a list of files into a specified directory.

Iterates over the self.files list and copies each non-None file into the target directory using the class's run method.

Parameters:

name (str) -- Target directory where files should be copied.

Example

>>> run_transfer("epw_run")