(git:d18deda)
Loading...
Searching...
No Matches
qs_subsys_methods.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Routines that work on qs_subsys_type
10!> \author Ole Schuett
11! **************************************************************************************************
13 USE atom_types, ONLY: lmat
18 USE cell_methods, ONLY: cell_create,&
19 read_cell,&
21 USE cell_types, ONLY: cell_clone,&
35 USE kinds, ONLY: dp
46#include "./base/base_uses.f90"
47
48 IMPLICIT NONE
49 PRIVATE
50
51 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_subsys_methods'
52
53 PUBLIC :: qs_subsys_create
54
55CONTAINS
56
57! **************************************************************************************************
58!> \brief Creates a qs_subsys. Optionally an existsing cp_subsys is used.
59!> \param subsys ...
60!> \param para_env ...
61!> \param root_section ...
62!> \param force_env_section ...
63!> \param subsys_section ...
64!> \param use_motion_section ...
65!> \param cp_subsys ...
66!> \param cell ...
67!> \param cell_ref ...
68!> \param elkind ...
69!> \param silent ...
70! **************************************************************************************************
71 SUBROUTINE qs_subsys_create(subsys, para_env, root_section, force_env_section, subsys_section, &
72 use_motion_section, cp_subsys, cell, cell_ref, elkind, silent)
73 TYPE(qs_subsys_type), INTENT(OUT) :: subsys
74 TYPE(mp_para_env_type), POINTER :: para_env
75 TYPE(section_vals_type), OPTIONAL, POINTER :: root_section
76 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
77 LOGICAL, INTENT(IN) :: use_motion_section
78 TYPE(cp_subsys_type), OPTIONAL, POINTER :: cp_subsys
79 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
80 LOGICAL, INTENT(IN), OPTIONAL :: elkind, silent
81
82 LOGICAL :: be_silent, use_ref_cell
83 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
84 TYPE(cell_type), POINTER :: my_cell, my_cell_ref
85 TYPE(cp_subsys_type), POINTER :: my_cp_subsys
86 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
87 TYPE(section_vals_type), POINTER :: cell_section, kind_section
88
89 NULLIFY (atomic_kind_set, qs_kind_set, cell_section, kind_section, my_cell, my_cell_ref, my_cp_subsys)
90
91 be_silent = .false.
92 IF (PRESENT(silent)) be_silent = silent
93 ! create cp_subsys
94 IF (PRESENT(cp_subsys)) THEN
95 my_cp_subsys => cp_subsys
96 ELSE IF (PRESENT(root_section)) THEN
97 CALL cp_subsys_create(my_cp_subsys, para_env, root_section=root_section, &
98 force_env_section=force_env_section, &
99 subsys_section=subsys_section, &
100 use_motion_section=use_motion_section, &
101 elkind=elkind)
102 ELSE
103 cpabort("qs_subsys_create: cp_subsys or root_section needed")
104 END IF
105
106 ! create cp_subsys%cell
107 !TODO: moved to cp_subsys_create(), needs further disentanglement of cell_ref.
108 use_ref_cell = .false.
109 IF (PRESENT(cell)) THEN
110 my_cell => cell
111 IF (PRESENT(cell_ref)) THEN
112 my_cell_ref => cell_ref
113 use_ref_cell = .true.
114 ELSE
115 CALL cell_create(my_cell_ref)
116 CALL cell_clone(my_cell, my_cell_ref, tag="CELL_REF")
117 END IF
118 ELSE
119 cell_section => section_vals_get_subs_vals(subsys_section, "CELL")
120 CALL read_cell(my_cell, my_cell_ref, use_ref_cell=use_ref_cell, &
121 cell_section=cell_section, para_env=para_env)
122 END IF
123 CALL cp_subsys_set(my_cp_subsys, cell=my_cell)
124 CALL write_cell(my_cell, subsys_section)
125 CALL write_cell(my_cell_ref, subsys_section)
126
127 ! setup qs_kinds
128 CALL cp_subsys_get(my_cp_subsys, atomic_kind_set=atomic_kind_set)
129 kind_section => section_vals_get_subs_vals(subsys_section, "KIND")
130 CALL create_qs_kind_set(qs_kind_set, atomic_kind_set, kind_section, &
131 para_env, force_env_section, be_silent)
132
133 CALL num_ao_el_per_molecule(my_cp_subsys%molecule_kinds%els, &
134 qs_kind_set)
135
136 CALL qs_subsys_set(subsys, &
137 cp_subsys=my_cp_subsys, &
138 cell_ref=my_cell_ref, &
139 use_ref_cell=use_ref_cell, &
140 qs_kind_set=qs_kind_set)
141
142 IF (.NOT. PRESENT(cell)) CALL cell_release(my_cell)
143 IF (.NOT. PRESENT(cell_ref)) CALL cell_release(my_cell_ref)
144 IF (.NOT. PRESENT(cp_subsys)) CALL cp_subsys_release(my_cp_subsys)
145
146 END SUBROUTINE qs_subsys_create
147
148! **************************************************************************************************
149!> \brief Read a molecule kind data set from the input file.
150!> \param molecule_kind_set ...
151!> \param qs_kind_set ...
152!> \date 22.11.2004
153!> \par History
154!> Rustam Z. Khaliullin 10.2014 - charges and electrons of molecules
155!> are now in agreement with atomic guess
156!> \author MI
157!> \version 1.0
158! **************************************************************************************************
159 SUBROUTINE num_ao_el_per_molecule(molecule_kind_set, qs_kind_set)
160
161 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
162 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
163
164 INTEGER :: arbitrary_spin, iatom, ikind, imol, &
165 n_ao, natom, nmol_kind, nsgf, nspins, &
166 z_molecule
167 INTEGER, DIMENSION(0:lmat, 10) :: ne_core, ne_elem, ne_explicit
168 INTEGER, DIMENSION(2) :: n_occ_alpha_and_beta
169 REAL(kind=dp) :: charge_molecule, zeff, zeff_correction
170 REAL(kind=dp), DIMENSION(0:lmat, 10, 2) :: edelta
171 TYPE(all_potential_type), POINTER :: all_potential
172 TYPE(atomic_kind_type), POINTER :: atomic_kind
173 TYPE(gth_potential_type), POINTER :: gth_potential
174 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
175 TYPE(molecule_kind_type), POINTER :: molecule_kind
176 TYPE(sgp_potential_type), POINTER :: sgp_potential
177
178 IF (ASSOCIATED(molecule_kind_set)) THEN
179
180 nspins = 2
181 nmol_kind = SIZE(molecule_kind_set, 1)
182 natom = 0
183
184 ! *** Initialize the molecule kind data structure ***
185 arbitrary_spin = 1
186 DO imol = 1, nmol_kind
187
188 molecule_kind => molecule_kind_set(imol)
189 CALL get_molecule_kind(molecule_kind=molecule_kind, &
190 natom=natom)
191 !nelectron = 0
192 n_ao = 0
193 n_occ_alpha_and_beta(1:nspins) = 0
194 z_molecule = 0
195
196 DO iatom = 1, natom
197
198 atomic_kind => molecule_kind%atom_list(iatom)%atomic_kind
199 CALL get_atomic_kind(atomic_kind, kind_number=ikind)
200 CALL get_qs_kind(qs_kind_set(ikind), &
201 basis_set=orb_basis_set, &
202 all_potential=all_potential, &
203 gth_potential=gth_potential, &
204 sgp_potential=sgp_potential)
205
206 ! Obtain the electronic state of the atom
207 ! The same state is used to calculate the ATOMIC GUESS
208 ! It is great that we are consistent with ATOMIC_GUESS
209 CALL init_atom_electronic_state(atomic_kind=atomic_kind, &
210 qs_kind=qs_kind_set(ikind), &
211 ncalc=ne_explicit, &
212 ncore=ne_core, &
213 nelem=ne_elem, &
214 edelta=edelta)
215
216 ! If &BS section is used ATOMIC_GUESS is calculated twice
217 ! for two separate wfns with their own alpha-beta combinations
218 ! This is done to break the spin symmetry of the initial wfn
219 ! For now, only alpha part of &BS is used to count electrons on
220 ! molecules
221 ! Get the number of explicit electrons (i.e. with orbitals)
222 ! For now, only the total number of electrons can be obtained
223 ! from init_atom_electronic_state
224 n_occ_alpha_and_beta(arbitrary_spin) = &
225 n_occ_alpha_and_beta(arbitrary_spin) + sum(ne_explicit) + &
226 sum(nint(2*edelta(:, :, arbitrary_spin)))
227 ! We need a way to specify the number of alpha and beta electrons
228 ! on each molecule (i.e. multiplicity is not enough)
229 !n_occ(ispin) = n_occ(ispin) + SUM(ne_explicit) + SUM(NINT(2*edelta(:, :, ispin)))
230
231 IF (ASSOCIATED(all_potential)) THEN
232 CALL get_potential(potential=all_potential, zeff=zeff, &
233 zeff_correction=zeff_correction)
234 ELSE IF (ASSOCIATED(gth_potential)) THEN
235 CALL get_potential(potential=gth_potential, zeff=zeff, &
236 zeff_correction=zeff_correction)
237 ELSE IF (ASSOCIATED(sgp_potential)) THEN
238 CALL get_potential(potential=sgp_potential, zeff=zeff, &
239 zeff_correction=zeff_correction)
240 ELSE
241 zeff = 0.0_dp
242 zeff_correction = 0.0_dp
243 END IF
244 z_molecule = z_molecule + nint(zeff - zeff_correction)
245
246 ! this one does not work because nelem is not adjusted in the symmetry breaking code
247 !CALL get_atomic_kind(atomic_kind,z=z)
248 !z_molecule=z_molecule+z
249
250 IF (ASSOCIATED(orb_basis_set)) THEN
251 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, nsgf=nsgf)
252 ELSE
253 nsgf = 0
254 END IF
255 n_ao = n_ao + nsgf
256
257 END DO ! iatom
258
259 ! At this point we have the number of electrons (alpha+beta) on the molecule
260 ! as they are seen by the ATOMIC GUESS routines
261 charge_molecule = real(z_molecule - n_occ_alpha_and_beta(arbitrary_spin), dp)
262 CALL set_molecule_kind(molecule_kind=molecule_kind, &
263 nelectron=n_occ_alpha_and_beta(arbitrary_spin), &
264 charge=charge_molecule, &
265 nsgf=n_ao)
266
267 END DO ! imol
268 END IF
269
270 END SUBROUTINE num_ao_el_per_molecule
271
272END MODULE qs_subsys_methods
Define the atom type and its sub types.
Definition atom_types.F:15
integer, parameter, public lmat
Definition atom_types.F:67
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.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum)
...
Handles all functions related to the CELL.
recursive subroutine, public read_cell(cell, cell_ref, use_ref_cell, cell_section, check_for_ref, para_env)
...
subroutine, public write_cell(cell, subsys_section, tag)
Write the cell parameters to the output unit.
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:559
subroutine, public cell_clone(cell_in, cell_out, tag)
Clone cell variable.
Definition cell_types.F:107
Initialize a small environment for a particular calculation.
subroutine, public cp_subsys_create(subsys, para_env, root_section, force_env_section, subsys_section, use_motion_section, qmmm, qmmm_env, exclusions, elkind)
Creates allocates and fills subsys from given input.
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_release(subsys)
releases a subsys (see doc/ReferenceCounting.html)
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)
sets various propreties of the subsys
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
Definition of the atomic potential types.
objects that represent the structure of input sections and the data contained in an input section
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
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
subroutine, public get_molecule_kind(molecule_kind, atom_list, bond_list, bend_list, ub_list, impr_list, opbend_list, colv_list, fixd_list, g3x3_list, g4x6_list, vsite_list, torsion_list, shell_list, name, mass, charge, kind_number, natom, nbend, nbond, nub, nimpr, nopbend, nconstraint, nconstraint_fixd, nfixd, ncolv, ng3x3, ng4x6, nvsite, nfixd_restraint, ng3x3_restraint, ng4x6_restraint, nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion, molecule_list, nelectron, nelectron_alpha, nelectron_beta, bond_kind_set, bend_kind_set, ub_kind_set, impr_kind_set, opbend_kind_set, torsion_kind_set, molname_generated)
Get informations about a molecule kind.
subroutine, public set_molecule_kind(molecule_kind, name, mass, charge, kind_number, molecule_list, atom_list, nbond, bond_list, nbend, bend_list, nub, ub_list, nimpr, impr_list, nopbend, opbend_list, ntorsion, torsion_list, fixd_list, ncolv, colv_list, ng3x3, g3x3_list, ng4x6, nfixd, g4x6_list, nvsite, vsite_list, ng3x3_restraint, ng4x6_restraint, nfixd_restraint, nshell, shell_list, nvsite_restraint, bond_kind_set, bend_kind_set, ub_kind_set, torsion_kind_set, impr_kind_set, opbend_kind_set, nelectron, nsgf, molname_generated)
Set the components of a molecule kind.
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, zatom, 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_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_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public init_atom_electronic_state(atomic_kind, qs_kind, ncalc, ncore, nelem, edelta)
...
subroutine, public create_qs_kind_set(qs_kind_set, atomic_kind_set, kind_section, para_env, force_env_section, silent)
Read an atomic kind set data set from the input file.
Routines that work on qs_subsys_type.
subroutine, public qs_subsys_create(subsys, para_env, root_section, force_env_section, subsys_section, use_motion_section, cp_subsys, cell, cell_ref, elkind, silent)
Creates a qs_subsys. Optionally an existsing cp_subsys is used.
types that represent a quickstep subsys
subroutine, public qs_subsys_set(subsys, cp_subsys, local_particles, local_molecules, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, nelectron_total, nelectron_spin)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
represents a system: atoms, molecules, their pos,vel,...
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.