16 USE iso_fortran_env,
ONLY: file_storage_size
45 dbt_contract, dbt_copy, dbt_copy_matrix_to_tensor, dbt_create, dbt_destroy, dbt_get_block, &
46 dbt_get_info, dbt_iterator_blocks_left, dbt_iterator_next_block, dbt_iterator_start, &
47 dbt_iterator_stop, dbt_iterator_type, dbt_nblks_total, dbt_pgrid_create, &
48 dbt_pgrid_destroy, dbt_pgrid_type, dbt_type
50 USE ieee_arithmetic,
ONLY: ieee_is_finite
74#include "./base/base_uses.f90"
79 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cc4s_export'
82 INTEGER(int_8),
PARAMETER :: output_count_limit = int(huge(0),
int_8)/
dp_size
83 INTEGER(int_8),
PARAMETER :: backend_data_limit = output_count_limit/2
85 INTEGER(int_8),
PARAMETER :: backend_block_limit = int(huge(0),
int_8)/64
86 REAL(dp),
PARAMETER :: elements_per_mib = 1024.0_dp**2/real(
dp_size, dp)
97 LOGICAL,
INTENT(IN) :: converged
99 CHARACTER(len=*),
PARAMETER :: routinen =
'write_cc4s'
100 REAL(dp),
PARAMETER :: hf_fraction_tolerance = 1.0e-14_dp
102 CHARACTER(len=8) :: method
103 CHARACTER(len=default_path_length) :: filename
104 INTEGER :: frozen, functional, handle, homo, max_iter, method_id, nao, nmo, nri, nstored, &
105 output_unit, poisson_periodic, stage_handle
106 INTEGER(KIND=int_8) :: buffer_elements, total_elements
107 INTEGER,
DIMENSION(2) :: dims2
108 INTEGER,
DIMENSION(3) :: dims3
109 LOGICAL :: admm_section_present, do_kpoints, &
111 REAL(dp) :: amp_conv, cutoff_radius, energy_conv, export_start, fermi_energy, max_cutoff, &
112 max_memory_mb, memory_mb, output_buffer_mib, vertex_norm, write_start
113 REAL(dp),
ALLOCATABLE :: eigenvalues(:)
114 REAL(dp),
DIMENSION(5) :: elapsed
117 TYPE(
cp_fm_type) :: fm_active, fm_coeff, fm_fock, &
121 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
123 TYPE(dbt_type) :: coefficients
125 TYPE(
hfx_type),
DIMENSION(:, :),
POINTER :: x_data
135 IF (.NOT. enabled)
RETURN
136 IF (.NOT. qs_env%single_point_run)
THEN
137 CALL cp_abort(__location__,
"CC4S: export requires a single-point RUN_TYPE ENERGY or ENERGY_FORCE")
141 IF (filename(1:1) ==
'=' .OR. filename ==
'__STD_OUT__')
THEN
142 CALL cp_abort(__location__, &
143 "CC4S: FILENAME must be a file prefix, not an exact name (=name) or __STD_OUT__")
145 CALL timeset(routinen, handle)
157 IF (.NOT. ieee_is_finite(output_buffer_mib))
THEN
158 cpabort(
"CC4S: OUTPUT_BUFFER_SIZE must be finite")
160 IF (output_buffer_mib < 1.0_dp/elements_per_mib .OR. &
161 output_buffer_mib > real(huge(1), dp)/elements_per_mib)
THEN
162 CALL cp_abort(__location__, &
163 "CC4S: OUTPUT_BUFFER_SIZE must hold at least one Real64 value and fit the MPI integer count")
165 buffer_elements = floor(output_buffer_mib*elements_per_mib, kind=
int_8)
166 SELECT CASE (method_id)
174 cpabort(
"CC4S: unsupported method")
176 IF (.NOT. ieee_is_finite(max_memory_mb)) cpabort(
"CC4S: MAX_MEMORY must be finite")
177 IF (max_iter < 1 .OR. energy_conv <= 0.0_dp .OR. amp_conv <= 0.0_dp .OR. max_memory_mb <= 0.0_dp)
THEN
178 CALL cp_abort(__location__, &
179 "CC4S: iteration, convergence and memory limits must be positive")
181 CALL get_qs_env(qs_env, x_data=x_data, mos=mos, para_env=para_env, dft_control=dft_control, &
182 cell=cell, do_kpoints=do_kpoints, scf_control=scf_control, &
183 matrix_ks=matrix_ks, matrix_s=matrix_s)
184 IF (dft_control%qs_control%cdft)
THEN
185 cpabort(
"CC4S: constrained DFT is unsupported")
187 IF (.NOT. converged)
THEN
188 cpabort(
"CC4S: export requires a converged SCF")
192 cpabort(
"CC4S: k-point sampling is unsupported")
194 periodic = all(cell%perd == 1) .AND. poisson_periodic ==
use_perd_xyz
195 IF (.NOT. periodic .AND. &
196 (any(cell%perd /= 0) .OR. poisson_periodic /=
use_perd_none))
THEN
197 CALL cp_abort(__location__, &
198 "CC4S: CELL and POISSON must both use PERIODIC NONE or both PERIODIC XYZ")
200 IF (periodic .AND. dft_control%charge /= 0)
THEN
201 cpabort(
"CC4S: periodic cells must be neutral")
203 IF (dft_control%nspins /= 1 .OR. dft_control%uks .OR. dft_control%roks .OR. dft_control%smear)
THEN
204 CALL cp_abort(__location__, &
205 "CC4S: a restricted closed-shell reference without smearing is required")
209 IF (admm_section_present)
THEN
210 cpabort(
"CC4S: AUXILIARY_DENSITY_MATRIX_METHOD is unsupported")
212 IF (dft_control%dft_plus_u .OR. dft_control%sic_method_id /=
sic_none)
THEN
213 cpabort(
"CC4S: DFT+U and self-interaction corrections are unsupported")
216 IF (functional /=
xc_none)
THEN
217 CALL cp_abort(__location__, &
218 "CC4S: canonical HF orbitals required; use XC_FUNCTIONAL NONE")
220 IF (.NOT.
ASSOCIATED(x_data))
THEN
221 cpabort(
"CC4S: enable HF with RI_FLAVOR MO")
223 IF (
SIZE(x_data, 1) /= 1)
THEN
224 CALL cp_abort(__location__, &
225 "CC4S: exactly one HF section is allowed")
227 IF (abs(x_data(1, 1)%general_parameter%fraction - 1.0_dp) > hf_fraction_tolerance)
THEN
228 cpabort(
"CC4S: HF FRACTION must be 1")
230 IF (.NOT. x_data(1, 1)%do_hfx_ri)
THEN
231 cpabort(
"CC4S: enable HF/RI with RI_FLAVOR MO")
233 IF (.NOT.
ASSOCIATED(x_data(1, 1)%ri_data))
THEN
234 cpabort(
"CC4S: RI-HFX data are unavailable")
236 IF (x_data(1, 1)%ri_data%flavor /=
ri_mo)
THEN
237 cpabort(
"CC4S: HF/RI requires RI_FLAVOR MO")
239 cutoff_radius = 0.0_dp
241 IF (.NOT. x_data(1, 1)%ri_data%same_op .OR. &
243 CALL cp_abort(__location__, &
244 "CC4S: periodic export requires TRUNCATED HF interaction and the same RI metric; use RI_METRIC HFX")
246 cutoff_radius = x_data(1, 1)%ri_data%hfx_pot%cutoff_radius
249 IF (cutoff_radius <= 0.0_dp .OR. cutoff_radius >= max_cutoff)
THEN
250 CALL cp_abort(__location__, &
251 "CC4S: positive HF CUTOFF_RADIUS must be smaller than half the minimal cell plane spacing")
254 IF (.NOT. x_data(1, 1)%ri_data%same_op .OR. &
256 CALL cp_abort(__location__, &
257 "CC4S: molecular HF interaction and RI metric must both be COULOMB")
261 CALL get_mo_set(mos(1), mo_coeff=mo_coeff, homo=homo, nmo=nstored, nao=nao)
262 IF (homo < 1 .OR. homo > nstored)
THEN
263 cpabort(
"CC4S: no occupied orbitals")
267 CALL cp_abort(__location__, &
268 "CC4S: occupations must be 2 below the HOMO and 0 above")
270 IF (frozen < 0 .OR. frozen >= homo)
THEN
271 CALL cp_abort(__location__, &
272 "CC4S: N_FROZEN_CORE must leave at least one occupied orbital")
274 CALL dbt_get_info(x_data(1, 1)%ri_data%t_3c_int_ctr_1(1, 1), nfull_total=dims3)
276 cpassert(dims3(1) == nao .AND. dims3(3) == nao .AND. nri > 0)
278 IF (limited_product([int(nao,
int_8), int(nao,
int_8)], backend_data_limit) > backend_data_limit)
THEN
279 cpabort(
"CC4S: canonical matrices exceed backend count limits")
281 IF (limited_product([int(nri,
int_8), int(nri,
int_8)], backend_data_limit) > backend_data_limit)
THEN
282 cpabort(
"CC4S: RI metric exceeds backend count limits")
285 memory_mb = real(
dp_size, dp)*6.0_dp*real(nao, dp)**2/1.0e6_dp
286 IF (memory_mb > max_memory_mb)
THEN
287 cpabort(
"CC4S: canonicalization exceeds MAX_MEMORY [MB]")
295 template_fmstruct=mo_coeff%matrix_struct)
303 ALLOCATE (eigenvalues(nao))
305 scf_control%eps_eigval, nmo_retained=nmo)
306 IF (nmo <= homo)
THEN
307 CALL cp_abort(__location__, &
308 "CC4S: no virtual orbitals after removing overlap null modes")
310 IF (eigenvalues(homo + 1) <= eigenvalues(homo))
THEN
311 CALL cp_abort(__location__, &
312 "CC4S: a positive HOMO-LUMO gap is required")
314 fermi_energy = 0.5_dp*(eigenvalues(homo) + eigenvalues(homo + 1))
316 total_elements = vertex_size(nri, nmo)
317 buffer_elements = min(buffer_elements, total_elements, output_count_limit)
320 IF (limited_product([int(nao,
int_8), int(nmo,
int_8)], backend_block_limit) > backend_block_limit)
THEN
321 cpabort(
"CC4S: coefficients exceed backend count limits")
323 IF (output_unit > 0)
THEN
324 WRITE (output_unit,
'(/,T3,A)')
"CC4S| Reference export"
325 WRITE (output_unit,
'(T3,A,T60,A21)')
"CC4S| Reference:",
"Restricted RI-HF"
327 WRITE (output_unit,
'(T3,A,T60,A21)')
"CC4S| Boundary conditions:",
"Periodic Gamma"
328 WRITE (output_unit,
'(T3,A,T60,A21)')
"CC4S| Coulomb interaction:",
"TRUNCATED"
329 WRITE (output_unit,
'(T3,A,T69,F12.6)')
"CC4S| Coulomb cutoff radius [bohr]:", cutoff_radius
331 WRITE (output_unit,
'(T3,A,T60,A21)')
"CC4S| Boundary conditions:",
"Isolated"
332 WRITE (output_unit,
'(T3,A,T60,A21)')
"CC4S| Coulomb interaction:",
"COULOMB"
334 WRITE (output_unit,
'(T3,A)')
"CC4S|"
335 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of auxiliary basis functions:", nri
336 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of exported orbitals:", nmo
337 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of exported occupied orbitals:", homo - frozen
338 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of exported virtual orbitals:", nmo - homo + frozen
339 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of frozen occupied orbitals:", frozen
340 WRITE (output_unit,
'(T3,A,T63,F18.6)') &
341 "CC4S| Expected Coulomb vertex size [MiB]:", real(total_elements, dp)/elements_per_mib
342 WRITE (output_unit,
'(T3,A)')
"CC4S|"
343 WRITE (output_unit,
'(T3,A,T69,F12.6)') &
344 "CC4S| Actual output buffer size per MPI rank [MiB]:", real(buffer_elements, dp)/elements_per_mib
346 CALL cp_fm_struct_create(fm_struct, nrow_global=nao, ncol_global=nmo, template_fmstruct=mo_coeff%matrix_struct)
347 CALL cp_fm_create(fm_active, fm_struct, name=
"CC4S active orbitals")
349 CALL cp_fm_to_fm(fm_coeff, fm_active, ncol=nmo, source_start=frozen + 1)
351 CALL dbt_create(coefficient_matrix, coefficients, name=
"CC4S coefficients")
352 CALL dbt_copy_matrix_to_tensor(coefficient_matrix, coefficients)
360 CALL dbt_get_info(x_data(1, 1)%ri_data%t_2c_int(1, 1), nfull_total=dims2)
361 cpassert(all(dims2 == nri))
363 CALL export_vertex_batches(x_data(1, 1)%ri_data%t_3c_int_ctr_1(1, 1), &
364 x_data(1, 1)%ri_data%t_2c_int(1, 1), coefficients, para_env, &
365 logger, print_section, nmo, max_memory_mb, buffer_elements, &
366 periodic, cutoff_radius, cell%hmat, output_unit, vertex_norm, elapsed, &
367 homo - frozen, eigenvalues(frozen + 1:frozen + nmo), fermi_energy)
368 CALL dbt_destroy(coefficients)
369 CALL timeset(
"cc4s_write_files", stage_handle)
371 IF (para_env%is_source())
THEN
372 CALL write_cc4s_in(logger, print_section, method, homo - frozen, max_iter, energy_conv, amp_conv)
374 elapsed(5) = elapsed(5) +
m_walltime() - write_start
375 CALL timestop(stage_handle)
376 IF (para_env%is_source())
THEN
377 IF (output_unit > 0)
THEN
378 WRITE (output_unit,
'(/,T3,A)')
"CC4S| Export completed"
379 WRITE (output_unit,
'(T3,A,T56,ES25.16)')
"CC4S| Vertex norm squared [Ha]:", vertex_norm
380 WRITE (output_unit,
'(T3,A,T56,ES25.16)') &
381 "CC4S| Sum of exported orbital energies [Ha]:", sum(eigenvalues(frozen + 1:frozen + nmo))
382 WRITE (output_unit,
'(T3,A)')
"CC4S|"
384 WRITE (output_unit,
'(T3,A,T41,A)')
"CC4S| Orbital energies metadata:", &
385 adjustr(filename(:max(40, len_trim(filename))))
387 WRITE (output_unit,
'(T3,A,T41,A)')
"CC4S| Orbital energies data:", &
388 adjustr(filename(:max(40, len_trim(filename))))
390 WRITE (output_unit,
'(T3,A,T41,A)')
"CC4S| Coulomb vertex metadata:", &
391 adjustr(filename(:max(40, len_trim(filename))))
393 WRITE (output_unit,
'(T3,A,T41,A)')
"CC4S| Coulomb vertex file:", &
394 adjustr(filename(:max(40, len_trim(filename))))
395 CALL print_vertex_file_size(output_unit, filename)
398 DEALLOCATE (eigenvalues)
402 CALL para_env%max(elapsed)
403 IF (output_unit > 0)
THEN
404 WRITE (output_unit,
'(T3,A,T69,F12.3)')
"CC4S| Total export time [s]:", elapsed(1)
405 WRITE (output_unit,
'(T3,A,T69,F12.3)')
"CC4S| Orbital transformation time [s]:", elapsed(2)
406 WRITE (output_unit,
'(T3,A,T69,F12.3)')
"CC4S| Metric contraction time [s]:", elapsed(3)
407 WRITE (output_unit,
'(T3,A,T69,F12.3)')
"CC4S| Output gathering time [s]:", elapsed(4)
408 WRITE (output_unit,
'(T3,A,T69,F12.3)')
"CC4S| File writing time [s]:", elapsed(5)
410 IF (para_env%is_source())
THEN
411 IF (output_unit > 0)
THEN
412 WRITE (output_unit,
'(/,T3,A)')
"CC4S| Generated CC4S input"
414 WRITE (output_unit,
'(T3,A,T41,A)')
"CC4S| Generated input file:", &
415 adjustr(filename(:max(40, len_trim(filename))))
416 IF (method ==
'CCSD_T')
THEN
417 WRITE (output_unit,
'(T3,A,T73,A8)')
"CC4S| Requested method:",
'CCSD(T)'
419 WRITE (output_unit,
'(T3,A,T73,A8)')
"CC4S| Requested method:", trim(method)
421 IF (method /=
'MP2')
THEN
422 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Maximum CCSD iterations:", max_iter
423 WRITE (output_unit,
'(T3,A,T73,ES8.1)')
"CC4S| CCSD energy convergence [Ha]:", energy_conv
424 WRITE (output_unit,
'(T3,A,T73,ES8.1)')
"CC4S| CCSD amplitudes convergence:", amp_conv
428 CALL timestop(handle)
436 SUBROUTINE print_vertex_file_size(output_unit, filename)
437 INTEGER,
INTENT(IN) :: output_unit
438 CHARACTER(len=*),
INTENT(IN) :: filename
441 INTEGER(int_8) :: file_size
446 INQUIRE (file=trim(filename), size=file_size, iostat=io_status)
447 IF (io_status == 0)
THEN
448 IF (file_size >= 0_int_8)
THEN
449 size_mib = real(file_size, dp)*real(file_storage_size, dp)/(8.0_dp*1024.0_dp**2)
452 IF (size_mib >= 0.0_dp)
THEN
453 WRITE (output_unit,
'(T3,A,T63,F18.6)')
"CC4S| Written Coulomb vertex size [MiB]:", size_mib
455 WRITE (output_unit,
'(T3,A,T63,A18)')
"CC4S| Written Coulomb vertex size [MiB]:",
"unavailable"
457 END SUBROUTINE print_vertex_file_size
480 SUBROUTINE export_vertex_batches(integrals, metric, coefficients, para_env, logger, print_section, &
481 nmo, max_memory_mb, buffer_elements, periodic, cutoff_radius, hmat, &
482 output_unit, vertex_norm, elapsed, homo, eigenvalues, fermi_energy)
483 TYPE(dbt_type),
INTENT(INOUT) :: integrals, metric, coefficients
487 INTEGER,
INTENT(IN) :: nmo
488 REAL(dp),
INTENT(IN) :: max_memory_mb
489 INTEGER(KIND=int_8),
INTENT(IN) :: buffer_elements
490 LOGICAL,
INTENT(IN) :: periodic
491 REAL(dp),
INTENT(IN) :: cutoff_radius, hmat(3, 3)
492 INTEGER,
INTENT(IN) :: output_unit
493 REAL(dp),
INTENT(OUT) :: vertex_norm
494 REAL(dp),
INTENT(INOUT) :: elapsed(5)
495 INTEGER,
INTENT(IN) :: homo
496 REAL(dp),
INTENT(IN) :: eigenvalues(nmo), fermi_energy
498 INTEGER :: block_width, bounds2(2, 2), bounds3(2, 3), handle, im, ir, iunit, mb, &
499 metric_blocks(2), mfirst, mlast, nao, nri, pdims(3), pdims2(2), rb, rfirst, rlast
500 INTEGER,
ALLOCATABLE :: ao(:), d1(:), d2(:), d3(:), mo(:), ri(:)
501 REAL(dp) :: memory_mb, pressure, start, trial_m, &
503 REAL(dp),
ALLOCATABLE :: values(:)
504 TYPE(dbt_pgrid_type) :: grid, grid2
505 TYPE(dbt_type) :: ao_triangle, coeff, coeff_batch,
gamma, &
506 half, metric_copy, triangle
508 ALLOCATE (ao(dbt_nblks_total(integrals, 1)), ri(dbt_nblks_total(integrals, 2)))
509 CALL dbt_get_info(integrals, blk_size_1=ao, blk_size_2=ri)
514 DO WHILE (limited_product([int(nri,
int_8), int(nmo,
int_8), int(block_width,
int_8)], &
515 backend_data_limit) > backend_data_limit .AND. block_width > 1)
516 block_width = block_width/2
518 ALLOCATE (mo(1 + (nmo - 1)/block_width))
520 mo(
SIZE(mo)) = nmo - (
SIZE(mo) - 1)*block_width
521 CALL dbt_get_info(metric, nblks_total=metric_blocks)
523 IF (limited_product([int(para_env%num_pe,
int_8), int(metric_blocks(1),
int_8) +
SIZE(ri, kind=
int_8), &
524 int(metric_blocks(2),
int_8) +
SIZE(ri, kind=
int_8)], &
525 backend_block_limit) > backend_block_limit)
THEN
526 cpabort(
"CC4S: RI metric metadata exceeds backend limits")
532 pressure = batch_pressure(ao, ri, mo, mb, rb, para_env%num_pe, buffer_elements, max_memory_mb)
533 DO WHILE (pressure > 1.0_dp .AND. (mb > 1 .OR. rb > 1))
534 trial_m = huge(0.0_dp)
535 trial_r = huge(0.0_dp)
536 IF (mb > 1) trial_m = batch_pressure(ao, ri, mo, mb/2 +
modulo(mb, 2), rb, para_env%num_pe, &
537 buffer_elements, max_memory_mb)
538 IF (rb > 1) trial_r = batch_pressure(ao, ri, mo, mb, rb/2 +
modulo(rb, 2), para_env%num_pe, &
539 buffer_elements, max_memory_mb)
540 IF (trial_m <= trial_r)
THEN
545 pressure = min(trial_m, trial_r)
547 memory_mb = batch_workspace(nao, nri, nmo, mo, ri, mb, rb, buffer_elements)
548 IF (.NOT. batch_counts_fit(ao, ri, mo, mb, rb, para_env%num_pe))
THEN
549 cpabort(
"CC4S: minimum batch exceeds backend count limits")
551 IF (output_unit > 0)
THEN
552 WRITE (output_unit,
'(T3,A,T69,F12.3)') &
553 "CC4S| Estimated export workspace per MPI rank [MB]:", memory_mb
554 WRITE (output_unit,
'(T3,A,T69,F12.3)') &
555 "CC4S| Export workspace budget per MPI rank [MB]:", max_memory_mb
557 IF (memory_mb > max_memory_mb)
THEN
558 CALL cp_abort(__location__, &
559 "CC4S: minimum transformation batch exceeds MAX_MEMORY; increase the limit or reduce OUTPUT_BUFFER_SIZE")
561 IF (output_unit > 0)
THEN
562 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Maximum orbitals per transformation batch:", batch_width(mo, mb)
563 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Maximum auxiliary functions per batch:", batch_width(ri, rb)
564 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of orbital batches:", 1 + (
SIZE(mo) - 1)/mb
565 WRITE (output_unit,
'(T3,A,T69,I12)')
"CC4S| Number of auxiliary batches:", 1 + (
SIZE(ri) - 1)/rb
569 CALL dbt_pgrid_create(para_env, pdims, grid, tensor_dims=[
SIZE(mo),
SIZE(ri),
SIZE(ao)])
570 CALL dbt_pgrid_create(para_env, pdims2, grid2, tensor_dims=[
SIZE(ao),
SIZE(mo)])
571 CALL create_2c_tensor(coeff, d1, d2, grid2, ao, mo, name=
"CC4S active coefficients")
573 CALL dbt_copy(coefficients, coeff)
575 CALL create_2c_tensor(metric_copy, d1, d2, grid2, ri, ri, name=
"CC4S inverse metric")
577 CALL dbt_copy(metric, metric_copy)
578 ALLOCATE (values(buffer_elements))
582 IF (para_env%is_source())
THEN
583 CALL write_eigen_energies_files(logger, print_section, nmo, homo, eigenvalues, fermi_energy)
584 CALL open_coulomb_vertex_file(logger, print_section, nri, nmo, periodic, cutoff_radius, hmat, iunit)
586 elapsed(5) = elapsed(5) +
m_walltime() - start
587 DO im = 1,
SIZE(mo), mb
588 CALL dbt_create(coeff, coeff_batch, name=
"CC4S coefficient batch")
589 CALL create_3c_tensor(
gamma, d1, d2, d3, grid, ri, mo, mo, [1, 2], [3], &
590 name=
"CC4S Coulomb vertex batch")
591 DEALLOCATE (d1, d2, d3)
592 mfirst = sum(mo(:im - 1)) + 1
593 mlast = sum(mo(:im + min(mb - 1,
SIZE(mo) - im)))
594 bounds2(:, 1) = [1, nao]
595 bounds2(:, 2) = [mfirst, mlast]
596 CALL dbt_copy(coeff, coeff_batch, bounds=bounds2)
597 DO ir = 1,
SIZE(ri), rb
598 rfirst = sum(ri(:ir - 1)) + 1
599 rlast = sum(ri(:ir + min(rb - 1,
SIZE(ri) - ir)))
601 CALL timeset(
"cc4s_transform", handle)
602 bounds3(:, 1) = [1, nao]
603 bounds3(:, 2) = [rfirst, rlast]
604 bounds3(:, 3) = [1, nao]
605 CALL dbt_create(integrals, ao_triangle)
606 CALL create_3c_tensor(half, d1, d2, d3, grid, mo, ri, ao, [1], [2, 3], &
607 name=
"CC4S half transform")
608 DEALLOCATE (d1, d2, d3)
610 CALL dbt_copy(integrals, ao_triangle, bounds=bounds3)
611 CALL dbt_contract(1.0_dp, coeff_batch, ao_triangle, 0.0_dp, half, &
612 contract_1=[1], notcontract_1=[2], contract_2=[1], notcontract_2=[2, 3], &
613 map_1=[1], map_2=[2, 3], filter_eps=0.0_dp)
616 CALL dbt_contract(1.0_dp, coeff_batch, ao_triangle, 1.0_dp, half, &
617 contract_1=[1], notcontract_1=[2], contract_2=[3], notcontract_2=[2, 1], &
618 map_1=[1], map_2=[2, 3], filter_eps=0.0_dp)
619 CALL dbt_destroy(ao_triangle)
620 CALL create_3c_tensor(triangle, d1, d2, d3, grid, ri, mo, mo, [1, 2], [3], &
621 name=
"CC4S MO batch")
622 DEALLOCATE (d1, d2, d3)
623 CALL dbt_contract(1.0_dp, half, coeff, 0.0_dp, triangle, &
624 contract_1=[3], notcontract_1=[1, 2], contract_2=[1], notcontract_2=[2], &
625 map_1=[3, 1], map_2=[2], filter_eps=0.0_dp)
626 CALL dbt_destroy(half)
627 CALL timestop(handle)
628 elapsed(2) = elapsed(2) +
m_walltime() - start
630 CALL timeset(
"cc4s_metric", handle)
631 CALL dbt_contract(1.0_dp, metric_copy, triangle, 1.0_dp,
gamma, &
632 contract_1=[1], notcontract_1=[2], contract_2=[1], notcontract_2=[2, 3], &
633 map_1=[1], map_2=[2, 3], filter_eps=0.0_dp)
634 CALL dbt_destroy(triangle)
635 CALL timestop(handle)
636 elapsed(3) = elapsed(3) +
m_walltime() - start
638 CALL write_coulomb_vertex_batch(para_env, nri, nmo,
gamma, iunit, mfirst, mlast, values, vertex_norm, elapsed)
639 CALL dbt_destroy(
gamma)
640 CALL dbt_destroy(coeff_batch)
644 elapsed(5) = elapsed(5) +
m_walltime() - start
646 CALL dbt_destroy(metric_copy)
647 CALL dbt_destroy(coeff)
648 CALL dbt_pgrid_destroy(grid)
649 CALL dbt_pgrid_destroy(grid2)
650 DEALLOCATE (ao, ri, mo)
651 END SUBROUTINE export_vertex_batches
659 PURE FUNCTION limited_product(factors, limit)
RESULT(value)
660 INTEGER(int_8),
INTENT(IN) :: factors(:), limit
661 INTEGER(int_8) :: value
666 DO i = 1,
SIZE(factors)
667 IF (factors(i) == 0_int_8)
THEN
672 DO i = 1,
SIZE(factors)
673 IF (
value > limit/factors(i))
THEN
674 value = limit + 1_int_8
677 value =
value*factors(i)
679 END FUNCTION limited_product
687 FUNCTION vertex_size(nri, nmo)
RESULT(elements)
688 INTEGER,
INTENT(IN) :: nri, nmo
689 INTEGER(int_8) :: elements
691 INTEGER(int_8),
PARAMETER :: file_limit = huge(0_int_8)/
dp_size
693 cpassert(nri > 0 .AND. nmo > 0)
694 elements = limited_product([int(nri,
int_8), int(nmo,
int_8), int(nmo,
int_8)], file_limit)
695 IF (elements > file_limit) cpabort(
"CC4S: vertex exceeds stream position range")
696 END FUNCTION vertex_size
707 PURE SUBROUTINE segment_overlap(start, length, offset, count, lo, hi)
708 INTEGER(int_8),
INTENT(IN) :: start
709 INTEGER,
INTENT(IN) :: length
710 INTEGER(int_8),
INTENT(IN) :: offset, count
711 INTEGER,
INTENT(OUT) :: lo, hi
713 INTEGER(int_8) :: first, last
715 first = max(start, offset)
716 last = min(start + int(length,
int_8), offset + count)
719 IF (first >= last)
RETURN
720 lo = int(first - start) + 1
721 hi = int(last - start)
722 END SUBROUTINE segment_overlap
735 FUNCTION batch_counts_fit(ao, ri, mo, mb, rb, nranks, pressure)
RESULT(fits)
736 INTEGER,
INTENT(IN) :: ao(:), ri(:), mo(:), mb, rb, nranks
737 REAL(dp),
INTENT(OUT),
OPTIONAL :: pressure
740 INTEGER(int_8),
PARAMETER :: product_limit = huge(0_int_8)/
dp_size
742 INTEGER(int_8) :: a, b, block_count, data_count, m, na, &
745 a = sum(int(ao,
int_8))
746 r = sum(int(ri,
int_8))
747 m = sum(int(mo,
int_8))
748 b = int(batch_width(mo, mb),
int_8)
749 q = int(batch_width(ri, rb),
int_8)
750 na =
SIZE(ao, kind=
int_8)
751 nr =
SIZE(ri, kind=
int_8)
752 nm =
SIZE(mo, kind=
int_8)
755 data_count = max(limited_product([a, a, q], product_limit), &
756 limited_product([b, q, a], product_limit), &
757 limited_product([q, m, b], product_limit), &
758 limited_product([r, m, b], product_limit))
761 block_count = max(limited_product([8_int_8, int(nranks,
int_8), na, nm], product_limit), &
762 limited_product([8_int_8, int(nranks,
int_8), na, na, nq], product_limit), &
763 limited_product([8_int_8, int(nranks,
int_8), nb, nq, na], product_limit), &
764 limited_product([8_int_8, int(nranks,
int_8), nq, nm, nb], product_limit), &
765 limited_product([8_int_8, int(nranks,
int_8), nr, nm, nb], product_limit))
766 fits = data_count <= backend_data_limit .AND. block_count <= backend_block_limit
767 IF (
PRESENT(pressure)) pressure = max(real(data_count, dp)/real(backend_data_limit, dp), &
768 REAL(block_count, dp)/
REAL(backend_block_limit, dp))
769 END FUNCTION batch_counts_fit
783 FUNCTION batch_pressure(ao, ri, mo, mb, rb, nranks, buffer_elements, max_memory_mb)
RESULT(pressure)
784 INTEGER,
INTENT(IN) :: ao(:), ri(:), mo(:), mb, rb, nranks
785 INTEGER(int_8),
INTENT(IN) :: buffer_elements
786 REAL(dp),
INTENT(IN) :: max_memory_mb
789 REAL(dp) :: count_pressure
791 pressure = batch_workspace(sum(ao), sum(ri), sum(mo), mo, ri, mb, rb, buffer_elements)/max_memory_mb
792 IF (.NOT. batch_counts_fit(ao, ri, mo, mb, rb, nranks, count_pressure)) pressure = max(pressure, count_pressure)
793 END FUNCTION batch_pressure
801 FUNCTION batch_width(sizes, blocks)
RESULT(width)
802 INTEGER,
INTENT(IN) :: sizes(:), blocks
808 DO i = 1,
SIZE(sizes), blocks
809 width = max(width, sum(sizes(i:i + min(blocks - 1,
SIZE(sizes) - i))))
811 END FUNCTION batch_width
827 FUNCTION batch_workspace(nao, nri, nmo, mo, ri, mb, rb, buffer_elements)
RESULT(memory_mb)
828 INTEGER,
INTENT(IN) :: nao, nri, nmo, mo(:), ri(:), mb, rb
829 INTEGER(KIND=int_8),
INTENT(IN) :: buffer_elements
830 REAL(dp) :: memory_mb
832 REAL(dp) :: a, b, fixed, m, q, r, work
837 b = real(batch_width(mo, mb), dp)
838 q = real(batch_width(ri, rb), dp)
839 fixed = 4.0_dp*(r*r + a*m) + 2.0_dp*real(buffer_elements, dp)
840 work = 4.0_dp*(a*a*q + b*q*a + q*m*b + r*m*b + a*b)
841 memory_mb = real(
dp_size, dp)*max(6.0_dp*a*a, fixed + work)/1.0e6_dp
842 END FUNCTION batch_workspace
853 SUBROUTINE write_eigen_energies_files(logger, print_section, nMO, homo, eigenvalues, fermi_energy)
856 INTEGER,
INTENT(IN) :: nmo, homo
857 REAL(kind=dp),
INTENT(IN) :: eigenvalues(nmo), fermi_energy
861 iunit =
cp_print_key_unit_nr(logger, print_section, extension=
'.yaml', middle_name=
'EigenEnergies', &
862 file_status=
'REPLACE', file_position=
'REWIND')
863 WRITE (iunit,
'(A)')
'version: 100'
864 WRITE (iunit,
'(A)')
'type: Tensor'
865 WRITE (iunit,
'(A)')
'scalarType: Real64'
866 WRITE (iunit,
'(A)')
'dimensions:'
867 WRITE (iunit,
'(A,I0)')
'- length: ', nmo
868 WRITE (iunit,
'(A)')
' type: State'
869 WRITE (iunit,
'(A)')
'elements:'
870 WRITE (iunit,
'(A)')
' type: TextFile'
871 WRITE (iunit,
'(A)')
'unit: 1.0'
872 WRITE (iunit,
'(A)')
'metaData:'
873 WRITE (iunit,
'(A,ES25.16)')
' fermiEnergy: ', fermi_energy
874 WRITE (iunit,
'(A,I0)')
' homoIndex: ', homo
875 WRITE (iunit,
'(A)')
' energies:'
877 WRITE (iunit,
'(A,ES25.16)')
' - ', eigenvalues(i)
881 iunit =
cp_print_key_unit_nr(logger, print_section, extension=
'.elements', middle_name=
'EigenEnergies', &
882 file_status=
'REPLACE', file_position=
'REWIND')
884 WRITE (iunit,
'(ES25.16)') eigenvalues(i)
888 END SUBROUTINE write_eigen_energies_files
903 SUBROUTINE write_coulomb_vertex_batch(para_env, nRI, nMO, gamma, iunit, first_mo, last_mo, &
904 values, vertex_norm, elapsed)
906 INTEGER,
INTENT(IN) :: nri, nmo
907 TYPE(dbt_type),
INTENT(INOUT) ::
gamma
908 INTEGER,
INTENT(IN) :: iunit, first_mo, last_mo
909 REAL(dp),
INTENT(INOUT) :: values(:), vertex_norm, elapsed(5)
911 INTEGER :: column, handle, hi, ind(3), j, k, lo, &
913 INTEGER(KIND=int_8) :: count, first, last, mirror, nvalues, &
914 offset, row, segment, start, used, &
916 INTEGER,
ALLOCATABLE :: off1(:), off2(:), off3(:)
918 REAL(dp) :: start_time
919 REAL(dp),
ALLOCATABLE :: block(:, :, :)
920 TYPE(dbt_iterator_type) :: iter
923 CALL timeset(
"cc4s_gather", handle)
924 cpassert(
SIZE(values, kind=
int_8) <= output_count_limit)
925 ALLOCATE (off1(dbt_nblks_total(
gamma, 1)), off2(dbt_nblks_total(
gamma, 2)), &
926 off3(dbt_nblks_total(
gamma, 3)))
927 CALL dbt_get_info(
gamma, blk_offset_1=off1, blk_offset_2=off2, blk_offset_3=off3)
928 DO column = first_mo, last_mo
930 nvalues = offset + int(nri,
int_8)*int(column,
int_8)
932 DO WHILE (offset < nvalues)
933 count = min(
SIZE(values, kind=
int_8), nvalues - offset)
939 CALL dbt_iterator_start(iter,
gamma)
940 DO WHILE (dbt_iterator_blocks_left(iter))
941 CALL dbt_iterator_next_block(iter, ind, blk_size=sizes)
942 first = int(off1(ind(1)) - 1,
int_8) + int(nri,
int_8)* &
943 (int(off2(ind(2)) - 1,
int_8) + int(nmo,
int_8)*int(off3(ind(3)) - 1,
int_8))
944 last = first + int(sizes(1),
int_8) + int(nri,
int_8)* &
946 IF (first >= offset + count .OR. last <= offset) cycle
947 CALL dbt_get_block(
gamma, ind, block, found)
952 CALL segment_overlap(start, sizes(1), offset, count, lo, hi)
954 values(start + lo - offset:start + hi - offset) = block(lo:hi, j, k)
959 CALL dbt_iterator_stop(iter)
961 CALL para_env%sum(values(:count), para_env%source)
962 CALL timestop(handle)
963 elapsed(4) = elapsed(4) +
m_walltime() - start_time
965 CALL timeset(
"cc4s_write_files", handle)
966 IF (para_env%is_source())
THEN
967 CALL write_coulomb_vertex_block(iunit, offset, values(:count))
968 vertex_norm = vertex_norm + sum(values(:count)**2)
970 DO WHILE (used < count)
972 row = within/int(nri,
int_8) + 1_int_8
974 segment = min(count - used, int(nri,
int_8) - within)
975 IF (row < column)
THEN
976 mirror = within + int(nri,
int_8)*(int(column - 1,
int_8) + int(nmo,
int_8)*(row - 1_int_8))
977 CALL write_coulomb_vertex_block(iunit, mirror, values(used + 1:used + segment))
978 vertex_norm = vertex_norm + sum(values(used + 1:used + segment)**2)
980 used = used + segment
983 CALL timestop(handle)
984 elapsed(5) = elapsed(5) +
m_walltime() - start_time
986 CALL timeset(
"cc4s_gather", handle)
987 offset = offset + count
990 DEALLOCATE (off1, off2, off3)
991 CALL timestop(handle)
992 elapsed(4) = elapsed(4) +
m_walltime() - start_time
993 END SUBROUTINE write_coulomb_vertex_batch
1006 SUBROUTINE open_coulomb_vertex_file(logger, print_section, nRI, nMO, periodic, cutoff_radius, hmat, iunit)
1009 INTEGER,
INTENT(IN) :: nri, nmo
1010 LOGICAL,
INTENT(IN) :: periodic
1011 REAL(kind=dp),
INTENT(IN) :: cutoff_radius, hmat(3, 3)
1012 INTEGER,
INTENT(OUT) :: iunit
1016 iunit =
cp_print_key_unit_nr(logger, print_section, extension=
'.yaml', middle_name=
'CoulombVertex', &
1017 file_status=
'REPLACE', file_position=
'REWIND')
1018 WRITE (iunit,
'(A)')
'version: 100'
1019 WRITE (iunit,
'(A)')
'type: Tensor'
1020 WRITE (iunit,
'(A)')
'scalarType: Real64'
1021 WRITE (iunit,
'(A)')
'dimensions:'
1022 WRITE (iunit,
'(A,I0)')
'- length: ', nri
1023 WRITE (iunit,
'(A)')
' type: AuxiliaryField'
1024 WRITE (iunit,
'(A,I0)')
'- length: ', nmo
1025 WRITE (iunit,
'(A)')
' type: State'
1026 WRITE (iunit,
'(A,I0)')
'- length: ', nmo
1027 WRITE (iunit,
'(A)')
' type: State'
1028 WRITE (iunit,
'(A)')
'elements:'
1029 WRITE (iunit,
'(A)')
' type: IeeeBinaryFile'
1030 WRITE (iunit,
'(A)')
'unit: 1.0'
1031 WRITE (iunit,
'(A)')
'metaData:'
1033 WRITE (iunit,
'(A)')
' boundaryConditions: "periodic-3d-gamma"'
1034 WRITE (iunit,
'(A)')
' interactionPotential: "TRUNCATED"'
1035 WRITE (iunit,
'(A,ES25.16)')
' cutoffRadiusBohr: ', cutoff_radius
1036 WRITE (iunit,
'(A)')
' madelungCorrection: 0.0'
1037 WRITE (iunit,
'(A)')
' latticeVectorsBohr:'
1039 WRITE (iunit,
'(A,ES25.16,A,ES25.16,A,ES25.16,A)') &
1040 ' - [', hmat(1, i),
', ', hmat(2, i),
', ', hmat(3, i),
']'
1043 WRITE (iunit,
'(A)')
' boundaryConditions: "molecular"'
1044 WRITE (iunit,
'(A)')
' interactionPotential: "COULOMB"'
1048 iunit =
cp_print_key_unit_nr(logger, print_section, extension=
'.elements', middle_name=
'CoulombVertex', &
1049 file_status=
'REPLACE', file_position=
'REWIND', &
1050 file_form=
'UNFORMATTED', file_access=
'STREAM')
1051 END SUBROUTINE open_coulomb_vertex_file
1059 SUBROUTINE write_coulomb_vertex_block(iunit, offset, values)
1060 INTEGER,
INTENT(IN) :: iunit
1061 INTEGER(KIND=int_8),
INTENT(IN) :: offset
1062 REAL(kind=dp),
CONTIGUOUS,
INTENT(IN) :: values(:)
1064 INTEGER :: io_status
1065 INTEGER(KIND=int_8) :: position
1068 cpassert(offset >= 0_int_8)
1069 cpassert(
SIZE(values, kind=
int_8) > 0_int_8)
1070 cpassert(
SIZE(values, kind=
int_8) <= huge(position)/int(
dp_size,
int_8) - offset)
1072 WRITE (iunit, pos=position, iostat=io_status) values
1073 IF (io_status /= 0)
THEN
1074 cpabort(
"CC4S: failed writing CoulombVertex.elements")
1076 END SUBROUTINE write_coulomb_vertex_block
1088 SUBROUTINE write_cc4s_in(logger, print_section, method, nocc, max_iter, energy_conv, amp_conv)
1091 CHARACTER(LEN=*),
INTENT(IN) :: method
1092 INTEGER,
INTENT(IN) :: nocc, max_iter
1093 REAL(dp),
INTENT(IN) :: energy_conv, amp_conv
1095 CHARACTER(len=default_path_length) :: filename
1099 file_status=
'REPLACE', file_position=
'REWIND')
1103 CALL write_tensor_read(iunit, filename,
'CoulombVertex')
1105 CALL write_tensor_read(iunit, filename,
'EigenEnergies')
1106 WRITE (iunit,
'(A)')
'- name: DefineHolesAndParticles'
1107 WRITE (iunit,
'(A)')
' in:'
1108 WRITE (iunit,
'(A)')
' eigenEnergies: EigenEnergies'
1109 WRITE (iunit,
'(A)')
' out:'
1110 WRITE (iunit,
'(A)')
' slicedEigenEnergies: EigenEnergies'
1111 WRITE (iunit,
'(A)')
'- name: SliceOperator'
1112 WRITE (iunit,
'(A)')
' in:'
1113 WRITE (iunit,
'(A)')
' slicedEigenEnergies: EigenEnergies'
1114 WRITE (iunit,
'(A)')
' operator: CoulombVertex'
1115 WRITE (iunit,
'(A)')
' out:'
1116 WRITE (iunit,
'(A)')
' slicedOperator: CoulombVertex'
1117 WRITE (iunit,
'(A)')
'- name: VertexCoulombIntegrals'
1118 WRITE (iunit,
'(A)')
' in:'
1119 WRITE (iunit,
'(A)')
' slicedCoulombVertex: CoulombVertex'
1120 WRITE (iunit,
'(A)')
' out:'
1121 WRITE (iunit,
'(A)')
' coulombIntegrals: CoulombIntegrals'
1124 WRITE (iunit,
'(A)')
'- name: SecondOrderPerturbationTheory'
1125 WRITE (iunit,
'(A)')
' in:'
1126 WRITE (iunit,
'(A)')
' coulombIntegrals: CoulombIntegrals'
1127 WRITE (iunit,
'(A)')
' slicedEigenEnergies: EigenEnergies'
1128 WRITE (iunit,
'(A)')
' out:'
1129 WRITE (iunit,
'(A)')
' energy: Mp2Energy'
1132 SELECT CASE (trim(method))
1135 CASE (
'CCSD',
'CCSD_T')
1136 CALL write_coupled_cluster_step(iunit,
'Ccsd',
'Amplitudes', nocc, max_iter, energy_conv, amp_conv)
1138 cpabort(
"CC4S: unsupported method")
1142 IF (trim(method) ==
'CCSD_T')
THEN
1143 WRITE (iunit,
'(A)')
'- name: PerturbativeTriples'
1144 WRITE (iunit,
'(A)')
' in:'
1145 WRITE (iunit,
'(A)')
' slicedEigenEnergies: EigenEnergies'
1146 WRITE (iunit,
'(A)')
' amplitudes: Amplitudes'
1147 WRITE (iunit,
'(A)')
' coulombIntegrals: CoulombIntegrals'
1148 WRITE (iunit,
'(A)')
' out: {}'
1153 END SUBROUTINE write_cc4s_in
1165 SUBROUTINE write_coupled_cluster_step(iunit, cc_method, amp_key, nocc, max_iter, energy_conv, amp_conv)
1166 INTEGER,
INTENT(IN) :: iunit
1167 CHARACTER(LEN=*),
INTENT(IN) :: cc_method, amp_key
1168 INTEGER,
INTENT(IN) :: nocc, max_iter
1169 REAL(dp),
INTENT(IN) :: energy_conv, amp_conv
1171 WRITE (iunit,
'(A)')
'- name: CoupledCluster'
1172 WRITE (iunit,
'(A)')
' in:'
1173 WRITE (iunit,
'(A)')
' method: '//trim(cc_method)
1175 WRITE (iunit,
'(A,I0)')
' integralsSliceSize: ', nocc
1176 WRITE (iunit,
'(A)')
' slicedEigenEnergies: EigenEnergies'
1177 WRITE (iunit,
'(A)')
' coulombIntegrals: CoulombIntegrals'
1178 WRITE (iunit,
'(A)')
' slicedCoulombVertex: CoulombVertex'
1179 WRITE (iunit,
'(A,I0)')
' maxIterations: ', max_iter
1180 WRITE (iunit,
'(A,ES25.16)')
' energyConvergence: ', energy_conv
1181 WRITE (iunit,
'(A,ES25.16)')
' amplitudesConvergence: ', amp_conv
1182 WRITE (iunit,
'(A)')
' mixer:'
1183 WRITE (iunit,
'(A)')
' type: DiisMixer'
1184 WRITE (iunit,
'(A)')
' maxResidua: 4'
1185 WRITE (iunit,
'(A)')
' out:'
1186 WRITE (iunit,
'(A)')
' amplitudes: '//trim(amp_key)
1187 WRITE (iunit,
'(A)')
' energy: CoupledClusterEnergy'
1189 END SUBROUTINE write_coupled_cluster_step
1197 SUBROUTINE write_tensor_read(iunit, filename, destination)
1198 INTEGER,
INTENT(IN) :: iunit
1199 CHARACTER(len=*),
INTENT(IN) :: filename, destination
1203 WRITE (iunit,
'(A)')
'- name: Read'
1204 WRITE (iunit,
'(A)')
' in:'
1205 WRITE (iunit,
'(A)', advance=
'NO')
" fileName: '"
1207 DO i = index(filename,
'/', back=.true.) + 1, len_trim(filename)
1208 WRITE (iunit,
'(A)', advance=
'NO') filename(i:i)
1209 IF (filename(i:i) ==
"'")
WRITE (iunit,
'(A)', advance=
'NO')
"'"
1211 WRITE (iunit,
'(A)')
"'"
1212 WRITE (iunit,
'(A)')
' out:'
1213 WRITE (iunit,
'(A)')
' destination: '//destination
1214 END SUBROUTINE write_tensor_read
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Molecular and Gamma-point periodic CC4S export from restricted RI-HF. RI_FLAVOR MO stores a weighted ...
subroutine, public write_cc4s(qs_env, converged)
Check the requested export, canonicalize private Fock/overlap copies and write tensors.
Handles all functions related to the CELL.
integer, parameter, public use_perd_xyz
integer, parameter, public use_perd_none
real(kind=dp) function, public plane_distance(h, k, l, cell)
Calculate the distance between two lattice planes as defined by a triple of Miller indices (hkl).
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_release(matrix)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_fm_to_dbcsr_row_template(matrix, fm_in, template)
Utility function to copy a specially shaped fm to dbcsr_matrix The result matrix will be the matrix i...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public cp_fm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, nmo_retained)
General Eigenvalue Problem AX = BXE Use canonical diagonalization : U*s**(-1/2).
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_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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...
character(len=default_path_length) function, public cp_print_key_generate_filename(logger, print_key, middle_name, extension, my_local)
Utility function that returns a unit number to write the print key. Might open a file with a unique f...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
logical function, public cp_printkey_is_on(iteration_info, print_key)
returns true if the printlevel activates this printkey does not look if this iteration it should be p...
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout, file_access)
...
This is the start of a dbt_api, all publically needed functions are exported here....
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Types and set/get functions for HFX.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp_size
integer, parameter, public dp
integer, parameter, public default_path_length
Machine interface based on Fortran 2003 and POSIX.
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Interface to the message passing library MPI.
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.
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, cmo_coeff)
Get the components of a MO set data structure.
logical function, public has_uniform_occupation(mo_set, first_mo, last_mo, occupation, tolerance)
Check if the set of MOs in mo_set specifed by the MO index range [first_mo,last_mo] an integer occupa...
Utility methods to build 3-center integral tensors of various types.
subroutine, public create_2c_tensor(t2c, dist_1, dist_2, pgrid, sizes_1, sizes_2, order, name)
...
subroutine, public create_3c_tensor(t3c, dist_1, dist_2, dist_3, pgrid, sizes_1, sizes_2, sizes_3, map1, map2, name)
...
parameters that control an scf iteration
Type defining parameters related to the simulation cell.
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...
stores some data used in construction of Kohn-Sham matrix
stores all the informations relevant to an mpi environment