30 USE dbcsr_api,
ONLY: dbcsr_copy,&
32 dbcsr_type_no_symmetry
49 molecular_scf_guess_env_type,&
61 #include "./base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mscfg_methods'
82 TYPE(global_environment_type),
POINTER :: globenv
83 TYPE(force_env_type),
POINTER :: force_env
86 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: charge_of_frag, first_atom_of_frag, &
87 last_atom_of_frag, multip_of_frag
88 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
89 TYPE(qs_environment_type),
POINTER :: qs_env
92 cpassert(
ASSOCIATED(qs_env))
94 molecule_set=molecule_set)
96 nmols =
SIZE(molecule_set)
98 ALLOCATE (first_atom_of_frag(nmols))
99 ALLOCATE (last_atom_of_frag(nmols))
100 ALLOCATE (charge_of_frag(nmols))
101 ALLOCATE (multip_of_frag(nmols))
104 mol_to_first_atom=first_atom_of_frag, &
105 mol_to_last_atom=last_atom_of_frag, &
106 mol_to_charge=charge_of_frag, &
107 mol_to_multiplicity=multip_of_frag)
109 CALL calcs_on_isolated_molecules(force_env, globenv, nmols, &
110 first_atom_of_frag, last_atom_of_frag, charge_of_frag, multip_of_frag)
112 DEALLOCATE (first_atom_of_frag)
113 DEALLOCATE (last_atom_of_frag)
114 DEALLOCATE (charge_of_frag)
115 DEALLOCATE (multip_of_frag)
134 SUBROUTINE calcs_on_isolated_molecules(force_env, globenv, nfrags, &
135 first_atom_of_frag, last_atom_of_frag, charge_of_frag, multip_of_frag)
137 TYPE(force_env_type),
POINTER :: force_env
138 TYPE(global_environment_type),
POINTER :: globenv
139 INTEGER,
INTENT(IN) :: nfrags
140 INTEGER,
DIMENSION(:),
INTENT(IN) :: first_atom_of_frag, last_atom_of_frag, &
141 charge_of_frag, multip_of_frag
143 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calcs_on_isolated_molecules'
145 CHARACTER(LEN=default_string_length) :: name
146 CHARACTER(LEN=default_string_length), &
147 DIMENSION(:),
POINTER :: atom_type
148 INTEGER :: first_atom, force_method, global_charge, global_multpl, handle, i, ifrag, imo, &
149 isize, j, k, last_atom, my_targ, nb_eigenval_stored, nmo, nmo_of_frag, nmosets_of_frag, &
150 tot_added_mos, tot_isize
151 INTEGER,
DIMENSION(:),
POINTER :: atom_index, atom_list
152 LOGICAL :: global_almo_scf_keyword, smear_almo_scf
153 TYPE(almo_scf_env_type),
POINTER :: almo_scf_env
154 TYPE(cell_type),
POINTER :: cell
155 TYPE(cp_subsys_type),
POINTER :: subsys, subsys_loc
156 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos, mos_of_frag
157 TYPE(molecular_scf_guess_env_type),
POINTER :: mscfg_env
158 TYPE(mp_para_env_type),
POINTER :: para_env
159 TYPE(particle_list_type),
POINTER :: particles
160 TYPE(qs_energy_type),
POINTER ::
qs_energy
161 TYPE(qs_environment_type),
POINTER :: qs_env, qs_env_loc
162 TYPE(section_vals_type),
POINTER :: dft_section, force_env_section, &
163 qs_section, root_section, scf_section, &
166 CALL timeset(routinen, handle)
168 NULLIFY (subsys_loc, subsys, particles, para_env, cell, atom_index, atom_type, &
169 force_env_section, qs_env_loc, mscfg_env, qs_env,
qs_energy)
170 CALL force_env_get(force_env, force_env_section=force_env_section, &
173 cpassert(force_method .EQ.
do_qs)
174 root_section => force_env%root_section
188 CALL force_env_get(force_env=force_env, subsys=subsys, para_env=para_env, &
191 CALL get_qs_env(qs_env, mscfg_env=mscfg_env, almo_scf_env=almo_scf_env)
192 cpassert(
ASSOCIATED(mscfg_env))
193 IF (global_almo_scf_keyword)
THEN
194 smear_almo_scf = qs_env%scf_control%smear%do_smear
195 IF (smear_almo_scf)
THEN
198 tot_isize = last_atom_of_frag(nfrags) - first_atom_of_frag(1) + 1
201 IF (tot_isize .NE. tot_added_mos)
THEN
202 cpabort(
"ALMO smearing currently requires ADDED_MOS == total number of atoms")
206 IF (
SIZE(mos) .GT. 1) cpabort(
"Unrestricted ALMO methods are NYI")
209 cpassert(
ASSOCIATED(almo_scf_env))
210 ALLOCATE (almo_scf_env%mo_energies(nmo,
SIZE(mos)))
211 ALLOCATE (almo_scf_env%kTS(
SIZE(mos)))
212 nb_eigenval_stored = 0
215 smear_almo_scf = .false.
257 first_atom = first_atom_of_frag(ifrag)
258 last_atom = last_atom_of_frag(ifrag)
259 isize = last_atom - first_atom + 1
260 ALLOCATE (atom_index(isize))
261 atom_index(1:isize) = (/(i, i=first_atom, last_atom)/)
265 ALLOCATE (atom_type(isize))
267 my_targ = atom_index(j)
268 DO k = 1,
SIZE(particles%els)
269 CALL get_atomic_kind(particles%els(k)%atomic_kind, atom_list=atom_list, name=name)
270 IF (any(atom_list == my_targ))
EXIT
277 IF (smear_almo_scf)
THEN
284 small_para_env=para_env, small_cell=cell, sub_atom_index=atom_index, &
285 sub_atom_kind_name=atom_type, para_env=para_env, &
286 force_env_section=force_env_section, subsys_section=subsys_section)
287 ALLOCATE (qs_env_loc)
289 CALL qs_init(qs_env_loc, para_env, root_section, globenv=globenv, cp_subsys=subsys_loc, &
290 force_env_section=force_env_section, subsys_section=subsys_section, &
291 use_motion_section=.false.)
297 CALL print_frag_info(atom_index, atom_type, ifrag, nfrags, &
298 charge_of_frag(ifrag), multip_of_frag(ifrag))
311 mscfg_env%energy_of_frag(ifrag) =
qs_energy%total
312 nmosets_of_frag =
SIZE(mos_of_frag)
314 mscfg_env%nmosets_of_frag(ifrag) = nmosets_of_frag
315 DO imo = 1, nmosets_of_frag
317 IF (global_almo_scf_keyword)
THEN
322 mos_of_frag(imo)%mo_coeff_b)
323 IF (smear_almo_scf)
THEN
325 nmo_of_frag =
SIZE(mos_of_frag(imo)%eigenvalues)
326 almo_scf_env%mo_energies(nb_eigenval_stored + 1:nb_eigenval_stored + nmo_of_frag, imo) &
327 = mos_of_frag(imo)%eigenvalues(:)
329 nb_eigenval_stored = nb_eigenval_stored + nmo_of_frag
334 CALL dbcsr_create(mscfg_env%mos_of_frag(ifrag, imo), &
335 template=mos_of_frag(imo)%mo_coeff_b, &
336 matrix_type=dbcsr_type_no_symmetry)
337 CALL dbcsr_copy(mscfg_env%mos_of_frag(ifrag, imo), &
338 mos_of_frag(imo)%mo_coeff_b)
345 DEALLOCATE (qs_env_loc)
346 DEALLOCATE (atom_index)
347 DEALLOCATE (atom_type)
355 CALL timestop(handle)
357 END SUBROUTINE calcs_on_isolated_molecules
372 SUBROUTINE print_frag_info(atom_index, atom_type, frag, nfrags, charge, &
375 INTEGER,
DIMENSION(:),
POINTER :: atom_index
376 CHARACTER(len=default_string_length), &
377 DIMENSION(:),
POINTER :: atom_type
378 INTEGER,
INTENT(IN) :: frag, nfrags, charge, multpl
380 CHARACTER(len=11) :: chari
382 TYPE(cp_logger_type),
POINTER :: logger
386 IF (logger%para_env%is_source())
THEN
394 WRITE (unit=iw, fmt=
"(/,T2,A)") repeat(
"-", 79)
395 WRITE (unit=iw, fmt=
"(T2,A,T80,A)")
"-",
"-"
396 WRITE (unit=iw, fmt=
"(T2,A,T5,A,T25,A,T40,I11,T53,A,T67,I11,T80,A)") &
397 "-",
"MOLECULAR GUESS:",
"FRAGMENT", frag,
"OUT OF", nfrags,
"-"
398 WRITE (unit=iw, fmt=
"(T2,A,T25,A,T40,I11,T53,A,T67,I11,T80,A)")
"-",
"CHARGE", charge,
"MULTIPLICITY", &
400 WRITE (unit=iw, fmt=
"(T2,A,T80,A)")
"-",
"-"
401 WRITE (unit=iw, fmt=
"(T2,A,T25,A,T53,A,T80,A)")
"-",
"ATOM INDEX",
"ATOM NAME",
"-"
402 WRITE (unit=iw, fmt=
"(T2,A,T25,A,T53,A,T80,A)")
"-",
"----------",
"---------",
"-"
403 DO i = 1,
SIZE(atom_index)
404 WRITE (chari,
'(I11)') atom_index(i)
405 WRITE (unit=iw, fmt=
"(T2,A,T25,A,T53,A,T80,A)")
"-", adjustl(chari), trim(atom_type(i)),
"-"
407 WRITE (unit=iw, fmt=
"(T2,A)") repeat(
"-", 79)
410 END SUBROUTINE print_frag_info
422 TYPE(force_env_type),
POINTER :: force_env
425 INTEGER :: almo_guess_type, frz_term_type, &
426 method_name_id, scf_guess_type
427 LOGICAL :: almo_scf_is_on, is_crystal, is_fast_dirty
428 TYPE(molecular_scf_guess_env_type),
POINTER :: mscfg_env
429 TYPE(qs_environment_type),
POINTER :: qs_env
430 TYPE(section_vals_type),
POINTER :: force_env_section, subsection
434 is_fast_dirty = .true.
436 almo_scf_is_on = .false.
438 NULLIFY (qs_env, mscfg_env, force_env_section, subsection)
439 CALL force_env_get(force_env, force_env_section=force_env_section)
442 IF (method_name_id .EQ.
do_qs)
THEN
445 cpassert(
ASSOCIATED(qs_env))
448 cpassert(
ASSOCIATED(mscfg_env))
485 is_fast_dirty = .false.
493 mscfg_env%is_fast_dirty = is_fast_dirty
494 mscfg_env%is_crystal = is_crystal
Types for all ALMO-based methods.
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.
DBCSR operations in CP2K.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Initialize a small environment for a particular calculation.
subroutine, public create_small_subsys(small_subsys, big_subsys, small_cell, small_para_env, sub_atom_index, sub_atom_kind_name, para_env, force_env_section, subsys_section, ignore_outside_box)
updates the molecule information of the given subsys
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_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
Interface for the force calculations.
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
Define type storing the global information of a run. Keep the amount of stored data small....
Defines the basic variable types.
integer, parameter, public default_string_length
Interface to the message passing library MPI.
Define the data structure for the molecule information.
subroutine, public get_molecule_set_info(molecule_set, atom_to_mol, mol_to_first_atom, mol_to_last_atom, mol_to_nelectrons, mol_to_nbasis, mol_to_charge, mol_to_multiplicity)
returns information about molecules in the set.
Subroutines to perform calculations on molecules from a bigger system. Useful to generate a high-qual...
subroutine, public loop_over_molecules(globenv, force_env)
Prepare data for calculations on isolated molecules.
logical function, public do_mol_loop(force_env)
Is the loop over molecules requested?
Types used to generate the molecular SCF guess.
integer, parameter, public mscfg_max_moset_size
subroutine, public molecular_scf_guess_env_init(env, nfrags)
Allocates data.
represent a simple array based list of the given type
Perform a QUICKSTEP wavefunction optimization (single point)
subroutine, public qs_energies(qs_env, consistent_energies, calc_forces)
Driver routine for QUICKSTEP single point wavefunction optimization.
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.
subroutine, public qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
subroutine, public qs_env_create(qs_env, globenv)
allocates and intitializes a qs_env
subroutine, public qs_init(qs_env, para_env, root_section, globenv, cp_subsys, kpoint_env, cell, cell_ref, qmmm, qmmm_env_qm, force_env_section, subsys_section, use_motion_section)
Read the input and the database files for the setup of the QUICKSTEP environment.
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kTS, mu, flexible_electron_count)
Get the components of a MO set data structure.