22 USE dbcsr_api,
ONLY: &
23 dbcsr_add, dbcsr_copy, dbcsr_get_block_p, dbcsr_iterator_blocks_left, &
24 dbcsr_iterator_next_block, dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, &
25 dbcsr_p_type, dbcsr_set
30 ewald_environment_type,&
71 #include "./base/base_uses.f90"
84 CHARACTER(len=*),
PARAMETER,
PRIVATE :: modulen =
'qmmm_tb_methods'
103 TYPE(qs_environment_type),
POINTER :: qs_env
104 TYPE(qmmm_env_qm_type),
POINTER :: qmmm_env
105 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_mm
106 TYPE(cell_type),
POINTER :: mm_cell
107 TYPE(mp_para_env_type),
POINTER :: para_env
109 CHARACTER(len=*),
PARAMETER :: routinen =
'build_tb_qmmm_matrix'
111 INTEGER :: blk, handle, i, iatom, ikind, jatom, &
113 INTEGER,
DIMENSION(:),
POINTER ::
list
114 LOGICAL :: defined, do_dftb, do_xtb, found
115 REAL(kind=
dp) :: pc_ener, zeff
116 REAL(kind=
dp),
DIMENSION(0:3) :: eta_a
117 REAL(kind=
dp),
DIMENSION(:),
POINTER :: qpot
118 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hblock, sblock
119 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
120 TYPE(dbcsr_iterator_type) :: iter
121 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_h, matrix_s
122 TYPE(dft_control_type),
POINTER :: dft_control
123 TYPE(dftb_control_type),
POINTER :: dftb_control
124 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
126 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_qm
127 TYPE(qs_dftb_atom_type),
POINTER :: dftb_kind
128 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
129 TYPE(qs_ks_env_type),
POINTER :: ks_env
130 TYPE(qs_ks_qmmm_env_type),
POINTER :: ks_qmmm_env_loc
131 TYPE(qs_rho_type),
POINTER :: rho
132 TYPE(xtb_atom_type),
POINTER :: xtb_kind
133 TYPE(xtb_control_type),
POINTER :: xtb_control
135 CALL timeset(routinen, handle)
138 dft_control=dft_control, &
139 atomic_kind_set=atomic_kind_set, &
140 particle_set=particles_qm, &
141 qs_kind_set=qs_kind_set, &
144 dftb_control => dft_control%qs_control%dftb_control
145 xtb_control => dft_control%qs_control%xtb_control
147 IF (dft_control%qs_control%dftb)
THEN
150 ELSEIF (dft_control%qs_control%xtb)
THEN
154 cpabort(
"TB method unknown")
163 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, sab_orb=sab_nl)
164 CALL build_overlap_matrix(ks_env, matrix_s, basis_type_a=
'ORB', basis_type_b=
'ORB', sab_nl=sab_nl)
167 ALLOCATE (qpot(natom))
171 nkind =
SIZE(atomic_kind_set)
176 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
178 defined=defined, eta=eta_a, natorb=natorb)
180 IF (.NOT. dftb_control%self_consistent) eta_a(0) =
eta_mm
181 IF (.NOT. defined .OR. natorb < 1) cycle
184 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
190 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%Potentials, particles_mm, &
191 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, mm_cell, iatom, &
192 qmmm_env%spherical_cutoff, particles_qm)
194 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
195 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%added_charges%potentials, &
196 qmmm_env%added_charges%added_particles, &
197 qmmm_env%added_charges%mm_atom_chrg, &
198 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
199 qmmm_env%spherical_cutoff, &
202 pc_ener = pc_ener + qpot(iatom)*zeff
207 CALL get_qs_env(qs_env=qs_env, ks_qmmm_env=ks_qmmm_env_loc)
208 matrix_h => ks_qmmm_env_loc%matrix_h
210 ALLOCATE (matrix_h(1)%matrix)
211 CALL dbcsr_copy(matrix_h(1)%matrix, matrix_s(1)%matrix, &
212 name=
"QMMM HAMILTONIAN MATRIX")
213 CALL dbcsr_set(matrix_h(1)%matrix, 0.0_dp)
215 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
216 DO WHILE (dbcsr_iterator_blocks_left(iter))
217 CALL dbcsr_iterator_next_block(iter, iatom, jatom, sblock, blk)
219 CALL dbcsr_get_block_p(matrix=matrix_h(1)%matrix, &
220 row=iatom, col=jatom, block=hblock, found=found)
222 hblock = hblock - 0.5_dp*sblock*(qpot(iatom) + qpot(jatom))
224 CALL dbcsr_iterator_stop(iter)
226 ks_qmmm_env_loc%matrix_h => matrix_h
227 ks_qmmm_env_loc%pc_ener = pc_ener
233 CALL timestop(handle)
245 TYPE(qs_environment_type),
POINTER :: qs_env
246 TYPE(mp_para_env_type),
POINTER :: para_env
248 CHARACTER(len=*),
PARAMETER :: routinen =
'build_tb_qmmm_matrix_zero'
251 LOGICAL :: do_dftb, do_xtb
252 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_h, matrix_s
253 TYPE(dft_control_type),
POINTER :: dft_control
254 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
256 TYPE(qs_ks_env_type),
POINTER :: ks_env
257 TYPE(qs_ks_qmmm_env_type),
POINTER :: ks_qmmm_env_loc
259 CALL timeset(routinen, handle)
261 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
263 IF (dft_control%qs_control%dftb)
THEN
266 ELSEIF (dft_control%qs_control%xtb)
THEN
270 cpabort(
"TB method unknown")
279 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, sab_orb=sab_nl)
280 CALL build_overlap_matrix(ks_env, matrix_s, basis_type_a=
'ORB', basis_type_b=
'ORB', sab_nl=sab_nl)
284 CALL get_qs_env(qs_env=qs_env, ks_qmmm_env=ks_qmmm_env_loc)
285 matrix_h => ks_qmmm_env_loc%matrix_h
287 ALLOCATE (matrix_h(1)%matrix)
288 CALL dbcsr_copy(matrix_h(1)%matrix, matrix_s(1)%matrix, &
289 name=
"QMMM HAMILTONIAN MATRIX")
290 CALL dbcsr_set(matrix_h(1)%matrix, 0.0_dp)
291 ks_qmmm_env_loc%matrix_h => matrix_h
292 ks_qmmm_env_loc%pc_ener = 0.0_dp
296 CALL timestop(handle)
311 TYPE(qs_environment_type),
POINTER :: qs_env
312 TYPE(qmmm_env_qm_type),
POINTER :: qmmm_env
313 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_mm
314 TYPE(cell_type),
POINTER :: mm_cell
315 TYPE(mp_para_env_type),
POINTER :: para_env
317 CHARACTER(len=*),
PARAMETER :: routinen =
'build_tb_qmmm_matrix_pc'
319 INTEGER :: blk, do_ipol, ewald_type, handle, i, &
320 iatom, ikind, imm, imp, indmm, ipot, &
321 jatom, natom, natorb, nkind, nmm
322 INTEGER,
DIMENSION(:),
POINTER ::
list
323 LOGICAL :: defined, do_dftb, do_multipoles, do_xtb, &
325 REAL(kind=
dp) :: alpha, pc_ener, zeff
326 REAL(kind=
dp),
DIMENSION(0:3) :: eta_a
327 REAL(kind=
dp),
DIMENSION(2) :: rcutoff
328 REAL(kind=
dp),
DIMENSION(:),
POINTER :: charges_mm, qpot
329 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hblock, sblock
330 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
331 TYPE(dbcsr_iterator_type) :: iter
332 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_h, matrix_s
333 TYPE(dft_control_type),
POINTER :: dft_control
334 TYPE(dftb_control_type),
POINTER :: dftb_control
335 TYPE(ewald_environment_type),
POINTER :: ewald_env
336 TYPE(ewald_pw_type),
POINTER :: ewald_pw
337 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
339 TYPE(particle_type),
DIMENSION(:),
POINTER :: atoms_mm, particles_qm
340 TYPE(qmmm_pot_type),
POINTER :: pot
341 TYPE(qs_dftb_atom_type),
POINTER :: dftb_kind
342 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
343 TYPE(qs_ks_env_type),
POINTER :: ks_env
344 TYPE(qs_ks_qmmm_env_type),
POINTER :: ks_qmmm_env_loc
345 TYPE(qs_rho_type),
POINTER :: rho
346 TYPE(section_vals_type),
POINTER :: ewald_section, poisson_section, &
348 TYPE(xtb_atom_type),
POINTER :: xtb_kind
349 TYPE(xtb_control_type),
POINTER :: xtb_control
351 CALL timeset(routinen, handle)
354 dft_control=dft_control, &
355 atomic_kind_set=atomic_kind_set, &
356 particle_set=particles_qm, &
357 qs_kind_set=qs_kind_set, &
360 dftb_control => dft_control%qs_control%dftb_control
361 xtb_control => dft_control%qs_control%xtb_control
363 IF (dft_control%qs_control%dftb)
THEN
366 ELSEIF (dft_control%qs_control%xtb)
THEN
370 cpabort(
"TB method unknown")
379 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, sab_orb=sab_nl)
380 CALL build_overlap_matrix(ks_env, matrix_s, basis_type_a=
'ORB', basis_type_b=
'ORB', sab_nl=sab_nl)
383 ALLOCATE (qpot(natom))
391 CALL ewald_env_set(ewald_env, poisson_section=poisson_section)
396 CALL ewald_pw_create(ewald_pw, ewald_env, mm_cell, mm_cell, print_section=print_section)
398 CALL ewald_env_get(ewald_env, ewald_type=ewald_type, do_multipoles=do_multipoles, do_ipol=do_ipol)
399 IF (do_multipoles) cpabort(
"No multipole force fields allowed in TB QM/MM")
400 IF (do_ipol /=
do_fist_pol_none) cpabort(
"No polarizable force fields allowed in TB QM/MM")
402 SELECT CASE (ewald_type)
404 cpabort(
"PME Ewald type not implemented for TB/QMMM")
406 DO ipot = 1,
SIZE(qmmm_env%Potentials)
407 pot => qmmm_env%Potentials(ipot)%Pot
408 nmm =
SIZE(pot%mm_atom_index)
412 ALLOCATE (charges_mm(nmm))
414 imm = pot%mm_atom_index(imp)
415 indmm = qmmm_env%mm_atom_index(imm)
416 atoms_mm(imp)%r = particles_mm(indmm)%r
417 atoms_mm(imp)%atomic_kind => particles_mm(indmm)%atomic_kind
418 charges_mm(imp) = qmmm_env%mm_atom_chrg(imm)
421 cpabort(
"Ewald not implemented for TB/QMMM")
424 CALL spme_potential(ewald_env, ewald_pw, mm_cell, atoms_mm, charges_mm, particles_qm, qpot)
427 DEALLOCATE (charges_mm)
429 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
430 DO ipot = 1,
SIZE(qmmm_env%added_charges%Potentials)
431 pot => qmmm_env%added_charges%Potentials(ipot)%Pot
432 nmm =
SIZE(pot%mm_atom_index)
436 ALLOCATE (charges_mm(nmm))
438 imm = pot%mm_atom_index(imp)
439 indmm = qmmm_env%added_charges%mm_atom_index(imm)
440 atoms_mm(imp)%r = qmmm_env%added_charges%added_particles(indmm)%r
441 atoms_mm(imp)%atomic_kind => qmmm_env%added_charges%added_particles(indmm)%atomic_kind
442 charges_mm(imp) = qmmm_env%added_charges%mm_atom_chrg(imm)
445 cpabort(
"Ewald not implemented for TB/QMMM")
448 CALL spme_potential(ewald_env, ewald_pw, mm_cell, atoms_mm, charges_mm, particles_qm, qpot)
451 DEALLOCATE (charges_mm)
454 CALL para_env%sum(qpot)
459 rcutoff(2) = 0.025_dp*rcutoff(1)
460 rcutoff(1) = 2.0_dp*rcutoff(1)
461 nkind =
SIZE(atomic_kind_set)
466 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
468 defined=defined, eta=eta_a, natorb=natorb)
470 IF (.NOT. dftb_control%self_consistent) eta_a(0) =
eta_mm
471 IF (.NOT. defined .OR. natorb < 1) cycle
474 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
480 CALL build_mm_pot(qpot(iatom), 1, eta_a(0), qmmm_env%Potentials, particles_mm, &
481 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, mm_cell, iatom, rcutoff, &
483 CALL build_mm_pot(qpot(iatom), 2, alpha, qmmm_env%Potentials, particles_mm, &
484 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, mm_cell, iatom, rcutoff, &
487 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
488 CALL build_mm_pot(qpot(iatom), 1, eta_a(0), qmmm_env%added_charges%potentials, &
489 qmmm_env%added_charges%added_particles, &
490 qmmm_env%added_charges%mm_atom_chrg, &
491 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, rcutoff, &
493 CALL build_mm_pot(qpot(iatom), 2, alpha, qmmm_env%added_charges%potentials, &
494 qmmm_env%added_charges%added_particles, &
495 qmmm_env%added_charges%mm_atom_chrg, &
496 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, rcutoff, &
499 pc_ener = pc_ener + qpot(iatom)*zeff
504 nkind =
SIZE(atomic_kind_set)
509 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
511 defined=defined, eta=eta_a, natorb=natorb)
513 IF (.NOT. dftb_control%self_consistent) eta_a(0) =
eta_mm
514 IF (.NOT. defined .OR. natorb < 1) cycle
517 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
523 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%Potentials, particles_mm, &
524 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, mm_cell, iatom, &
525 qmmm_env%spherical_cutoff, particles_qm)
527 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
528 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%added_charges%potentials, &
529 qmmm_env%added_charges%added_particles, &
530 qmmm_env%added_charges%mm_atom_chrg, &
531 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
532 qmmm_env%spherical_cutoff, &
535 pc_ener = pc_ener + qpot(iatom)*zeff
539 cpabort(
"Unknown Ewald type!")
543 CALL get_qs_env(qs_env=qs_env, ks_qmmm_env=ks_qmmm_env_loc)
544 matrix_h => ks_qmmm_env_loc%matrix_h
546 ALLOCATE (matrix_h(1)%matrix)
547 CALL dbcsr_copy(matrix_h(1)%matrix, matrix_s(1)%matrix, &
548 name=
"QMMM HAMILTONIAN MATRIX")
549 CALL dbcsr_set(matrix_h(1)%matrix, 0.0_dp)
551 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
552 DO WHILE (dbcsr_iterator_blocks_left(iter))
553 CALL dbcsr_iterator_next_block(iter, iatom, jatom, sblock, blk)
555 CALL dbcsr_get_block_p(matrix=matrix_h(1)%matrix, &
556 row=iatom, col=jatom, block=hblock, found=found)
558 hblock = hblock - 0.5_dp*sblock*(qpot(iatom) + qpot(jatom))
560 CALL dbcsr_iterator_stop(iter)
562 ks_qmmm_env_loc%matrix_h => matrix_h
563 ks_qmmm_env_loc%pc_ener = pc_ener
569 DEALLOCATE (ewald_env)
571 DEALLOCATE (ewald_pw)
575 CALL timestop(handle)
592 calc_force, Forces, Forces_added_charges)
594 TYPE(qs_environment_type),
POINTER :: qs_env
595 TYPE(qmmm_env_qm_type),
POINTER :: qmmm_env
596 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_mm
597 TYPE(cell_type),
POINTER :: mm_cell
598 TYPE(mp_para_env_type),
POINTER :: para_env
599 LOGICAL,
INTENT(in),
OPTIONAL :: calc_force
600 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: forces, forces_added_charges
602 CHARACTER(len=*),
PARAMETER :: routinen =
'deriv_tb_qmmm_matrix'
604 INTEGER :: atom_a, blk, handle, i, iatom, ikind, &
605 iqm, jatom, natom, natorb, nkind, &
606 nspins, number_qm_atoms
607 INTEGER,
DIMENSION(:),
POINTER ::
list
608 LOGICAL :: defined, do_dftb, do_xtb, found
609 REAL(kind=
dp) :: fi, gmij, zeff
610 REAL(kind=
dp),
DIMENSION(0:3) :: eta_a
611 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mcharge, qpot
612 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges, dsblock, forces_qm, pblock, &
614 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
615 TYPE(dbcsr_iterator_type) :: iter
616 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p, matrix_s
617 TYPE(dft_control_type),
POINTER :: dft_control
618 TYPE(dftb_control_type),
POINTER :: dftb_control
619 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
621 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_qm
622 TYPE(qs_dftb_atom_type),
POINTER :: dftb_kind
623 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
624 TYPE(qs_ks_env_type),
POINTER :: ks_env
625 TYPE(qs_ks_qmmm_env_type),
POINTER :: ks_qmmm_env_loc
626 TYPE(qs_rho_type),
POINTER :: rho
627 TYPE(xtb_atom_type),
POINTER :: xtb_kind
628 TYPE(xtb_control_type),
POINTER :: xtb_control
630 CALL timeset(routinen, handle)
632 NULLIFY (rho, atomic_kind_set, qs_kind_set, particles_qm)
635 atomic_kind_set=atomic_kind_set, &
636 qs_kind_set=qs_kind_set, &
637 ks_qmmm_env=ks_qmmm_env_loc, &
638 dft_control=dft_control, &
639 particle_set=particles_qm, &
640 natom=number_qm_atoms)
641 dftb_control => dft_control%qs_control%dftb_control
642 xtb_control => dft_control%qs_control%xtb_control
644 IF (dft_control%qs_control%dftb)
THEN
647 ELSEIF (dft_control%qs_control%xtb)
THEN
651 cpabort(
"TB method unknown")
658 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, sab_orb=sab_nl)
660 basis_type_a=
'ORB', basis_type_b=
'ORB', sab_nl=sab_nl)
665 nspins = dft_control%nspins
666 nkind =
SIZE(atomic_kind_set)
668 ALLOCATE (charges(number_qm_atoms, nspins))
670 CALL mulliken_charges(matrix_p, matrix_s(1)%matrix, para_env, charges)
672 ALLOCATE (mcharge(number_qm_atoms))
676 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
679 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
683 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
684 mcharge(atom_a) = zeff - sum(charges(atom_a, 1:nspins))
689 ALLOCATE (qpot(number_qm_atoms))
691 ALLOCATE (forces_qm(3, number_qm_atoms))
700 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
702 defined=defined, eta=eta_a, natorb=natorb)
704 IF (.NOT. dftb_control%self_consistent) eta_a(0) =
eta_mm
705 IF (.NOT. defined .OR. natorb < 1) cycle
712 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%Potentials, particles_mm, &
713 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, mm_cell, iatom, &
714 qmmm_env%spherical_cutoff, particles_qm)
715 CALL build_mm_dpot(mcharge(iatom), 0, eta_a(0), qmmm_env%Potentials, particles_mm, &
716 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, &
717 mm_cell, iatom, forces, forces_qm(:, iqm), &
718 qmmm_env%spherical_cutoff, particles_qm)
720 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
721 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%added_charges%potentials, &
722 qmmm_env%added_charges%added_particles, &
723 qmmm_env%added_charges%mm_atom_chrg, &
724 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
725 qmmm_env%spherical_cutoff, &
727 CALL build_mm_dpot(mcharge(iatom), 0, eta_a(0), qmmm_env%added_charges%potentials, &
728 qmmm_env%added_charges%added_particles, &
729 qmmm_env%added_charges%mm_atom_chrg, &
730 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
731 forces_added_charges, &
732 forces_qm(:, iqm), qmmm_env%spherical_cutoff, particles_qm)
743 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
745 IF (.NOT. defined .OR. natorb < 1) cycle
751 iatom = qmmm_env%qm_atom_index(
list(i))
752 particles_mm(iatom)%f(:) = particles_mm(iatom)%f(:) + forces_qm(:, iqm)
758 IF (
SIZE(matrix_p) == 2)
THEN
759 CALL dbcsr_add(matrix_p(1)%matrix, matrix_p(2)%matrix, &
760 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
763 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
764 DO WHILE (dbcsr_iterator_blocks_left(iter))
765 CALL dbcsr_iterator_next_block(iter, iatom, jatom, sblock, blk)
767 IF (iatom == jatom) cycle
769 gmij = -0.5_dp*(qpot(iatom) + qpot(jatom))
771 CALL dbcsr_get_block_p(matrix=matrix_p(1)%matrix, &
772 row=iatom, col=jatom, block=pblock, found=found)
776 CALL dbcsr_get_block_p(matrix=matrix_s(1 + i)%matrix, &
777 row=iatom, col=jatom, block=dsblock, found=found)
779 fi = -2.0_dp*gmij*sum(pblock*dsblock)
780 forces_qm(i, iatom) = forces_qm(i, iatom) + fi
781 forces_qm(i, jatom) = forces_qm(i, jatom) - fi
784 CALL dbcsr_iterator_stop(iter)
786 IF (
SIZE(matrix_p) == 2)
THEN
787 CALL dbcsr_add(matrix_p(1)%matrix, matrix_p(2)%matrix, &
788 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
792 CALL para_env%sum(forces_qm)
797 iatom = qmmm_env%qm_atom_index(iqm)
798 particles_mm(iatom)%f(:) = particles_mm(iatom)%f(:) + forces_qm(:, iqm)
806 DEALLOCATE (forces_qm)
812 CALL timestop(handle)
829 calc_force, Forces, Forces_added_charges)
831 TYPE(qs_environment_type),
POINTER :: qs_env
832 TYPE(qmmm_env_qm_type),
POINTER :: qmmm_env
833 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_mm
834 TYPE(cell_type),
POINTER :: mm_cell
835 TYPE(mp_para_env_type),
POINTER :: para_env
836 LOGICAL,
INTENT(in),
OPTIONAL :: calc_force
837 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: forces, forces_added_charges
839 CHARACTER(len=*),
PARAMETER :: routinen =
'deriv_tb_qmmm_matrix_pc'
841 INTEGER :: atom_a, blk, do_ipol, ewald_type, handle, i, iatom, ikind, imm, imp, indmm, ipot, &
842 iqm, jatom, natom, natorb, nkind, nmm, nspins, number_qm_atoms
843 INTEGER,
DIMENSION(:),
POINTER ::
list
844 LOGICAL :: defined, do_dftb, do_multipoles, do_xtb, &
846 REAL(kind=
dp) :: alpha, fi, gmij, zeff
847 REAL(kind=
dp),
DIMENSION(0:3) :: eta_a
848 REAL(kind=
dp),
DIMENSION(2) :: rcutoff
849 REAL(kind=
dp),
DIMENSION(:),
POINTER :: charges_mm, mcharge, qpot
850 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges, dsblock, forces_mm, forces_qm, &
852 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
853 TYPE(dbcsr_iterator_type) :: iter
854 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p, matrix_s
855 TYPE(dft_control_type),
POINTER :: dft_control
856 TYPE(dftb_control_type),
POINTER :: dftb_control
857 TYPE(ewald_environment_type),
POINTER :: ewald_env
858 TYPE(ewald_pw_type),
POINTER :: ewald_pw
859 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
861 TYPE(particle_type),
DIMENSION(:),
POINTER :: atoms_mm, particles_qm
862 TYPE(qmmm_pot_type),
POINTER :: pot
863 TYPE(qs_dftb_atom_type),
POINTER :: dftb_kind
864 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
865 TYPE(qs_ks_env_type),
POINTER :: ks_env
866 TYPE(qs_ks_qmmm_env_type),
POINTER :: ks_qmmm_env_loc
867 TYPE(qs_rho_type),
POINTER :: rho
868 TYPE(section_vals_type),
POINTER :: ewald_section, poisson_section, &
870 TYPE(xtb_atom_type),
POINTER :: xtb_kind
871 TYPE(xtb_control_type),
POINTER :: xtb_control
873 CALL timeset(routinen, handle)
875 NULLIFY (rho, atomic_kind_set, qs_kind_set, particles_qm)
878 atomic_kind_set=atomic_kind_set, &
879 qs_kind_set=qs_kind_set, &
880 ks_qmmm_env=ks_qmmm_env_loc, &
881 dft_control=dft_control, &
882 particle_set=particles_qm, &
883 natom=number_qm_atoms)
884 dftb_control => dft_control%qs_control%dftb_control
885 xtb_control => dft_control%qs_control%xtb_control
887 IF (dft_control%qs_control%dftb)
THEN
890 ELSEIF (dft_control%qs_control%xtb)
THEN
894 cpabort(
"TB method unknown")
901 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, sab_orb=sab_nl)
903 basis_type_a=
'ORB', basis_type_b=
'ORB', sab_nl=sab_nl)
907 nspins = dft_control%nspins
908 nkind =
SIZE(atomic_kind_set)
910 ALLOCATE (charges(number_qm_atoms, nspins))
912 CALL mulliken_charges(matrix_p, matrix_s(1)%matrix, para_env, charges)
914 ALLOCATE (mcharge(number_qm_atoms))
918 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
921 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
925 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
926 mcharge(atom_a) = zeff - sum(charges(atom_a, 1:nspins))
931 ALLOCATE (qpot(number_qm_atoms))
933 ALLOCATE (forces_qm(3, number_qm_atoms))
940 CALL ewald_env_set(ewald_env, poisson_section=poisson_section)
945 CALL ewald_pw_create(ewald_pw, ewald_env, mm_cell, mm_cell, print_section=print_section)
947 CALL ewald_env_get(ewald_env, ewald_type=ewald_type, do_multipoles=do_multipoles, do_ipol=do_ipol)
948 IF (do_multipoles) cpabort(
"No multipole force fields allowed in DFTB QM/MM")
949 IF (do_ipol /=
do_fist_pol_none) cpabort(
"No polarizable force fields allowed in DFTB QM/MM")
951 SELECT CASE (ewald_type)
953 cpabort(
"PME Ewald type not implemented for DFTB/QMMM")
955 DO ipot = 1,
SIZE(qmmm_env%Potentials)
956 pot => qmmm_env%Potentials(ipot)%Pot
957 nmm =
SIZE(pot%mm_atom_index)
961 ALLOCATE (charges_mm(nmm))
963 imm = pot%mm_atom_index(imp)
964 indmm = qmmm_env%mm_atom_index(imm)
965 atoms_mm(imp)%r = particles_mm(indmm)%r
966 atoms_mm(imp)%atomic_kind => particles_mm(indmm)%atomic_kind
967 charges_mm(imp) = qmmm_env%mm_atom_chrg(imm)
970 ALLOCATE (forces_mm(3, nmm))
973 cpabort(
"Ewald not implemented for DFTB/QMMM")
976 CALL spme_potential(ewald_env, ewald_pw, mm_cell, atoms_mm, charges_mm, &
979 CALL spme_forces(ewald_env, ewald_pw, mm_cell, atoms_mm, charges_mm, &
980 particles_qm, mcharge, forces_qm)
982 CALL spme_forces(ewald_env, ewald_pw, mm_cell, particles_qm, mcharge, &
983 atoms_mm, charges_mm, forces_mm)
986 DEALLOCATE (charges_mm)
988 CALL para_env%sum(forces_mm)
990 imm = pot%mm_atom_index(imp)
991 forces(:, imm) = forces(:, imm) - forces_mm(:, imp)
993 DEALLOCATE (forces_mm)
996 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
997 DO ipot = 1,
SIZE(qmmm_env%added_charges%Potentials)
998 pot => qmmm_env%added_charges%Potentials(ipot)%Pot
999 nmm =
SIZE(pot%mm_atom_index)
1003 ALLOCATE (charges_mm(nmm))
1005 imm = pot%mm_atom_index(imp)
1006 indmm = qmmm_env%added_charges%mm_atom_index(imm)
1007 atoms_mm(imp)%r = qmmm_env%added_charges%added_particles(indmm)%r
1008 atoms_mm(imp)%atomic_kind => qmmm_env%added_charges%added_particles(indmm)%atomic_kind
1009 charges_mm(imp) = qmmm_env%added_charges%mm_atom_chrg(imm)
1012 ALLOCATE (forces_mm(3, nmm))
1015 cpabort(
"Ewald not implemented for DFTB/QMMM")
1019 charges_mm, particles_qm, qpot)
1021 CALL spme_forces(ewald_env, ewald_pw, mm_cell, atoms_mm, charges_mm, &
1022 particles_qm, mcharge, forces_qm)
1024 CALL spme_forces(ewald_env, ewald_pw, mm_cell, particles_qm, mcharge, &
1025 atoms_mm, charges_mm, forces_mm)
1029 CALL para_env%sum(forces_mm)
1031 imm = pot%mm_atom_index(imp)
1032 forces_added_charges(:, imm) = forces_added_charges(:, imm) - forces_mm(:, imp)
1034 DEALLOCATE (forces_mm)
1037 CALL para_env%sum(qpot)
1038 CALL para_env%sum(forces_qm)
1043 rcutoff(2) = 0.025_dp*rcutoff(1)
1044 rcutoff(1) = 2.0_dp*rcutoff(1)
1045 nkind =
SIZE(atomic_kind_set)
1051 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
1053 defined=defined, eta=eta_a, natorb=natorb)
1055 IF (.NOT. dftb_control%self_consistent) eta_a(0) =
eta_mm
1056 IF (.NOT. defined .OR. natorb < 1) cycle
1057 ELSEIF (do_xtb)
THEN
1060 DO i = 1,
SIZE(
list)
1063 CALL build_mm_pot(qpot(iatom), 1, eta_a(0), qmmm_env%Potentials, particles_mm, &
1064 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, &
1065 mm_cell, iatom, rcutoff, particles_qm)
1066 CALL build_mm_dpot(mcharge(iatom), 1, eta_a(0), qmmm_env%Potentials, particles_mm, &
1067 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, &
1068 mm_cell, iatom, forces, forces_qm(:, iqm), &
1069 rcutoff, particles_qm)
1070 CALL build_mm_pot(qpot(iatom), 2, alpha, qmmm_env%Potentials, particles_mm, &
1071 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, &
1072 mm_cell, iatom, rcutoff, particles_qm)
1073 CALL build_mm_dpot(mcharge(iatom), 2, alpha, qmmm_env%Potentials, particles_mm, &
1074 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, &
1075 mm_cell, iatom, forces, forces_qm(:, iqm), &
1076 rcutoff, particles_qm)
1078 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
1079 CALL build_mm_pot(qpot(iatom), 1, eta_a(0), qmmm_env%added_charges%potentials, &
1080 qmmm_env%added_charges%added_particles, &
1081 qmmm_env%added_charges%mm_atom_chrg, &
1082 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, rcutoff, &
1084 CALL build_mm_dpot( &
1085 mcharge(iatom), 1, eta_a(0), qmmm_env%added_charges%potentials, &
1086 qmmm_env%added_charges%added_particles, qmmm_env%added_charges%mm_atom_chrg, &
1087 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
1088 forces_added_charges, forces_qm(:, iqm), &
1089 rcutoff, particles_qm)
1090 CALL build_mm_pot(qpot(iatom), 2, alpha, qmmm_env%added_charges%potentials, &
1091 qmmm_env%added_charges%added_particles, &
1092 qmmm_env%added_charges%mm_atom_chrg, &
1093 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, rcutoff, &
1095 CALL build_mm_dpot( &
1096 mcharge(iatom), 2, alpha, qmmm_env%added_charges%potentials, &
1097 qmmm_env%added_charges%added_particles, qmmm_env%added_charges%mm_atom_chrg, &
1098 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
1099 forces_added_charges, forces_qm(:, iqm), &
1100 rcutoff, particles_qm)
1113 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
1115 defined=defined, eta=eta_a, natorb=natorb)
1117 IF (.NOT. dftb_control%self_consistent) eta_a(0) =
eta_mm
1118 IF (.NOT. defined .OR. natorb < 1) cycle
1119 ELSEIF (do_xtb)
THEN
1122 DO i = 1,
SIZE(
list)
1125 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%Potentials, particles_mm, &
1126 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, mm_cell, iatom, &
1127 qmmm_env%spherical_cutoff, particles_qm)
1128 CALL build_mm_dpot(mcharge(iatom), 0, eta_a(0), qmmm_env%Potentials, particles_mm, &
1129 qmmm_env%mm_atom_chrg, qmmm_env%mm_atom_index, &
1130 mm_cell, iatom, forces, forces_qm(:, iqm), &
1131 qmmm_env%spherical_cutoff, particles_qm)
1133 IF (qmmm_env%move_mm_charges .OR. qmmm_env%add_mm_charges)
THEN
1134 CALL build_mm_pot(qpot(iatom), 0, eta_a(0), qmmm_env%added_charges%potentials, &
1135 qmmm_env%added_charges%added_particles, &
1136 qmmm_env%added_charges%mm_atom_chrg, &
1137 qmmm_env%added_charges%mm_atom_index, &
1138 mm_cell, iatom, qmmm_env%spherical_cutoff, &
1140 CALL build_mm_dpot(mcharge(iatom), 0, eta_a(0), qmmm_env%added_charges%potentials, &
1141 qmmm_env%added_charges%added_particles, &
1142 qmmm_env%added_charges%mm_atom_chrg, &
1143 qmmm_env%added_charges%mm_atom_index, mm_cell, iatom, &
1144 forces_added_charges, &
1145 forces_qm(:, iqm), qmmm_env%spherical_cutoff, particles_qm)
1150 cpabort(
"Unknown Ewald type!")
1159 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
1161 IF (.NOT. defined .OR. natorb < 1) cycle
1162 ELSEIF (do_xtb)
THEN
1165 DO i = 1,
SIZE(
list)
1167 iatom = qmmm_env%qm_atom_index(
list(i))
1168 particles_mm(iatom)%f(:) = particles_mm(iatom)%f(:) + forces_qm(:, iqm)
1174 IF (
SIZE(matrix_p) == 2)
THEN
1175 CALL dbcsr_add(matrix_p(1)%matrix, matrix_p(2)%matrix, &
1176 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
1179 CALL dbcsr_iterator_start(iter, matrix_s(1)%matrix)
1180 DO WHILE (dbcsr_iterator_blocks_left(iter))
1181 CALL dbcsr_iterator_next_block(iter, iatom, jatom, sblock, blk)
1183 IF (iatom == jatom) cycle
1185 gmij = -0.5_dp*(qpot(iatom) + qpot(jatom))
1187 CALL dbcsr_get_block_p(matrix=matrix_p(1)%matrix, &
1188 row=iatom, col=jatom, block=pblock, found=found)
1192 CALL dbcsr_get_block_p(matrix=matrix_s(1 + i)%matrix, &
1193 row=iatom, col=jatom, block=dsblock, found=found)
1195 fi = -2.0_dp*gmij*sum(pblock*dsblock)
1196 forces_qm(i, iatom) = forces_qm(i, iatom) + fi
1197 forces_qm(i, jatom) = forces_qm(i, jatom) - fi
1200 CALL dbcsr_iterator_stop(iter)
1202 IF (
SIZE(matrix_p) == 2)
THEN
1203 CALL dbcsr_add(matrix_p(1)%matrix, matrix_p(2)%matrix, &
1204 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
1208 CALL para_env%sum(forces_qm)
1211 DO i = 1,
SIZE(
list)
1213 iatom = qmmm_env%qm_atom_index(iqm)
1214 particles_mm(iatom)%f(:) = particles_mm(iatom)%f(:) + forces_qm(:, iqm)
1218 DEALLOCATE (mcharge)
1222 DEALLOCATE (forces_qm)
1227 DEALLOCATE (ewald_env)
1229 DEALLOCATE (ewald_pw)
1235 CALL timestop(handle)
1253 SUBROUTINE build_mm_pot(qpot, pot_type, qm_alpha, potentials, &
1254 particles_mm, mm_charges, mm_atom_index, mm_cell, IndQM, &
1255 qmmm_spherical_cutoff, particles_qm)
1257 REAL(kind=
dp),
INTENT(INOUT) :: qpot
1258 INTEGER,
INTENT(IN) :: pot_type
1259 REAL(kind=
dp),
INTENT(IN) :: qm_alpha
1260 TYPE(qmmm_pot_p_type),
DIMENSION(:),
POINTER :: potentials
1261 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_mm
1262 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mm_charges
1263 INTEGER,
DIMENSION(:),
POINTER :: mm_atom_index
1264 TYPE(cell_type),
POINTER :: mm_cell
1265 INTEGER,
INTENT(IN) :: indqm
1266 REAL(kind=
dp),
INTENT(IN) :: qmmm_spherical_cutoff(2)
1267 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_qm
1269 CHARACTER(len=*),
PARAMETER :: routinen =
'build_mm_pot'
1270 REAL(kind=
dp),
PARAMETER :: qsmall = 1.0e-15_dp
1272 INTEGER :: handle, imm, imp, indmm, ipot
1273 REAL(kind=
dp) :: dr, qeff, rt1, rt2, rt3, &
1275 REAL(kind=
dp),
DIMENSION(3) :: r_pbc, rij
1276 TYPE(qmmm_pot_type),
POINTER :: pot
1278 CALL timeset(routinen, handle)
1281 mainlooppot:
DO ipot = 1,
SIZE(potentials)
1282 pot => potentials(ipot)%Pot
1284 loopmm:
DO imp = 1,
SIZE(pot%mm_atom_index)
1285 imm = pot%mm_atom_index(imp)
1286 indmm = mm_atom_index(imm)
1287 r_pbc =
pbc(particles_mm(indmm)%r - particles_qm(indqm)%r, mm_cell)
1291 rij = (/rt1, rt2, rt3/)
1292 dr = sqrt(sum(rij**2))
1293 qeff = mm_charges(imm)
1295 IF (qmmm_spherical_cutoff(1) > 0.0_dp)
THEN
1297 qeff = qeff*sph_chrg_factor
1299 IF (abs(qeff) <= qsmall) cycle
1300 IF (dr >
rtiny)
THEN
1301 IF (pot_type == 0)
THEN
1303 qpot = qpot + qeff*(1.0_dp/dr - sr)
1304 ELSE IF (pot_type == 1)
THEN
1306 qpot = qpot - qeff*sr
1307 ELSE IF (pot_type == 2)
THEN
1308 sr = erfc(qm_alpha*dr)/dr
1309 qpot = qpot + qeff*sr
1316 CALL timestop(handle)
1317 END SUBROUTINE build_mm_pot
1335 SUBROUTINE build_mm_dpot(qcharge, pot_type, qm_alpha, potentials, &
1336 particles_mm, mm_charges, mm_atom_index, mm_cell, IndQM, &
1337 forces, forces_qm, qmmm_spherical_cutoff, particles_qm)
1339 REAL(kind=
dp),
INTENT(IN) :: qcharge
1340 INTEGER,
INTENT(IN) :: pot_type
1341 REAL(kind=
dp),
INTENT(IN) :: qm_alpha
1342 TYPE(qmmm_pot_p_type),
DIMENSION(:),
POINTER :: potentials
1343 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_mm
1344 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mm_charges
1345 INTEGER,
DIMENSION(:),
POINTER :: mm_atom_index
1346 TYPE(cell_type),
POINTER :: mm_cell
1347 INTEGER,
INTENT(IN) :: indqm
1348 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: forces
1349 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: forces_qm
1350 REAL(kind=
dp),
INTENT(IN) :: qmmm_spherical_cutoff(2)
1351 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles_qm
1353 CHARACTER(len=*),
PARAMETER :: routinen =
'build_mm_dpot'
1354 REAL(kind=
dp),
PARAMETER :: qsmall = 1.0e-15_dp
1356 INTEGER :: handle, imm, imp, indmm, ipot
1357 REAL(kind=
dp) :: dr, drm, drp, dsr, fsr, qeff, rt1, rt2, &
1358 rt3, sph_chrg_factor
1359 REAL(kind=
dp),
DIMENSION(3) :: force_ab, r_pbc, rij
1360 TYPE(qmmm_pot_type),
POINTER :: pot
1362 CALL timeset(routinen, handle)
1365 mainlooppot:
DO ipot = 1,
SIZE(potentials)
1366 pot => potentials(ipot)%Pot
1368 loopmm:
DO imp = 1,
SIZE(pot%mm_atom_index)
1369 imm = pot%mm_atom_index(imp)
1370 indmm = mm_atom_index(imm)
1371 r_pbc =
pbc(particles_mm(indmm)%r - particles_qm(indqm)%r, mm_cell)
1375 rij = (/rt1, rt2, rt3/)
1376 dr = sqrt(sum(rij**2))
1377 qeff = mm_charges(imm)
1380 IF (qmmm_spherical_cutoff(1) > 0.0_dp)
THEN
1382 qeff = qeff*sph_chrg_factor
1384 IF (abs(qeff) <= qsmall) cycle
1385 IF (dr >
rtiny)
THEN
1388 IF (pot_type == 0)
THEN
1391 fsr = qeff*qcharge*(-1.0_dp/(dr*dr) - dsr)
1392 ELSE IF (pot_type == 1)
THEN
1395 fsr = -qeff*qcharge*dsr
1396 ELSE IF (pot_type == 2)
THEN
1397 dsr = 0.5_dp*(erfc(qm_alpha*drp)/drp - erfc(qm_alpha*drm)/drm)/
ddrmm
1398 fsr = qeff*qcharge*dsr
1402 force_ab = -fsr*rij/dr
1407 forces_qm(:) = forces_qm(:) - force_ab
1409 forces(:, imm) = forces(:, imm) - force_ab
1413 CALL timestop(handle)
1415 END SUBROUTINE build_mm_dpot
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public ewald_env_set(ewald_env, ewald_type, alpha, epsilon, eps_pol, gmax, ns_max, precs, o_spline, para_env, poisson_section, interaction_cutoffs, cell_hmat)
Purpose: Set the EWALD environment.
subroutine, public ewald_env_create(ewald_env, para_env)
allocates and intitializes a ewald_env
subroutine, public read_ewald_section(ewald_env, ewald_section)
Purpose: read the EWALD section.
subroutine, public ewald_env_release(ewald_env)
releases the given ewald_env (see doc/ReferenceCounting.html)
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
subroutine, public ewald_pw_release(ewald_pw)
releases the memory used by the ewald_pw
subroutine, public ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, print_section)
creates the structure ewald_pw_type
Defines the basic variable types.
integer, parameter, public dp
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Define the data structure for the particle information.
subroutine, public deallocate_particle_set(particle_set)
Deallocate a particle set.
subroutine, public allocate_particle_set(particle_set, nparticle)
Allocate a particle set.
functions related to the poisson solver on regular grids
integer, parameter, public do_ewald_pme
integer, parameter, public do_ewald_ewald
integer, parameter, public do_ewald_none
integer, parameter, public do_ewald_spme
TB methods used with QMMM.
subroutine, public deriv_tb_qmmm_matrix_pc(qs_env, qmmm_env, particles_mm, mm_cell, para_env, calc_force, Forces, Forces_added_charges)
Constructs the derivative w.r.t. 1-el DFTB hamiltonian QMMM terms.
subroutine, public deriv_tb_qmmm_matrix(qs_env, qmmm_env, particles_mm, mm_cell, para_env, calc_force, Forces, Forces_added_charges)
Constructs the derivative w.r.t. 1-el DFTB hamiltonian QMMM terms.
subroutine, public build_tb_qmmm_matrix_zero(qs_env, para_env)
Constructs an empty 1-el DFTB hamiltonian.
subroutine, public build_tb_qmmm_matrix_pc(qs_env, qmmm_env, particles_mm, mm_cell, para_env)
Constructs the 1-el DFTB hamiltonian.
subroutine, public build_tb_qmmm_matrix(qs_env, qmmm_env, particles_mm, mm_cell, para_env)
Constructs the 1-el DFTB hamiltonian.
real(dp), parameter rtiny
real(dp), parameter eta_mm
real(dp), parameter ddrmm
subroutine, public spherical_cutoff_factor(spherical_cutoff, rij, factor)
Computes a spherical cutoff factor for the QMMM interactions.
Calculation of Coulomb contributions in DFTB.
real(dp) function, public gamma_rab_sr(r, ga, gb, hb_para)
Computes the short-range gamma parameter from exact Coulomb interaction of normalized exp(-a*r) charg...
Calculation of Overlap and Hamiltonian matrices in DFTB.
subroutine, public build_dftb_overlap(qs_env, nderivative, matrix_s)
...
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_r3d_rs_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, U_of_dft_plus_u, J_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Define the neighbor list data types and the corresponding functionality.
Generate the atomic neighbor lists.
subroutine, public build_qs_neighbor_lists(qs_env, para_env, molecular, force_env_section)
Build all the required neighbor lists for Quickstep.
Calculation of overlap matrix, its derivatives and forces.
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p)
Calculation of the overlap matrix over Cartesian Gaussian functions.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Calculate the electrostatic energy by the Smooth Particle Ewald method.
subroutine, public spme_forces(ewald_env, ewald_pw, box, particle_set_a, charges_a, particle_set_b, charges_b, forces_b)
Calculate the forces on particles B for the electrostatic interaction betrween particles A and B.
subroutine, public spme_potential(ewald_env, ewald_pw, box, particle_set_a, charges_a, particle_set_b, potential)
Calculate the electrostatic potential from particles A (charge A) at positions of particles B.
Definition of the xTB parameter types.
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, occupation, electronegativity, chmax)
...