(git:1f9fd2c)
Loading...
Searching...
No Matches
topology.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Control for reading in different topologies and coordinates
10!> \par History
11!> none
12! **************************************************************************************************
16 USE cell_methods, ONLY: cell_create,&
17 read_cell,&
19 USE cell_types, ONLY: cell_clone,&
24 USE colvar_types, ONLY: colvar_p_type,&
35 USE input_constants, ONLY: &
45 USE kinds, ONLY: default_path_length,&
47 dp
58 USE string_table, ONLY: id2str,&
59 s2s,&
60 str2id
83 USE topology_psf, ONLY: idm_psf,&
97#include "./base/base_uses.f90"
98
99 IMPLICIT NONE
100
101 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'topology'
102
103 PRIVATE
104
105 ! Public parameters
106 PUBLIC :: topology_control, &
108
109CONTAINS
110
111! **************************************************************************************************
112!> \brief ...
113!> \param atomic_kind_set ...
114!> \param particle_set ...
115!> \param molecule_kind_set ...
116!> \param molecule_set ...
117!> \param colvar_p ...
118!> \param gci ...
119!> \param root_section ...
120!> \param para_env ...
121!> \param qmmm ...
122!> \param qmmm_env ...
123!> \param force_env_section ...
124!> \param subsys_section ...
125!> \param use_motion_section ...
126!> \param exclusions ...
127!> \param elkind ...
128!> \param subsys ...
129! **************************************************************************************************
130 SUBROUTINE topology_control(atomic_kind_set, particle_set, molecule_kind_set, &
131 molecule_set, colvar_p, gci, root_section, para_env, qmmm, qmmm_env, &
132 force_env_section, subsys_section, use_motion_section, &
133 exclusions, elkind, subsys)
134
135 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
136 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
137 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
138 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
139 TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_p
140 TYPE(global_constraint_type), POINTER :: gci
141 TYPE(section_vals_type), POINTER :: root_section
142 TYPE(mp_para_env_type), POINTER :: para_env
143 LOGICAL, INTENT(IN), OPTIONAL :: qmmm
144 TYPE(qmmm_env_mm_type), OPTIONAL, POINTER :: qmmm_env
145 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
146 LOGICAL, INTENT(IN) :: use_motion_section
147 TYPE(exclusion_type), DIMENSION(:), OPTIONAL, &
148 POINTER :: exclusions
149 LOGICAL, INTENT(IN), OPTIONAL :: elkind
150 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
151
152 CHARACTER(LEN=*), PARAMETER :: routinen = 'topology_control'
153
154 INTEGER :: handle, iw, iw2
155 LOGICAL :: binary_coord_read, el_as_kind, explicit, &
156 my_qmmm, use_ref_cell
157 TYPE(cell_type), POINTER :: my_cell, my_cell_ref
158 TYPE(cp_logger_type), POINTER :: logger
159 TYPE(section_vals_type), POINTER :: cell_ref_section, cell_section, &
160 constraint_section, fragment_section, &
161 topology_section
163
164 NULLIFY (logger)
165 logger => cp_get_default_logger()
166 CALL timeset(routinen, handle)
167 NULLIFY (cell_section, cell_ref_section, constraint_section, topology_section, fragment_section)
168
169 cell_section => section_vals_get_subs_vals(subsys_section, "CELL")
170 IF (use_motion_section) THEN
171 constraint_section => section_vals_get_subs_vals(root_section, "MOTION%CONSTRAINT")
172 END IF
173 topology_section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY")
174 iw = cp_print_key_unit_nr(logger, subsys_section, "PRINT%TOPOLOGY_INFO", &
175 extension=".mmLog")
176 my_qmmm = .false.
177 IF (PRESENT(qmmm) .AND. PRESENT(qmmm_env)) my_qmmm = qmmm
178
179 IF (PRESENT(elkind)) THEN
180 CALL section_vals_val_get(topology_section, "USE_ELEMENT_AS_KIND", explicit=explicit)
181 IF (explicit) THEN
182 CALL section_vals_val_get(topology_section, "USE_ELEMENT_AS_KIND", l_val=el_as_kind)
183 ELSE
184 el_as_kind = elkind
185 END IF
186 ELSE
187 CALL section_vals_val_get(topology_section, "USE_ELEMENT_AS_KIND", l_val=el_as_kind)
188 END IF
189
190 ! 1. Initialize the topology structure type
192
193 ! 2. Get the cell info
194 NULLIFY (my_cell, my_cell_ref)
195 CALL read_cell(my_cell, my_cell_ref, cell_section=cell_section, &
196 topology_section=topology_section, para_env=para_env)
197 use_ref_cell = .false.
198 cell_ref_section => section_vals_get_subs_vals(cell_section, "CELL_REF")
199 CALL section_vals_get(cell_ref_section, explicit=use_ref_cell)
200 IF (.NOT. ASSOCIATED(topology%cell)) CALL cell_create(topology%cell)
201 IF (.NOT. ASSOCIATED(topology%cell_ref)) CALL cell_create(topology%cell_ref)
202 CALL cell_clone(my_cell, topology%cell)
203 CALL cell_clone(my_cell_ref, topology%cell_ref)
204 CALL setup_cell_muc(topology%cell_muc, topology%cell, subsys_section)
205 IF (PRESENT(subsys)) THEN ! subsys is passed from cp_subsys_create
206 CALL cp_subsys_set(subsys, cell=my_cell, cell_ref=my_cell_ref, &
207 use_ref_cell=use_ref_cell)
208 END IF
209 CALL write_cell(my_cell, subsys_section, tag="CELL")
210 CALL write_cell(my_cell_ref, subsys_section, tag="CELL_REF")
211 CALL cell_release(my_cell)
212 CALL cell_release(my_cell_ref)
213
214 ! 3. Read in the topology section in the input file if any
215 CALL read_topology_section(topology, topology_section)
216
217 ! 4. Read in the constraints section
218 CALL read_constraints_section(topology, colvar_p, constraint_section)
219
220 ! 5. Read in the coordinates
221 CALL read_binary_coordinates(topology, root_section, para_env, subsys_section, &
222 binary_coord_read)
223 IF (.NOT. binary_coord_read) THEN
224 CALL coordinate_control(topology, root_section, para_env, subsys_section)
225 END IF
226
227 ! 6. Read in or generate the molecular connectivity
228 CALL connectivity_control(topology, para_env, my_qmmm, qmmm_env, subsys_section, &
229 force_env_section)
230
231 IF (el_as_kind) THEN
232 ! redefine atom names with the name of the element
233 topology%atom_info%id_atmname(:) = topology%atom_info%id_element(:)
234 END IF
235
236 ! 7. Pack everything into the molecular types
237 CALL topology_connectivity_pack(molecule_kind_set, molecule_set, &
238 topology, subsys_section)
239
240 ! 8. Set up the QM/MM linkage (if any)
241 ! This part takes care of the molecule in which QM atoms were defined.
242 ! Preliminary setup for QM/MM link region
243 IF (my_qmmm) THEN
244 CALL qmmm_connectivity_control(molecule_set, qmmm_env, subsys_section)
245 END IF
246
247 ! 9. Pack everything into the atomic types
248 IF (my_qmmm) THEN
249 CALL topology_coordinate_pack(particle_set, atomic_kind_set, &
250 molecule_kind_set, molecule_set, &
251 topology, my_qmmm, qmmm_env, subsys_section, &
252 force_env_section=force_env_section, exclusions=exclusions)
253 ELSE
254 CALL topology_coordinate_pack(particle_set, atomic_kind_set, &
255 molecule_kind_set, molecule_set, &
256 topology, subsys_section=subsys_section, &
257 force_env_section=force_env_section, exclusions=exclusions)
258 END IF
259
260 !10. Post-Process colvar definitions (if needed)
261 CALL topology_post_proc_colvar(colvar_p, particle_set)
262
263 !11. Deal with the constraint stuff if requested
264 IF (my_qmmm) THEN
265 CALL topology_constraint_pack(molecule_kind_set, molecule_set, &
266 topology, qmmm_env, particle_set, root_section, subsys_section, &
267 gci)
268 ELSE
269 CALL topology_constraint_pack(molecule_kind_set, molecule_set, &
270 topology, particle_set=particle_set, input_file=root_section, &
271 subsys_section=subsys_section, gci=gci)
272 END IF
273
274 !12. Dump the topology informations
275 iw2 = cp_print_key_unit_nr(logger, subsys_section, "TOPOLOGY%DUMP_PDB", &
276 file_status="REPLACE", extension=".pdb")
277 IF (iw2 > 0) THEN
278 CALL write_coordinate_pdb(iw2, topology, subsys_section)
279 END IF
280 CALL cp_print_key_finished_output(iw2, logger, subsys_section, &
281 "TOPOLOGY%DUMP_PDB")
282 iw2 = cp_print_key_unit_nr(logger, subsys_section, "TOPOLOGY%DUMP_PSF", &
283 file_status="REPLACE", extension=".psf")
284 IF (iw2 > 0) THEN
285 CALL write_topology_psf(iw2, topology, subsys_section, force_env_section)
286 END IF
287 CALL cp_print_key_finished_output(iw2, logger, subsys_section, &
288 "TOPOLOGY%DUMP_PSF")
289 !13. Read fragmentation
290 fragment_section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY%FRAGMENTS")
291 CALL section_vals_get(fragment_section, explicit=explicit)
292 IF (explicit) THEN
293 CALL read_fragments(topology, subsys_section, particle_set=particle_set)
294 END IF
295
296 !13. Cleanup the topology structure type
298 CALL timestop(handle)
299 CALL cp_print_key_finished_output(iw, logger, subsys_section, &
300 "PRINT%TOPOLOGY_INFO")
301
302 END SUBROUTINE topology_control
303
304! **************************************************************************************************
305!> \brief 1. If reading in from external file, make sure its there first
306!> 2. Generate the connectivity if no information to be read in
307!> \param topology ...
308!> \param para_env ...
309!> \param qmmm ...
310!> \param qmmm_env ...
311!> \param subsys_section ...
312!> \param force_env_section ...
313!> \par History
314!> none
315!> \author IKUO 08.01.2003
316! **************************************************************************************************
317 SUBROUTINE connectivity_control(topology, para_env, qmmm, qmmm_env, subsys_section, &
318 force_env_section)
319
320 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
321 TYPE(mp_para_env_type), POINTER :: para_env
322 LOGICAL, INTENT(in), OPTIONAL :: qmmm
323 TYPE(qmmm_env_mm_type), OPTIONAL, POINTER :: qmmm_env
324 TYPE(section_vals_type), POINTER :: subsys_section, force_env_section
325
326 CHARACTER(len=*), PARAMETER :: routinen = 'connectivity_control'
327 INTEGER, PARAMETER :: map0 = ichar("0"), map9 = ichar("9")
328
329 CHARACTER(len=default_string_length) :: element0, my_element
330 CHARACTER(len=default_string_length), &
331 ALLOCATABLE, DIMENSION(:) :: elements
332 INTEGER :: handle, handle2, i, id, itmp, iw, j, k
333 LOGICAL :: check, my_qmmm, use_mm_map_first
334 TYPE(cp_logger_type), POINTER :: logger
335
336 NULLIFY (logger)
337 logger => cp_get_default_logger()
338 iw = cp_print_key_unit_nr(logger, subsys_section, "PRINT%TOPOLOGY_INFO", &
339 extension=".mmLog")
340 CALL timeset(routinen, handle)
341
342 my_qmmm = .false.
343 IF (PRESENT(qmmm) .AND. PRESENT(qmmm_env)) my_qmmm = qmmm
344
345 ! 1. Read in the connectivity information (if this is the case)
346 SELECT CASE (topology%conn_type)
348 ! Do nothing for the time being.. after we check element and proceed with the workflow..
349 CASE DEFAULT
350 ! Prepare arrays
352
353 ! Read connectivity from file
354 CALL read_topology_conn(topology, topology%conn_type, topology%conn_file_name, &
355 para_env, subsys_section)
356
357 ! Post process of PSF and AMBER information
358 SELECT CASE (topology%conn_type)
360 CALL psf_post_process(topology, subsys_section)
361 END SELECT
362 END SELECT
363
364 ! 2. In case element was autoassigned let's keep up2date the element name
365 ! with the atom_name
366 IF (topology%aa_element) THEN
367 check = SIZE(topology%atom_info%id_element) == SIZE(topology%atom_info%id_atmname)
368 cpassert(check)
369 topology%atom_info%id_element = topology%atom_info%id_atmname
370 END IF
371
372 ! 3. Check for the element name..
373 CALL timeset(routinen//"_check_element_name", handle2)
374 ! Fix element name
375
376 ! we will only translate names if we actually have a connectivity file given
377 SELECT CASE (topology%conn_type)
379 use_mm_map_first = .true.
380 CASE DEFAULT
381 use_mm_map_first = .false.
382 END SELECT
383 CALL create_ff_map("AMBER")
384 CALL create_ff_map("CHARMM")
385 CALL create_ff_map("GROMOS")
386
387 ALLOCATE (elements(SIZE(topology%atom_info%id_element)))
388 DO i = 1, SIZE(elements)
389 elements(i) = id2str(topology%atom_info%id_element(i))
390 END DO
391
392 DO i = 1, topology%natoms
393 IF (elements(i) == "__DEF__") cycle
394 ! If present an underscore let's skip all that over the underscore
395 id = index(elements(i), "_") - 1
396 IF (id == -1) id = len_trim(elements(i))
397 ! Many atomic kind have been defined as ELEMENT+LETTER+NUMBER
398 ! the number at the end can vary arbitrarily..
399 ! Let's check all ELEMENT+LETTER skipping the number.. we should
400 ! identify in any case the element
401 DO j = id, 1, -1
402 itmp = ichar(elements(i) (j:j))
403 IF ((itmp < map0) .OR. (itmp > map9)) EXIT
404 END DO
405 element0 = elements(i) (1:j)
406 ! ALWAYS check for elements..
407 CALL check_subsys_element(element0, id2str(topology%atom_info%id_atmname(i)), my_element, &
408 subsys_section, use_mm_map_first)
409 ! Earn time fixing same element labels for same atoms
410 element0 = elements(i)
411 DO k = i, topology%natoms
412 IF (element0 == id2str(topology%atom_info%id_element(k))) THEN
413 topology%atom_info%id_element(k) = str2id(s2s(my_element))
414 elements(k) = "__DEF__"
415 END IF
416 END DO
417 END DO
418 DEALLOCATE (elements)
419 CALL destroy_ff_map("GROMOS")
420 CALL destroy_ff_map("CHARMM")
421 CALL destroy_ff_map("AMBER")
422 CALL timestop(handle2)
423
424 ! 4. Generate the connectivity information otherwise
425 SELECT CASE (topology%conn_type)
426 CASE (do_conn_generate)
427 CALL topology_set_atm_mass(topology, subsys_section)
428 CALL topology_generate_bond(topology, para_env, subsys_section)
429 IF (topology%reorder_atom) THEN
430 ! If we generate connectivity we can save memory reordering the molecules
431 ! in this case once a first connectivity has been created we match according
432 ! molecule names provided in the PDB and reorder the connectivity according to that.
433 CALL topology_reorder_atoms(topology, qmmm, qmmm_env, subsys_section, &
434 force_env_section)
435 CALL topology_set_atm_mass(topology, subsys_section)
436 CALL topology_generate_bond(topology, para_env, subsys_section)
437 END IF
438 CALL topology_generate_bend(topology, subsys_section)
439 CALL topology_generate_ub(topology, subsys_section)
440 CALL topology_generate_dihe(topology, subsys_section)
441 CALL topology_generate_impr(topology, subsys_section)
442 CALL topology_generate_onfo(topology, subsys_section)
444 CALL topology_set_atm_mass(topology, subsys_section)
445 CALL topology_generate_bend(topology, subsys_section)
446 CALL topology_generate_ub(topology, subsys_section)
447 CALL topology_generate_dihe(topology, subsys_section)
448 CALL topology_generate_impr(topology, subsys_section)
449 CALL topology_generate_onfo(topology, subsys_section)
450 END SELECT
451
452 ! 5. Handle multiple unit_cell - Update atoms_info
453 CALL topology_muc(topology, subsys_section)
454
455 ! 6. Handle multiple unit_cell - Update conn_info
456 CALL topology_conn_multiple(topology, subsys_section)
457
458 ! 7. Generate Molecules
459 CALL topology_generate_molecule(topology, my_qmmm, qmmm_env, subsys_section)
460 IF (topology%molecules_check) CALL topology_molecules_check(topology, subsys_section)
461
462 ! 8. Modify for QM/MM
463 IF (my_qmmm) THEN
464 CALL qmmm_coordinate_control(topology, qmmm_env, subsys_section)
465 END IF
466 CALL timestop(handle)
467 CALL cp_print_key_finished_output(iw, logger, subsys_section, &
468 "PRINT%TOPOLOGY_INFO")
469
470 END SUBROUTINE connectivity_control
471! **************************************************************************************************
472!> \brief Reads fragments from input file
473!> \param topology ...
474!> \param subsys_section ...
475!> \param particle_set ...
476! **************************************************************************************************
477 SUBROUTINE read_fragments(topology, subsys_section, particle_set)
478
479 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
480 TYPE(section_vals_type), POINTER :: subsys_section
481 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
482
483 INTEGER :: i_rep, ifrag, n_rep
484 INTEGER, DIMENSION(:), POINTER :: frag_range
485 TYPE(section_vals_type), POINTER :: section
486
487 NULLIFY (section)
488 NULLIFY (frag_range)
489
490 section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY%FRAGMENTS")
491 section => section_vals_get_subs_vals(section, "FRAGMENT")
492 CALL section_vals_get(section, n_repetition=n_rep)
493 ALLOCATE (topology%fragments(n_rep))
494
495 DO i_rep = 1, n_rep
496 CALL section_vals_val_get(section, "FRAG_RANGE", i_vals=frag_range, i_rep_section=i_rep)
497 topology%fragments(i_rep)%frag_start = frag_range(1)
498 topology%fragments(i_rep)%frag_end = frag_range(2)
499 DO ifrag = topology%fragments(i_rep)%frag_start, topology%fragments(i_rep)%frag_end
500 particle_set(ifrag)%fragment_index = i_rep
501 END DO
502 END DO
503
504 END SUBROUTINE read_fragments
505
506! **************************************************************************************************
507!> \brief Reads connectivity from file
508!> \param topology ...
509!> \param conn_type ...
510!> \param conn_file_name ...
511!> \param para_env ...
512!> \param subsys_section ...
513!> \author Teodoro Laino [tlaino] - 10.2009
514! **************************************************************************************************
515 RECURSIVE SUBROUTINE read_topology_conn(topology, conn_type, conn_file_name, para_env, &
516 subsys_section)
517
518 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
519 INTEGER, INTENT(IN) :: conn_type
520 CHARACTER(LEN=default_path_length), INTENT(IN) :: conn_file_name
521 TYPE(mp_para_env_type), POINTER :: para_env
522 TYPE(section_vals_type), POINTER :: subsys_section
523
524 CHARACTER(len=default_path_length) :: filename
525 INTEGER :: i_rep, imol, loc_conn_type, n_rep, nmol
526 TYPE(section_vals_type), POINTER :: section
527
528 NULLIFY (section)
529
530 SELECT CASE (conn_type)
531 CASE (do_conn_mol_set)
532 section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY%MOL_SET")
533 section => section_vals_get_subs_vals(section, "MOLECULE")
534 CALL section_vals_get(section, n_repetition=n_rep)
535 DO i_rep = 1, n_rep
536 CALL section_vals_val_get(section, "NMOL", i_val=nmol, i_rep_section=i_rep)
537 CALL section_vals_val_get(section, "CONN_FILE_NAME", c_val=filename, i_rep_section=i_rep)
538 CALL section_vals_val_get(section, "CONN_FILE_FORMAT", i_val=loc_conn_type, i_rep_section=i_rep)
539
540 SELECT CASE (loc_conn_type)
542 DO imol = 1, nmol
543 CALL read_topology_conn(topology, loc_conn_type, filename, para_env, subsys_section)
544 END DO
545 CASE DEFAULT
546 CALL cp_abort(__location__, &
547 "MOL_SET feature implemented only for PSF/UPSF, G87/G96 and AMBER "// &
548 "connectivity type.")
549 END SELECT
550 END DO
551 IF (SIZE(topology%atom_info%id_molname) /= topology%natoms) &
552 CALL cp_abort(__location__, &
553 "Number of atoms in connectivity control is larger than the "// &
554 "number of atoms in coordinate control. check coordinates and "// &
555 "connectivity. ")
556
557 ! Merge defined structures
558 section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY%MOL_SET%MERGE_MOLECULES")
559 CALL idm_psf(topology, section, subsys_section)
560
562 CALL read_topology_gromos(conn_file_name, topology, para_env, subsys_section)
564 CALL read_topology_psf(conn_file_name, topology, para_env, subsys_section, conn_type)
565 CASE (do_conn_amb7)
566 CALL read_connectivity_amber(conn_file_name, topology, para_env, subsys_section)
567 END SELECT
568
569 END SUBROUTINE read_topology_conn
570
571! **************************************************************************************************
572!> \brief 1. If reading in from external file, make sure its there first
573!> 2. Read in the coordinates from the corresponding locations
574!> \param topology ...
575!> \param root_section ...
576!> \param para_env ...
577!> \param subsys_section ...
578!> \par History
579!> - Teodoro Laino [tlaino] - University of Zurich 10.2008
580!> adding support for AMBER coordinates
581!> \author IKUO 08.11.2003
582! **************************************************************************************************
583 SUBROUTINE coordinate_control(topology, root_section, para_env, subsys_section)
584
585 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
586 TYPE(section_vals_type), POINTER :: root_section
587 TYPE(mp_para_env_type), POINTER :: para_env
588 TYPE(section_vals_type), POINTER :: subsys_section
589
590 CHARACTER(len=*), PARAMETER :: routinen = 'coordinate_control'
591
592 CHARACTER(LEN=default_string_length) :: message
593 INTEGER :: handle, handle2, istat, iw
594 LOGICAL :: found, save_mem
595 TYPE(cp_logger_type), POINTER :: logger
596 TYPE(section_vals_type), POINTER :: global_section
597
598 NULLIFY (logger)
599 logger => cp_get_default_logger()
600 iw = cp_print_key_unit_nr(logger, subsys_section, "PRINT%TOPOLOGY_INFO", &
601 extension=".mmLog")
602 CALL timeset(routinen, handle)
603
604 NULLIFY (global_section)
605 global_section => section_vals_get_subs_vals(root_section, "GLOBAL")
606 CALL section_vals_val_get(global_section, "SAVE_MEM", l_val=save_mem)
607 !-----------------------------------------------------------------------------
608 ! 1. If reading in from external file, make sure its there first
609 !-----------------------------------------------------------------------------
610 IF (topology%coordinate) THEN
611 INQUIRE (file=topology%coord_file_name, exist=found, iostat=istat)
612 IF (istat /= 0) THEN
613 WRITE (unit=message, fmt="(A,I0,A)") &
614 "An error occurred inquiring the file <"// &
615 trim(topology%coord_file_name)//"> (IOSTAT = ", istat, ")"
616 cpabort(trim(message))
617 END IF
618 IF (.NOT. found) THEN
619 CALL cp_abort(__location__, &
620 "Coordinate file <"//trim(topology%coord_file_name)// &
621 "> not found.")
622 END IF
623 END IF
624 !-----------------------------------------------------------------------------
625 ! 2. Read in the coordinates from the corresponding locations
626 !-----------------------------------------------------------------------------
627 CALL timeset(routinen//"_READ_COORDINATE", handle2)
628 SELECT CASE (topology%coord_type)
629 CASE (do_coord_off)
630 ! Do nothing.. we will parse later from the &COORD section..
631 CASE (do_coord_g96)
632 CALL read_coordinate_g96(topology, para_env, subsys_section)
633 CALL transform_external_cartesian_coordinates(topology)
634 CASE (do_coord_crd)
635 CALL read_coordinate_crd(topology, para_env, subsys_section)
636 CALL transform_external_cartesian_coordinates(topology)
637 CASE (do_coord_pdb)
638 CALL read_coordinate_pdb(topology, para_env, subsys_section)
639 CALL transform_external_cartesian_coordinates(topology)
640 CASE (do_coord_xyz)
641 CALL read_coordinate_xyz(topology, para_env, subsys_section)
642 CALL transform_external_cartesian_coordinates(topology)
643 CASE (do_coord_cif)
644 CALL read_coordinate_cif(topology, para_env, subsys_section)
645 CASE (do_coord_xtl)
646 CALL read_coordinate_xtl(topology, para_env, subsys_section)
647 CASE (do_coord_cp2k)
648 CALL read_coordinate_cp2k(topology, para_env, subsys_section)
649 CASE DEFAULT
650 ! We should never reach this point..
651 cpabort("")
652 END SELECT
653
654 ! Parse &COORD section and in case overwrite
655 IF (topology%coord_type /= do_coord_cp2k) THEN
656 CALL read_atoms_input(topology, overwrite=(topology%coord_type /= do_coord_off), &
657 subsys_section=subsys_section, save_mem=save_mem)
658 END IF
659 CALL section_vals_val_set(subsys_section, "TOPOLOGY%NUMBER_OF_ATOMS", &
660 i_val=topology%natoms)
661 CALL timestop(handle2)
662 ! Check on atom numbers
663 IF (topology%natoms <= 0) &
664 cpabort("No atomic coordinates have been found! ")
665 CALL timestop(handle)
666 CALL cp_print_key_finished_output(iw, logger, subsys_section, &
667 "PRINT%TOPOLOGY_INFO")
668 END SUBROUTINE coordinate_control
669
670! **************************************************************************************************
671!> \brief Transform Cartesian coordinates read from external files to the internal cell frame.
672!> \param topology ...
673! **************************************************************************************************
674 SUBROUTINE transform_external_cartesian_coordinates(topology)
675
676 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
677
678 INTEGER :: iatom
679
680 IF (.NOT. ASSOCIATED(topology%cell_muc)) RETURN
681
682 DO iatom = 1, topology%natoms
683 CALL cell_transform_input_cartesian(topology%cell_muc, topology%atom_info%r(:, iatom))
684 END DO
685
686 END SUBROUTINE transform_external_cartesian_coordinates
687
688! **************************************************************************************************
689!> \brief ...
690!> \param colvar_p ...
691!> \param particle_set ...
692!> \par History
693!> none
694!> \author Teodoro Laino [tlaino] - 07.2007
695! **************************************************************************************************
696 SUBROUTINE topology_post_proc_colvar(colvar_p, particle_set)
697
698 TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_p
699 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
700
701 INTEGER :: i, j
702
703 IF (ASSOCIATED(colvar_p)) THEN
704 DO i = 1, SIZE(colvar_p)
705 IF (colvar_p(i)%colvar%type_id == combine_colvar_id) THEN
706 DO j = 1, SIZE(colvar_p(i)%colvar%combine_cvs_param%colvar_p)
707 CALL post_process_colvar(colvar_p(i)%colvar%combine_cvs_param%colvar_p(j)%colvar, particle_set)
708 END DO
709 CALL colvar_setup(colvar_p(i)%colvar)
710 ELSE
711 CALL post_process_colvar(colvar_p(i)%colvar, particle_set)
712 END IF
713 END DO
714 END IF
715 END SUBROUTINE topology_post_proc_colvar
716
717! **************************************************************************************************
718!> \brief Setup the cell used for handling properly the multiple_unit_cell option
719!> \param cell_muc ...
720!> \param cell ...
721!> \param subsys_section ...
722!> \author Teodoro Laino [tlaino] - 06.2009
723! **************************************************************************************************
724 SUBROUTINE setup_cell_muc(cell_muc, cell, subsys_section)
725
726 TYPE(cell_type), POINTER :: cell_muc, cell
727 TYPE(section_vals_type), POINTER :: subsys_section
728
729 INTEGER, DIMENSION(:), POINTER :: multiple_unit_cell
730 REAL(kind=dp), DIMENSION(3, 3) :: hmat_ref
731
732 cpassert(.NOT. ASSOCIATED(cell_muc))
733
734 CALL section_vals_val_get(subsys_section, "CELL%MULTIPLE_UNIT_CELL", &
735 i_vals=multiple_unit_cell)
736 IF (any(multiple_unit_cell /= 1)) THEN
737 ! Restore the original cell
738 hmat_ref(:, 1) = cell%hmat(:, 1)/multiple_unit_cell(1)
739 hmat_ref(:, 2) = cell%hmat(:, 2)/multiple_unit_cell(2)
740 hmat_ref(:, 3) = cell%hmat(:, 3)/multiple_unit_cell(3)
741 ! Create the MUC cell
742 CALL cell_create(cell_muc, hmat=hmat_ref, periodic=cell%perd, tag="CELL_UC")
743 CALL write_cell(cell_muc, subsys_section)
744 ELSE
745 ! If a multiple_unit_cell was not requested just point to the original cell
746 CALL cell_retain(cell)
747 cell_muc => cell
748 END IF
749
750 END SUBROUTINE setup_cell_muc
751
752END MODULE topology
Define the atomic kind types and their sub types.
subroutine, public read_atoms_input(topology, overwrite, subsys_section, save_mem)
...
Definition atoms_input.F:71
Handles all functions related to the CELL.
subroutine, public write_cell(cell, subsys_section, tag)
Write the cell parameters to the output unit.
recursive subroutine, public read_cell(cell, cell_ref, use_ref_cell, cell_section, topology_section, check_for_ref, para_env)
...
subroutine, public cell_create(cell, hmat, periodic, tag)
allocates and initializes a cell
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:608
subroutine, public cell_clone(cell_in, cell_out, tag)
Clone cell variable.
Definition cell_types.F:118
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:591
subroutine, public cell_transform_input_cartesian(cell, vector)
Transform a Cartesian real-space vector from the user input cell frame into CP2K's canonical internal...
Definition cell_types.F:261
Initialize the collective variables types.
integer, parameter, public combine_colvar_id
subroutine, public colvar_setup(colvar)
Finalize the setup of the collective variable.
evaluations of colvar for internal coordinates schemes
subroutine, public post_process_colvar(colvar, particles)
Complete the description of the COORDINATION colvar when defined using KINDS.
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,...
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_set(subsys, atomic_kinds, particles, local_particles, molecules, molecule_kinds, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, results, cell, cell_ref, use_ref_cell)
sets various propreties of the subsys
an exclusion type
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_conn_g87
integer, parameter, public do_coord_crd
integer, parameter, public do_coord_xtl
integer, parameter, public do_conn_psf_u
integer, parameter, public do_conn_off
integer, parameter, public do_conn_user
integer, parameter, public do_coord_cif
integer, parameter, public do_conn_amb7
integer, parameter, public do_conn_psf
integer, parameter, public do_conn_generate
integer, parameter, public do_conn_mol_set
integer, parameter, public do_conn_g96
integer, parameter, public do_coord_pdb
integer, parameter, public do_coord_xyz
integer, parameter, public do_coord_off
integer, parameter, public do_coord_g96
integer, parameter, public do_coord_cp2k
Routines to read the binary restart file of CP2K.
subroutine, public read_binary_coordinates(topology, root_section, para_env, subsys_section, binary_file_read)
Read the input section &COORD from an external file written in binary format.
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Interface to the message passing library MPI.
Contains the mapping ATOM_KIND -> ELEMENT for the most common cases in CHARMM and AMBER This should a...
subroutine, public create_ff_map(ff_type)
Initialize arrays for mapping KINDS <-> ELEMENTS for major elements in AMBER and CHARMM.
subroutine, public destroy_ff_map(ff_type)
Deallocates the arrays used for mapping.
Define the molecule kind structure types and the corresponding functionality.
Define the data structure for the molecule information.
Define the data structure for the particle information.
subroutine, public qmmm_coordinate_control(topology, qmmm_env, subsys_section)
Modifies the atom_infoid_atmname.
subroutine, public qmmm_connectivity_control(molecule_set, qmmm_env, subsys_section)
Set up the connectivity for QM/MM calculations.
generates a unique id number for a string (str2id) that can be used two compare two strings....
character(len=default_string_length) function, public s2s(str)
converts a string in a string of default_string_length
integer function, public str2id(str)
returns a unique id for a given string, and stores the string for later retrieval using the id.
character(len=default_string_length) function, public id2str(id)
returns the string associated with a given id
Handles all functions used to read and interpret AMBER coordinates and topology files.
subroutine, public read_coordinate_crd(topology, para_env, subsys_section)
Reads the ‘coord’ version generated by the PARM or LEaP programs, as well as the ‘restrt’ version,...
subroutine, public read_connectivity_amber(filename, topology, para_env, subsys_section)
Read AMBER topology file (.top) : At this level we parse only the connectivity info the ....
Handles CIF (Crystallographic Information File) files.
subroutine, public read_coordinate_cif(topology, para_env, subsys_section)
Performs the real task of reading the proper information from the CIF file.
Collection of subroutine needed for topology related things.
subroutine, public topology_conn_multiple(topology, subsys_section)
Handles the multiple unit cell option for the connectivity.
subroutine, public topology_connectivity_pack(molecule_kind_set, molecule_set, topology, subsys_section)
topology connectivity pack
Collection of subroutine needed for topology related things.
subroutine, public topology_constraint_pack(molecule_kind_set, molecule_set, topology, qmmm_env, particle_set, input_file, subsys_section, gci)
Pack in all the information needed for the constraints.
Collection of subroutine needed for topology related things.
subroutine, public topology_coordinate_pack(particle_set, atomic_kind_set, molecule_kind_set, molecule_set, topology, qmmm, qmmm_env, subsys_section, force_env_section, exclusions, ignore_outside_box)
Take info readin from different file format and stuff it into compatible data structure in cp2k.
subroutine, public read_coordinate_cp2k(topology, para_env, subsys_section)
Read the CP2K &COORD section from an external file, i.e. read atomic coordinates and molecule/residue...
Collection of subroutine needed for topology related things.
subroutine, public topology_generate_impr(topology, subsys_section)
Using a list of bends, generate a list of impr.
subroutine, public topology_generate_onfo(topology, subsys_section)
Using a list of torsion, generate a list of onfo.
subroutine, public topology_generate_bend(topology, subsys_section)
Using a list of bonds, generate a list of bends.
subroutine, public topology_generate_molecule(topology, qmmm, qmmm_env, subsys_section)
Use information from bond list to generate molecule. (ie clustering)
subroutine, public topology_generate_dihe(topology, subsys_section)
Generate a list of torsions from bonds.
subroutine, public topology_generate_ub(topology, subsys_section)
The list of Urey-Bradley is equal to the list of bends.
subroutine, public topology_generate_bond(topology, para_env, subsys_section)
Use info from periodic table and assumptions to generate bonds.
subroutine, public read_coordinate_g96(topology, para_env, subsys_section)
...
subroutine, public read_topology_gromos(file_name, topology, para_env, subsys_section)
Read GROMOS topology file.
Reads the input sections "topology".
subroutine, public read_topology_section(topology, topology_section)
reads the input section topology
subroutine, public read_constraints_section(topology, colvar_p, constraint_section)
Read all the distance parameters. Put them in the constraint_distance array.
Handles the multiple unit cell option regarding atomic coordinates.
subroutine, public topology_muc(topology, subsys_section)
Handles the multiple_unit_cell for the atomic coordinates.
Handles PDB files.
subroutine, public write_coordinate_pdb(file_unit, topology, subsys_section)
...
subroutine, public read_coordinate_pdb(topology, para_env, subsys_section)
...
Functionality to read in PSF topologies and convert it into local data structures.
subroutine, public read_topology_psf(filename, topology, para_env, subsys_section, psf_type)
Read PSF topology file Teodoro Laino - Introduced CHARMM31 EXT PSF standard format.
subroutine, public idm_psf(topology, section, subsys_section)
Input driven modification (IDM) of PSF defined structures.
subroutine, public write_topology_psf(file_unit, topology, subsys_section, force_env_section)
Teodoro Laino - 01.2006 Write PSF topology file in the CHARMM31 EXT standard format.
subroutine, public psf_post_process(topology, subsys_section)
Post processing of PSF informations.
subroutine, public deallocate_topology(topology)
Just DEALLOCATE all the stuff
subroutine, public pre_read_topology(topology)
Deallocate possibly allocated arrays before reading topology.
subroutine, public init_topology(topology)
Just NULLIFY and zero all the stuff
Collection of subroutine needed for topology related things.
subroutine, public topology_molecules_check(topology, subsys_section)
Check and verify that all molecules of the same kind are bonded the same.
subroutine, public topology_reorder_atoms(topology, qmmm, qmmm_env_mm, subsys_section, force_env_section)
...
subroutine, public topology_set_atm_mass(topology, subsys_section)
Use info from periodic table and set atm_mass.
subroutine, public check_subsys_element(element_in, atom_name_in, element_out, subsys_section, use_mm_map_first)
Check and returns the ELEMENT label.
Handles XTL (Molecular Simulations, Inc (MSI)) files.
subroutine, public read_coordinate_xtl(topology, para_env, subsys_section)
Performs the real task of reading the proper information from the XTL file.
subroutine, public read_coordinate_xyz(topology, para_env, subsys_section)
...
Control for reading in different topologies and coordinates.
Definition topology.F:13
subroutine, public connectivity_control(topology, para_env, qmmm, qmmm_env, subsys_section, force_env_section)
If reading in from external file, make sure its there first
Definition topology.F:319
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, subsys)
...
Definition topology.F:134
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
A type used to store lists of exclusions and onfos.
stores all the informations relevant to an mpi environment