(git:d43dca4)
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,&
23 USE colvar_types, ONLY: colvar_p_type,&
34 USE input_constants, ONLY: &
44 USE kinds, ONLY: default_path_length,&
46 dp
57 USE string_table, ONLY: id2str,&
58 s2s,&
59 str2id
82 USE topology_psf, ONLY: idm_psf,&
96#include "./base/base_uses.f90"
97
98 IMPLICIT NONE
99
100 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'topology'
101
102 PRIVATE
103
104 ! Public parameters
105 PUBLIC :: topology_control, &
107
108CONTAINS
109
110! **************************************************************************************************
111!> \brief ...
112!> \param atomic_kind_set ...
113!> \param particle_set ...
114!> \param molecule_kind_set ...
115!> \param molecule_set ...
116!> \param colvar_p ...
117!> \param gci ...
118!> \param root_section ...
119!> \param para_env ...
120!> \param qmmm ...
121!> \param qmmm_env ...
122!> \param force_env_section ...
123!> \param subsys_section ...
124!> \param use_motion_section ...
125!> \param exclusions ...
126!> \param elkind ...
127!> \param subsys ...
128! **************************************************************************************************
129 SUBROUTINE topology_control(atomic_kind_set, particle_set, molecule_kind_set, &
130 molecule_set, colvar_p, gci, root_section, para_env, qmmm, qmmm_env, &
131 force_env_section, subsys_section, use_motion_section, &
132 exclusions, elkind, subsys)
133
134 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
135 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
136 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
137 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
138 TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_p
139 TYPE(global_constraint_type), POINTER :: gci
140 TYPE(section_vals_type), POINTER :: root_section
141 TYPE(mp_para_env_type), POINTER :: para_env
142 LOGICAL, INTENT(IN), OPTIONAL :: qmmm
143 TYPE(qmmm_env_mm_type), OPTIONAL, POINTER :: qmmm_env
144 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
145 LOGICAL, INTENT(IN) :: use_motion_section
146 TYPE(exclusion_type), DIMENSION(:), OPTIONAL, &
147 POINTER :: exclusions
148 LOGICAL, INTENT(IN), OPTIONAL :: elkind
149 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
150
151 CHARACTER(LEN=*), PARAMETER :: routinen = 'topology_control'
152
153 INTEGER :: handle, iw, iw2
154 LOGICAL :: binary_coord_read, el_as_kind, explicit, &
155 my_qmmm, use_ref_cell
156 TYPE(cell_type), POINTER :: my_cell, my_cell_ref
157 TYPE(cp_logger_type), POINTER :: logger
158 TYPE(section_vals_type), POINTER :: cell_ref_section, cell_section, &
159 constraint_section, topology_section
161
162 NULLIFY (logger)
163 logger => cp_get_default_logger()
164 CALL timeset(routinen, handle)
165 NULLIFY (cell_section, cell_ref_section, constraint_section, topology_section)
166
167 cell_section => section_vals_get_subs_vals(subsys_section, "CELL")
168 IF (use_motion_section) THEN
169 constraint_section => section_vals_get_subs_vals(root_section, "MOTION%CONSTRAINT")
170 END IF
171 topology_section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY")
172 iw = cp_print_key_unit_nr(logger, subsys_section, "PRINT%TOPOLOGY_INFO", &
173 extension=".mmLog")
174 my_qmmm = .false.
175 IF (PRESENT(qmmm) .AND. PRESENT(qmmm_env)) my_qmmm = qmmm
176
177 IF (PRESENT(elkind)) THEN
178 CALL section_vals_val_get(topology_section, "USE_ELEMENT_AS_KIND", explicit=explicit)
179 IF (explicit) THEN
180 CALL section_vals_val_get(topology_section, "USE_ELEMENT_AS_KIND", l_val=el_as_kind)
181 ELSE
182 el_as_kind = elkind
183 END IF
184 ELSE
185 CALL section_vals_val_get(topology_section, "USE_ELEMENT_AS_KIND", l_val=el_as_kind)
186 END IF
187
188 ! 1. Initialize the topology structure type
190
191 ! 2. Get the cell info
192 NULLIFY (my_cell, my_cell_ref)
193 CALL read_cell(my_cell, my_cell_ref, cell_section=cell_section, &
194 topology_section=topology_section, para_env=para_env)
195 use_ref_cell = .false.
196 cell_ref_section => section_vals_get_subs_vals(cell_section, "CELL_REF")
197 CALL section_vals_get(cell_ref_section, explicit=use_ref_cell)
198 IF (.NOT. ASSOCIATED(topology%cell)) CALL cell_create(topology%cell)
199 IF (.NOT. ASSOCIATED(topology%cell_ref)) CALL cell_create(topology%cell_ref)
200 CALL cell_clone(my_cell, topology%cell)
201 CALL cell_clone(my_cell_ref, topology%cell_ref)
202 CALL setup_cell_muc(topology%cell_muc, topology%cell, subsys_section)
203 IF (PRESENT(subsys)) THEN ! subsys is passed from cp_subsys_create
204 CALL cp_subsys_set(subsys, cell=my_cell, cell_ref=my_cell_ref, &
205 use_ref_cell=use_ref_cell)
206 END IF
207 CALL write_cell(my_cell, subsys_section, tag="CELL")
208 CALL write_cell(my_cell_ref, subsys_section, tag="CELL_REF")
209 CALL cell_release(my_cell)
210 CALL cell_release(my_cell_ref)
211
212 ! 3. Read in the topology section in the input file if any
213 CALL read_topology_section(topology, topology_section)
214
215 ! 4. Read in the constraints section
216 CALL read_constraints_section(topology, colvar_p, constraint_section)
217
218 ! 5. Read in the coordinates
219 CALL read_binary_coordinates(topology, root_section, para_env, subsys_section, &
220 binary_coord_read)
221 IF (.NOT. binary_coord_read) THEN
222 CALL coordinate_control(topology, root_section, para_env, subsys_section)
223 END IF
224
225 ! 6. Read in or generate the molecular connectivity
226 CALL connectivity_control(topology, para_env, my_qmmm, qmmm_env, subsys_section, &
227 force_env_section)
228
229 IF (el_as_kind) THEN
230 ! redefine atom names with the name of the element
231 topology%atom_info%id_atmname(:) = topology%atom_info%id_element(:)
232 END IF
233
234 ! 7. Pack everything into the molecular types
235 CALL topology_connectivity_pack(molecule_kind_set, molecule_set, &
236 topology, subsys_section)
237
238 ! 8. Set up the QM/MM linkage (if any)
239 ! This part takes care of the molecule in which QM atoms were defined.
240 ! Preliminary setup for QM/MM link region
241 IF (my_qmmm) THEN
242 CALL qmmm_connectivity_control(molecule_set, qmmm_env, subsys_section)
243 END IF
244
245 ! 9. Pack everything into the atomic types
246 IF (my_qmmm) THEN
247 CALL topology_coordinate_pack(particle_set, atomic_kind_set, &
248 molecule_kind_set, molecule_set, &
249 topology, my_qmmm, qmmm_env, subsys_section, &
250 force_env_section=force_env_section, exclusions=exclusions)
251 ELSE
252 CALL topology_coordinate_pack(particle_set, atomic_kind_set, &
253 molecule_kind_set, molecule_set, &
254 topology, subsys_section=subsys_section, &
255 force_env_section=force_env_section, exclusions=exclusions)
256 END IF
257
258 !10. Post-Process colvar definitions (if needed)
259 CALL topology_post_proc_colvar(colvar_p, particle_set)
260
261 !11. Deal with the constraint stuff if requested
262 IF (my_qmmm) THEN
263 CALL topology_constraint_pack(molecule_kind_set, molecule_set, &
264 topology, qmmm_env, particle_set, root_section, subsys_section, &
265 gci)
266 ELSE
267 CALL topology_constraint_pack(molecule_kind_set, molecule_set, &
268 topology, particle_set=particle_set, input_file=root_section, &
269 subsys_section=subsys_section, gci=gci)
270 END IF
271
272 !12. Dump the topology informations
273 iw2 = cp_print_key_unit_nr(logger, subsys_section, "TOPOLOGY%DUMP_PDB", &
274 file_status="REPLACE", extension=".pdb")
275 IF (iw2 > 0) THEN
276 CALL write_coordinate_pdb(iw2, topology, subsys_section)
277 END IF
278 CALL cp_print_key_finished_output(iw2, logger, subsys_section, &
279 "TOPOLOGY%DUMP_PDB")
280 iw2 = cp_print_key_unit_nr(logger, subsys_section, "TOPOLOGY%DUMP_PSF", &
281 file_status="REPLACE", extension=".psf")
282 IF (iw2 > 0) THEN
283 CALL write_topology_psf(iw2, topology, subsys_section, force_env_section)
284 END IF
285 CALL cp_print_key_finished_output(iw2, logger, subsys_section, &
286 "TOPOLOGY%DUMP_PSF")
287
288 !13. Cleanup the topology structure type
290 CALL timestop(handle)
291 CALL cp_print_key_finished_output(iw, logger, subsys_section, &
292 "PRINT%TOPOLOGY_INFO")
293 END SUBROUTINE topology_control
294
295! **************************************************************************************************
296!> \brief 1. If reading in from external file, make sure its there first
297!> 2. Generate the connectivity if no information to be read in
298!> \param topology ...
299!> \param para_env ...
300!> \param qmmm ...
301!> \param qmmm_env ...
302!> \param subsys_section ...
303!> \param force_env_section ...
304!> \par History
305!> none
306!> \author IKUO 08.01.2003
307! **************************************************************************************************
308 SUBROUTINE connectivity_control(topology, para_env, qmmm, qmmm_env, subsys_section, &
309 force_env_section)
310
311 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
312 TYPE(mp_para_env_type), POINTER :: para_env
313 LOGICAL, INTENT(in), OPTIONAL :: qmmm
314 TYPE(qmmm_env_mm_type), OPTIONAL, POINTER :: qmmm_env
315 TYPE(section_vals_type), POINTER :: subsys_section, force_env_section
316
317 CHARACTER(len=*), PARAMETER :: routinen = 'connectivity_control'
318 INTEGER, PARAMETER :: map0 = ichar("0"), map9 = ichar("9")
319
320 CHARACTER(len=default_string_length) :: element0, my_element
321 CHARACTER(len=default_string_length), &
322 ALLOCATABLE, DIMENSION(:) :: elements
323 INTEGER :: handle, handle2, i, id, itmp, iw, j, k
324 LOGICAL :: check, my_qmmm, use_mm_map_first
325 TYPE(cp_logger_type), POINTER :: logger
326
327 NULLIFY (logger)
328 logger => cp_get_default_logger()
329 iw = cp_print_key_unit_nr(logger, subsys_section, "PRINT%TOPOLOGY_INFO", &
330 extension=".mmLog")
331 CALL timeset(routinen, handle)
332
333 my_qmmm = .false.
334 IF (PRESENT(qmmm) .AND. PRESENT(qmmm_env)) my_qmmm = qmmm
335
336 ! 1. Read in the connectivity information (if this is the case)
337 SELECT CASE (topology%conn_type)
339 ! Do nothing for the time being.. after we check element and proceed with the workflow..
340 CASE DEFAULT
341 ! Prepare arrays
343
344 ! Read connectivity from file
345 CALL read_topology_conn(topology, topology%conn_type, topology%conn_file_name, &
346 para_env, subsys_section)
347
348 ! Post process of PSF and AMBER information
349 SELECT CASE (topology%conn_type)
351 CALL psf_post_process(topology, subsys_section)
352 END SELECT
353 END SELECT
354
355 ! 2. In case element was autoassigned let's keep up2date the element name
356 ! with the atom_name
357 IF (topology%aa_element) THEN
358 check = SIZE(topology%atom_info%id_element) == SIZE(topology%atom_info%id_atmname)
359 cpassert(check)
360 topology%atom_info%id_element = topology%atom_info%id_atmname
361 END IF
362
363 ! 3. Check for the element name..
364 CALL timeset(routinen//"_check_element_name", handle2)
365 ! Fix element name
366
367 ! we will only translate names if we actually have a connectivity file given
368 SELECT CASE (topology%conn_type)
370 use_mm_map_first = .true.
371 CASE DEFAULT
372 use_mm_map_first = .false.
373 END SELECT
374 CALL create_ff_map("AMBER")
375 CALL create_ff_map("CHARMM")
376 CALL create_ff_map("GROMOS")
377
378 ALLOCATE (elements(SIZE(topology%atom_info%id_element)))
379 DO i = 1, SIZE(elements)
380 elements(i) = id2str(topology%atom_info%id_element(i))
381 END DO
382
383 DO i = 1, topology%natoms
384 IF (elements(i) == "__DEF__") cycle
385 ! If present an underscore let's skip all that over the underscore
386 id = index(elements(i), "_") - 1
387 IF (id == -1) id = len_trim(elements(i))
388 ! Many atomic kind have been defined as ELEMENT+LETTER+NUMBER
389 ! the number at the end can vary arbitrarily..
390 ! Let's check all ELEMENT+LETTER skipping the number.. we should
391 ! identify in any case the element
392 DO j = id, 1, -1
393 itmp = ichar(elements(i) (j:j))
394 IF ((itmp < map0) .OR. (itmp > map9)) EXIT
395 END DO
396 element0 = elements(i) (1:j)
397 ! ALWAYS check for elements..
398 CALL check_subsys_element(element0, id2str(topology%atom_info%id_atmname(i)), my_element, &
399 subsys_section, use_mm_map_first)
400 ! Earn time fixing same element labels for same atoms
401 element0 = elements(i)
402 DO k = i, topology%natoms
403 IF (element0 == id2str(topology%atom_info%id_element(k))) THEN
404 topology%atom_info%id_element(k) = str2id(s2s(my_element))
405 elements(k) = "__DEF__"
406 END IF
407 END DO
408 END DO
409 DEALLOCATE (elements)
410 CALL destroy_ff_map("GROMOS")
411 CALL destroy_ff_map("CHARMM")
412 CALL destroy_ff_map("AMBER")
413 CALL timestop(handle2)
414
415 ! 4. Generate the connectivity information otherwise
416 SELECT CASE (topology%conn_type)
417 CASE (do_conn_generate)
418 CALL topology_set_atm_mass(topology, subsys_section)
419 CALL topology_generate_bond(topology, para_env, subsys_section)
420 IF (topology%reorder_atom) THEN
421 ! If we generate connectivity we can save memory reordering the molecules
422 ! in this case once a first connectivity has been created we match according
423 ! molecule names provided in the PDB and reorder the connectivity according to that.
424 CALL topology_reorder_atoms(topology, qmmm, qmmm_env, subsys_section, &
425 force_env_section)
426 CALL topology_set_atm_mass(topology, subsys_section)
427 CALL topology_generate_bond(topology, para_env, subsys_section)
428 END IF
429 CALL topology_generate_bend(topology, subsys_section)
430 CALL topology_generate_ub(topology, subsys_section)
431 CALL topology_generate_dihe(topology, subsys_section)
432 CALL topology_generate_impr(topology, subsys_section)
433 CALL topology_generate_onfo(topology, subsys_section)
435 CALL topology_set_atm_mass(topology, subsys_section)
436 CALL topology_generate_bend(topology, subsys_section)
437 CALL topology_generate_ub(topology, subsys_section)
438 CALL topology_generate_dihe(topology, subsys_section)
439 CALL topology_generate_impr(topology, subsys_section)
440 CALL topology_generate_onfo(topology, subsys_section)
441 END SELECT
442
443 ! 5. Handle multiple unit_cell - Update atoms_info
444 CALL topology_muc(topology, subsys_section)
445
446 ! 6. Handle multiple unit_cell - Update conn_info
447 CALL topology_conn_multiple(topology, subsys_section)
448
449 ! 7. Generate Molecules
450 CALL topology_generate_molecule(topology, my_qmmm, qmmm_env, subsys_section)
451 IF (topology%molecules_check) CALL topology_molecules_check(topology, subsys_section)
452
453 ! 8. Modify for QM/MM
454 IF (my_qmmm) THEN
455 CALL qmmm_coordinate_control(topology, qmmm_env, subsys_section)
456 END IF
457 CALL timestop(handle)
458 CALL cp_print_key_finished_output(iw, logger, subsys_section, &
459 "PRINT%TOPOLOGY_INFO")
460
461 END SUBROUTINE connectivity_control
462
463! **************************************************************************************************
464!> \brief Reads connectivity from file
465!> \param topology ...
466!> \param conn_type ...
467!> \param conn_file_name ...
468!> \param para_env ...
469!> \param subsys_section ...
470!> \author Teodoro Laino [tlaino] - 10.2009
471! **************************************************************************************************
472 RECURSIVE SUBROUTINE read_topology_conn(topology, conn_type, conn_file_name, para_env, &
473 subsys_section)
474
475 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
476 INTEGER, INTENT(IN) :: conn_type
477 CHARACTER(LEN=default_path_length), INTENT(IN) :: conn_file_name
478 TYPE(mp_para_env_type), POINTER :: para_env
479 TYPE(section_vals_type), POINTER :: subsys_section
480
481 CHARACTER(len=default_path_length) :: filename
482 INTEGER :: i_rep, imol, loc_conn_type, n_rep, nmol
483 TYPE(section_vals_type), POINTER :: section
484
485 NULLIFY (section)
486
487 SELECT CASE (conn_type)
488 CASE (do_conn_mol_set)
489 section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY%MOL_SET")
490 section => section_vals_get_subs_vals(section, "MOLECULE")
491 CALL section_vals_get(section, n_repetition=n_rep)
492 DO i_rep = 1, n_rep
493 CALL section_vals_val_get(section, "NMOL", i_val=nmol, i_rep_section=i_rep)
494 CALL section_vals_val_get(section, "CONN_FILE_NAME", c_val=filename, i_rep_section=i_rep)
495 CALL section_vals_val_get(section, "CONN_FILE_FORMAT", i_val=loc_conn_type, i_rep_section=i_rep)
496
497 SELECT CASE (loc_conn_type)
499 DO imol = 1, nmol
500 CALL read_topology_conn(topology, loc_conn_type, filename, para_env, subsys_section)
501 END DO
502 CASE DEFAULT
503 CALL cp_abort(__location__, &
504 "MOL_SET feature implemented only for PSF/UPSF, G87/G96 and AMBER "// &
505 "connectivity type.")
506 END SELECT
507 END DO
508 IF (SIZE(topology%atom_info%id_molname) /= topology%natoms) &
509 CALL cp_abort(__location__, &
510 "Number of atoms in connectivity control is larger than the "// &
511 "number of atoms in coordinate control. check coordinates and "// &
512 "connectivity. ")
513
514 ! Merge defined structures
515 section => section_vals_get_subs_vals(subsys_section, "TOPOLOGY%MOL_SET%MERGE_MOLECULES")
516 CALL idm_psf(topology, section, subsys_section)
517
519 CALL read_topology_gromos(conn_file_name, topology, para_env, subsys_section)
521 CALL read_topology_psf(conn_file_name, topology, para_env, subsys_section, conn_type)
522 CASE (do_conn_amb7)
523 CALL read_connectivity_amber(conn_file_name, topology, para_env, subsys_section)
524 END SELECT
525
526 END SUBROUTINE read_topology_conn
527
528! **************************************************************************************************
529!> \brief 1. If reading in from external file, make sure its there first
530!> 2. Read in the coordinates from the corresponding locations
531!> \param topology ...
532!> \param root_section ...
533!> \param para_env ...
534!> \param subsys_section ...
535!> \par History
536!> - Teodoro Laino [tlaino] - University of Zurich 10.2008
537!> adding support for AMBER coordinates
538!> \author IKUO 08.11.2003
539! **************************************************************************************************
540 SUBROUTINE coordinate_control(topology, root_section, para_env, subsys_section)
541
542 TYPE(topology_parameters_type), INTENT(INOUT) :: topology
543 TYPE(section_vals_type), POINTER :: root_section
544 TYPE(mp_para_env_type), POINTER :: para_env
545 TYPE(section_vals_type), POINTER :: subsys_section
546
547 CHARACTER(len=*), PARAMETER :: routinen = 'coordinate_control'
548
549 CHARACTER(LEN=default_string_length) :: message
550 INTEGER :: handle, handle2, istat, iw
551 LOGICAL :: found, save_mem
552 TYPE(cp_logger_type), POINTER :: logger
553 TYPE(section_vals_type), POINTER :: global_section
554
555 NULLIFY (logger)
556 logger => cp_get_default_logger()
557 iw = cp_print_key_unit_nr(logger, subsys_section, "PRINT%TOPOLOGY_INFO", &
558 extension=".mmLog")
559 CALL timeset(routinen, handle)
560
561 NULLIFY (global_section)
562 global_section => section_vals_get_subs_vals(root_section, "GLOBAL")
563 CALL section_vals_val_get(global_section, "SAVE_MEM", l_val=save_mem)
564 !-----------------------------------------------------------------------------
565 ! 1. If reading in from external file, make sure its there first
566 !-----------------------------------------------------------------------------
567 IF (topology%coordinate) THEN
568 INQUIRE (file=topology%coord_file_name, exist=found, iostat=istat)
569 IF (istat /= 0) THEN
570 WRITE (unit=message, fmt="(A,I0,A)") &
571 "An error occurred inquiring the file <"// &
572 trim(topology%coord_file_name)//"> (IOSTAT = ", istat, ")"
573 cpabort(trim(message))
574 END IF
575 IF (.NOT. found) THEN
576 CALL cp_abort(__location__, &
577 "Coordinate file <"//trim(topology%coord_file_name)// &
578 "> not found.")
579 END IF
580 END IF
581 !-----------------------------------------------------------------------------
582 ! 2. Read in the coordinates from the corresponding locations
583 !-----------------------------------------------------------------------------
584 CALL timeset(routinen//"_READ_COORDINATE", handle2)
585 SELECT CASE (topology%coord_type)
586 CASE (do_coord_off)
587 ! Do nothing.. we will parse later from the &COORD section..
588 CASE (do_coord_g96)
589 CALL read_coordinate_g96(topology, para_env, subsys_section)
590 CASE (do_coord_crd)
591 CALL read_coordinate_crd(topology, para_env, subsys_section)
592 CASE (do_coord_pdb)
593 CALL read_coordinate_pdb(topology, para_env, subsys_section)
594 CASE (do_coord_xyz)
595 CALL read_coordinate_xyz(topology, para_env, subsys_section)
596 CASE (do_coord_cif)
597 CALL read_coordinate_cif(topology, para_env, subsys_section)
598 CASE (do_coord_xtl)
599 CALL read_coordinate_xtl(topology, para_env, subsys_section)
600 CASE (do_coord_cp2k)
601 CALL read_coordinate_cp2k(topology, para_env, subsys_section)
602 CASE DEFAULT
603 ! We should never reach this point..
604 cpabort("")
605 END SELECT
606
607 ! Parse &COORD section and in case overwrite
608 IF (topology%coord_type /= do_coord_cp2k) THEN
609 CALL read_atoms_input(topology, overwrite=(topology%coord_type /= do_coord_off), &
610 subsys_section=subsys_section, save_mem=save_mem)
611 END IF
612 CALL section_vals_val_set(subsys_section, "TOPOLOGY%NUMBER_OF_ATOMS", &
613 i_val=topology%natoms)
614 CALL timestop(handle2)
615 ! Check on atom numbers
616 IF (topology%natoms <= 0) &
617 cpabort("No atomic coordinates have been found! ")
618 CALL timestop(handle)
619 CALL cp_print_key_finished_output(iw, logger, subsys_section, &
620 "PRINT%TOPOLOGY_INFO")
621 END SUBROUTINE coordinate_control
622
623! **************************************************************************************************
624!> \brief ...
625!> \param colvar_p ...
626!> \param particle_set ...
627!> \par History
628!> none
629!> \author Teodoro Laino [tlaino] - 07.2007
630! **************************************************************************************************
631 SUBROUTINE topology_post_proc_colvar(colvar_p, particle_set)
632
633 TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_p
634 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
635
636 INTEGER :: i, j
637
638 IF (ASSOCIATED(colvar_p)) THEN
639 DO i = 1, SIZE(colvar_p)
640 IF (colvar_p(i)%colvar%type_id == combine_colvar_id) THEN
641 DO j = 1, SIZE(colvar_p(i)%colvar%combine_cvs_param%colvar_p)
642 CALL post_process_colvar(colvar_p(i)%colvar%combine_cvs_param%colvar_p(j)%colvar, particle_set)
643 END DO
644 CALL colvar_setup(colvar_p(i)%colvar)
645 ELSE
646 CALL post_process_colvar(colvar_p(i)%colvar, particle_set)
647 END IF
648 END DO
649 END IF
650 END SUBROUTINE topology_post_proc_colvar
651
652! **************************************************************************************************
653!> \brief Setup the cell used for handling properly the multiple_unit_cell option
654!> \param cell_muc ...
655!> \param cell ...
656!> \param subsys_section ...
657!> \author Teodoro Laino [tlaino] - 06.2009
658! **************************************************************************************************
659 SUBROUTINE setup_cell_muc(cell_muc, cell, subsys_section)
660
661 TYPE(cell_type), POINTER :: cell_muc, cell
662 TYPE(section_vals_type), POINTER :: subsys_section
663
664 INTEGER, DIMENSION(:), POINTER :: multiple_unit_cell
665 REAL(kind=dp), DIMENSION(3, 3) :: hmat_ref
666
667 cpassert(.NOT. ASSOCIATED(cell_muc))
668
669 CALL section_vals_val_get(subsys_section, "CELL%MULTIPLE_UNIT_CELL", &
670 i_vals=multiple_unit_cell)
671 IF (any(multiple_unit_cell /= 1)) THEN
672 ! Restore the original cell
673 hmat_ref(:, 1) = cell%hmat(:, 1)/multiple_unit_cell(1)
674 hmat_ref(:, 2) = cell%hmat(:, 2)/multiple_unit_cell(2)
675 hmat_ref(:, 3) = cell%hmat(:, 3)/multiple_unit_cell(3)
676 ! Create the MUC cell
677 CALL cell_create(cell_muc, hmat=hmat_ref, periodic=cell%perd, tag="CELL_UC")
678 CALL write_cell(cell_muc, subsys_section)
679 ELSE
680 ! If a multiple_unit_cell was not requested just point to the original cell
681 CALL cell_retain(cell)
682 cell_muc => cell
683 END IF
684
685 END SUBROUTINE setup_cell_muc
686
687END 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:70
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:564
subroutine, public cell_clone(cell_in, cell_out, tag)
Clone cell variable.
Definition cell_types.F:112
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:547
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:310
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:133
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