33 #include "./base/base_uses.f90"
40 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'fp_methods'
54 TYPE(fp_type),
POINTER :: fp_env
55 TYPE(cp_subsys_type),
POINTER :: subsys
56 TYPE(cell_type),
POINTER :: cell
58 CHARACTER(len=*),
PARAMETER :: routinen =
'fp_eval'
60 CHARACTER(LEN=15) :: tmpstr
61 INTEGER :: handle, i, icenter, iparticle, &
63 LOGICAL :: zero_weight
64 REAL(kind=
dp) :: c, dcdr, kt, r, rab(3), sf, strength
65 TYPE(cp_logger_type),
POINTER :: logger
66 TYPE(particle_list_type),
POINTER :: particles_list
67 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles
69 CALL timeset(routinen, handle)
71 cpassert(
ASSOCIATED(fp_env))
72 cpassert(fp_env%use_fp)
73 cpassert(
ASSOCIATED(subsys))
75 particles => particles_list%els
80 fp_env%restraint_energy = 0.0_dp
81 icenter = fp_env%central_atom
82 strength = fp_env%strength
83 fp_env%i1 = 0; fp_env%i2 = 0; fp_env%o1 = 0; fp_env%o2 = 0
84 fp_env%ri1 = 0.0_dp; fp_env%ri2 = 0.0_dp; fp_env%ro1 = 0.0_dp; fp_env%ro2 = 0.0_dp
85 fp_env%energy = 0.0_dp
88 DO i = 1,
SIZE(fp_env%inner_atoms)
89 iparticle = fp_env%inner_atoms(i)
90 rab = particles(iparticle)%r - particles(icenter)%r
94 IF (r > fp_env%outer_radius)
THEN
96 fp_env%restraint_energy = fp_env%restraint_energy + 0.5_dp*strength*(r - fp_env%outer_radius)**2
97 sf = strength*(r - fp_env%outer_radius)/r
98 particles(iparticle)%f = particles(iparticle)%f - sf*rab
99 particles(icenter)%f = particles(icenter)%f + sf*rab
102 IF (r > fp_env%inner_radius)
THEN
103 fp_env%i2 = fp_env%i2 + 1
105 fp_env%i1 = fp_env%i1 + 1
108 CALL smooth_count(r, fp_env%inner_radius, fp_env%smooth_width, c, dcdr)
109 fp_env%ri1 = fp_env%ri1 + c
110 fp_env%ri2 = fp_env%ri2 + (1.0_dp - c)
114 DO i = 1,
SIZE(fp_env%outer_atoms)
115 iparticle = fp_env%outer_atoms(i)
116 rab = particles(iparticle)%r - particles(icenter)%r
118 r = sqrt(sum(rab**2))
120 IF (r < fp_env%inner_radius)
THEN
122 fp_env%restraint_energy = fp_env%restraint_energy + &
123 0.5_dp*strength*(r - fp_env%inner_radius)**2
124 sf = strength*(r - fp_env%inner_radius)/r
125 particles(iparticle)%f = particles(iparticle)%f - sf*rab
126 particles(icenter)%f = particles(icenter)%f + sf*rab
129 IF (r > fp_env%outer_radius)
THEN
130 fp_env%o2 = fp_env%o2 + 1
132 fp_env%o1 = fp_env%o1 + 1
135 CALL smooth_count(r, fp_env%outer_radius, fp_env%smooth_width, c, dcdr)
136 fp_env%ro1 = fp_env%ro1 + c
137 fp_env%ro2 = fp_env%ro2 + (1.0_dp - c)
139 fp_env%energy = fp_env%energy + fp_env%restraint_energy
142 i = fp_env%i2 + fp_env%o1
144 fp_env%comb_weight = (
fac(fp_env%i2)*
fac(fp_env%o1))/
fac(i)
150 fp_env%bias_energy = 0.0_dp
151 IF (fp_env%bias)
THEN
152 kt = fp_env%temperature
153 fp_env%bias_energy = kt*(log_gamma(fp_env%ro1 + fp_env%ri2 + 1) - &
154 log_gamma(fp_env%ro1 + 1) - log_gamma(fp_env%ri2 + 1))
158 DO i = 1,
SIZE(fp_env%inner_atoms)
159 iparticle = fp_env%inner_atoms(i)
160 rab = particles(iparticle)%r - particles(icenter)%r
162 r = sqrt(sum(rab**2))
163 CALL smooth_count(r, fp_env%inner_radius, fp_env%smooth_width, c, dcdr)
164 sf = kt*(
psi(fp_env%ro1 + fp_env%ri2 + 1) -
psi(fp_env%ri2 + 1))*(-dcdr)/r
165 particles(iparticle)%f = particles(iparticle)%f - sf*rab
166 particles(icenter)%f = particles(icenter)%f + sf*rab
169 DO i = 1,
SIZE(fp_env%outer_atoms)
170 iparticle = fp_env%outer_atoms(i)
171 rab = particles(iparticle)%r - particles(icenter)%r
173 r = sqrt(sum(rab**2))
174 CALL smooth_count(r, fp_env%outer_radius, fp_env%smooth_width, c, dcdr)
175 sf = kt*(
psi(fp_env%ro1 + fp_env%ri2 + 1) -
psi(fp_env%ro1 + 1))*(dcdr)/r
176 particles(iparticle)%f = particles(iparticle)%f - sf*rab
177 particles(icenter)%f = particles(icenter)%f + sf*rab
180 fp_env%energy = fp_env%energy + fp_env%bias_energy
181 fp_env%bias_weight = exp(fp_env%bias_energy/kt)
184 IF (zero_weight)
THEN
185 fp_env%weight = 0.0_dp
187 fp_env%weight = fp_env%comb_weight*fp_env%bias_weight
193 extension=
".weights")
194 IF (output_unit > 0)
THEN
196 WRITE (output_unit,
'(T2,A15,6(1X,F16.10),4(1X,I4),4(1X,F16.10))') &
198 fp_env%weight, fp_env%comb_weight, fp_env%bias_weight, &
199 fp_env%energy, fp_env%restraint_energy, fp_env%bias_energy, &
200 fp_env%i1, fp_env%i2, fp_env%o1, fp_env%o2, &
201 fp_env%ri1, fp_env%ri2, fp_env%ro1, fp_env%ro2
207 CALL timestop(handle)
223 SUBROUTINE smooth_count(r, r1, width, c, dcdr)
224 REAL(kind=
dp),
INTENT(IN) :: r, r1, width
225 REAL(kind=
dp),
INTENT(OUT) :: c, dcdr
231 c = (1.0_dp + erf(arg))/2.0_dp
232 dcdr = (-
oorootpi/width)*exp(-arg**2)
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
real(dp) function, public psi(xx)
...
Handles all functions related to the CELL.
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
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
character(len=default_string_length) function, public cp_iter_string(iter_info, print_key, for_file)
returns the iteration string, a string that is useful to create unique filenames (once you trim it)
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
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 used in the flexible partitioning scheme
subroutine, public fp_eval(fp_env, subsys, cell)
computest the forces and the energy due to the flexible potential & bias, and writes the weights file
types used in the flexible partitioning scheme
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public oorootpi
integer, parameter, public maxfac
real(kind=dp), dimension(0:maxfac), parameter, public fac
represent a simple array based list of the given type
Define the data structure for the particle information.