48 global_constraint_type,&
56 #include "../base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'glbopt_master'
63 PUBLIC :: glbopt_master_type
67 TYPE glbopt_master_type
69 REAL(KIND=
dp) :: e_lowest = huge(1.0_dp)
70 REAL(KIND=
dp) :: e_target = tiny(1.0_dp)
72 INTEGER :: progress_traj_unit = 0
73 INTEGER(int_8) :: total_md_steps = 0
74 INTEGER(int_8) :: total_gopt_steps = 0
75 INTEGER(int_8) :: count_reports = 0
77 TYPE(minhop_type),
POINTER :: minhop => null()
78 TYPE(mincrawl_type),
POINTER :: mincrawl => null()
79 INTEGER :: i_iteration = 0
80 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set => null()
81 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set => null()
82 TYPE(section_vals_type),
POINTER :: glbopt_section => null()
83 END TYPE glbopt_master_type
97 TYPE(glbopt_master_type),
INTENT(INOUT) :: this
98 TYPE(mp_para_env_type),
POINTER :: para_env
99 TYPE(section_vals_type),
POINTER :: root_section
100 INTEGER,
INTENT(IN) :: n_walkers, iw
102 TYPE(cp_logger_type),
POINTER :: logger
114 CALL glbopt_read_particle_set(this, para_env, root_section)
118 this%glbopt_section,
"PROGRESS_TRAJECTORY", &
119 middle_name=
"progress", extension=
".xyz", &
120 file_action=
"WRITE", file_position=
"REWIND")
122 SELECT CASE (this%method)
124 ALLOCATE (this%minhop)
125 CALL minhop_init(this%minhop, this%glbopt_section, n_walkers, iw)
127 ALLOCATE (this%mincrawl)
128 CALL mincrawl_init(this%mincrawl, this%glbopt_section, n_walkers, iw, this%particle_set)
130 cpabort(
"Unknown glbopt_method")
141 SUBROUTINE glbopt_read_particle_set(this, para_env, root_section)
142 TYPE(glbopt_master_type),
INTENT(INOUT) :: this
143 TYPE(mp_para_env_type),
POINTER :: para_env
144 TYPE(section_vals_type),
POINTER :: root_section
146 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
147 TYPE(colvar_p_type),
DIMENSION(:),
POINTER :: colvar_p
148 TYPE(exclusion_type),
DIMENSION(:),
POINTER :: exclusions
149 TYPE(global_constraint_type),
POINTER :: gci
150 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
151 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
152 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
153 TYPE(section_vals_type),
POINTER :: force_env_section, subsys_section
155 NULLIFY (atomic_kind_set, particle_set, molecule_kind_set, molecule_set)
156 NULLIFY (colvar_p, gci, exclusions, force_env_section, subsys_section)
167 root_section=root_section, &
169 force_env_section=force_env_section, &
170 subsys_section=subsys_section, &
171 use_motion_section=.false., &
172 exclusions=exclusions)
175 this%atomic_kind_set => atomic_kind_set
176 this%particle_set => particle_set
183 END SUBROUTINE glbopt_read_particle_set
194 TYPE(glbopt_master_type),
INTENT(INOUT) :: this
195 TYPE(swarm_message_type) :: report, cmd
196 LOGICAL,
INTENT(INOUT) :: should_stop
198 CALL progress_report(this, report)
200 SELECT CASE (this%method)
206 cpabort(
"Unknown glbopt_method")
209 IF (this%E_lowest < this%E_target)
THEN
210 IF (this%iw > 0)
WRITE (this%iw,
"(A,I8,A)") &
211 " GLBOPT| Reached E_pot < E_target after ", this%i_iteration,
" iterations. Quitting."
222 SUBROUTINE progress_report(this, report)
223 TYPE(glbopt_master_type),
INTENT(INOUT) :: this
224 TYPE(swarm_message_type) :: report
226 CHARACTER(len=default_string_length) :: status
227 INTEGER :: gopt_steps, md_steps, report_worker_id
228 REAL(kind=
dp) :: report_epot
230 this%i_iteration = this%i_iteration + 1
232 CALL swarm_message_get(report,
"worker_id", report_worker_id)
233 CALL swarm_message_get(report,
"status", status)
235 IF (trim(status) ==
"ok")
THEN
236 CALL swarm_message_get(report,
"Epot", report_epot)
237 CALL swarm_message_get(report,
"md_steps", md_steps)
238 CALL swarm_message_get(report,
"gopt_steps", gopt_steps)
239 this%total_md_steps = this%total_md_steps + md_steps
240 this%total_gopt_steps = this%total_gopt_steps + gopt_steps
241 this%count_reports = this%count_reports + 1
243 IF (report_epot < this%E_lowest)
THEN
244 this%E_lowest = report_epot
245 CALL write_progress_traj(this, report)
248 IF (this%iw > 0)
THEN
249 WRITE (this%iw,
'(A,46X,I8)') &
250 " GLBOPT| Reporting worker ", report_worker_id
251 WRITE (this%iw,
'(A,20X,E15.8)') &
252 " GLBOPT| Reported potential energy [Hartree] ", report_epot
253 WRITE (this%iw,
'(A,13X,E15.8)') &
254 " GLBOPT| Lowest reported potential energy [Hartree] ", this%E_lowest
255 WRITE (this%iw,
'(A,T71,F10.1)') &
256 " GLBOPT| Average number of MD steps", real(this%total_md_steps, kind=
dp)/this%count_reports
257 WRITE (this%iw,
'(A,T71,F10.1)') &
258 " GLBOPT| Average number of Geo-Opt steps", real(this%total_gopt_steps, kind=
dp)/this%count_reports
261 END SUBROUTINE progress_report
269 SUBROUTINE write_progress_traj(this, report)
270 TYPE(glbopt_master_type),
INTENT(INOUT) :: this
271 TYPE(swarm_message_type),
INTENT(IN) :: report
273 CHARACTER(len=default_string_length) :: title, unit_str
274 INTEGER :: report_worker_id
275 REAL(kind=
dp) :: report_epot, unit_conv
276 REAL(kind=
dp),
DIMENSION(:),
POINTER :: report_positions
278 NULLIFY (report_positions)
280 IF (this%progress_traj_unit <= 0)
RETURN
282 CALL swarm_message_get(report,
"worker_id", report_worker_id)
283 CALL swarm_message_get(report,
"positions", report_positions)
284 CALL swarm_message_get(report,
"Epot", report_epot)
286 WRITE (title,
'(A,I8,A,I5,A,F20.10)')
'i = ', this%i_iteration, &
287 ' worker_id = ', report_worker_id,
' Epot = ', report_epot
294 iunit=this%progress_traj_unit, &
298 array=report_positions, &
300 DEALLOCATE (report_positions)
301 END SUBROUTINE write_progress_traj
309 TYPE(glbopt_master_type),
INTENT(INOUT) :: this
311 TYPE(cp_logger_type),
POINTER :: logger
315 SELECT CASE (this%method)
318 DEALLOCATE (this%minhop)
321 DEALLOCATE (this%mincrawl)
323 cpabort(
"Unknown glbopt_method")
328 this%glbopt_section,
"PROGRESS_TRAJECTORY")
Define the atomic kind types and their sub types.
subroutine, public deallocate_atomic_kind_set(atomic_kind_set)
Destructor routine for a set of atomic kinds.
Initialize the collective variables types.
subroutine, public colvar_p_release(colvar_p)
Deallocate a set of colvar_p_type.
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...
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,...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
subroutine, public exclusion_release(exclusions)
Release exclusion type.
Master's routines for global optimization.
subroutine, public glbopt_master_steer(this, report, cmd, should_stop)
Central steering routine of global optimizer.
subroutine, public glbopt_master_init(this, para_env, root_section, n_walkers, iw)
Initializes the master of the global optimizer.
subroutine, public glbopt_master_finalize(this)
Finalized the master of the global optimizer.
Routines for the Minima Crawling global optimization scheme.
subroutine, public mincrawl_init(this, glbopt_section, n_workers, iw, particle_set)
Initializes master for Minima Crawling.
subroutine, public mincrawl_finalize(this)
Finalizes master for Minima Crawling.
subroutine, public mincrawl_steer(this, report, cmd)
Central steering routine of Minima Crawling.
Routines for the Minima Hopping global optimization scheme.
subroutine, public minhop_finalize(this)
Finalizes master for Minima Hopping.
subroutine, public minhop_init(this, glbopt_section, n_workers, iw)
Initializes master for Minima Hopping.
subroutine, public minhop_steer(this, report, cmd)
Central steering routine of Minima Hopping.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
subroutine, public deallocate_molecule_kind_set(molecule_kind_set)
Deallocate a molecule kind set.
Define the data structure for the molecule information.
subroutine, public deallocate_molecule_set(molecule_set)
Deallocate a molecule set.
subroutine, public deallocate_global_constraint(gci)
Deallocate a global constraint.
Define methods related to particle_type.
subroutine, public write_particle_coordinates(particle_set, iunit, output_format, content, title, cell, array, unit_conv, charge_occup, charge_beta, charge_extended, print_kind)
Should be able to write a few formats e.g. xmol, and some binary format (dcd) some format can be used...
Define the data structure for the particle information.
subroutine, public deallocate_particle_set(particle_set)
Deallocate a particle set.
Swarm-message, a convenient data-container for with build-in serialization.
Control for reading in different topologies and coordinates.
subroutine, public topology_control(atomic_kind_set, particle_set, molecule_kind_set, molecule_set, colvar_p, gci, root_section, para_env, qmmm, qmmm_env, force_env_section, subsys_section, use_motion_section, exclusions, elkind)
...