38 #include "./base/base_uses.f90"
43 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'external_potential_methods'
55 TYPE(force_env_type),
POINTER :: force_env
57 CHARACTER(len=*),
PARAMETER :: routinen =
'add_external_potential'
59 CHARACTER(LEN=default_path_length) :: coupling_function
60 CHARACTER(LEN=default_string_length) :: def_error, this_error
61 CHARACTER(LEN=default_string_length), &
62 DIMENSION(:),
POINTER :: my_par
63 INTEGER :: a_var, handle, i, iatom, j, k, n_var, &
65 INTEGER,
DIMENSION(:),
POINTER :: iatms, nparticle
67 REAL(kind=
dp) :: dedf, dx, energy, err, lerr
68 REAL(kind=
dp),
DIMENSION(:),
POINTER :: my_val
69 TYPE(cp_logger_type),
POINTER :: logger
70 TYPE(cp_subsys_type),
POINTER :: subsys
71 TYPE(particle_list_type),
POINTER :: particles
72 TYPE(section_vals_type),
POINTER :: ext_pot_section
75 CALL timeset(routinen, handle)
76 NULLIFY (my_par, my_val, logger, subsys, particles, ext_pot_section, nparticle)
85 CALL get_generic_info(ext_pot_section,
"FUNCTION", coupling_function, my_par, my_val, &
86 input_variables=(/
"X",
"Y",
"Z"/), i_rep_sec=rep)
88 CALL parsef(1, trim(coupling_function), my_par)
91 NULLIFY (particles, subsys)
97 CALL section_vals_val_get(ext_pot_section,
"ATOMS_LIST", i_rep_val=k, i_vals=iatms, i_rep_section=rep)
98 CALL reallocate(nparticle, 1, natom +
SIZE(iatms))
99 nparticle(natom + 1:natom +
SIZE(iatms)) = iatms
100 natom = natom +
SIZE(iatms)
103 natom = particles%n_els
112 my_val(1) = particles%els(iatom)%r(1)
113 my_val(2) = particles%els(iatom)%r(2)
114 my_val(3) = particles%els(iatom)%r(3)
116 energy = energy +
evalf(1, my_val)
118 dedf =
evalfd(1, j, my_val, dx, err)
119 IF (abs(err) > lerr)
THEN
120 WRITE (this_error,
"(A,G12.6,A)")
"(", err,
")"
121 WRITE (def_error,
"(A,G12.6,A)")
"(", lerr,
")"
124 CALL cp_warn(__location__, &
125 'ASSERTION (cond) failed at line '//cp_to_string(__line__)// &
126 ' Error '//trim(this_error)//
' in computing numerical derivatives larger then'// &
127 trim(def_error)//
' .')
129 particles%els(iatom)%f(j) = particles%els(iatom)%f(j) - dedf
136 DEALLOCATE (nparticle)
140 CALL timestop(handle)
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell)
returns information about various attributes of the given subsys
Methods to include the effect of an external potential during an MD or energy calculation.
subroutine, public add_external_potential(force_env)
...
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env)
returns various attributes about the force environment
subroutine, public force_env_set(force_env, meta_env, fp_env, force_env_section, method_name_id, additional_potential)
changes some attributes of the force_env
subroutine, public get_generic_info(gen_section, func_name, xfunction, parameters, values, var_values, size_variables, i_rep_sec, input_variables)
Reads from the input structure all information for generic functions.
This public domain function parser module is intended for applications where a set of mathematical ex...
real(rn) function, public evalf(i, Val)
...
real(kind=rn) function, public evalfd(id_fun, ipar, vals, h, err)
Evaluates derivatives.
subroutine, public finalizef()
...
subroutine, public initf(n)
...
subroutine, public parsef(i, FuncStr, Var)
Parse ith function string FuncStr and compile it into bytecode.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Utility routines for the memory handling.
represent a simple array based list of the given type
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.