# Example: DRF: scripting tool¶

Download DIMQM_DRF_plams.run

In this example a python script is used for DRF calculations, that uses PLAMS (Python Library for Automating Molecular Simulation). PLAMS takes care of input preparation, job execution, file management and output processing, see also the PLAMS documentation in the Scripting manual. The DRF python script has default settings which can be easily modified if this is required. In the simplest case the user just needs to provide the QM and DRF regions (in xyz format). Typically the user may also want to choose the functional, basis set and numerical quality for the QM and DRF region. By default, atomic charges that are used for the DRF are computed with LDA functional, DZP basis set and normal numerical quality. Also by default, atomic polarizabilities (computed with the Thole’s model) are taken from a inner database including H, C, N, O, F, S, Cl, Br, I atoms [146]. The main program defines a series of functions for general settings for a DRF calculation, reading QM and DRF regions, classifying DRF molecules of the same type (first by formula and then for configurations for a given formula), computing, for a given settings, the charges for a single molecule of unique DRF type and assigning the atomic charges for the rest of molecules that belong to a given DRF type (preserving atom orders).

The DRF python script DIMQM_DRF_plams.py users will probably want to change or extend:

from DIMQM_DRF_plams_module import full_DIMQM_DRF

qm_region_filename = 'qm.xyz'
drf_region_filename = 'drf.xyz'

settings = Settings()
settings.input.Basis.Type = 'TZP'
settings.input.XC['_1'] = 'GGA BLYP'
settings.input.NumericalQuality = 'Normal'

full_DIMQM_DRF(qm_region_filename, drf_region_filename, settings, drf_charges_type='MDC-q charges', drf_fragment_settings=None)


This DRF python script DIMQM_DRF_plams.py imports DIMQM_DRF_plams_module.py, which contains a script full_DIMQM_DRF that splits the DRF region into unique molecules, computes the atomic charges of a single DRF molecule for each unique type, assignes the atomic charges and atomic polarizabilities for all the DRF molecules and defines the QM_DRF settings.

The run script DIMQM_DRF_plams.run contains an example, how one could use the DIMQM_DRF_plams.py script. In this simple example both the QM and DRF region consists of a Formic acid molecule.

cp $ADFHOME/examples/adf/DIMQM_DRF_plams/formic_acid_qm.xyz qm.xyz cp$ADFHOME/examples/adf/DIMQM_DRF_plams/formic_acid_drf.xyz drf.xyz
cp $ADFHOME/examples/adf/DIMQM_DRF_plams/DIMQM_DRF_plams_module.py . cp$ADFHOME/examples/adf/DIMQM_DRF_plams/DIMQM_DRF_plams.py .