[1]:
# useful to autoreload the module without restarting the kernel
%load_ext autoreload
%autoreload 2
[2]:
from mppi import InputFiles as I, Utilities as U

Tutorial for the YamboInput class

Follow the tutorial for the QeCalculator to produce the .save folder needed to generate the yambo SAVE.

This tutorial describes the main features and the usage of the YamboInput class that enables us to create and manage the input files for the yambo computations

We choose a folder that contain a yambo SAVE folder so that yambo can be executed. The generation of the SAVE folder from a pw computation is performed by a function of the Utils module in the and is described in the tutorial for the YamboCalculator class.

[3]:
source_dir = 'QeCalculator_test/bands_12.save'
run_dir = 'YamboCalculator_test'
[4]:
U.build_SAVE(source_dir,run_dir)
Create folder YamboCalculator_test
Executing command: cd QeCalculator_test/bands_12.save; p2y -a 2
Create a symlink of /home/marco/Applications/MPPI/sphinx_source/tutorials/QeCalculator_test/bands_12.save/SAVE in YamboCalculator_test
Executing command: cd YamboCalculator_test;OMP_NUM_THREADS=1 yambo

The main usage of YamboInput is as follows

[7]:
inp = I.YamboInput(args='yambo -d -k hartree -g n -p p',folder=run_dir,filename='yambo_test.in')

where the content of args specifies the selected yambo runlevel.

In this way yambo has run with the chose arguments and the file filename has been written on disk. The inp object is a python dictionary that contains all the elements of the file

[8]:
inp
[8]:
{'args': 'yambo -d -k hartree -g n -p p',
 'folder': 'YamboCalculator_test',
 'filename': 'yambo_test.in',
 'arguments': ['em1d', 'gw0', 'HF_and_locXC', 'ppa'],
 'variables': {'X_Threads': [0.0, ''],
  'DIP_Threads': [0.0, ''],
  'SE_Threads': [0.0, ''],
  'EXXRLvcs': [9377.0, 'RL'],
  'VXCRLvcs': [9377.0, 'RL'],
  'NGsBlkXp': [1.0, 'RL'],
  'PPAPntXp': [27.21138, 'eV'],
  'GWoIter': [0.0, ''],
  'GWIter': [0.0, ''],
  'Chimod': 'HARTREE',
  'XTermKind': 'none',
  'GTermKind': 'none',
  'DysSolver': 'n',
  'BndsRnXp': [[1, 12], ''],
  'LongDrXp': [[1.0, 0.0, 0.0], ''],
  'GbndRnge': [[1, 12], ''],
  'QPkrange': [[1, 32, 1, 12], '']}}

Alternatively, inp can be initialized using a yambo input file. In this way yambo do not run and the presence of the SAVE folder is not needed. This options may be useful, for instance, for managing the yambo input when the SAVE folder is on a remote computer.

[9]:
inp2 = I.YamboInput(folder=run_dir,filename='yambo_test.in')
inp2
[9]:
{'args': '',
 'folder': 'YamboCalculator_test',
 'filename': 'yambo_test.in',
 'arguments': ['em1d', 'gw0', 'HF_and_locXC', 'ppa'],
 'variables': {'X_Threads': [0.0, ''],
  'DIP_Threads': [0.0, ''],
  'SE_Threads': [0.0, ''],
  'EXXRLvcs': [9377.0, 'RL'],
  'VXCRLvcs': [9377.0, 'RL'],
  'NGsBlkXp': [1.0, 'RL'],
  'PPAPntXp': [27.21138, 'eV'],
  'GWoIter': [0.0, ''],
  'GWIter': [0.0, ''],
  'Chimod': 'HARTREE',
  'XTermKind': 'none',
  'GTermKind': 'none',
  'DysSolver': 'n',
  'BndsRnXp': [[1, 12], ''],
  'LongDrXp': [[1.0, 0.0, 0.0], ''],
  'GbndRnge': [[1, 12], ''],
  'QPkrange': [[1, 32, 1, 12], '']}}

The input dictionary can be modified as needed, for instance

[10]:
updated = dict()
updated['QPkrange'] = [[1,32,1,6],'']
inp['variables'].update(updated)
[11]:
inp
[11]:
{'args': 'yambo -d -k hartree -g n -p p',
 'folder': 'YamboCalculator_test',
 'filename': 'yambo_test.in',
 'arguments': ['em1d', 'gw0', 'HF_and_locXC', 'ppa'],
 'variables': {'X_Threads': [0.0, ''],
  'DIP_Threads': [0.0, ''],
  'SE_Threads': [0.0, ''],
  'EXXRLvcs': [9377.0, 'RL'],
  'VXCRLvcs': [9377.0, 'RL'],
  'NGsBlkXp': [1.0, 'RL'],
  'PPAPntXp': [27.21138, 'eV'],
  'GWoIter': [0.0, ''],
  'GWIter': [0.0, ''],
  'Chimod': 'HARTREE',
  'XTermKind': 'none',
  'GTermKind': 'none',
  'DysSolver': 'n',
  'BndsRnXp': [[1, 12], ''],
  'LongDrXp': [[1.0, 0.0, 0.0], ''],
  'GbndRnge': [[1, 12], ''],
  'QPkrange': [[1, 32, 1, 6], '']}}

Specific methods that modify some parameteres are provided, for instance

[12]:
inp.set_kRange(1,2)
inp.set_bandRange(6,8)
inp.set_GbndRange(4,8)
inp.set_BndsRnXp(2,8)
inp
[12]:
{'args': 'yambo -d -k hartree -g n -p p',
 'folder': 'YamboCalculator_test',
 'filename': 'yambo_test.in',
 'arguments': ['em1d', 'gw0', 'HF_and_locXC', 'ppa'],
 'variables': {'X_Threads': [0.0, ''],
  'DIP_Threads': [0.0, ''],
  'SE_Threads': [0.0, ''],
  'EXXRLvcs': [9377.0, 'RL'],
  'VXCRLvcs': [9377.0, 'RL'],
  'NGsBlkXp': [1.0, 'RL'],
  'PPAPntXp': [27.21138, 'eV'],
  'GWoIter': [0.0, ''],
  'GWIter': [0.0, ''],
  'Chimod': 'HARTREE',
  'XTermKind': 'none',
  'GTermKind': 'none',
  'DysSolver': 'n',
  'BndsRnXp': [[2, 8], ''],
  'LongDrXp': [[1.0, 0.0, 0.0], ''],
  'GbndRnge': [[4, 8], ''],
  'QPkrange': [[1, 2, 6, 8], '']}}

Lastly,the yambo input is written again on file with the write method of the class.

[13]:
inp.write(inp['folder'],'yambo_test_modified.in',reformat=True)

The inp written on file can be exectued by yambo but loose part of its original format. The reformat option, that is True by default, run yambo with the proper args to recover the format of the original input file. This option is only active if args is no empty.

Generation of a ypp input file

The same class can manage the input for a ypp computation, for instance for computing the band structure along a path

[14]:
inp = I.YamboInput(args='ypp -s b',folder=run_dir,filename='ypp_test.in')
inp
[14]:
{'args': 'ypp -s b',
 'folder': 'YamboCalculator_test',
 'filename': 'ypp_test.in',
 'arguments': [],
 'variables': {'OutputAlat': [0.0, ''],
  'INTERP_Shell_Fac': [20.0, ''],
  'INTERP_NofNN': [1.0, ''],
  'BANDS_steps': [10.0, ''],
  'INTERP_mode': 'NN',
  'cooIn': 'rlu',
  'cooOut': 'rlu',
  'CIRCUIT_E_DB_path': 'none',
  'PROJECT_mode': 'none',
  'BANDS_bands': [[1, 12], '']}}

The object can be modified and written again on file

[25]:
inp['variables']['BANDS_bands'] = [[4,8],'']
inp
[25]:
{'args': 'ypp -s b',
 'folder': 'YamboCalculator_test',
 'filename': 'ypp_test.in',
 'arguments': [],
 'variables': {'OutputAlat': [10.3, ''],
  'INTERP_Shell_Fac': [20.0, ''],
  'BANDS_steps': [10.0, ''],
  'INTERP_mode': 'NN',
  'cooIn': 'rlu',
  'cooOut': 'rlu',
  'CIRCUIT_E_DB_path': 'none',
  'BANDS_bands': [[4, 8], ''],
  'INTERP_Grid': [['-1', '-1', '-1'], ''],
  'BANDS_kpts': [[''], '']}}
[26]:
inp.write(inp['folder'],'ypp_test_modified.in',reformat=True)
[ ]: