(git:26ffdda)
Loading...
Searching...
No Matches
topology_state_io.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 Versioned Gaussian-basis snapshots for cross-geometry topology overlaps.
10!> Atomic units, full contraction coefficients, CP2K periodic atom images.
11! **************************************************************************************************
15 USE cell_types, ONLY: cell_type,&
16 pbc
17 USE cp_files, ONLY: open_file
18 USE kinds, ONLY: dp
20 USE orbital_pointers, ONLY: indco,&
21 ncoset
25 USE qs_kind_types, ONLY: get_qs_kind,&
27#include "./base/base_uses.f90"
28
29 IMPLICIT NONE
30 PRIVATE
31 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'topology_state_io'
33CONTAINS
34
35! **************************************************************************************************
36!> \brief Write basis metadata; all ranks call, only the source writes.
37!> \param qs_env electronic structure environment
38!> \param filename snapshot file
39!> \param nao number of AO functions
40!> \param nband retained states
41!> \param npoint k-points
42!> \param nspin spinor components, one for a selected collinear channel
43!> \param ntotal all computed eigenvalues
44!> \param spin_channel collinear channel label
45!> \param bands retained band indices
46!> \param unit source output unit, -1 on other ranks
47! **************************************************************************************************
48 SUBROUTINE topology_state_begin(qs_env, filename, nao, nband, npoint, nspin, ntotal, spin_channel, bands, unit)
49 TYPE(qs_environment_type), POINTER :: qs_env
50 CHARACTER(len=*), INTENT(IN) :: filename
51 INTEGER, INTENT(IN) :: nao, nband, npoint, nspin, ntotal, &
52 spin_channel, bands(:)
53 INTEGER, INTENT(OUT) :: unit
54
55 INTEGER :: count_ao, first, ia, ic, ik, ip, iset, &
56 j, ncart, ns, row
57 TYPE(cell_type), POINTER :: cell
58 TYPE(gto_basis_set_type), POINTER :: basis
59 TYPE(mp_para_env_type), POINTER :: para_env
60 TYPE(particle_type), POINTER :: particles(:)
61 TYPE(qs_kind_type), POINTER :: kinds_set(:)
62
63 CALL get_qs_env(qs_env, cell=cell, particle_set=particles, qs_kind_set=kinds_set, para_env=para_env)
64 unit = -1
65 IF (.NOT. para_env%is_source()) RETURN
66 CALL open_file(filename, unit_number=unit, file_status="UNKNOWN", file_action="WRITE")
67 WRITE (unit, '(A)') 'CP2K_TOPOLOGY_STATE 1'
68 WRITE (unit, '(7I12)') SIZE(particles), nao, nband, npoint, nspin, ntotal, spin_channel
69 WRITE (unit, '(*(I12))') bands
70 DO j = 1, 3
71 WRITE (unit, '(3ES26.17)') cell%hmat(:, j)
72 END DO
73 WRITE (unit, '(3I12)') cell%perd
74 count_ao = 0
75 DO ia = 1, SIZE(particles)
76 CALL get_atomic_kind(particles(ia)%atomic_kind, kind_number=ik)
77 CALL get_qs_kind(kinds_set(ik), basis_set=basis)
78 IF (.NOT. ASSOCIATED(basis)) THEN
79 cpabort("STATE_EXPORT requires a Gaussian orbital basis on every atom.")
80 END IF
81 WRITE (unit, '(4I12)') ia, ik, basis%nset, basis%nsgf
82 WRITE (unit, '(3ES26.17)') pbc(particles(ia)%r, cell)
83 DO iset = 1, basis%nset
84 first = basis%first_sgf(1, iset)
85 ns = basis%nsgf_set(iset)
86 ncart = ncoset(basis%lmax(iset))
87 WRITE (unit, '(5I12,ES26.17)') first, ns, basis%npgf(iset), ncart, basis%lmin(iset), &
88 basis%set_radius(iset)
89 DO ip = 1, basis%npgf(iset)
90 WRITE (unit, '(2ES26.17)') basis%zet(ip, iset), basis%pgf_radius(ip, iset)
91 DO ic = 1, ncart
92 row = (ip - 1)*ncart + ic
93 WRITE (unit, '(3I5,*(ES26.17))') indco(:, ic), basis%sphi(row, first:first + ns - 1)
94 END DO
95 END DO
96 END DO
97 count_ao = count_ao + basis%nsgf
98 END DO
99 IF (count_ao /= nao) cpabort("STATE_EXPORT: inconsistent atom/AO dimensions.")
100 END SUBROUTINE topology_state_begin
101
102! **************************************************************************************************
103!> \brief Write one point with eigenvalues in Hartree and physical AO coefficients.
104!> \param unit snapshot output unit, -1 skips output
105!> \param point one-based point index
106!> \param k fractional reciprocal coordinates
107!> \param eigenvalues all computed eigenvalues, including excluded states
108!> \param coefficients selected states; spinor components are stacked by AO
109! **************************************************************************************************
110 SUBROUTINE topology_state_point(unit, point, k, eigenvalues, coefficients)
111 INTEGER, INTENT(IN) :: unit, point
112 REAL(kind=dp), INTENT(IN) :: k(3), eigenvalues(:)
113 COMPLEX(KIND=dp), INTENT(IN) :: coefficients(:, :)
114
115 INTEGER :: i, j
116
117 IF (unit < 0) RETURN
118 WRITE (unit, '(I12,3ES26.17)') point, k
119 WRITE (unit, '(*(ES26.17))') eigenvalues
120 DO j = 1, SIZE(coefficients, 2)
121 DO i = 1, SIZE(coefficients, 1)
122 WRITE (unit, '(2ES26.17)') real(coefficients(i, j), dp), aimag(coefficients(i, j))
123 END DO
124 END DO
125 END SUBROUTINE topology_state_point
126END MODULE topology_state_io
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.
Definition cell_types.F:15
Utility routines to open and close files. Tracking of preconnections.
Definition cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition cp_files.F:311
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :), allocatable, public indco
Define the data structure for the particle information.
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, mimic, 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_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, 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, matrix_vhxc, 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, xcint_weights, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, harris_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, eeq, rhs, do_rixs, tb_tblite)
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, cneo_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, hund_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, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Versioned Gaussian-basis snapshots for cross-geometry topology overlaps. Atomic units,...
subroutine, public topology_state_begin(qs_env, filename, nao, nband, npoint, nspin, ntotal, spin_channel, bands, unit)
Write basis metadata; all ranks call, only the source writes.
subroutine, public topology_state_point(unit, point, k, eigenvalues, coefficients)
Write one point with eigenvalues in Hartree and physical AO coefficients.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.