QeCalculator¶
This module manages calculations performed with QuantumESPRESSO. Actually the run of the computation can be managed by the python subprocess package (direct scheduler) or by the slurm scheduler.
-
class
mppi.Calculators.QeCalculator.QeCalculator(omp=1, mpi=2, mpi_run='mpirun -np', executable='pw.x', scheduler='direct', skip=True, clean_restart=True, verbose=True, **kwargs)[source]¶ Bases:
mppi.Calculators.Runner.RunnerPerform a QuantumESPRESSO calculation. Computations are managed by a scheduler that, in the actual implementation of the class, can be direct or slurm.
- Parameters
omp (
int) – value of the OMP_NUM_THREADS variablempi (
int) – number of mpi processesmpi_run (
string) – command for the execution of mpirun, e.g. ‘mpirun -np’ or ‘mpiexec -np’executable (
string) – set the executable (pw.x, ph.x, ..) of the QuantumESPRESSO packagescheduler (
string) – choose the scheduler used to submit the job, actually the choices implemented are ‘direct’ that runs the computation using the python subprocess package and ‘slurm’ that creates a slurm scriptskip (
bool) – if True evaluate if the computation can be skipped. This is done by checking if the file $prefix.xml is present in the run_dir folderclean_restart (
bool) – if True delete the folder $prefix.save before running the computationverbose (
bool) – set the amount of information provided on terminalkwargs – other parameters that are stored in the _global_options dictionary
Example
>>> code = calculator(omp=1,mpi=4,mpi_run='mpirun -np',skip=True,clean_restart=True,verbose=True,scheduler='direct') >>> code.run(input = ..., run_dir = ...,name = ..., source_dir = ..., **kwargs)
where the arguments of the run method are:
- Parameters
run_dir (
string) – the folder in which the simulation is performedinput (
string) – instance of thePwInputclass that define the input objectname (
string) – string with the name associated to the input file. Usually it is convenient to set the name equal to the prefix of the input object so the name of the input file and the prefix folder built by QuantumESPRESSO are the samesource_dir (
string) – location of the scf source folder for a nscf computation. If present the class copies this folder in the run_dir with the name $prefix.savekwargs – other parameters that are stored in the run_options dictionary
The calculator looks for the following variables in the run_options dictionary. These options may be useful for interacting with the code in particular in _asincronous_ computation managed the slurm scheduler.
dry_run=True with this option the calculator setup the calculations and write the script for submitting the job, but the computations are not run
wait_end_run=False with this option the wait of the end of the run is suppressed
sbatch_options = [option1,option2,….] allows the user to include further options in the slurm script
-
build_slurm_script()[source]¶ Create the slurm script associated to the run.
- Returns
string with the name of the slurm script
- Return type
string
-
is_to_run()[source]¶ The method evaluates if the computation can be skipped. This is done by checking if the file $prefix.xml is already present in the run_dir.
- Returns
the boolean is True if the computation needs to be run
- Return type
bool
-
post_processing()[source]¶ Return the name, including the path, of the data-file-schema.xml file. If the file is absent the method displays a warning.
- Returns
name, including the path, of the xml data-file-schema file
- Return type
string
-
pre_processing()[source]¶ Process local run dictionary to create the run directory and input file. If clean_restart = True the run_dir is cleaned before the run. If the ‘source_dir’ key is passed to the run method copy the source folder in the run_dir with the name $prefix.
-
process_run()[source]¶ Method associated to the running of the executable. The method runs the computation and wait the end of the computation before passing to the
post_processing()method.
-
run_command()[source]¶ Define the run command used to run the computation. The value of the command depends on the chosen scheduler.
- Returns
command that runs the computation
- Return type
string
-
run_ended(job)[source]¶ Check the status of the running job.
- Parameters
job – reference to the actual job. job is an istance of Popen for direct scheduler or a string for slurm scheduler
- Returns
return True if the computation is ended and False if it is running
- Return type
bool
-
run_job()[source]¶ Run the computation. The operations performed depend on the scheduler adopted. If the dry_run option is enabled the run is not performed but the slurm script is written on disk.
- Returns
The type of the object depends on the chosen scheduler. For scheduler direct job is an instance of Popen, while for slurm scheduler job is the name of the slurm script.
-
wait(job)[source]¶ Wait the end of the job. If the dry_run option is enabled or wait_end_run is False the check is not performed.
- Parameters
jobs – The reference to the job to be executed. If the scheduler is direct jobs is an instance of Popen of the :py:class:subprocess package. If the scheduler is slurm jobs is a string with the name of the slurm script