Previous topic

BigDFT.Fragments module

Next topic

The Datasets module

This Page

BigDFT.Calculators module

This module defines some classes to perform a calculation using BigDFT using binding (GIBinding) or using system call (SystemCalculator).

class BigDFT.Calculators.GIBinding[source]

Calculator for BigDFT from Gobject Introspection bindings.

run()[source]
set(inputfile=None)[source]
update(inputfile)[source]
class BigDFT.Calculators.Runner(**kwargs)[source]

Run of something.

Object dealing with global and local options of a run method. All arguments in the __init__ call is stored as global options. For each run, these global options may updated by the arguments of the run call.

get_global_option(key)[source]

Get one key in global options

Parameters:key (string) – the global option key
Returns:The value of the global options labelled by key
global_options()[source]

Get all global options

Returns:The dictionary of the global options in its current status
pop_global_option(key)[source]

Remove a given global option from the global option dictionary

Parameters:key (string) – the global option key
Returns:The value of the global option
post_processing(**kwargs)[source]

Post-processing, take the arguments as they are provided by the process_run.

Returns:The final object that each call to the run method is supposed to provide.
pre_processing()[source]

Pre-treat the keyword arguments and the options, if needed.

Returns:dictionary of the pre-treated keyword arguments that have to be actually considered by process_run.
process_run(**kwargs)[source]

Main item of the runner, defines the information that have to be post_processed by post_processing.

Parameters:**kwargs** (dict) – keyword arguments as returned from the pre_processing() method.
Returns:objects to be passed to post_processing
run(**kwargs)[source]

Run method of the class. It performs the following actions:

  • Constructs the local dictionary to be passed as *kwargs* to the process_run function
  • Calls the pre_processing method (intended to prepare some actions associated to the process_run method
  • Calls process_run
  • Returns the object passed by the call to post_processing class method
update_global_options(**kwargs)[source]

Update the global options by providing keyword arguments.

class BigDFT.Calculators.SystemCalculator(omp='1', mpi_run='', dry_run=False, skip=False, verbose=True)[source]

Bases: BigDFT.Calculators.Runner

Define a BigDFT calculator.

Main calculator of BigDFT code. It performs os.system() calls to the main bigdft executable in the $BIGDFT_ROOT directory. It is designed for two purposes:

  • Run the code in a workstation-based environment, for exemple within notebooks or scripts.
  • Run the code from a python script that is submitted to a batch scheduler in a potnentially large-scale supercomputer.

For triggering the execution, this code gets two variables from the environment:

  • The value of OMP_NUM_THREADS to set the number of OMP_NUM_THREADS. If this variable is not present in the environment, SystemCalculator sets it to the value provided by the omp keyword at initialization.
  • The value of BIGDFT_MPIRUN to define the MPI execution command. If absent, the run is executed simply by $BIGDFT_ROOT/bigdft, followed by the command given by post-processing.
Parameters:
  • omp (int) – number of OpenMP threads. It defaults to the $OMP_NUM_THREADS variable in the environment, if present, otherwise it fixes the run to 1 thread.
  • mpi_run (str) – define the MPI command to be used. It defaults to the value $BIGDFT_MPIRUN of the environment, if present. When using this calculator into a job submission script, the value of $BIGDFT_MPIRUN variable may be set appropriately to launch the bigdft executable.
  • skip (bool) – if True, do not run the calculation if the corresponding logfile exists.
  • verbose (bool) – if True the class prints out informations about the operations that are being performed by the calculator
  • dry_run (bool) – check the input, estimate the memory but do not perform the calculation.
  • dry_mpi (int) – Number of MPI processes for the estimation of the memory when dry_run is True (not yet implemented)
  • taskgroup_size (int) – number of MPI processes of each of the taskgroup in the case of a runs_file.

Warning

At the initialization, SystemCalculator checks if the environment variable $BIGDFT_ROOT is defined. This would mean (although not guarantee) that the environment has been properly set prior to the evaluation of the python command. Also, it checks that the executable file bigdft might be found in the $BIGDFT_ROOT/bigdft path.

Example

>>> inpdict = { 'dft': { 'ixc': 'LDA' }} #a simple input file
>>> study = SystemCalculator(omp=1)
>>> logf = study.run(name="test",input=inpdict)
Executing command:  $BIGDFT_MPIRUN <path_to_$BIGDFT_ROOT>/bigdft test
os = <module 'os' from '/home/docs/checkouts/readthedocs.org/user_builds/pybigdft/envs/latest/lib/python2.7/os.pyc'>
post_processing(timedbg, logname, command)[source]

Check the existence and the log file and return an instance logfile.

Returns:A BigDFT.Logfile class instance associated to the run which has been just performed. If the run failed for some reasons, the logfile seem not existing or it cannot be parsed it returns None.
pre_processing()[source]

Run a calculation building the input file from a dictionary.

Parameters:
  • name (str) – naming scheme of the run i.e. <name>.yaml is the input file and log-<name>.yaml the output one. Data will then be written in the directory data-<name>.yaml, unless the “radical” keyword is specified in the input dictionary.
  • run_dir (str) – specify the directory where bigdft will be executed (the input and log file will be created in it) it must be a simple
  • outdir (str) – specify the output directory for all data coming from bigdft (parameter of bigdft)
  • run_name (str) – File containing the list of the run ids which have to be launched independently (list in yaml format). The option runs-file is not compatible with the name option.
  • input (dict) – give the input parameters (a dictionary or a list of dictionary)
  • posinp (filename) – indicate the posinp file (atomic position file).
Returns:

a Logfile instance is returned. It returns None if an error occurred

Return type:

Logfile

Todo

Set the return value of run in the case of a run_file. It should be a list of Logfile classes

process_run(command)[source]

Finally launch the code.

Routine associated to the running of the bigdft executable.

Parameters:command (str) – the command as it is set by the pre_processing method.
shutil = <module 'shutil' from '/usr/lib/python2.7/shutil.pyc'>