CP2K I/O and driver

Module contents for quippy.cp2k:

Classes

CP2KPotential([fpointer, finalise, error]) QUIP Potential interface to the CP2K code.
CP2KInputHeader([filename]) Read a cp2k_input.inp.header file and parse into an ordered dictionary.

Functions

read_cp2k_qm_kind(fh) Read a file in cp2k_input.qmmm_qm_kind
read_psf(psf[, rev_sort_index]) Read the PSF topology file from the filename psf.
apply_cp2k_sort_order(at[, ...]) Reorder atoms in at so that they match rev_sort_index read from file.
bonds_from_avgpos(at) Compute connectivity of at using avgpos positions.
qmmm_link_bonds(at[, run_suffix]) Return the set of QM/MM link bonds in at.
class quippy.cp2k.CP2KPotential(fpointer=None, finalise=True, error=None)[source]

Bases: quippy.potential.Potential

QUIP Potential interface to the CP2K code.

Calls do_cp2k_calc() in QUIP_FilePot_Drivers/cp2k_driver_module.f95 to do the heavy lifting

class quippy.cp2k.CP2KInputHeader(filename=None)[source]

Bases: quippy.ordereddict.OrderedDict

Read a cp2k_input.inp.header file and parse into an ordered dictionary.

quippy.cp2k.read_cp2k_qm_kind(fh)[source]

Read a file in cp2k_input.qmmm_qm_kind

This is the format produced by the QUIP cp2k_driver. Returns a list of tuples (qm_kind, atom_indices).

quippy.cp2k.read_psf(psf, rev_sort_index=None)[source]

Read the PSF topology file from the filename psf.

Returns a pair of lists (bonds, angles). bonds is a list of pairs of bonded atom indices (i, j) and angles is a list of triplets (i, j, k). Order is same as that in PSF file

quippy.cp2k.apply_cp2k_sort_order(at, rev_sort_index_filename='quip_rev_sort_index')[source]

Reorder atoms in at so that they match rev_sort_index read from file.

Returns sort_index and rev_sort_index arrays.

quippy.cp2k.bonds_from_avgpos(at)[source]

Compute connectivity of at using avgpos positions.

A copy of at is made to avoid changing its connect object. Returns list of bonds as a set.

Return the set of QM/MM link bonds in at.

Bonds are computed from average positions using bonds_from_avgpos(). run_suffix is used to find the relevant cluster_mark property.

guts of cp2k driver from template

Module contents for quippy.cp2k_driver:

Functions

calc_charge_lsd(...)
Parameters:
do_cp2k_calc(at,args_str,n0,n1,[error])

args_str options

read_output(...)
Parameters:
cp2k_state_change(...)
Parameters:
qmmm_qm_abc(at,qm_list_a,qm_vacuum)
Parameters:
quippy.cp2k_driver.calc_charge_lsd(at, qm_list_a, n_hydrogen, hydrogen_charge, n_extra_electrons, use_mm_charges[, error])
Parameters:

at : Atoms object

qm_list_a : input rank-1 array(‘i’) with bounds (qp_n0)

charge : int

do_lsd : int

n_hydrogen : input int

hydrogen_charge : input float

n_extra_electrons : input int

use_mm_charges : input int

error : in/output rank-0 array(int,’i’), optional

References

Routine is wrapper around Fortran routine calc_charge_lsd defined in file src/FilePot_drivers/cp2k_driver_module.f95.

quippy.cp2k_driver.do_cp2k_calc(at, args_str, n0, n1[, error])

args_str options

Name Type Default Comments
MM_param_file str None If tmp_run_dir>0, where to find MM parameter file to copy it to the cp2k run dir on /tmp.
PSF_print str NO_PSF When to print PSF file: NO_PSF, DRIVER_PRINT_AND_SAVE, USE_EXISTING_PSF
QM_basis_file str None If tmp_run_dir>0, where to find QM BASIS_SET file to copy it to the cp2k run dir on /tmp.
QM_potential_file str None If tmp_run_dir>0, where to find QM POTENTIAL file to copy it to the cp2k run dir on /tmp.
Run_Type str PARAM_MANDATORY Type of run QS, MM, or QMMM
auto_centre bool False If true, automatically center configuration. May cause energy/force fluctuations. Mutually exclusive with centre_pos
break_bond int 0 0 Bond to break (for EVB)
centre_pos float 0.0 0.0 0.0 Position to center around, mutually exclusive with auto_centre
clean_up_files bool True If true, clean up run directory files
clean_up_keep_n int 1 Number of old run directories to keep if cleaning up
cp2k_calc_fake bool False If true, do fake cp2k runs that just read from old output files
cp2k_program str PARAM_MANDATORY Path to cp2k executable
cp2k_template_file str cp2k_input.template Filename for cp2k input template
create_residue_labels bool True If true, recreate residue labels each time PSF file is generated (default T)
do_mom_cons bool True Do we need momentum conservation?
force_run_dir_i int -1 If > 0, force to run in this # run directory
form_bond int 0 0 Extra bond to form (for EVB)
have_silica_potential bool False If true, use 2.8A SILICA_CUTOFF for the connectivities
have_titania_potential bool False If true, use 2.8A TITANIA_CUTOFF for the connectivities
max_force_warning float 2.0 Generate warning if any force is larger than this
max_n_tries int 2 Max number of times to run cp2k on failure
persistent bool False If true, use persistent connection to cp2k with REFTRAJ
persistent_max_wait_time float 600.0 Max amount of time in s to wait for forces to be available in persistent mode
persistent_restart_interval int 100 How often to restart cp2k for persistent connection
qm_charges str None If not blank, name of property to put QM charges in
qm_vacuum float 6.0 Amount of vacuum to add to size of qm region in hybrid (and nonperiodic?) runs
qmmm_link_fix_pbc bool True If true (default) move outer atoms in any QM links which straddle a periodic boundary so link is continous
qmmm_link_n_electrons int 1 Number of electrons to add per QM-MM link when qmmm_link_type=QM_KIND
qmmm_link_qm_kind str OSTAR QM kind to use for inner boundary atoms when qmmm_link_type=QM_KIND
qmmm_link_qm_kind_z int 8 Atomic number of QM_KIND species (default 8)
qmmm_link_template_file str None Filename for cp2k link atoms template file
qmmm_link_type str IMOMM Type of QMMM links to create: one of IMOMM, PSEUDO or QM_KIND. Default IMOMM
qmmm_same_lattice bool False If true, use full original MM lattice for QM calculation
qmmm_use_mm_charges bool True If true (default) use classical point charges of atoms in QM region to calculate total DFT charge
remove_Si_H_silica_bonds bool True If true (default) remove any Si-H bonds detected in silica residue
remove_Ti_H_titania_bonds bool True If true (default) remove any Ti-H bonds detected in titania residue
res_num_silica int 1 Residue number for silica residue
run_suffix str None String to append to various marks and saved info to indicate distinct sets of calculations or QM/MM QM regions
save_output_files bool True If true, save the output files
save_output_wfn_files bool False If true, save output wavefunction files
silica_add_23_body bool True If true and if have_silica_potential is true, add bonds for silica 2- and 3-body terms to PSF
silica_charge_transfer float 2.4 Amount of charge transferred from Si to O in silica bulk, per formula unit
silica_pos_dep_charges bool True If true and if have_silica_potential is true, use variable charges for silicon and oxygen ions in silica residue
tmp_run_dir_i int -1 If >0, the cp2k run directory will be /tmp/cp2k_run_$tmp_run_dir_i$, and all input files are also copied here when first called
topology_suffix str None String to append to file containing topology info (for runs that do multiple topologies not to accidentally reuse PSF file
try_reuse_wfn bool True If true, try to reuse previous wavefunction file
use_buffer bool True If true, use buffer as specified in relevant hybrid_mark
verbosity str NORMAL Verbosity level
virial str None If not blank, name of property to put virial in
Parameters:

at : Atoms object

f : rank-2 array(‘d’) with bounds (qp_n0,qp_n1)

n0 : input int

shape(qp_f,0)

n1 : input int

shape(qp_f,1)

e : float

args_str : input string(len=-1)

error : in/output rank-0 array(int,’i’), optional

References

Routine is wrapper around Fortran routine do_cp2k_calc defined in file src/FilePot_drivers/cp2k_driver_module.f95.

quippy.cp2k_driver.read_output(at, qm_list_a, cur_qmmm_qm_abc, run_dir, proj, calc_qm_charges, do_calc_virial, save_reordering_index, n1, n2[, out_i, error])
Parameters:

at : Atoms object

qm_list_a : input rank-1 array(‘i’) with bounds (qp_n0)

cur_qmmm_qm_abc : input rank-1 array(‘d’) with bounds (3)

run_dir : input string(len=-1)

proj : input string(len=-1)

e : float

f : rank-2 array(‘d’) with bounds (qp_n1,qp_n2)

n1 : input int

shape(qp_f,0)

n2 : input int

shape(qp_f,1)

calc_qm_charges : input string(len=-1)

do_calc_virial : input int

save_reordering_index : input int

out_i : input int, optional

error : in/output rank-0 array(int,’i’), optional

References

Routine is wrapper around Fortran routine read_output defined in file src/FilePot_drivers/cp2k_driver_module.f95.

quippy.cp2k_driver.cp2k_state_change(at, to, from_list[, ignore_failure, error])
Parameters:

at : Atoms object

to : input string(len=-1)

from_list : input rank-2 array(‘S’) with bounds (qp_n0,(*))

ignore_failure : input int, optional

error : in/output rank-0 array(int,’i’), optional

References

Routine is wrapper around Fortran routine cp2k_state_change defined in file src/FilePot_drivers/cp2k_driver_module.f95.

quippy.cp2k_driver.qmmm_qm_abc(at, qm_list_a, qm_vacuum)
Parameters:

at : Atoms object

qm_list_a : input rank-1 array(‘i’) with bounds (qp_n0)

qm_vacuum : input float

Returns:

ret_qmmm_qm_abc : rank-1 array(‘d’) with bounds (3)

References

Routine is wrapper around Fortran routine qmmm_qm_abc defined in file src/FilePot_drivers/cp2k_driver_module.f95.