71#include "./base/base_uses.f90"
77 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'force_env_types'
89 CHARACTER(LEN=10),
DIMENSION(501:509),
PARAMETER,
PUBLIC :: &
140 INTEGER :: ref_count = 0, in_use = 0, method_name_id = 0
141 REAL(kind=
dp) :: additional_potential = 0.0_dp
185 cpassert(
ASSOCIATED(force_env))
186 cpassert(force_env%ref_count > 0)
187 force_env%ref_count = force_env%ref_count + 1
202 INTEGER :: i, my_group
205 IF (
ASSOCIATED(force_env))
THEN
206 cpassert(force_env%ref_count > 0)
207 force_env%ref_count = force_env%ref_count - 1
208 IF (force_env%ref_count == 0)
THEN
210 IF (
ASSOCIATED(force_env%sub_force_env))
THEN
211 DO i = 1,
SIZE(force_env%sub_force_env)
212 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(i)%force_env)) cycle
215 my_group = force_env%mixed_env%group_distribution(force_env%para_env%mepos)
216 my_logger => force_env%mixed_env%sub_logger(my_group + 1)%p
221 my_group = force_env%embed_env%group_distribution(force_env%para_env%mepos)
222 my_logger => force_env%embed_env%sub_logger(my_group + 1)%p
231 DEALLOCATE (force_env%sub_force_env)
234 SELECT CASE (force_env%in_use)
237 DEALLOCATE (force_env%fist_env)
240 DEALLOCATE (force_env%qs_env)
243 DEALLOCATE (force_env%eip_env)
246 DEALLOCATE (force_env%pwdft_env)
249 DEALLOCATE (force_env%mixed_env)
252 DEALLOCATE (force_env%nnp_env)
255 DEALLOCATE (force_env%embed_env)
260 cpassert(.NOT.
ASSOCIATED(force_env%fist_env))
261 cpassert(.NOT.
ASSOCIATED(force_env%qs_env))
262 cpassert(.NOT.
ASSOCIATED(force_env%eip_env))
263 cpassert(.NOT.
ASSOCIATED(force_env%pwdft_env))
264 cpassert(.NOT.
ASSOCIATED(force_env%mixed_env))
265 cpassert(.NOT.
ASSOCIATED(force_env%nnp_env))
266 cpassert(.NOT.
ASSOCIATED(force_env%embed_env))
267 IF (
ASSOCIATED(force_env%meta_env))
THEN
269 DEALLOCATE (force_env%meta_env)
271 IF (
ASSOCIATED(force_env%fp_env))
THEN
273 DEALLOCATE (force_env%fp_env)
275 IF (
ASSOCIATED(force_env%qmmm_env))
THEN
277 DEALLOCATE (force_env%qmmm_env)
279 IF (
ASSOCIATED(force_env%qmmmx_env))
THEN
281 DEALLOCATE (force_env%qmmmx_env)
285 DEALLOCATE (force_env)
325 meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, &
326 kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, &
327 qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, &
328 method_name_id, root_section, mixed_env, nnp_env, embed_env)
330 INTEGER,
INTENT(out),
OPTIONAL :: in_use
334 TYPE(
fp_type),
OPTIONAL,
POINTER :: fp_env
337 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: potential_energy, additional_potential, &
338 kinetic_energy, harmonic_shell, &
340 TYPE(
cell_type),
OPTIONAL,
POINTER :: cell
342 POINTER :: sub_force_env
349 INTEGER,
INTENT(out),
OPTIONAL :: method_name_id
352 TYPE(
nnp_type),
OPTIONAL,
POINTER :: nnp_env
355 REAL(kind=
dp) :: eip_kinetic_energy, eip_potential_energy
364 cpassert(force_env%ref_count > 0)
366 SELECT CASE (force_env%in_use)
368 cpassert(
ASSOCIATED(force_env%qs_env))
369 cpassert(.NOT.
PRESENT(fist_env))
370 cpassert(.NOT.
PRESENT(eip_env))
371 cpassert(.NOT.
PRESENT(pwdft_env))
376 IF (
PRESENT(potential_energy)) potential_energy =
qs_energy%total
377 cpassert(.NOT.
PRESENT(kinetic_energy))
379 cpassert(
ASSOCIATED(force_env%fist_env))
380 cpassert(.NOT.
PRESENT(input))
384 IF (
PRESENT(potential_energy)) potential_energy = thermo%pot
385 IF (
PRESENT(kinetic_energy)) kinetic_energy = thermo%kin
386 IF (
PRESENT(kinetic_shell)) kinetic_shell = thermo%kin_shell
387 IF (
PRESENT(harmonic_shell)) harmonic_shell = thermo%harm_shell
389 cpassert(
ASSOCIATED(force_env%eip_env))
390 cpassert(.NOT.
PRESENT(qs_env))
391 cpassert(.NOT.
PRESENT(fist_env))
393 eip_potential_energy=eip_potential_energy, &
394 eip_kinetic_energy=eip_kinetic_energy, &
396 IF (
PRESENT(potential_energy))
THEN
397 potential_energy = eip_potential_energy
399 IF (
PRESENT(kinetic_energy)) kinetic_energy = eip_kinetic_energy
400 cpassert(.NOT.
PRESENT(kinetic_energy))
402 cpassert(
ASSOCIATED(force_env%pwdft_env))
403 cpassert(.NOT.
PRESENT(qs_env))
404 cpassert(.NOT.
PRESENT(fist_env))
407 IF (
PRESENT(potential_energy)) potential_energy = pwdft_energy%etotal
408 cpassert(.NOT.
PRESENT(kinetic_energy))
412 potential_energy=potential_energy, &
413 kinetic_energy=kinetic_energy)
417 potential_energy=potential_energy, &
418 kinetic_energy=kinetic_energy)
420 cpassert(
ASSOCIATED(force_env%mixed_env))
421 cpassert(.NOT.
PRESENT(input))
423 mixed_energy=mixed_energy, &
425 IF (
PRESENT(potential_energy)) potential_energy = mixed_energy%pot
426 IF (
PRESENT(kinetic_energy)) kinetic_energy = mixed_energy%kin
429 cpassert(
ASSOCIATED(force_env%embed_env))
430 cpassert(.NOT.
PRESENT(input))
432 pot_energy=potential_energy, &
435 cpassert(
ASSOCIATED(force_env%nnp_env))
437 nnp_potential_energy=potential_energy, &
439 cpassert(.NOT.
PRESENT(kinetic_energy))
441 cpabort(
"unknown in_use flag value ")
444 IF (
PRESENT(force_env_section)) force_env_section => force_env%force_env_section
445 IF (
PRESENT(in_use)) in_use = force_env%in_use
446 IF (
PRESENT(method_name_id)) method_name_id = force_env%method_name_id
447 IF (
PRESENT(fist_env))
THEN
448 fist_env => force_env%fist_env
450 IF (
PRESENT(qs_env))
THEN
451 qs_env => force_env%qs_env
453 IF (
PRESENT(eip_env))
THEN
454 eip_env => force_env%eip_env
456 IF (
PRESENT(pwdft_env))
THEN
457 pwdft_env => force_env%pwdft_env
459 IF (
PRESENT(nnp_env))
THEN
460 nnp_env => force_env%nnp_env
462 IF (
PRESENT(para_env)) para_env => force_env%para_env
464 IF (
ASSOCIATED(force_env%meta_env))
THEN
465 IF (
PRESENT(potential_energy))
THEN
466 potential_energy = potential_energy + &
467 force_env%meta_env%epot_s + &
468 force_env%meta_env%epot_walls + &
469 force_env%meta_env%hills_env%energy
471 IF (
PRESENT(kinetic_energy))
THEN
472 kinetic_energy = kinetic_energy + force_env%meta_env%ekin_s
476 IF (
ASSOCIATED(force_env%fp_env) .AND.
PRESENT(potential_energy))
THEN
477 IF (force_env%fp_env%use_fp)
THEN
478 potential_energy = potential_energy + force_env%fp_env%energy
481 IF (
PRESENT(potential_energy))
THEN
482 potential_energy = potential_energy + force_env%additional_potential
484 IF (
PRESENT(additional_potential))
THEN
485 additional_potential = force_env%additional_potential
487 IF (
PRESENT(cell))
THEN
491 IF (
PRESENT(fp_env)) fp_env => force_env%fp_env
492 IF (
PRESENT(meta_env)) meta_env => force_env%meta_env
493 IF (
PRESENT(sub_force_env)) sub_force_env => force_env%sub_force_env
494 IF (
PRESENT(qmmm_env)) qmmm_env => force_env%qmmm_env
495 IF (
PRESENT(qmmmx_env)) qmmmx_env => force_env%qmmmx_env
496 IF (
PRESENT(mixed_env)) mixed_env => force_env%mixed_env
497 IF (
PRESENT(embed_env)) embed_env => force_env%embed_env
498 IF (
PRESENT(globenv)) globenv => force_env%globenv
499 IF (
PRESENT(root_section)) root_section => force_env%root_section
534 INTEGER :: n_particle
556 REAL(kind=
dp),
DIMENSION(*),
INTENT(OUT) :: frc
557 INTEGER,
INTENT(IN) :: n
559 CHARACTER(LEN=*),
PARAMETER :: routinen =
'force_env_get_frc'
564 CALL timeset(routinen, handle)
565 cpassert(force_env%ref_count > 0)
568 CALL timestop(handle)
583 REAL(kind=
dp),
DIMENSION(*),
INTENT(OUT) :: pos
584 INTEGER,
INTENT(IN) :: n
586 CHARACTER(LEN=*),
PARAMETER :: routinen =
'force_env_get_pos'
591 CALL timeset(routinen, handle)
592 cpassert(force_env%ref_count > 0)
595 CALL timestop(handle)
610 REAL(kind=
dp),
DIMENSION(*),
INTENT(OUT) :: vel
611 INTEGER,
INTENT(IN) :: n
613 CHARACTER(LEN=*),
PARAMETER :: routinen =
'force_env_get_vel'
618 CALL timeset(routinen, handle)
619 cpassert(force_env%ref_count > 0)
622 CALL timestop(handle)
639 method_name_id, additional_potential)
643 TYPE(
fp_type),
OPTIONAL,
POINTER :: fp_env
645 INTEGER,
OPTIONAL :: method_name_id
646 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: additional_potential
648 cpassert(force_env%ref_count > 0)
649 IF (
PRESENT(meta_env))
THEN
650 IF (
ASSOCIATED(force_env%meta_env))
THEN
652 DEALLOCATE (force_env%meta_env)
654 force_env%meta_env => meta_env
656 IF (
PRESENT(fp_env))
THEN
657 IF (
ASSOCIATED(force_env%fp_env))
CALL fp_env_release(force_env%fp_env)
658 force_env%fp_env => fp_env
660 IF (
PRESENT(force_env_section))
THEN
661 IF (
ASSOCIATED(force_env_section))
THEN
664 force_env%force_env_section => force_env_section
667 IF (
PRESENT(additional_potential))
THEN
668 force_env%additional_potential = additional_potential
670 IF (
PRESENT(method_name_id))
THEN
671 force_env%method_name_id = method_name_id
687 INTEGER,
DIMENSION(:),
POINTER :: i_force_eval
688 INTEGER :: nforce_eval
690 INTEGER :: iforce_eval, main_force_eval
691 INTEGER,
DIMENSION(:),
POINTER :: my_i_force_eval
697 i_vals=my_i_force_eval)
698 ALLOCATE (i_force_eval(nforce_eval))
699 IF (nforce_eval > 0)
THEN
700 IF (nforce_eval ==
SIZE(my_i_force_eval))
THEN
701 i_force_eval = my_i_force_eval
704 cpassert(nforce_eval -
SIZE(my_i_force_eval) == 1)
705 DO iforce_eval = 1, nforce_eval
706 IF (any(my_i_force_eval == iforce_eval)) cycle
707 main_force_eval = iforce_eval
710 i_force_eval(1) = main_force_eval
711 i_force_eval(2:nforce_eval) = my_i_force_eval
Handles all functions related to the CELL.
various routines to log and control the output. The idea is that decisions about where to log should ...
subroutine, public cp_rm_default_logger()
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has ...
subroutine, public cp_add_default_logger(logger)
adds a default logger. MUST be called before logging occours
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell)
returns information about various attributes of the given subsys
subroutine, public pack_subsys_particles(subsys, f, r, s, v, fscale, cell)
Pack components of a subsystem particle sets into a single vector.
The environment for the empirical interatomic potential methods.
subroutine, public eip_env_release(eip_env)
Releases the given eip environment (see doc/ReferenceCounting.html)
subroutine, public eip_env_get(eip_env, eip_model, eip_energy, eip_energy_var, eip_forces, coord_avg, coord_var, count, subsys, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, eip_input, force_env_input, cell, cell_ref, use_ref_cell, eip_kinetic_energy, eip_potential_energy, virial)
Returns various attributes of the eip environment.
subroutine, public get_embed_env(embed_env, atomic_kind_set, particle_set, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, para_env, sub_para_env, subsys, input, results, pot_energy)
Get the embed environment.
subroutine, public embed_env_release(embed_env)
...
subroutine, public fist_env_release(fist_env)
releases the given fist_env (see doc/ReferenceCounting.html)
subroutine, public fist_env_get(fist_env, atomic_kind_set, particle_set, ewald_pw, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, ewald_env, fist_nonbond_env, thermo, para_env, subsys, qmmm, qmmm_env, input, shell_model, shell_model_ad, shell_particle_set, core_particle_set, multipoles, results, exclusions, efield)
Purpose: Get the FIST environment.
Interface for the force calculations.
integer function, public force_env_get_natom(force_env)
returns the number of atoms
subroutine, public force_env_get_vel(force_env, vel, n)
returns the particle velocities in a dimension(*) array
integer, parameter, public use_qmmm
subroutine, public multiple_fe_list(force_env_sections, root_section, i_force_eval, nforce_eval)
returns the order of the multiple force_env
character(len=10), dimension(501:509), parameter, public use_prog_name
integer, parameter, public use_mixed_force
integer, parameter, public use_eip_force
integer, parameter, public use_embed
integer, parameter, public use_qmmmx
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env)
returns various attributes about the force environment
subroutine, public force_env_retain(force_env)
retains the given force env
subroutine, public force_env_get_pos(force_env, pos, n)
returns the particle positions in a dimension(*) array
subroutine, public force_env_set(force_env, meta_env, fp_env, force_env_section, method_name_id, additional_potential)
changes some attributes of the force_env
integer, parameter, public use_qs_force
subroutine, public force_env_get_frc(force_env, frc, n)
returns the particle forces in a dimension(*) array
integer, parameter, public use_pwdft_force
integer, parameter, public use_nnp_force
recursive subroutine, public force_env_release(force_env)
releases the given force env
integer, parameter, public use_fist_force
integer function, public force_env_get_nparticle(force_env)
returns the number of particles in a force environment
types used in the flexible partitioning scheme
subroutine, public fp_env_release(fp_env)
...
Define type storing the global information of a run. Keep the amount of stored data small....
subroutine, public globenv_release(globenv)
Releases the global environment globenv.
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
subroutine, public mixed_env_release(mixed_env)
releases the given mixed_env (see doc/ReferenceCounting.html)
subroutine, public get_mixed_env(mixed_env, atomic_kind_set, particle_set, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, mixed_energy, para_env, sub_para_env, subsys, input, results, cdft_control)
Get the MIXED environment.
Data types for neural network potentials.
subroutine, public nnp_env_get(nnp_env, nnp_forces, subsys, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, nnp_input, force_env_input, cell, cell_ref, use_ref_cell, nnp_potential_energy, virial)
Returns various attributes of the nnp environment.
subroutine, public nnp_env_release(nnp_env)
Release data structure that holds all the information for neural network potentials.
The type definitions for the PWDFT environment.
subroutine, public pwdft_env_get(pwdft_env, pwdft_input, force_env_input, xc_input, cp_subsys, qs_subsys, para_env, energy, forces, stress, sctx, gs_handler, ks_handler)
Returns various attributes of the pwdft environment.
subroutine, public pwdft_env_release(pwdft_env)
Releases the given pwdft environment (see doc/ReferenceCounting.html)
Basic container type for QM/MM.
subroutine, public qmmm_env_release(qmmm_env)
releases the given qmmm_env (see doc/ReferenceCounting.html)
subroutine, public qmmm_env_get(qmmm_env, subsys, potential_energy, kinetic_energy)
...
Basic container type for QM/MM with force mixing.
subroutine, public qmmmx_env_release(qmmmx_env)
releases the given qmmmx_env (see doc/ReferenceCounting.html)
subroutine, public qmmmx_env_get(qmmmx_env, subsys, potential_energy, kinetic_energy)
...
Perform a QUICKSTEP wavefunction optimization (single point)
subroutine, public qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
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.
Type defining parameters related to the simulation cell.
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,...
The empirical interatomic potential environment.
Embedding environment type.
allows for the creation of an array of force_env
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
Main data type collecting all relevant data for neural network potentials.
The PWDFT environment type.