This module defines some classes to perform a calculation using BigDFT using binding (GIBinding) or using system call (SystemCalculator).
BigDFT.Calculators.
GIBinding
[source]¶Calculator for BigDFT from Gobject Introspection bindings.
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 theprocess_run
method- Calls
process_run
- Returns the object passed by the call to
post_processing
class method
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 theomp
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: |
|
---|
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: |
|
---|---|
Returns: | a Logfile instance is returned. It returns None if an error occurred |
Return type: |
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'>¶