Tools

This module contains some functions that implement useful operations to deal with the Yambo and QuantumESPRESSO calculators. The module can be loaded in the notebook in one of the following way

>>> from mppi.Utilities import Tools
>>> Tools.init_yambo_run_dir

or as

>>> import mppi.Utilities.Tools
>>> Tools.init_yambo_run_dir

or to load directly some elements

>>> from mppi.Utilities.Tools import init_yambo_run_dir
>>> init_yambo_run_dir
mppi.Calculators.Tools.build_FixSymm_input(run_dir, polarization='linear', Efield1=[1.0, 0.0, 0.0], Efield2=[0.0, 1.0, 0.0], removeTimeReversal=True)[source]

Create the input file for the fixSymm procedure to remove the symmetries broken by the electric field.

Parameters:
  • run_dir (string) – folder with the SAVE directory

  • polarization (string) – specifies the linear or circular polarization of the field

  • Efield1 (list) – direction of the first electric field

  • Efield2 (list) – direction of the second electric field. Useful for the circular polarization case

  • removeTimeReversal (bool) – if True remove the time reversal symmetry

mppi.Calculators.Tools.build_pw_klist(kpoints, kweight=None)[source]

Build a list of kpoints with the structure [[k1_x,k1_y,k1_z,w1],…[kn_x,kn_y,kn_z,wn]], where wi is the weight of the i-th kpoint.

Parameters:
  • kpoints (array) – array with the coordinates of the kpoints

  • kweight (list) – array with the weigth of each kpoint. If is None a uniform weight equal to 1 is attributed to each kpoint

Returns:

list of kpoints with the structure [[k1_x,k1_y,k1_z,w1],…[kn_x,kn_y,kn_z,wn]]

Return type:

list

mppi.Calculators.Tools.build_pw_kpath(*kpoints, numstep=40)[source]

Build a list of kpoints to be passed to the set_kpoints methods of the PwInput for computing the band structure along a path.

Example

>>> build_kpath(L,G,X,K,G,numstep=30)
Parameters:
  • kpoints – arguments that specify the high symmetry points along the k-path

  • numstep (int) – specifies the number of intermediate points used to build the path

Returns:

list of kpoints as nedded by pw in the bands computation with the tpiba_b option

Return type:

list

mppi.Calculators.Tools.build_r_setup(yambo_dir='./', overwrite_if_found=False, yambo_command='yambo')[source]

Create the r_setup file by executing the yambo_command in the yambo_dir. If an instance of the r_setup file is found do not perform any operation unless the overwrite_if_found option is True.

Parameters:
  • yambo_dir (string) – location of the yambo_dir

  • overwrite_if_found (bool) – if True clean the yambo_dir

  • yambo_command (string) – command for generation the r_setup file. Default is ‘yambo’

mppi.Calculators.Tools.find_string_file(file, string)[source]

Look for a string in the lines of a file.

Parameters:
  • file (string) – name of the file, including the path

  • string (string) – name of the string

Returns:

return the first occurence of the line that match the search. If no line is found or the file does not exsists return None

Return type:

string

mppi.Calculators.Tools.init_yambo_dir(yambo_dir='.', input_dir='./', overwrite_if_found=False, p2y_command='p2y', yambo_command='yambo')[source]

Create and initialize the run directory where Yambo computations can be performed. The function runs the make_p2y and build_r_setup function of the module.

Parameters:
  • yambo_dir (string) – location of the yambo_dir, it can be a nested directory path and if the path is not found is created by the function using the os.makedirs()

  • input_dir (string) – name of the folder with the PW wave functions

  • make_link (bool) – if True create a symbolic link of the SAVE folder, otherwise the SAVE folder is copied in the run_dir

  • overwrite_if_found (bool) – if True delete the SAVE folder in the run_dir and the r_setup and l_setup (if found) and build them again (also the ‘yambo.in’ input file is deleted to build the r_setup file)

  • p2y_command (string) – command for execution of the p2y program. Default is ‘p2y’

  • yambo_command (string) – command for generation the r_setup file. Default is ‘yambo’

mppi.Calculators.Tools.make_p2y(yambo_dir='./', input_dir='./', overwrite_if_found=False, p2y_command='p2y')[source]

Run p2y in the yambo_dir using the PW wave functions. The function creates the SAVE Folder using the command provided as the p2y_command parameter.

cd $yambo_dir; $p2y_command -I $input_dir

If the yambo_dir does not exists it is built by the function. If a SAVE folder is already found in the yambo_dir no operations are performed, unless the overwrite_if_found option is True.

Parameters:
  • yambo_dir (string) – location of the yambo_dir, it can be a nested directory path and if the path is not found is created by the function using the os.makedirs()

  • input_dir (string) – name of the folder with the PW wave functions

  • overwrite_if_found (bool) – if True delete the SAVE folder

  • p2y_command (string) – command for execution of the p2y program. Default is ‘p2y’