37 dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, &
61 USE trexio,
ONLY: trexio_open, trexio_close, &
62 trexio_hdf5, trexio_success, &
63 trexio_string_of_error, trexio_t, trexio_exit_code, &
64 trexio_write_metadata_code, trexio_write_metadata_code_num, &
65 trexio_write_nucleus_coord, trexio_read_nucleus_coord, &
66 trexio_write_nucleus_num, trexio_read_nucleus_num, &
67 trexio_write_nucleus_charge, trexio_read_nucleus_charge, &
68 trexio_write_nucleus_label, trexio_read_nucleus_label, &
69 trexio_write_nucleus_repulsion, &
70 trexio_write_cell_a, trexio_write_cell_b, trexio_write_cell_c, &
71 trexio_write_cell_g_a, trexio_write_cell_g_b, &
72 trexio_write_cell_g_c, trexio_write_cell_two_pi, &
73 trexio_write_pbc_periodic, trexio_write_pbc_k_point_num, &
74 trexio_write_pbc_k_point, trexio_write_pbc_k_point_weight, &
75 trexio_write_electron_num, trexio_read_electron_num, &
76 trexio_write_electron_up_num, trexio_read_electron_up_num, &
77 trexio_write_electron_dn_num, trexio_read_electron_dn_num, &
78 trexio_write_state_num, trexio_write_state_id, &
79 trexio_write_state_energy, &
80 trexio_write_basis_type, trexio_write_basis_prim_num, &
81 trexio_write_basis_shell_num, trexio_read_basis_shell_num, &
82 trexio_write_basis_nucleus_index, &
83 trexio_write_basis_shell_ang_mom, trexio_read_basis_shell_ang_mom, &
84 trexio_write_basis_shell_factor, &
85 trexio_write_basis_r_power, trexio_write_basis_shell_index, &
86 trexio_write_basis_exponent, trexio_write_basis_coefficient, &
87 trexio_write_basis_prim_factor, &
88 trexio_write_ecp_z_core, trexio_write_ecp_max_ang_mom_plus_1, &
89 trexio_write_ecp_num, trexio_write_ecp_ang_mom, &
90 trexio_write_ecp_nucleus_index, trexio_write_ecp_exponent, &
91 trexio_write_ecp_coefficient, trexio_write_ecp_power, &
92 trexio_write_ao_cartesian, trexio_write_ao_num, &
93 trexio_read_ao_cartesian, trexio_read_ao_num, &
94 trexio_write_ao_shell, trexio_write_ao_normalization, &
95 trexio_read_ao_shell, trexio_read_ao_normalization, &
96 trexio_write_mo_num, trexio_write_mo_energy, &
97 trexio_read_mo_num, trexio_read_mo_energy, &
98 trexio_write_mo_occupation, trexio_write_mo_spin, &
99 trexio_read_mo_occupation, trexio_read_mo_spin, &
100 trexio_write_mo_class, trexio_write_mo_coefficient, &
101 trexio_read_mo_class, trexio_read_mo_coefficient, &
102 trexio_write_mo_coefficient_im, trexio_write_mo_k_point, &
105#include "./base/base_uses.f90"
111 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'trexio_utils'
126 TYPE(
dbcsr_p_type),
INTENT(IN),
DIMENSION(:),
POINTER,
OPTIONAL :: energy_derivative
129 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_trexio'
131 INTEGER :: handle, output_unit, unit_trexio
132 CHARACTER(len=default_path_length) :: filename, filename_de
133 INTEGER(trexio_t) :: f
134 INTEGER(trexio_exit_code) :: rc
135 LOGICAL :: explicit, do_kpoints, ecp_semi_local, &
136 ecp_local, sgp_potential_present, ionode, &
137 use_real_wfn, save_cartesian
138 REAL(kind=
dp) :: e_nn, zeff, expzet, prefac, zeta, gcca, &
150 TYPE(
mo_set_type),
DIMENSION(:, :),
POINTER :: mos_kp
155 TYPE(
cp_fm_type) :: fm_mo_coeff, fm_dummy, fm_mo_coeff_im
158 CHARACTER(LEN=2) :: element_symbol
159 CHARACTER(LEN=2),
DIMENSION(:),
ALLOCATABLE :: label
160 INTEGER :: iatom, natoms, periodic, nkp, nel_tot, &
161 nspins, ikind, ishell_loc, ishell, &
162 shell_num, prim_num, nset, iset, ipgf, z, &
163 sl_lmax, ecp_num, nloc, nsemiloc, sl_l, iecp, &
164 iao, icgf_atom, ncgf, nao_shell, ao_num, nmo, &
165 mo_num, ispin, ikp, imo, ikp_loc, nsgf, ncgf_atom, &
166 i, j, k, l, m, unit_de, &
167 row, col, row_size, col_size, &
168 row_offset, col_offset
169 INTEGER,
DIMENSION(2) :: nel_spin, kp_range, nmo_spin
170 INTEGER,
DIMENSION(0:10) :: npot
171 INTEGER,
DIMENSION(:),
ALLOCATABLE :: nucleus_index, shell_ang_mom, r_power, &
172 shell_index, z_core, max_ang_mom_plus_1, &
173 ang_mom, powers, ao_shell, mo_spin, mo_kpoint, &
174 cp2k_to_trexio_ang_mom
175 INTEGER,
DIMENSION(:),
POINTER :: nshell, npgf
176 INTEGER,
DIMENSION(:, :),
POINTER :: l_shell_set
177 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: charge, shell_factor, exponents, coefficients, &
178 prim_factor, ao_normalization, mo_energy, &
179 mo_occupation, sgcc, ecp_coefficients, &
181 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp, norm_cgf
182 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: coord, mo_coefficient, mo_coefficient_im, &
184 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: zetas, data_block, xkp
185 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: gcc
187 CALL timeset(routinen, handle)
189 NULLIFY (cell, logger, dft_control, basis_set, kpoints, particle_set, energy, kind_set)
190 NULLIFY (sgp_potential, mos, mos_kp, kp_env, para_env, para_env_inter_kp, blacs_env)
191 NULLIFY (fm_struct, nshell, npgf, l_shell_set, wkp, norm_cgf, zetas, data_block, gcc)
196 cpassert(
ASSOCIATED(qs_env))
200 IF (.NOT. explicit)
THEN
201 filename = trim(logger%iter_info%project_name)//
'-TREXIO.h5'
203 filename = trim(filename)//
'.h5'
207 ionode = para_env%is_source()
212 CALL open_file(filename, unit_number=unit_trexio)
213 CALL close_file(unit_number=unit_trexio, file_status=
"DELETE")
219 WRITE (output_unit,
"((T2,A,A))")
'TREXIO| Writing trexio file ', trim(filename)
220 f = trexio_open(filename,
'w', trexio_hdf5, rc)
221 CALL trexio_error(rc)
226 rc = trexio_write_metadata_code_num(f, 1)
227 CALL trexio_error(rc)
230 CALL trexio_error(rc)
235 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set, qs_kind_set=kind_set, natom=natoms)
237 rc = trexio_write_nucleus_num(f, natoms)
238 CALL trexio_error(rc)
240 ALLOCATE (coord(3, natoms))
241 ALLOCATE (label(natoms))
242 ALLOCATE (charge(natoms))
245 coord(:, iatom) = particle_set(iatom)%r(1:3)
247 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, element_symbol=element_symbol, kind_number=ikind)
249 label(iatom) = element_symbol
255 rc = trexio_write_nucleus_coord(f, coord)
256 CALL trexio_error(rc)
259 rc = trexio_write_nucleus_charge(f, charge)
260 CALL trexio_error(rc)
263 rc = trexio_write_nucleus_label(f, label, 3)
264 CALL trexio_error(rc)
268 IF (sum(cell%perd) == 0)
THEN
269 CALL nuclear_repulsion_energy(particle_set, kind_set, e_nn)
270 rc = trexio_write_nucleus_repulsion(f, e_nn)
271 CALL trexio_error(rc)
277 rc = trexio_write_cell_a(f, cell%hmat(:, 1))
278 CALL trexio_error(rc)
280 rc = trexio_write_cell_b(f, cell%hmat(:, 2))
281 CALL trexio_error(rc)
283 rc = trexio_write_cell_c(f, cell%hmat(:, 3))
284 CALL trexio_error(rc)
286 rc = trexio_write_cell_g_a(f, cell%h_inv(:, 1))
287 CALL trexio_error(rc)
289 rc = trexio_write_cell_g_b(f, cell%h_inv(:, 2))
290 CALL trexio_error(rc)
292 rc = trexio_write_cell_g_c(f, cell%h_inv(:, 3))
293 CALL trexio_error(rc)
295 rc = trexio_write_cell_two_pi(f, 0)
296 CALL trexio_error(rc)
301 CALL get_qs_env(qs_env, do_kpoints=do_kpoints, kpoints=kpoints)
304 IF (sum(cell%perd) /= 0) periodic = 1
305 rc = trexio_write_pbc_periodic(f, periodic)
306 CALL trexio_error(rc)
311 rc = trexio_write_pbc_k_point_num(f, nkp)
312 CALL trexio_error(rc)
314 rc = trexio_write_pbc_k_point(f, xkp)
315 CALL trexio_error(rc)
317 rc = trexio_write_pbc_k_point_weight(f, wkp)
318 CALL trexio_error(rc)
324 CALL get_qs_env(qs_env, dft_control=dft_control, nelectron_total=nel_tot)
326 rc = trexio_write_electron_num(f, nel_tot)
327 CALL trexio_error(rc)
329 nspins = dft_control%nspins
330 IF (nspins == 1)
THEN
333 nel_spin(1) = nel_tot/2
334 nel_spin(2) = nel_tot/2
338 CALL get_qs_env(qs_env, nelectron_spin=nel_spin)
340 rc = trexio_write_electron_up_num(f, nel_spin(1))
341 CALL trexio_error(rc)
342 rc = trexio_write_electron_dn_num(f, nel_spin(2))
343 CALL trexio_error(rc)
350 rc = trexio_write_state_num(f, 1)
351 CALL trexio_error(rc)
353 rc = trexio_write_state_id(f, 1)
354 CALL trexio_error(rc)
357 CALL trexio_error(rc)
364 CALL get_qs_env(qs_env, qs_kind_set=kind_set, natom=natoms, particle_set=particle_set)
370 rc = trexio_write_basis_type(f,
'Gaussian', len_trim(
'Gaussian') + 1)
371 CALL trexio_error(rc)
373 rc = trexio_write_basis_shell_num(f, shell_num)
374 CALL trexio_error(rc)
376 rc = trexio_write_basis_prim_num(f, prim_num)
377 CALL trexio_error(rc)
381 ALLOCATE (nucleus_index(shell_num))
382 ALLOCATE (shell_ang_mom(shell_num))
383 ALLOCATE (shell_index(prim_num))
384 ALLOCATE (exponents(prim_num))
385 ALLOCATE (coefficients(prim_num))
386 ALLOCATE (prim_factor(prim_num))
389 IF (.NOT. save_cartesian)
THEN
390 ALLOCATE (sgf_coefficients(prim_num))
397 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
399 CALL get_qs_kind(kind_set(ikind), basis_set=basis_set, basis_type=
"ORB")
410 DO ishell_loc = 1, nshell(iset)
414 nucleus_index(ishell) = iatom
417 l = l_shell_set(ishell_loc, iset)
418 shell_ang_mom(ishell) = l
421 shell_index(ipgf + 1:ipgf + npgf(iset)) = ishell
424 exponents(ipgf + 1:ipgf + npgf(iset)) = zetas(1:npgf(iset), iset)
428 expzet = 0.25_dp*real(2*l + 3,
dp)
429 prefac = 2.0_dp**l*(2.0_dp/
pi)**0.75_dp
431 gcca = gcc(i, ishell_loc, iset)
432 zeta = zetas(i, iset)
433 prim_cart_fac = prefac*zeta**expzet
436 coefficients(ipgf + i) = gcca/prim_cart_fac
438 IF (save_cartesian)
THEN
440 prim_factor(ipgf + i) = prim_cart_fac
443 prim_factor(ipgf + i) = sgf_norm(l, exponents(ipgf + i))
445 sgf_coefficients(ipgf + i) = coefficients(ipgf + i)*prim_factor(ipgf + i)
450 ipgf = ipgf + npgf(iset)
455 cpassert(ishell == shell_num)
456 cpassert(ipgf == prim_num)
459 rc = trexio_write_basis_nucleus_index(f, nucleus_index)
460 CALL trexio_error(rc)
462 rc = trexio_write_basis_shell_ang_mom(f, shell_ang_mom)
463 CALL trexio_error(rc)
466 ALLOCATE (shell_factor(shell_num))
467 shell_factor(:) = 1.0_dp
468 rc = trexio_write_basis_shell_factor(f, shell_factor)
469 CALL trexio_error(rc)
470 DEALLOCATE (shell_factor)
473 ALLOCATE (r_power(shell_num))
475 rc = trexio_write_basis_r_power(f, r_power)
476 CALL trexio_error(rc)
479 rc = trexio_write_basis_shell_index(f, shell_index)
480 CALL trexio_error(rc)
482 rc = trexio_write_basis_exponent(f, exponents)
483 CALL trexio_error(rc)
485 rc = trexio_write_basis_coefficient(f, coefficients)
486 CALL trexio_error(rc)
489 rc = trexio_write_basis_prim_factor(f, prim_factor)
490 CALL trexio_error(rc)
493 DEALLOCATE (nucleus_index)
494 DEALLOCATE (shell_index)
495 DEALLOCATE (exponents)
496 DEALLOCATE (coefficients)
497 DEALLOCATE (prim_factor)
504 CALL get_qs_kind_set(kind_set, sgp_potential_present=sgp_potential_present)
508 IF (sgp_potential_present)
THEN
511 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
513 CALL get_qs_kind(kind_set(ikind), sgp_potential=sgp_potential)
516 IF (
ASSOCIATED(sgp_potential))
THEN
517 CALL get_potential(potential=sgp_potential, ecp_local=ecp_local, ecp_semi_local=ecp_semi_local)
521 ecp_num = ecp_num + nloc
523 IF (ecp_semi_local)
THEN
526 ecp_num = ecp_num + sum(npot)
533 IF (ecp_num > 0)
THEN
534 ALLOCATE (z_core(natoms))
535 ALLOCATE (max_ang_mom_plus_1(natoms))
536 max_ang_mom_plus_1(:) = 0
538 ALLOCATE (ang_mom(ecp_num))
539 ALLOCATE (nucleus_index(ecp_num))
540 ALLOCATE (exponents(ecp_num))
541 ALLOCATE (ecp_coefficients(ecp_num))
542 ALLOCATE (powers(ecp_num))
547 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind, z=z)
549 CALL get_qs_kind(kind_set(ikind), sgp_potential=sgp_potential, zeff=zeff)
552 z_core(iatom) = z - int(zeff)
555 IF (
ASSOCIATED(sgp_potential))
THEN
556 CALL get_potential(potential=sgp_potential, ecp_local=ecp_local, ecp_semi_local=ecp_semi_local)
560 CALL get_potential(potential=sgp_potential, nloc=nloc, sl_lmax=sl_lmax)
561 ang_mom(iecp + 1:iecp + nloc) = sl_lmax + 1
562 nucleus_index(iecp + 1:iecp + nloc) = iatom
563 exponents(iecp + 1:iecp + nloc) = sgp_potential%bloc(1:nloc)
564 ecp_coefficients(iecp + 1:iecp + nloc) = sgp_potential%aloc(1:nloc)
565 powers(iecp + 1:iecp + nloc) = sgp_potential%nrloc(1:nloc) - 2
570 IF (ecp_semi_local)
THEN
571 CALL get_potential(potential=sgp_potential, npot=npot, sl_lmax=sl_lmax)
572 max_ang_mom_plus_1(iatom) = sl_lmax + 1
575 nsemiloc = npot(sl_l)
576 ang_mom(iecp + 1:iecp + nsemiloc) = sl_l
577 nucleus_index(iecp + 1:iecp + nsemiloc) = iatom
578 exponents(iecp + 1:iecp + nsemiloc) = sgp_potential%bpot(1:nsemiloc, sl_l)
579 ecp_coefficients(iecp + 1:iecp + nsemiloc) = sgp_potential%apot(1:nsemiloc, sl_l)
580 powers(iecp + 1:iecp + nsemiloc) = sgp_potential%nrpot(1:nsemiloc, sl_l) - 2
581 iecp = iecp + nsemiloc
588 cpassert(iecp == ecp_num)
590 rc = trexio_write_ecp_num(f, ecp_num)
591 CALL trexio_error(rc)
593 rc = trexio_write_ecp_z_core(f, z_core)
594 CALL trexio_error(rc)
597 rc = trexio_write_ecp_max_ang_mom_plus_1(f, max_ang_mom_plus_1)
598 CALL trexio_error(rc)
599 DEALLOCATE (max_ang_mom_plus_1)
601 rc = trexio_write_ecp_ang_mom(f, ang_mom)
602 CALL trexio_error(rc)
605 rc = trexio_write_ecp_nucleus_index(f, nucleus_index)
606 CALL trexio_error(rc)
607 DEALLOCATE (nucleus_index)
609 rc = trexio_write_ecp_exponent(f, exponents)
610 CALL trexio_error(rc)
611 DEALLOCATE (exponents)
613 rc = trexio_write_ecp_coefficient(f, ecp_coefficients)
614 CALL trexio_error(rc)
615 DEALLOCATE (ecp_coefficients)
617 rc = trexio_write_ecp_power(f, powers)
618 CALL trexio_error(rc)
635 IF (save_cartesian)
THEN
642 IF (save_cartesian)
THEN
643 rc = trexio_write_ao_cartesian(f, 1)
645 rc = trexio_write_ao_cartesian(f, 0)
647 CALL trexio_error(rc)
649 rc = trexio_write_ao_num(f, ao_num)
650 CALL trexio_error(rc)
654 ALLOCATE (ao_shell(ao_num))
655 ALLOCATE (ao_normalization(ao_num))
657 IF (.NOT. save_cartesian)
THEN
661 ALLOCATE (cp2k_to_trexio_ang_mom(ao_num))
663 DO ishell = 1, shell_num
664 l = shell_ang_mom(ishell)
666 m = (-1)**k*floor(real(k, kind=
dp)/2.0_dp)
667 cp2k_to_trexio_ang_mom(i + k) = i + l + 1 + m
671 cpassert(i == ao_num)
680 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
682 CALL get_qs_kind(kind_set(ikind), basis_set=basis_set, basis_type=
"ORB")
695 DO ishell_loc = 1, nshell(iset)
699 l = l_shell_set(ishell_loc, iset)
702 IF (save_cartesian)
THEN
709 ao_shell(iao + 1:iao + nao_shell) = ishell
712 IF (save_cartesian)
THEN
713 ao_normalization(iao + 1:iao + nao_shell) = norm_cgf(icgf_atom + 1:icgf_atom + nao_shell)
716 ALLOCATE (sloc(npgf(iset), npgf(iset)))
717 ALLOCATE (sgcc(npgf(iset)))
718 CALL sg_overlap(sloc, l, zetas(1:npgf(iset), iset), zetas(1:npgf(iset), iset))
721 sgcc(:) = matmul(sloc, sgf_coefficients(ipgf + 1:ipgf + npgf(iset)))
722 nsgto = 1.0_dp/sqrt(dot_product(sgf_coefficients(ipgf + 1:ipgf + npgf(iset)), sgcc))
730 ao_normalization(iao + 1:iao + nao_shell) = nsgto*sqrt((2*l + 1)/(4*
pi))
733 ipgf = ipgf + npgf(iset)
734 iao = iao + nao_shell
735 icgf_atom = icgf_atom +
nco(l)
739 cpassert(icgf_atom == ncgf_atom)
743 rc = trexio_write_ao_shell(f, ao_shell)
744 CALL trexio_error(rc)
746 rc = trexio_write_ao_normalization(f, ao_normalization)
747 CALL trexio_error(rc)
750 DEALLOCATE (ao_shell)
751 DEALLOCATE (ao_normalization)
752 IF (
ALLOCATED(sgf_coefficients))
DEALLOCATE (sgf_coefficients)
757 CALL get_qs_env(qs_env, do_kpoints=do_kpoints, kpoints=kpoints, dft_control=dft_control, &
758 particle_set=particle_set, qs_kind_set=kind_set, blacs_env=blacs_env)
759 nspins = dft_control%nspins
766 CALL get_kpoint_info(kpoints, kp_env=kp_env, nkp=nkp, use_real_wfn=use_real_wfn)
770 nmo_spin(ispin) = nmo
772 mo_num = nkp*sum(nmo_spin)
776 nrow_global=nsgf, ncol_global=mo_num)
779 IF (.NOT. use_real_wfn)
THEN
788 nmo_spin(ispin) = nmo
790 mo_num = sum(nmo_spin)
794 ALLOCATE (mo_coefficient(ao_num, mo_num))
795 mo_coefficient(:, :) = 0.0_dp
796 ALLOCATE (mo_energy(mo_num))
797 mo_energy(:) = 0.0_dp
798 ALLOCATE (mo_occupation(mo_num))
799 mo_occupation(:) = 0.0_dp
800 ALLOCATE (mo_spin(mo_num))
804 ALLOCATE (mo_coefficient_im(ao_num, mo_num))
805 mo_coefficient_im(:, :) = 0.0_dp
806 ALLOCATE (mo_kpoint(mo_num))
814 CALL get_kpoint_info(kpoints, kp_env=kp_env, nkp=nkp, kp_range=kp_range)
818 nmo = nmo_spin(ispin)
820 imo = (ikp - 1)*nmo + (ispin - 1)*nmo_spin(1)*nkp
823 IF (ikp >= kp_range(1) .AND. ikp <= kp_range(2))
THEN
824 ikp_loc = ikp - kp_range(1) + 1
829 IF (mos_kp(1, ispin)%use_mo_coeff_b)
THEN
830 CALL copy_dbcsr_to_fm(mos_kp(1, ispin)%mo_coeff_b, mos_kp(1, ispin)%mo_coeff)
834 nsgf, nmo, 1, 1, 1, imo + 1, blacs_env)
837 mo_energy(imo + 1:imo + nmo) = mos_kp(1, ispin)%eigenvalues(1:nmo)
840 mo_occupation(imo + 1:imo + nmo) = mos_kp(1, ispin)%occupation_numbers(1:nmo)
843 IF (.NOT. use_real_wfn)
THEN
844 IF (mos_kp(2, ispin)%use_mo_coeff_b)
THEN
845 CALL copy_dbcsr_to_fm(mos_kp(2, ispin)%mo_coeff_b, mos_kp(2, ispin)%mo_coeff)
848 nsgf, nmo, 1, 1, 1, imo + 1, blacs_env)
853 nsgf, nmo, 1, 1, 1, imo + 1, blacs_env)
854 IF (.NOT. use_real_wfn)
THEN
856 nsgf, nmo, 1, 1, 1, imo + 1, blacs_env)
866 CALL para_env_inter_kp%sum(mo_energy)
867 CALL para_env_inter_kp%sum(mo_occupation)
873 nmo = nmo_spin(ispin)
875 ALLOCATE (mos_sgf(nsgf, nmo))
876 mos_sgf(:, :) = 0.0_dp
881 imo = (ikp - 1)*nmo + (ispin - 1)*nmo_spin(1)*nkp
884 mo_kpoint(imo + 1:imo + nmo) = ikp
886 mo_spin(imo + 1:imo + nmo) = ispin - 1
890 IF (save_cartesian)
THEN
891 CALL spherical_to_cartesian_mo(mos_sgf, particle_set, kind_set, mo_coefficient(:, imo + 1:imo + nmo))
895 mo_coefficient(i, imo + 1:imo + nmo) = mos_sgf(cp2k_to_trexio_ang_mom(i), :)
900 IF (.NOT. use_real_wfn)
THEN
902 IF (save_cartesian)
THEN
903 CALL spherical_to_cartesian_mo(mos_sgf, particle_set, kind_set, mo_coefficient_im(:, imo + 1:imo + nmo))
907 mo_coefficient_im(i, imo + 1:imo + nmo) = mos_sgf(cp2k_to_trexio_ang_mom(i), :)
914 imo = (ispin - 1)*nmo_spin(1)
916 mo_energy(imo + 1:imo + nmo) = mos(ispin)%eigenvalues
918 mo_occupation(imo + 1:imo + nmo) = mos(ispin)%occupation_numbers
920 mo_spin(imo + 1:imo + nmo) = ispin - 1
923 IF (mos(ispin)%use_mo_coeff_b)
CALL copy_dbcsr_to_fm(mos(ispin)%mo_coeff_b, mos(ispin)%mo_coeff)
928 IF (save_cartesian)
THEN
929 CALL spherical_to_cartesian_mo(mos_sgf, particle_set, kind_set, mo_coefficient(:, imo + 1:imo + nmo))
933 mo_coefficient(i, imo + 1:imo + nmo) = mos_sgf(cp2k_to_trexio_ang_mom(i), :)
942 rc = trexio_write_mo_type(f,
'Canonical', len_trim(
'Canonical') + 1)
943 CALL trexio_error(rc)
945 rc = trexio_write_mo_num(f, mo_num)
946 CALL trexio_error(rc)
948 rc = trexio_write_mo_coefficient(f, mo_coefficient)
949 CALL trexio_error(rc)
951 rc = trexio_write_mo_energy(f, mo_energy)
952 CALL trexio_error(rc)
954 rc = trexio_write_mo_occupation(f, mo_occupation)
955 CALL trexio_error(rc)
957 rc = trexio_write_mo_spin(f, mo_spin)
958 CALL trexio_error(rc)
961 rc = trexio_write_mo_coefficient_im(f, mo_coefficient_im)
962 CALL trexio_error(rc)
964 rc = trexio_write_mo_k_point(f, mo_kpoint)
965 CALL trexio_error(rc)
969 DEALLOCATE (mo_coefficient)
970 DEALLOCATE (mo_energy)
971 DEALLOCATE (mo_occupation)
974 DEALLOCATE (mo_coefficient_im)
975 DEALLOCATE (mo_kpoint)
988 IF (
PRESENT(energy_derivative))
THEN
989 filename_de = trim(logger%iter_info%project_name)//
'-TREXIO.dEdP.dat'
991 ALLOCATE (dedp(nsgf, nsgf))
999 row_size=row_size, col_size=col_size, &
1000 row_offset=row_offset, col_offset=col_offset)
1005 dedp(row_offset + i - 1, col_offset + j - 1) = data_block(i, j)
1013 CASE (dbcsr_type_symmetric)
1015 CASE (dbcsr_type_antisymmetric)
1017 CASE (dbcsr_type_no_symmetry)
1019 cpabort(
"Unknown matrix type for energy derivative")
1024 CALL para_env%sum(dedp)
1028 WRITE (output_unit,
"((T2,A,A))")
'TREXIO| Writing derivative file ', trim(filename_de)
1032 file_action=
"WRITE", &
1033 file_status=
"UNKNOWN", &
1034 unit_number=unit_de)
1035 WRITE (unit_de,
'(I0, 1X, I0)') nsgf, nsgf
1037 WRITE (unit_de,
'(*(1X, F15.8))') (dedp(cp2k_to_trexio_ang_mom(i), &
1038 cp2k_to_trexio_ang_mom(j)), j=1, nsgf)
1047 IF (
ALLOCATED(shell_ang_mom))
DEALLOCATE (shell_ang_mom)
1048 IF (
ALLOCATED(cp2k_to_trexio_ang_mom))
DEALLOCATE (cp2k_to_trexio_ang_mom)
1054 rc = trexio_close(f)
1055 CALL trexio_error(rc)
1058 CALL timestop(handle)
1061 mark_used(trexio_section)
1062 mark_used(energy_derivative)
1063 cpwarn(
'TREXIO support has not been enabled in this build.')
1075 SUBROUTINE read_trexio(qs_env, trexio_filename, mo_set_trexio, energy_derivative)
1077 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: trexio_filename
1078 TYPE(
mo_set_type),
INTENT(OUT),
DIMENSION(:),
POINTER,
OPTIONAL :: mo_set_trexio
1079 TYPE(
dbcsr_p_type),
INTENT(OUT),
DIMENSION(:),
POINTER,
OPTIONAL :: energy_derivative
1083 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_trexio'
1085 INTEGER :: handle, output_unit, unit_de
1086 CHARACTER(len=default_path_length) :: filename, filename_de
1087 INTEGER(trexio_t) :: f
1088 INTEGER(trexio_exit_code) :: rc
1092 CHARACTER(LEN=2) :: element_symbol
1093 CHARACTER(LEN=2),
DIMENSION(:),
ALLOCATABLE :: label
1095 INTEGER :: ao_num, mo_num, nmo, nspins, ispin, nsgf, &
1096 save_cartesian, i, j, k, l, m, imo, ishell, &
1097 nshell, shell_num, nucleus_num, natoms, ikind, &
1098 iatom, nelectron, nrows, ncols, &
1099 row, col, row_size, col_size, &
1100 row_offset, col_offset, myprint
1101 INTEGER,
DIMENSION(2) :: nmo_spin, electron_num
1102 INTEGER,
DIMENSION(:),
ALLOCATABLE :: mo_spin, shell_ang_mom, trexio_to_cp2k_ang_mom
1104 REAL(kind=
dp) :: zeff, maxocc
1105 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: mo_energy, mo_occupation, charge
1106 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: mo_coefficient, mos_sgf, coord, dedp, temp
1107 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
1110 TYPE(
cp_fm_type),
POINTER :: mo_coeff_ref, mo_coeff_target
1119 CALL timeset(routinen, handle)
1121 NULLIFY (logger, mo_coeff_ref, mo_coeff_target, para_env, dft_control, matrix_s, kind_set, mos, particle_set)
1125 myprint = logger%iter_info%print_level
1127 cpassert(
ASSOCIATED(qs_env))
1130 IF (.NOT.
PRESENT(trexio_filename))
THEN
1131 filename = trim(logger%iter_info%project_name)//
'-TREXIO.h5'
1132 filename_de = trim(logger%iter_info%project_name)//
'-TREXIO.dEdP.dat'
1134 filename = trim(trexio_filename)//
'.h5'
1135 filename_de = trim(trexio_filename)//
'.dEdP.dat'
1139 ionode = para_env%is_source()
1143 WRITE (output_unit,
"((T2,A,A))")
'TREXIO| Opening file named ', trim(filename)
1144 f = trexio_open(filename,
'r', trexio_hdf5, rc)
1145 CALL trexio_error(rc)
1148 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading molecule information...'
1150 rc = trexio_read_nucleus_num(f, nucleus_num)
1151 CALL trexio_error(rc)
1154 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading nuclear coordinates...'
1156 ALLOCATE (coord(3, nucleus_num))
1157 rc = trexio_read_nucleus_coord(f, coord)
1158 CALL trexio_error(rc)
1161 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading nuclear labels...'
1163 ALLOCATE (label(nucleus_num))
1164 rc = trexio_read_nucleus_label(f, label, 3)
1165 CALL trexio_error(rc)
1168 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading nuclear charges...'
1170 ALLOCATE (charge(nucleus_num))
1171 rc = trexio_read_nucleus_charge(f, charge)
1172 CALL trexio_error(rc)
1175 CALL get_qs_env(qs_env, particle_set=particle_set, qs_kind_set=kind_set, natom=natoms)
1178 cpassert(nucleus_num == natoms)
1180 DO iatom = 1, natoms
1183 cpassert(abs(coord(i, iatom) - particle_set(iatom)%r(i)) < 1.0e-6_dp)
1187 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, element_symbol=element_symbol, kind_number=ikind)
1189 cpassert(trim(element_symbol) == trim(label(iatom)))
1194 cpassert(charge(iatom) == zeff)
1197 WRITE (output_unit,
"((T2,A))")
'TREXIO| Molecule is the same as in qs_env'
1204 rc = trexio_read_ao_cartesian(f, save_cartesian)
1205 CALL trexio_error(rc)
1207 rc = trexio_read_ao_num(f, ao_num)
1208 CALL trexio_error(rc)
1210 rc = trexio_read_basis_shell_num(f, shell_num)
1211 CALL trexio_error(rc)
1214 CALL para_env%bcast(save_cartesian, para_env%source)
1215 CALL para_env%bcast(ao_num, para_env%source)
1216 CALL para_env%bcast(shell_num, para_env%source)
1218 IF (save_cartesian == 1)
THEN
1219 cpabort(
'Reading Cartesian AOs is not yet supported.')
1223 CALL get_qs_env(qs_env, qs_kind_set=kind_set)
1225 cpassert(ao_num == nsgf)
1226 cpassert(shell_num == nshell)
1228 ALLOCATE (shell_ang_mom(shell_num))
1229 shell_ang_mom(:) = 0
1233 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading shell angular momenta...'
1235 rc = trexio_read_basis_shell_ang_mom(f, shell_ang_mom)
1236 CALL trexio_error(rc)
1239 CALL para_env%bcast(shell_ang_mom, para_env%source)
1244 ALLOCATE (trexio_to_cp2k_ang_mom(nsgf))
1246 DO ishell = 1, shell_num
1247 l = shell_ang_mom(ishell)
1249 m = (-1)**k*floor(real(k, kind=
dp)/2.0_dp)
1250 trexio_to_cp2k_ang_mom(i + l + 1 + m) = i + k
1257 IF (
PRESENT(mo_set_trexio))
THEN
1258 IF (output_unit > 1)
THEN
1259 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading molecular orbitals...'
1265 rc = trexio_read_mo_num(f, mo_num)
1266 CALL trexio_error(rc)
1268 rc = trexio_read_electron_up_num(f, electron_num(1))
1269 CALL trexio_error(rc)
1271 rc = trexio_read_electron_dn_num(f, electron_num(2))
1272 CALL trexio_error(rc)
1276 CALL para_env%bcast(mo_num, para_env%source)
1277 CALL para_env%bcast(electron_num, para_env%source)
1280 CALL get_qs_env(qs_env, mos=mos, dft_control=dft_control)
1281 nspins = dft_control%nspins
1283 DO ispin = 1, nspins
1285 nmo_spin(ispin) = nmo
1287 cpassert(mo_num == sum(nmo_spin))
1289 ALLOCATE (mo_coefficient(ao_num, mo_num))
1290 ALLOCATE (mo_energy(mo_num))
1291 ALLOCATE (mo_occupation(mo_num))
1292 ALLOCATE (mo_spin(mo_num))
1294 mo_coefficient(:, :) = 0.0_dp
1295 mo_energy(:) = 0.0_dp
1296 mo_occupation(:) = 0.0_dp
1302 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading MO coefficients...'
1304 rc = trexio_read_mo_coefficient(f, mo_coefficient)
1305 CALL trexio_error(rc)
1308 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading MO energies...'
1310 rc = trexio_read_mo_energy(f, mo_energy)
1311 CALL trexio_error(rc)
1314 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading MO occupations...'
1316 rc = trexio_read_mo_occupation(f, mo_occupation)
1317 CALL trexio_error(rc)
1320 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading MO spins...'
1322 rc = trexio_read_mo_spin(f, mo_spin)
1323 CALL trexio_error(rc)
1327 CALL para_env%bcast(mo_coefficient, para_env%source)
1328 CALL para_env%bcast(mo_energy, para_env%source)
1329 CALL para_env%bcast(mo_occupation, para_env%source)
1330 CALL para_env%bcast(mo_spin, para_env%source)
1334 DO ispin = 1, nspins
1336 imo = (ispin - 1)*nmo_spin(1)
1338 nmo = nmo_spin(ispin)
1340 ALLOCATE (mos_sgf(nsgf, nmo))
1341 mos_sgf(:, :) = 0.0_dp
1345 mos_sgf(i, :) = mo_coefficient(trexio_to_cp2k_ang_mom(i), imo + 1:imo + nmo)
1348 IF (nspins == 1)
THEN
1350 nelectron = electron_num(1) + electron_num(2)
1353 nelectron = electron_num(ispin)
1356 CALL allocate_mo_set(mo_set_trexio(ispin), nsgf, nmo, nelectron, 0.0_dp, maxocc, 0.0_dp)
1358 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff_ref)
1359 CALL init_mo_set(mo_set_trexio(ispin), fm_ref=mo_coeff_ref, name=
"TREXIO MOs")
1361 CALL get_mo_set(mo_set_trexio(ispin), mo_coeff=mo_coeff_target)
1364 cpassert(mo_spin(j) == ispin - 1)
1365 mo_set_trexio(ispin)%eigenvalues(j) = mo_energy(imo + j)
1366 mo_set_trexio(ispin)%occupation_numbers(j) = mo_occupation(imo + j)
1372 DEALLOCATE (mos_sgf)
1375 DEALLOCATE (mo_coefficient)
1376 DEALLOCATE (mo_energy)
1377 DEALLOCATE (mo_occupation)
1378 DEALLOCATE (mo_spin)
1383 IF (
PRESENT(energy_derivative))
THEN
1384 IF (output_unit > 1)
THEN
1385 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading energy derivatives...'
1392 ALLOCATE (temp(nsgf, nsgf))
1398 CALL open_file(file_name=filename_de, file_status=
"OLD", unit_number=unit_de)
1400 cpabort(
"Energy derivatives file "//trim(filename_de)//
" not found")
1405 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading header information...'
1407 READ (unit_de, *) nrows, ncols
1409 WRITE (output_unit,
"((T2,A))")
'TREXIO| Check size of dEdP matrix...'
1411 cpassert(nrows == nsgf)
1412 cpassert(ncols == nsgf)
1416 WRITE (output_unit,
"((T2,A))")
'TREXIO| Reading dEdP matrix...'
1420 READ (unit_de, *) (temp(i, j), j=1, ncols)
1427 CALL para_env%bcast(temp, para_env%source)
1430 ALLOCATE (dedp(nsgf, nsgf))
1437 dedp(i, j) = temp(trexio_to_cp2k_ang_mom(i), trexio_to_cp2k_ang_mom(j))
1446 DO ispin = 1, nspins
1447 ALLOCATE (energy_derivative(ispin)%matrix)
1450 CALL dbcsr_copy(energy_derivative(ispin)%matrix, matrix_s(1)%matrix, &
1451 name=
'Energy Derivative', keep_sparsity=.false.)
1452 CALL dbcsr_set(energy_derivative(ispin)%matrix, 0.0_dp)
1457 row_size=row_size, col_size=col_size, &
1458 row_offset=row_offset, col_offset=col_offset)
1463 data_block(i, j) = dedp(row_offset + i - 1, col_offset + j - 1)
1474 IF (
ALLOCATED(shell_ang_mom))
DEALLOCATE (shell_ang_mom)
1475 IF (
ALLOCATED(trexio_to_cp2k_ang_mom))
DEALLOCATE (trexio_to_cp2k_ang_mom)
1479 WRITE (output_unit,
"((T2,A,A))")
'TREXIO| Closing file named ', trim(filename)
1480 rc = trexio_close(f)
1481 CALL trexio_error(rc)
1484 CALL timestop(handle)
1488 mark_used(trexio_filename)
1489 mark_used(mo_set_trexio)
1490 mark_used(energy_derivative)
1491 cpwarn(
'TREXIO support has not been enabled in this build.')
1492 cpabort(
'TREXIO Not Available')
1502 SUBROUTINE trexio_error(rc)
1503 INTEGER(trexio_exit_code),
INTENT(IN) :: rc
1505 CHARACTER(LEN=128) :: err_msg
1507 IF (rc /= trexio_success)
THEN
1508 CALL trexio_string_of_error(rc, err_msg)
1509 cpabort(
'TREXIO Error: '//trim(err_msg))
1512 END SUBROUTINE trexio_error
1520 SUBROUTINE nuclear_repulsion_energy(particle_set, kind_set, e_nn)
1522 POINTER :: particle_set
1525 REAL(kind=
dp),
INTENT(OUT) :: e_nn
1527 INTEGER :: i, ikind, j, jkind, natoms
1528 REAL(kind=
dp) :: r_ij, zeff_i, zeff_j
1530 natoms =
SIZE(particle_set)
1535 DO j = i + 1, natoms
1536 r_ij = norm2(particle_set(i)%r - particle_set(j)%r)
1541 e_nn = e_nn + zeff_i*zeff_j/r_ij
1545 END SUBROUTINE nuclear_repulsion_energy
1553 FUNCTION sgf_norm(l, expnt)
RESULT(norm)
1554 INTEGER,
INTENT(IN) :: l
1555 REAL(kind=
dp),
INTENT(IN) :: expnt
1556 REAL(kind=
dp) :: norm
1559 norm = sqrt(2**(2*l + 3)*
fac(l + 1)*(2*expnt)**(l + 1.5)/(
fac(2*l + 2)*sqrt(
pi)))
1561 cpabort(
"The angular momentum should be >= 0!")
1564 END FUNCTION sgf_norm
1573 SUBROUTINE spherical_to_cartesian_mo(mos_sgf, particle_set, qs_kind_set, mos_cgf)
1574 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: mos_sgf
1576 POINTER :: particle_set
1578 POINTER :: qs_kind_set
1579 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: mos_cgf
1581 INTEGER :: iatom, icgf, ikind, iset, isgf, ishell, &
1582 lshell, ncgf, nmo, nset, nsgf
1583 INTEGER,
DIMENSION(:),
POINTER :: nshell
1584 INTEGER,
DIMENSION(:, :),
POINTER :: l
1589 mos_cgf(:, :) = 0.0_dp
1590 nmo =
SIZE(mos_sgf, 2)
1595 DO iatom = 1,
SIZE(particle_set)
1596 NULLIFY (orb_basis_set)
1597 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
1598 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1600 IF (
ASSOCIATED(orb_basis_set))
THEN
1606 DO ishell = 1, nshell(iset)
1607 lshell = l(ishell, iset)
1608 CALL dgemm(
"T",
"N",
nco(lshell), nmo,
nso(lshell), 1.0_dp, &
1610 mos_sgf(isgf, 1), nsgf, 0.0_dp, &
1611 mos_cgf(icgf, 1), ncgf)
1612 icgf = icgf +
nco(lshell)
1613 isgf = isgf +
nso(lshell)
1618 cpabort(
"Unknown basis set type")
1622 END SUBROUTINE spherical_to_cartesian_mo
1631 SUBROUTINE cartesian_to_spherical_mo(mos_cgf, particle_set, qs_kind_set, mos_sgf)
1632 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: mos_cgf
1634 POINTER :: particle_set
1636 POINTER :: qs_kind_set
1637 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: mos_sgf
1639 INTEGER :: iatom, icgf, ikind, iset, isgf, ishell, &
1640 lshell, ncgf, nmo, nset, nsgf
1641 INTEGER,
DIMENSION(:),
POINTER :: nshell
1642 INTEGER,
DIMENSION(:, :),
POINTER :: l
1647 mos_sgf(:, :) = 0.0_dp
1648 nmo =
SIZE(mos_cgf, 2)
1653 DO iatom = 1,
SIZE(particle_set)
1654 NULLIFY (orb_basis_set)
1655 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
1656 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1658 IF (
ASSOCIATED(orb_basis_set))
THEN
1664 DO ishell = 1, nshell(iset)
1665 lshell = l(ishell, iset)
1666 CALL dgemm(
"N",
"N",
nso(lshell), nmo,
nco(lshell), 1.0_dp, &
1668 mos_cgf(icgf, 1), ncgf, 0.0_dp, &
1669 mos_sgf(isgf, 1), nsgf)
1670 icgf = icgf +
nco(lshell)
1671 isgf = isgf +
nso(lshell)
1676 cpabort(
"Unknown basis set type")
1680 END SUBROUTINE cartesian_to_spherical_mo
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
subroutine, public sg_overlap(smat, l, pa, pb)
...
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.
some minimal info about CP2K, including its version and license
character(len= *), parameter, public cp2k_version
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
character function, public dbcsr_get_matrix_type(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_write_sparse_matrix(sparse_matrix, before, after, qs_env, para_env, first_row, last_row, first_col, last_col, scale, output_unit, omit_headers)
...
Utility routines to open and close files. Tracking of preconnections.
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.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_to_fm_submat_general(source, destination, nrows, ncols, s_firstrow, s_firstcol, d_firstrow, d_firstcol, global_context)
General copy of a submatrix of fm matrix to a submatrix of another fm matrix. The two matrices can ha...
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
subroutine, public cp_fm_set_element(matrix, irow_global, icol_global, alpha)
sets an element of a matrix
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public medium_print_level
Definition of the atomic potential types.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_env(kpoint_env, nkpoint, wkp, xkp, is_local, mos)
Get information from a single kpoint environment.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public fourpi
real(kind=dp), dimension(0:maxfac), parameter, public fac
Collection of simple mathematical functions and subroutines.
subroutine, public symmetrize_matrix(a, option)
Symmetrize the matrix a.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public nso
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, 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, 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, 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, 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, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Definition and initialisation of the mo data type.
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
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.
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
The module to read/write TREX IO files for interfacing CP2K with other programs.
subroutine, public write_trexio(qs_env, trexio_section, energy_derivative)
Write a trexio file.
subroutine, public read_trexio(qs_env, trexio_filename, mo_set_trexio, energy_derivative)
Read a trexio file.
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.