55 use,
intrinsic :: iso_fortran_env
108 real(real64),
target :: shift_aux
109 type(preconditioner_t) :: prec_aux
119 type(namespace_t),
intent(in) :: namespace
121 type(test_parameters_t) :: param
128 call param%init_from_file(namespace)
211 call parse_variable(namespace,
'TestMode', option__testmode__hartree, test_mode)
221 select case (test_mode)
222 case (option__testmode__hartree)
224 case (option__testmode__derivatives)
226 case (option__testmode__orthogonalization)
228 case (option__testmode__interpolation)
230 case (option__testmode__ion_interaction)
232 case (option__testmode__projector)
234 case (option__testmode__dft_u)
236 case (option__testmode__hamiltonian_apply)
238 case (option__testmode__density_calc)
240 case (option__testmode__exp_apply)
242 case (option__testmode__boundaries)
244 case (option__testmode__subspace_diag)
246 case (option__testmode__batch_ops)
248 case (option__testmode__clock)
250 case (option__testmode__linear_solver)
252 case (option__testmode__cgal)
254 case (option__testmode__dense_eigensolver)
256 case (option__testmode__grid_interpolation)
258 case (option__testmode__iihash)
260 case (option__testmode__sihash)
262 case (option__testmode__sphash)
264 case (option__testmode__mpiwrappers)
266 case (option__testmode__regridding)
268 case (option__testmode__helmholtz_decomposition)
270 case (option__testmode__vecpot_analytical)
272 case (option__testmode__current_density)
274 case (option__testmode__mixing_tests)
276 case (option__testmode__optimizers)
278 case (option__testmode__weighted_kmeans)
280 case (option__testmode__csv_input)
282 case (option__testmode__composition_chebyshev)
284 case (option__testmode__lalg_adv)
286 case (option__testmode__isdf_serial)
288 case (option__testmode__isdf)
306 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
308 call poisson_test(sys%hm%psolver, sys%space, sys%gr, sys%ions%latt, namespace, param%repetitions)
309 safe_deallocate_p(sys)
326 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
329 call helmholtz%init(namespace, sys%gr, sys%mc, sys%space)
332 write(
message(1),
'(a)')
"Helmholtz decomposition: beginning Hertzian dipole test"
336 write(
message(1),
'(a)')
"Helmholtz decomposition: beginning Gaussian test"
338 call gaussian_test(helmholtz, sys%gr, sys%namespace, sys%space)
340 safe_deallocate_p(sys)
347 use,
intrinsic :: iso_c_binding, only: c_ptr
351 real(real64),
allocatable :: rho(:), x(:),
center(:)
352 real(real64) :: rr, alpha, beta, res
354 integer,
target :: prefactor = -1
356 real(real64),
parameter :: threshold = 1.e-7_real64
362 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
368 shift_aux = 0.25_real64
374 alpha =
m_four * sys%gr%spacing(1)
375 beta =
m_one / (alpha**sys%space%dim *
sqrt(
m_pi)**sys%space%dim)
377 safe_allocate(
center(1:sys%space%dim))
380 safe_allocate(rho(1:sys%gr%np))
384 rho(ip) = beta*
exp(-(rr/alpha)**2)
387 safe_allocate(x(1:sys%gr%np))
394 threshold, userdata=[c_loc(sys%gr%der),c_loc(shift_aux),c_loc(prefactor)])
395 write(
message(1),
'(a,i6,a)')
"Info: CG converged with ", iter,
" iterations."
396 write(
message(2),
'(a,e14.6)')
"Info: The residue is ", res
397 write(
message(3),
'(a,e14.6)')
"Info: Norm solution CG ",
dmf_nrm2(sys%gr, x)
402 safe_deallocate_a(rho)
403 safe_deallocate_p(sys)
416 complex(real64),
allocatable :: psi(:, :)
422 call messages_write(
'Info: Testing the nonlocal part of the pseudopotential with SOC')
427 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
436 call sys%st%group%psib(1, 1)%copy_to(epsib)
440 do itime = 1, param%repetitions
442 sys%hm%ep%natoms, 2, sys%st%group%psib(1, 1), epsib)
445 safe_allocate(psi(1:sys%gr%np, 1:sys%st%d%dim))
446 do itime = 1, epsib%nst
448 write(
message(1),
'(a,i1,3x, f12.6)')
"Norm state ", itime,
zmf_nrm2(sys%gr, 2, psi)
451 safe_deallocate_a(psi)
455 safe_deallocate_p(sys)
467 integer :: itime, ist
469 real(real64),
allocatable :: ddot(:,:,:), dweight(:,:)
470 complex(real64),
allocatable :: zdot(:,:,:), zweight(:,:)
471 logical :: skipSOrbitals, useAllOrbitals
484 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
489 if (sys%st%pack_states)
call sys%st%pack()
491 call sys%st%group%psib(1, 1)%copy_to(epsib2, copy_data = .
true.)
494 if (.not. sys%hm%phase%is_allocated())
then
495 call sys%st%group%psib(1, 1)%copy_to(epsib, copy_data = .
true.)
497 call sys%st%group%psib(1, 1)%copy_to(epsib)
498 call sys%hm%phase%apply_to(sys%gr, sys%gr%np, &
499 .false., epsib, src=sys%st%group%psib(1, 1))
500 epsib2%has_phase = .
true.
507 call parse_variable(namespace,
'UseAllAtomicOrbitals', .false., useallorbitals)
511 call dorbitalbasis_build(basis, sys%namespace, sys%ions, sys%gr, sys%st%d%kpt, sys%st%d%dim, &
512 skipsorbitals, useallorbitals, verbose=.false.)
513 safe_allocate(dweight(1:basis%orbsets(1)%norbs, 1:epsib%nst_linear))
514 safe_allocate(ddot(1:sys%st%d%dim, 1:basis%orbsets(1)%norbs, 1:epsib%nst))
516 call zorbitalbasis_build(basis, sys%namespace, sys%ions, sys%gr, sys%st%d%kpt, sys%st%d%dim, &
517 skipsorbitals, useallorbitals, verbose=.false.)
519 safe_allocate(zweight(1:basis%orbsets(1)%norbs, 1:epsib%nst_linear))
520 safe_allocate(zdot(1:sys%st%d%dim, 1:basis%orbsets(1)%norbs, 1:epsib%nst))
523 if (sys%hm%phase%is_allocated())
then
529 do itime = 1, param%repetitions
544 if (epsib%is_packed())
then
545 call epsib%do_unpack(force = .
true.)
548 do ist = 1, epsib%nst
550 write(
message(1),
'(a,i2,3x,e13.6)')
"Dotp state ", ist, ddot(1,1,ist)
552 write(
message(1),
'(a,i2,2(3x,e13.6))')
"Dotp state ", ist, zdot(1,1,ist)
560 safe_deallocate_a(dweight)
561 safe_deallocate_a(zweight)
562 safe_deallocate_a(ddot)
563 safe_deallocate_a(zdot)
569 safe_deallocate_p(sys)
581 type(
wfs_elec_t) :: hpsib, hpsib_copy, hpsib_diff
582 integer :: itime, terms
584 logical :: copy_before_apply
585 real(real64),
allocatable :: norm_hpsib(:), norm_diff(:)
586 real(real64) :: max_rel_diff
587 real(real64),
parameter :: hamiltonian_copy_rel_tol = 1.0e-12_real64
606 call parse_variable(namespace,
'TestHamiltonianApply', option__testhamiltonianapply__term_all, terms)
607 if (terms == 0) terms = huge(1)
617 call parse_variable(namespace,
'TestHamiltonianCopyBeforeApply', .false., copy_before_apply)
623 call messages_write(
'Info: Testing the application of the Hamiltonian')
628 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
635 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
638 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
640 if (copy_before_apply)
then
644 call boundaries_set(sys%gr%der%boundaries, sys%gr, sys%st%group%psib(1, 1))
646 call sys%st%group%psib(1, 1)%copy_to(hpsib)
647 if (copy_before_apply)
call sys%st%group%psib(1, 1)%copy_to(hpsib_copy)
649 if (sys%hm%apply_packed())
then
650 call sys%st%group%psib(1, 1)%do_pack()
651 call hpsib%do_pack(copy = .false.)
652 if (copy_before_apply)
call hpsib_copy%do_pack(copy = .false.)
655 do itime = 1, param%repetitions
658 terms = terms, set_bc = .false.)
659 if (copy_before_apply)
then
661 terms = terms, set_bc = .false.)
665 terms = terms, set_bc = .false.)
666 if (copy_before_apply)
then
668 terms = terms, set_bc = .false.)
673 if (hpsib%is_packed())
then
674 call hpsib%do_unpack(force = .
true.)
676 if (copy_before_apply .and. hpsib_copy%is_packed())
then
677 call hpsib_copy%do_unpack(force = .
true.)
680 if (copy_before_apply)
then
681 call hpsib_copy%copy_to(hpsib_diff, copy_data = .
true.)
682 call batch_axpy(sys%gr%np, -1.0_real64, hpsib, hpsib_diff)
684 safe_allocate(norm_hpsib(1:hpsib%nst))
685 safe_allocate(norm_diff(1:hpsib_diff%nst))
689 max_rel_diff = maxval(norm_diff / max(norm_hpsib, tiny(1.0_real64)))
690 write(
message(1),
'(a,e23.16)')
'Hamiltonian copy max relative difference ', max_rel_diff
693 do ist = 1, hpsib%nst
694 if (norm_diff(ist) > hamiltonian_copy_rel_tol*max(norm_hpsib(ist), tiny(1.0_real64)))
then
695 write(
message(1),
'(a,i6)')
'Hamiltonian copy mismatch for state ', ist
700 safe_deallocate_a(norm_hpsib)
701 safe_deallocate_a(norm_diff)
702 call hpsib_diff%end(copy = .false.)
707 if (copy_before_apply)
then
709 call hpsib_copy%end(copy = .false.)
711 if (sys%hm%apply_packed())
then
712 call hpsib%do_pack(copy = .false.)
716 terms = terms, set_bc = .false.)
719 terms = terms, set_bc = .false.)
722 call hpsib%end(copy = .false.)
724 safe_deallocate_p(sys)
747 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
752 if (sys%st%pack_states)
call sys%st%pack()
754 do itime = 1, param%repetitions
758 write(
message(1),
'(a,3x, f12.6)')
"Norm density ",
dmf_nrm2(sys%gr, sys%st%rho(:,1))
762 safe_deallocate_p(sys)
785 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
790 if (sys%st%pack_states)
call sys%st%pack()
792 do itime = 1, param%repetitions
793 call boundaries_set(sys%gr%der%boundaries, sys%gr, sys%st%group%psib(1, 1))
799 safe_deallocate_p(sys)
813 integer,
allocatable :: degree(:)
821 call messages_write(
'Info: Testing Chebyshev filtering and its composition rule')
826 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
831 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
834 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
837 safe_allocate(degree(1:sys%st%group%nblocks))
847 call parse_variable(namespace,
'TestCompositionOrder', 2, degree_n)
859 call dchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
861 call zchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
865 call messages_write(
'Info: Result after calling 2n-th order filtering')
871 call sys%st%group%psib(1, 1)%copy_to(psib, copy_data=.
true.)
874 call dchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
875 call dchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
877 call zchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
878 call zchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
889 safe_deallocate_a(degree)
890 safe_deallocate_p(bounds)
894 safe_deallocate_p(sys)
919 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
926 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
929 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
933 if (sys%hm%apply_packed())
then
934 call sys%st%group%psib(1, 1)%do_pack()
937 do itime = 1, param%repetitions
938 call te%apply_batch(sys%namespace, sys%gr, sys%hm, sys%st%group%psib(1, 1), 1e-3_real64)
944 safe_deallocate_p(sys)
958 real(real64),
allocatable :: diff(:)
969 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
975 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
978 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
980 call sdiag%init(sys%namespace, sys%st)
982 safe_allocate(diff(1:sys%st%nst))
984 do itime = 1, param%repetitions
986 call dsubspace_diag(sdiag, sys%namespace, sys%gr, sys%st, sys%hm, 1, sys%st%eigenval(:, 1), diff)
988 call zsubspace_diag(sdiag, sys%namespace, sys%gr, sys%st, sys%hm, 1, sys%st%eigenval(:, 1), diff)
992 safe_deallocate_a(diff)
997 safe_deallocate_p(sys)
1009 integer :: itime, ops, ops_default, ist, jst, nst
1011 real(real64),
allocatable :: tmp(:)
1012 real(real64),
allocatable :: ddotv(:)
1013 complex(real64),
allocatable :: zdotv(:)
1014 real(real64),
allocatable :: ddot(:,:), df(:,:), dweight(:), dpoints(:,:,:)
1015 complex(real64),
allocatable :: zdot(:,:), zf(:,:), zweight(:), zpoints(:,:,:)
1016 integer :: sp, block_size, size
1045 option__testbatchops__ops_axpy + &
1046 option__testbatchops__ops_scal + &
1047 option__testbatchops__ops_nrm2 + &
1048 option__testbatchops__ops_dotp_matrix + &
1049 option__testbatchops__ops_dotp_self + &
1050 option__testbatchops__ops_dotp_vector + &
1051 option__testbatchops__ops_ax_function_py + &
1052 option__testbatchops__ops_get_points
1063 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
1064 call sys%init_parallelization(
mpi_world)
1068 if (sys%st%pack_states)
call sys%st%pack()
1070 if (
bitand(ops, option__testbatchops__ops_axpy) /= 0)
then
1071 message(1) =
'Info: Testing axpy'
1074 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1075 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1077 do itime = 1, param%repetitions
1078 call batch_axpy(sys%gr%np, 0.1_real64, xx, yy)
1086 if (
bitand(ops, option__testbatchops__ops_scal) /= 0)
then
1087 message(1) =
'Info: Testing scal'
1090 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1091 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1093 do itime = 1, param%repetitions
1102 if (
bitand(ops, option__testbatchops__ops_nrm2) /= 0)
then
1103 message(1) =
'Info: Testing nrm2'
1106 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1107 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1109 safe_allocate(tmp(1:xx%nst))
1111 do itime = 1, param%repetitions
1114 do itime = 1, xx%nst
1115 write(
message(1),
'(a,i1,3x,e23.16)')
"Nrm2 norm state ", itime, tmp(itime)
1119 safe_deallocate_a(tmp)
1125 if (
bitand(ops, option__testbatchops__ops_dotp_matrix) /= 0)
then
1127 message(1) =
'Info: Testing dotp_matrix'
1130 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1131 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1133 nst = sys%st%group%psib(1, 1)%nst
1136 safe_allocate(ddot(1:nst, 1:nst))
1137 do itime = 1, param%repetitions
1143 write(
message(jst),
'(a,2i3,3x,e23.16)')
'Dotp_matrix states', ist, jst, ddot(ist,jst)
1147 safe_deallocate_a(ddot)
1149 safe_allocate(zdot(1:nst, 1:nst))
1150 do itime = 1, param%repetitions
1156 write(
message(jst),
'(a,2i3,3x,2(e23.16,1x))')
'Dotp_matrix states', ist, jst, zdot(ist,jst)
1160 safe_deallocate_a(zdot)
1167 if (
bitand(ops, option__testbatchops__ops_dotp_vector) /= 0)
then
1169 message(1) =
'Info: Testing dotp_vector'
1172 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1173 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1175 nst = sys%st%group%psib(1, 1)%nst
1178 safe_allocate(ddotv(1:nst))
1179 do itime = 1, param%repetitions
1184 write(
message(ist),
'(a,i3,3x,e23.16)')
'Dotp_vector state', ist, ddotv(ist)
1187 safe_deallocate_a(ddotv)
1189 safe_allocate(zdotv(1:nst))
1190 do itime = 1, param%repetitions
1195 write(
message(ist),
'(a,i3,3x,2(e23.16,1x))')
'Dotp_vector state', ist, zdotv(ist)
1198 safe_deallocate_a(zdotv)
1205 if (
bitand(ops, option__testbatchops__ops_dotp_self) /= 0)
then
1207 message(1) =
'Info: Testing dotp_self'
1210 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1212 nst = sys%st%group%psib(1, 1)%nst
1215 safe_allocate(ddot(1:nst, 1:nst))
1216 do itime = 1, param%repetitions
1222 write(
message(jst),
'(a,2i3,3x,e23.16)')
'Dotp_self states', ist, jst, ddot(ist,jst)
1226 safe_deallocate_a(ddot)
1228 safe_allocate(zdot(1:nst, 1:nst))
1229 do itime = 1, param%repetitions
1235 write(
message(jst),
'(a,2i3,3x,2(e23.16,1x))')
'Dotp_self states', ist, jst, zdot(ist,jst)
1239 safe_deallocate_a(zdot)
1245 if (
bitand(ops, option__testbatchops__ops_ax_function_py) /= 0)
then
1246 message(1) =
'Info: Testing ax_function_py'
1249 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1252 safe_allocate(df(sys%gr%np, sys%st%d%dim))
1253 safe_allocate(dweight(1:sys%st%group%psib(1, 1)%nst_linear))
1254 dweight = 0.1_real64
1257 do itime = 1, param%repetitions
1260 safe_deallocate_a(df)
1261 safe_deallocate_a(dweight)
1263 safe_allocate(zf(sys%gr%np, sys%st%d%dim))
1264 safe_allocate(zweight(1:sys%st%group%psib(1, 1)%nst_linear))
1265 zweight = cmplx(0.1_real64,
m_zero, real64)
1268 do itime = 1, param%repetitions
1271 safe_deallocate_a(zf)
1278 if (
bitand(ops, option__testbatchops__ops_get_points) /= 0)
then
1283 call sys%st%group%psib(1, 1)%copy_to(yy)
1289 safe_allocate(dpoints(1:sys%st%nst, 1:sys%st%d%dim, 1:block_size))
1291 do itime = 1, param%repetitions
1292 do sp = 1, sys%gr%np, block_size
1293 size = min(block_size, sys%gr%np - sp + 1)
1298 safe_deallocate_a(dpoints)
1304 safe_allocate(zpoints(1:sys%st%nst, 1:sys%st%d%dim, 1:block_size))
1306 do itime = 1, param%repetitions
1307 do sp = 1, sys%gr%np, block_size
1308 size = min(block_size, sys%gr%np - sp + 1)
1313 safe_deallocate_a(dpoints)
1324 safe_deallocate_p(sys)
1338 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
1339 call sys%init_parallelization(
mpi_world)
1341 message(1) =
'Info: Testing the finite-differences derivatives.'
1345 if (param%type == option__testtype__all .or. param%type == option__testtype__real)
then
1346 call dderivatives_test(sys%gr%der, sys%namespace, param%repetitions, param%min_blocksize, param%max_blocksize)
1349 if (param%type == option__testtype__all .or. param%type == option__testtype__complex)
then
1350 call zderivatives_test(sys%gr%der, sys%namespace, param%repetitions, param%min_blocksize, param%max_blocksize)
1353 if (sys%space%dim > 1)
then
1357 safe_deallocate_p(sys)
1376 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
1377 call sys%init_parallelization(
mpi_world)
1379 message(1) =
'Info: Testing orthogonalization.'
1383 if (param%type == option__testtype__all .or. param%type == option__testtype__real)
then
1384 message(1) =
'Info: Real wave-functions.'
1386 do itime = 1, param%repetitions
1391 if (param%type == option__testtype__all .or. param%type == option__testtype__complex)
then
1392 message(1) =
'Info: Complex wave-functions.'
1394 do itime = 1, param%repetitions
1399 safe_deallocate_p(sys)
1414 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
1415 call sys%init_parallelization(
mpi_world)
1417 if (param%type == option__testtype__all .or. param%type == option__testtype__real)
then
1426 if (param%type == option__testtype__all .or. param%type == option__testtype__complex)
then
1428 call messages_write(
'Info: Testing complex interpolation routines')
1436 safe_deallocate_p(sys)
1451 sys =>
electrons_t(namespace, int(option__calculationmode__dummy, int32))
1452 call sys%init_parallelization(
mpi_world)
1454 call ion_interaction_test(sys%space, sys%ions%latt, sys%ions%atom, sys%ions%natoms, sys%ions%pos, &
1455 sys%gr%box%bounding_box_l, namespace, sys%mc)
1457 safe_deallocate_p(sys)
1466 type(
grid_t),
intent(in) :: gr
1467 class(
batch_t),
intent(inout) :: psib
1468 character(*),
optional,
intent(in) :: string
1471 complex(real64),
allocatable :: zpsi(:, :)
1472 real(real64),
allocatable :: dpsi(:, :)
1474 character(80) :: string_
1481 safe_allocate(dpsi(1:gr%np, 1:st%d%dim))
1483 safe_allocate(zpsi(1:gr%np, 1:st%d%dim))
1486 do itime = 1, psib%nst
1489 write(
message(1),
'(a,i2,3x,e23.16)')
"Norm state "//trim(string_)//
" ", itime,
dmf_nrm2(gr, st%d%dim, dpsi)
1492 write(
message(1),
'(a,i2,3x,e23.16)')
"Norm state "//trim(string_)//
" ", itime,
zmf_nrm2(gr, st%d%dim, zpsi)
1498 safe_deallocate_a(dpsi)
1500 safe_deallocate_a(zpsi)
1516 write(
message(1),
'(a)')
" Operation Counter Time Global step"
1531 call clock%set(
clock_t(time_step=
m_four, initial_iteration=1))
1535 write(
message(1),
'(a)')
" Clock comparisons:"
1538 other_clock =
clock_t(time_step=
m_one, initial_iteration=5)
1550 character(len=*),
intent(in) :: operation
1552 write(
message(1),
'(a17,1x,i6,1x,f10.1,1x,i16)') operation, clock%counter(), clock%value(), clock%global_step()
1557 character(len=*),
intent(in) :: condition
1558 logical,
intent(in) :: result
1560 write(
message(1),
'(a10," = ",i1," (",l1,")")') condition, abs(transfer(result, 0)), result
1577 message(1) =
"cgal_polyhedron_point_inside"
1589 integer :: N, ii, jj, N_list(4), i_N
1590 real(real64),
allocatable :: matrix(:, :), eigenvectors(:, :), eigenvalues(:), test(:)
1591 real(real64),
allocatable :: differences(:)
1595 n_list = [15, 32, 100, 500]
1599 safe_allocate(matrix(1:n, 1:n))
1600 safe_allocate(eigenvectors(1:n, 1:n))
1601 safe_allocate(eigenvalues(1:n))
1602 safe_allocate(test(1:n))
1603 safe_allocate(differences(1:n))
1609 matrix(ii, jj) = ii * jj
1614 eigenvectors(1:n, 1:n) = matrix(1:n, 1:n)
1618 test(:) = matmul(matrix, eigenvectors(:, ii)) - eigenvalues(ii) * eigenvectors(:, ii)
1619 differences(ii) = sum(abs(test)) / sum(abs(eigenvectors(:, ii)))
1621 write(
message(1),
"(A, I3, A, E13.6)")
"Parallel solver - N: ", n, &
1622 ", average difference: ", sum(differences)/n
1626 eigenvectors(1:n, 1:n) = matrix(1:n, 1:n)
1630 test(:) = matmul(matrix, eigenvectors(:, ii)) - eigenvalues(ii) * eigenvectors(:, ii)
1631 differences(ii) = sum(abs(test)) / sum(abs(eigenvectors(:, ii)))
1633 write(
message(1),
"(A, I3, A, E13.6)")
"Serial solver - N: ", n, &
1634 ", average difference: ", sum(differences)/n
1637 safe_deallocate_a(matrix)
1638 safe_deallocate_a(eigenvectors)
1639 safe_deallocate_a(eigenvalues)
1640 safe_deallocate_a(test)
1641 safe_deallocate_a(differences)
1648 class(
batch_t),
intent(inout) :: psib
1649 class(
mesh_t),
intent(in) :: mesh
1651 real(real64),
allocatable :: dff(:)
1652 complex(real64),
allocatable :: zff(:)
1654 real(real64) :: da, db, dc
1655 complex(real64) :: za, zb, zc
1660 da =
m_one/mesh%box%bounding_box_l(1)
1666 za = da +
m_zi*0.01_real64
1667 zb = db*
exp(
m_zi*0.345_real64)
1668 zc = dc -
m_zi*50.0_real64
1670 safe_allocate(zff(1:mesh%np))
1671 do ist = 1, psib%nst_linear
1675 zff(ip) = zb*
exp(-za*sum(mesh%x(:, ip)**2)) + zc
1680 safe_deallocate_a(zff)
1682 safe_allocate(dff(1:mesh%np))
1683 do ist = 1, psib%nst_linear
1687 dff(ip) = db*
exp(-da*sum(mesh%x(:, ip)**2)) + dc
1692 safe_deallocate_a(dff)
1706 call sys%init_parallelization(
mpi_world)
1709 sys%gr%stencil, sys%mc, nlevels=3)
1715 safe_deallocate_p(sys)
1731 write(
message(1),*)
'hash[1] :', found,
value
1735 write(
message(1),*)
'hash[2] :', found,
value
1739 write(
message(1),*)
'hash[3] :', found,
value
1751 integer ::
value, sum
1760 write(
message(1),*)
'hash["one"]: ', found,
value
1764 write(
message(1),*)
'hash["two"]: ', found,
value
1768 write(
message(1),*)
'hash["three"]: ', found,
value
1775 do while (it%has_next())
1776 value = it%get_next()
1778 write(
message(1),
'(I3,A,I5)') counter,
': hash[...] = ',
value
1780 counter = counter + 1
1782 write(
message(1),*)
'counter = ', counter
1783 write(
message(2),*)
'sum = ', sum
1805 class(*),
pointer :: value
1807 integer :: count_clock, count_space
1809 safe_allocate(clock_2)
1823 write(
message(1),*)
'hash["one"]: ', found,
value%counter()
1826 write(
message(1),*)
'hash["one"]: ', found,
value%short_info()
1829 write(
message(1),*)
'wrong type. found = ', found
1836 write(
message(1),*)
'hash["two"]: ', found,
value%counter()
1839 write(
message(1),*)
'hash["two"]: ', found,
value%short_info()
1842 write(
message(1),*)
'wrong type. found = ',found
1846 safe_deallocate_a(clock_2)
1851 write(
message(1),*)
'hash["three"]: ', found,
value%counter()
1854 write(
message(1),*)
'hash["three"]: ', found,
value%short_info()
1857 write(
message(1),*)
'wrong type. found = ',found
1866 do while (it%has_next())
1867 value => it%get_next()
1870 count_clock = count_clock + 1
1872 count_space = count_space + 1
1876 write(
message(1), *)
'Count_clock = ', count_clock
1877 write(
message(2), *)
'Count_space = ', count_space
1890 real(real64),
allocatable :: ff_A(:), ff_A_reference(:), ff_B(:), ff_B_reference(:), diff_A(:), diff_B(:)
1891 real(real64) :: norm_ff, norm_diff
1900 call sysa%init_parallelization(
mpi_world)
1901 call sysb%init_parallelization(
mpi_world)
1904 safe_allocate(ff_a(1:sysa%gr%np))
1905 safe_allocate(ff_a_reference(1:sysa%gr%np))
1906 safe_allocate(diff_a(1:sysa%gr%np))
1907 safe_allocate(ff_b(1:sysb%gr%np))
1908 safe_allocate(ff_b_reference(1:sysb%gr%np))
1909 safe_allocate(diff_b(1:sysb%gr%np))
1911 do ip = 1, sysa%gr%np
1912 ff_a_reference(ip) =
values(sysa%gr%x(:, ip))
1914 do ip = 1, sysb%gr%np
1915 ff_b_reference(ip) =
values(sysb%gr%x(:, ip))
1919 regridding =>
regridding_t(sysb%gr, sysa%gr, sysa%space, sysa%namespace)
1920 call regridding%do_transfer(ff_b, ff_a_reference)
1921 safe_deallocate_p(regridding)
1924 do ip = 1, sysb%gr%np
1926 ff_b_reference(ip) =
m_zero
1929 diff_b(ip) = abs(ff_b_reference(ip) - ff_b(ip))
1932 norm_ff =
dmf_nrm2(sysb%gr, ff_b_reference)
1933 norm_diff =
dmf_nrm2(sysb%gr, diff_b)
1935 write(
message(1),
'(a, E14.6)')
"Forward: difference of reference to mapped function (rel.): ", &
1940 sysb%gr, ff_b_reference,
unit_one, ierr)
1944 sysa%gr, ff_a_reference,
unit_one, ierr)
1947 regridding =>
regridding_t(sysa%gr, sysb%gr, sysb%space, sysb%namespace)
1948 call regridding%do_transfer(ff_a, ff_b_reference)
1949 safe_deallocate_p(regridding)
1951 do ip = 1, sysa%gr%np
1953 ff_a_reference(ip) =
m_zero
1956 diff_a(ip) = abs(ff_a_reference(ip) - ff_a(ip))
1959 norm_ff =
dmf_nrm2(sysa%gr, ff_a_reference)
1960 norm_diff =
dmf_nrm2(sysa%gr, diff_a)
1962 write(
message(1),
'(a, E14.6)')
"Backward: difference of reference to mapped function (rel.): ", &
1967 sysa%gr, ff_a_reference,
unit_one, ierr)
1971 sysb%gr, ff_b_reference,
unit_one, ierr)
1973 safe_deallocate_a(ff_a)
1974 safe_deallocate_a(ff_a_reference)
1975 safe_deallocate_a(ff_b)
1976 safe_deallocate_a(ff_b_reference)
1977 safe_deallocate_a(diff_a)
1978 safe_deallocate_a(diff_b)
1979 safe_deallocate_p(sysa)
1980 safe_deallocate_p(sysb)
1986 real(real64) function values(xx)
1987 real(real64),
intent(in) :: xx(:)
1988 real(real64) :: xx0(1:size(xx, dim=1))
1989 real(real64),
parameter :: aa =
m_half
1990 real(real64),
parameter :: bb =
m_four
1994 values = bb *
exp(-aa*sum((xx-xx0)**2))
2004 type(namespace_t),
intent(in) :: namespace
2006 class(maxwell_t),
pointer :: maxwell_system
2008 real(real64),
allocatable :: magnetic_field(:,:)
2009 real(real64),
allocatable :: vector_potential_mag(:,:)
2010 real(real64),
allocatable :: vector_potential_analytical(:,:)
2011 real(real64),
allocatable :: delta(:,:)
2012 real(real64) :: exp_factor
2016 real(real64) :: sigma
2017 integer :: ip, j, ierr, nn
2018 integer(int64) :: out_how
2019 character(len=MAX_PATH_LEN) :: fname, fname2, fname3
2022 maxwell_system => maxwell_t(namespace)
2023 sigma = maxwell_system%gr%box%bounding_box_l(1)/10_real64
2024 call maxwell_system%init_parallelization(mpi_world)
2026 safe_allocate(magnetic_field(1:maxwell_system%gr%np_part, 1:3))
2027 safe_allocate(vector_potential_mag(1:maxwell_system%gr%np_part, 1:3))
2028 safe_allocate(vector_potential_analytical(1:maxwell_system%gr%np_part, 1:3))
2029 safe_allocate(delta(1:maxwell_system%gr%np, 1:3))
2042 call parse_variable(namespace,
'TestVectorPotentialType', option__testvectorpotentialtype__bounded, nn)
2045 case (option__testvectorpotentialtype__bounded)
2046 do ip = 1, maxwell_system%gr%np_part
2047 xx = maxwell_system%gr%x(1, ip)
2048 yy = maxwell_system%gr%x(2, ip)
2049 zz = maxwell_system%gr%x(3, ip)
2050 exp_factor =
exp((-xx**2 - yy**2 - zz**2)*1/(2*sigma**2))
2051 magnetic_field(ip, 1) = exp_factor*yy*(1 - (-xx**2 + yy**2)/(3*sigma**2) - zz**2/(3*sigma**2))
2052 magnetic_field(ip, 2) = exp_factor * xx * (1 + (-xx**2 + yy**2)/(3*sigma**2) - zz**2/(3*sigma**2))
2053 magnetic_field(ip, 3) = exp_factor * 2 * xx * yy * zz * 1/(3*sigma**2)
2055 vector_potential_analytical(ip, 1) = m_third * xx * zz * exp_factor
2056 vector_potential_analytical(ip, 2) = - m_third * yy * zz * exp_factor
2057 vector_potential_analytical(ip, 3) = m_third * (-xx**2 + yy**2) * exp_factor
2059 case (option__testvectorpotentialtype__unbounded)
2061 do ip = 1, maxwell_system%gr%np_part
2062 magnetic_field(ip, 1) = maxwell_system%gr%x(2, ip)
2063 magnetic_field(ip, 2) = maxwell_system%gr%x(1, ip)
2064 magnetic_field(ip, 3) = m_zero
2066 vector_potential_analytical(ip, 1) = m_third * maxwell_system%gr%x(1, ip) * maxwell_system%gr%x(3, ip)
2067 vector_potential_analytical(ip, 2) = - m_third * maxwell_system%gr%x(2, ip) * maxwell_system%gr%x(3, ip)
2068 vector_potential_analytical(ip, 3) = - m_third * (maxwell_system%gr%x(1, ip)**2 - maxwell_system%gr%x(2, ip)**2)
2071 call maxwell_system%helmholtz%get_vector_potential(namespace, vector_potential_mag, magnetic_field)
2075 do ip = 1, maxwell_system%gr%np
2076 delta(ip,j) = vector_potential_analytical(ip, j) - vector_potential_mag(ip, j)
2081 write(message(j),*)
'j, norm2(delta)', j, norm2(delta(:,j))
2083 call messages_info(3)
2085 write(fname,
'(a)')
'deviation_from_analytical_formulation'
2086 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, maxwell_system%space, maxwell_system%gr, &
2087 delta, unit_one, ierr)
2088 write(fname2,
'(a)')
'vector_potential_analytical'
2089 call io_function_output_vector(out_how ,
'./' , trim(fname2), namespace, maxwell_system%space, maxwell_system%gr, &
2090 vector_potential_analytical, unit_one, ierr)
2091 write(fname3,
'(a)')
'vector_potential_mag'
2092 call io_function_output_vector(out_how ,
'./' , trim(fname3), namespace, maxwell_system%space, maxwell_system%gr, &
2093 vector_potential_mag, unit_one, ierr)
2095 safe_deallocate_a(magnetic_field)
2096 safe_deallocate_a(vector_potential_mag)
2097 safe_deallocate_a(vector_potential_analytical)
2098 safe_deallocate_a(delta)
2099 safe_deallocate_p(maxwell_system)
2105 type(multigrid_t),
intent(in) :: mgrid
2106 class(space_t),
intent(in) :: space
2108 real(real64),
allocatable :: guess0(:), res0(:), guess1(:)
2109 type(mesh_t),
pointer :: mesh0, mesh1
2110 real(real64) :: delta, xx(3,2), alpha, beta, rr
2111 integer :: nn, ip, ierr
2115 message(1) =
'Info: Testing the grid interpolation.'
2117 call messages_info(2)
2119 mesh0 => mgrid%level(0)%mesh
2120 mesh1 => mgrid%level(1)%mesh
2122 safe_allocate(guess0(1:mesh0%np_part))
2123 safe_allocate(res0(1:mesh0%np_part))
2124 safe_allocate(guess1(1:mesh1%np_part))
2126 alpha = m_four*mesh0%spacing(1)
2127 beta = m_one / (alpha**space%dim *
sqrt(m_pi)**space%dim)
2142 call mesh_r(mesh0, ip, rr, origin = xx(:, nn))
2143 guess0(ip) = guess0(ip) + (-1)**nn * beta*
exp(-(rr/alpha)**2)
2147 call dio_function_output (io_function_fill_how(
'AxisX'),
".",
"interpolation_target", global_namespace, &
2148 space, mesh0, guess0, unit_one, ierr)
2149 call dio_function_output (io_function_fill_how(
'AxisZ'),
".",
"interpolation_target", global_namespace, &
2150 space, mesh0, guess0, unit_one, ierr)
2151 call dio_function_output (io_function_fill_how(
'PlaneZ'),
".",
"interpolation_target", global_namespace, &
2152 space, mesh0, guess0, unit_one, ierr)
2159 call dmultigrid_fine2coarse(mgrid%level(1)%tt, mgrid%level(0)%der, mesh1, guess0, guess1, injection)
2161 call dmultigrid_coarse2fine(mgrid%level(1)%tt, mgrid%level(1)%der, mesh0, guess1, res0)
2163 call dio_function_output (io_function_fill_how(
'AxisX'),
".",
"interpolation_result", global_namespace, &
2164 space, mesh0, res0, unit_one, ierr)
2165 call dio_function_output (io_function_fill_how(
'AxisZ'),
".",
"interpolation_result", global_namespace, &
2166 space, mesh0, res0, unit_one, ierr)
2167 call dio_function_output (io_function_fill_how(
'PlaneZ'),
".",
"interpolation_result", global_namespace, &
2168 space, mesh0, res0, unit_one, ierr)
2170 delta = dmf_nrm2(mesh0, guess0(1:mesh0%np)-res0(1:mesh0%np))
2171 write(message(1),
'(a,e13.6)')
'Interpolation test (abs.) = ', delta
2177 call dmultigrid_fine2coarse(mgrid%level(1)%tt, mgrid%level(0)%der, mesh1, guess0, guess1, fullweight)
2179 call dmultigrid_coarse2fine(mgrid%level(1)%tt, mgrid%level(1)%der, mesh0, guess1, res0)
2181 call dio_function_output (io_function_fill_how(
'AxisX'),
".",
"restriction_result", global_namespace, &
2182 space, mesh0, res0, unit_one, ierr)
2183 call dio_function_output (io_function_fill_how(
'AxisZ'),
".",
"restriction_result", global_namespace, &
2184 space, mesh0, res0, unit_one, ierr)
2185 call dio_function_output (io_function_fill_how(
'PlaneZ'),
".",
"restriction_result", global_namespace, &
2186 space, mesh0, res0, unit_one, ierr)
2188 delta = dmf_nrm2(mesh0, guess0(1:mesh0%np)-res0(1:mesh0%np))
2189 write(message(2),
'(a,e13.6)')
'Restriction test (abs.) = ', delta
2190 call messages_info(2)
2192 safe_deallocate_a(guess0)
2193 safe_deallocate_a(res0)
2194 safe_deallocate_a(guess1)
2202 type(namespace_t),
intent(in) :: namespace
2203 type(electrons_t),
pointer :: sys
2205 type(current_t) :: current
2206 character(len=MAX_PATH_LEN) :: fname
2207 integer :: ierr, ip, idir
2208 integer(int64) :: out_how
2209 real(real64),
allocatable :: current_para_ref(:,:), current_dia_ref(:,:), current_mag_ref(:,:), delta(:)
2210 real(real64) :: xx(3), rr, a0, mag_curr, sin_thet, sin_phi, cos_phi, vec_pot_slope
2211 complex(real64) :: alpha
2213 sys => electrons_t(namespace, int(option__calculationmode__dummy, int32))
2214 call sys%init_parallelization(mpi_world)
2216 alpha = (0.0_real64, 0.5_real64)
2218 vec_pot_slope = 0.4_real64
2220 call states_elec_allocate_wfns(sys%st, sys%gr, wfs_type = type_cmplx)
2223 call current_init(current, namespace)
2225 call hamiltonian_elec_epot_generate(sys%hm, sys%namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, sys%st)
2227 safe_allocate(sys%hm%hm_base%vector_potential(1:3, 1:sys%gr%np))
2229 sys%hm%hm_base%vector_potential = m_zero
2230 do ip = 1, sys%gr%np
2231 xx = sys%gr%x(1:3, ip)
2232 sys%hm%hm_base%vector_potential(2, ip) = vec_pot_slope * xx(1) / p_c
2235 call states_elec_allocate_current(sys%st, sys%space, sys%gr)
2236 call density_calc(sys%st, sys%gr, sys%st%rho)
2238 call current_calculate(current, namespace, sys%gr, sys%hm, sys%space, sys%st)
2240 safe_allocate(current_para_ref(1:sys%gr%np,1:3))
2241 safe_allocate(current_dia_ref(1:sys%gr%np,1:3))
2242 safe_allocate(current_mag_ref(1:sys%gr%np,1:3))
2243 safe_allocate(delta(1:sys%gr%np))
2246 current_para_ref(:,:) = m_zero
2247 do ip = 1, sys%gr%np
2248 call mesh_r(sys%gr, ip, rr)
2249 xx = sys%gr%x(1:3, ip)
2250 if (rr > r_small)
then
2252 psi_1s(rr, a0) *
dr_psi_2s(rr, a0) ) * aimag(alpha) / (1 + abs(alpha)**2) * xx(1:3) / rr
2256 write(fname,
'(a)')
'current_para'
2257 out_how = io_function_fill_how(
"PlaneZ")
2258 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2259 sys%st%current_para(:,:,1), unit_one, ierr)
2261 write(fname,
'(a)')
'current_para-ref'
2262 out_how = io_function_fill_how(
"PlaneZ")
2263 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2264 current_para_ref(:,:), unit_one, ierr)
2268 delta(:) = current_para_ref(1:sys%gr%np, idir) - sys%st%current_para(1:sys%gr%np, idir, 1)
2269 write(message(idir),*)
'idir =',idir,
', norm2(delta paramagnetic)',norm2(delta)
2271 call messages_info(3)
2274 current_dia_ref(:,:) = m_zero
2275 do ip = 1, sys%gr%np
2276 call mesh_r(sys%gr, ip, rr)
2277 current_dia_ref(ip,1:3) = - sys%hm%hm_base%vector_potential(1:3,ip) *&
2281 write(fname,
'(a)')
'current_dia'
2282 out_how = io_function_fill_how(
"PlaneZ")
2283 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2284 sys%st%current_dia(:,:,1), unit_one, ierr)
2286 write(fname,
'(a)')
'current_dia-ref'
2287 out_how = io_function_fill_how(
"PlaneZ")
2288 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2289 current_dia_ref(:,:), unit_one, ierr)
2293 delta(:) = current_dia_ref(1:sys%gr%np, idir) - sys%st%current_dia(1:sys%gr%np, idir, 1)
2294 write(message(idir),*)
'idir =',idir,
', norm2(delta diamagnetic)',norm2(delta)
2296 call messages_info(3)
2299 call current_calculate_mag(sys%gr%der, sys%st)
2302 current_mag_ref(:,:) = m_zero
2303 do ip = 1, sys%gr%np
2304 call mesh_r(sys%gr, ip, rr)
2305 xx = sys%gr%x(1:3, ip)
2306 if (norm2(xx(1:2)) > r_small .and. rr > r_small)
then
2307 sin_thet = norm2(xx(1:2)) / rr
2308 sin_phi = xx(2) / norm2(xx(1:2))
2309 cos_phi = xx(1) / norm2(xx(1:2))
2313 current_mag_ref(ip,1) = m_half * mag_curr * sin_thet * sin_phi / (1+abs(alpha)**2)
2314 current_mag_ref(ip,2) = -m_half * mag_curr * sin_thet * cos_phi / (1+abs(alpha)**2)
2318 write(fname,
'(a)')
'current_mag'
2319 out_how = io_function_fill_how(
"PlaneZ")
2320 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2321 sys%st%current_mag(:,:,1), unit_one, ierr)
2323 write(fname,
'(a)')
'current_mag-ref'
2324 out_how = io_function_fill_how(
"PlaneZ")
2325 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2326 current_mag_ref(:,:), unit_one, ierr)
2330 delta(:) = current_mag_ref(1:sys%gr%np, idir) - sys%st%current_mag(1:sys%gr%np, idir, 1)
2331 write(message(idir),*)
'idir =',idir,
', norm2(delta magnetization)',norm2(delta)
2333 call messages_info(3)
2335 safe_deallocate_a(current_para_ref)
2336 safe_deallocate_a(current_dia_ref)
2337 safe_deallocate_a(current_mag_ref)
2338 safe_deallocate_a(delta)
2339 safe_deallocate_p(sys)
2345 class(batch_t),
intent(inout) :: psib
2346 class(mesh_t),
intent(in) :: mesh
2347 type(namespace_t),
intent(in) :: namespace
2348 complex(real64),
intent(in) :: alpha
2349 real(real64),
intent(in) :: a0
2351 complex(real64),
allocatable :: zff(:)
2358 safe_allocate(zff(1:mesh%np))
2359 if (type_is_complex(psib%type()))
then
2361 call mesh_r(mesh, ip, rr)
2363 call batch_set_state(psib, 1, mesh%np, zff)
2365 safe_deallocate_a(zff)
2367 write(message(1),*)
"States should be complex for the linear combination of hydrogenic states to work"
2368 call messages_info(1, namespace=namespace)
2375 real(real64),
intent(in) :: a0, rr
2376 complex(real64),
intent(in) :: alpha
2382 real(real64) function psi_1s(rr, a0)
2383 real(real64),
intent(in) :: a0, rr
2389 real(real64) function psi_2s(rr, a0)
2390 real(real64),
intent(in) :: a0, rr
2392 psi_2s =
sqrt(m_two) * a0**(-m_three/m_two) * (m_one - rr/(m_two * a0)) *
exp(-rr/(m_two * a0)) &
2393 / (m_two *
sqrt(m_pi))
2396 real(real64) function dr_psi_1s(rr, a0)
2397 real(real64),
intent(in) :: a0, rr
2402 real(real64) function dr_psi_2s(rr, a0)
2403 real(real64),
intent(in) :: a0, rr
2406 a0**(-m_five/m_two) *
exp(-rr/(m_two * a0)) / (
sqrt(m_two) * m_two *
sqrt(m_pi))
2411 type(namespace_t),
intent(in) :: namespace
2414 integer(int64) :: i, j, k
2415 integer(int64) :: dims(3)
2416 character(len=MAX_PATH_LEN) :: fname
2418 real(real64),
allocatable :: ff(:)
2428 call parse_variable(namespace,
'TestCSVFileName',
"", fname)
2430 message(1) =
"Attempting to probe "//trim(fname)
2431 call messages_info(1, namespace=namespace)
2433 call io_csv_get_info(fname, dims, ierr)
2435 message(1) =
"Probing successful."
2436 write(message(2),
'("found dimensions: ",3I20)') dims
2437 call messages_info(2, namespace=namespace)
2439 write(message(1),
'("Probing failed. ierr = ",I5)') ierr
2440 call messages_fatal(1, namespace=namespace)
2443 safe_allocate(ff(1:dims(1)*dims(2)*dims(3)))
2445 message(1) =
"Attempting to read "//trim(fname)
2446 call messages_info(1, namespace=namespace)
2448 call dread_csv(fname, dims(1)*dims(2)*dims(3), ff, ierr)
2450 message(1) =
"Reading successful."
2451 call messages_info(1, namespace=namespace)
2453 do k=1, min(4_int64, dims(3))
2454 do j=1, min(4_int64, dims(2))
2455 write(message(j),
'("data ",2I5, 1X, 4F8.2)') k, j, &
2456 (ff(i + dims(1)*(j-1) + dims(1)* dims(2)*(k-1)), i=1, min(4_int64, dims(1)))
2458 write(message(int(j, int32)),
'("")')
2459 call messages_info(int(j, int32), namespace=namespace)
2463 message(1) =
"Reading failed."
2464 call messages_fatal(1, namespace=namespace)
2467 safe_deallocate_a(ff)
batchified version of the BLAS axpy routine:
scale a batch by a constant or vector
There are several ways how to call batch_set_state and batch_get_state:
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
double exp(double __x) __attribute__((__nothrow__
double sqrt(double __x) __attribute__((__nothrow__
pure logical function, public accel_is_enabled()
This module implements batches of mesh functions.
This module implements common operations on batches of mesh functions.
subroutine, public dbatch_ax_function_py(np, aa, psi, yy)
This routine performs a set of axpy operations adding the same function psi to all functions of a bat...
subroutine, public batch_set_zero(this, np, async)
fill all mesh functions of the batch with zero
subroutine, public zbatch_ax_function_py(np, aa, psi, yy)
This routine performs a set of axpy operations adding the same function psi to all functions of a bat...
Module implementing boundary conditions in Octopus.
Module, implementing a factory for boxes.
This module handles the calculation mode.
integer, parameter, public p_strategy_kpoints
parallelization in k-points
integer, parameter, public p_strategy_domains
parallelization in domains
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer, parameter, public p_strategy_states
parallelization in states
subroutine, public cgal_polyhedron_init(cgal_poly, fname, verbose)
logical function, public cgal_polyhedron_point_inside(cgal_poly, xq, yq, zq)
subroutine, public cgal_polyhedron_end(cgal_poly)
pure real(real64) function center(this)
Center of the filter interval.
This module implements a calculator for the density and defines related functions.
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
This module provides unit tests for the derivatives.
subroutine, public zderivatives_test(this, namespace, repetitions, min_blocksize, max_blocksize)
unit test for derivatives
subroutine, public dderivatives_test(this, namespace, repetitions, min_blocksize, max_blocksize)
unit test for derivatives
subroutine, public derivatives_advanced_benchmark(this, namespace)
Further unit tests design to challenge numerical stability of the finite differences.
subroutine, public zchebyshev_filter(namespace, mesh, st, hm, degree, bounds, ik, normalize)
Chebyshev Filter.
subroutine, public dchebyshev_filter(namespace, mesh, st, hm, degree, bounds, ik, normalize)
Chebyshev Filter.
integer, parameter, public spin_polarized
subroutine, public exponential_init(te, namespace, full_batch)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_four
real(real64), parameter, public m_pi
some mathematical constants
complex(real64), parameter, public m_zi
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
subroutine, public zhamiltonian_elec_apply_batch(hm, namespace, mesh, psib, hpsib, terms, set_bc)
subroutine, public hamiltonian_elec_end(hm)
subroutine, public hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
subroutine, public hamiltonian_elec_copy(hm_out, hm_in)
Deep-copy a hamiltonian_elec_t snapshot.
subroutine, public dhamiltonian_elec_apply_batch(hm, namespace, mesh, psib, hpsib, terms, set_bc)
type(hardware_t), public cpu_hardware
Global instance of CPU hardware specification.
integer, parameter, public sizeof_real64
Number of bytes to store a variable of type real(real64)
integer, parameter, public sizeof_complex64
Number of bytes to store a variable of type complex(real64)
The Helmholtz decomposition is intended to contain "only mathematical" functions and procedures to co...
Test suit for the Helmholtz decomposition module.
subroutine, public gaussian_test(helmholtz, sys_grid, namespace, space)
subroutine, public hertzian_dipole_test(helmholtz, sys_grid, namespace, space)
This module implements a simple hash table for non-negative integer keys and integer values.
subroutine, public iihash_end(h)
Free a hash table.
subroutine, public iihash_insert(h, key, val)
Insert a (key, val) pair into the hash table h.
integer function, public iihash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
subroutine, public iihash_init(h)
Initialize a hash table h.
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
integer(int64) function, public io_function_fill_how(where)
Use this function to quickly plot functions for debugging purposes: call dio_function_output(io_funct...
subroutine, public ion_interaction_test(space, latt, atom, natoms, pos, lsize, namespace, mc)
This modules takes care of testing some linear algebra routines.
subroutine, public test_exponential_matrix(namespace)
Unit tests for the exponential of a matrix.
Computes and , suitable as an operator callback for iterative solvers (CG, QMR, etc....
subroutine, public dshifted_laplacian_op(x, lx, userdata)
Computes the shifted Laplacian operator: .
This module defines functions over batches of mesh functions.
subroutine, public dmesh_batch_dotp_matrix(mesh, aa, bb, dot, reduce)
Calculate the overlap matrix of two batches.
subroutine, public dmesh_batch_dotp_self(mesh, aa, dot, reduce)
calculate the overlap matrix of a batch with itself
subroutine, public mesh_batch_nrm2(mesh, aa, nrm2, reduce)
Calculate the norms (norm2, not the square!) of a batch of mesh functions.
subroutine, public zmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
calculate the vector of dot-products of mesh functions between two batches
subroutine, public zmesh_batch_dotp_matrix(mesh, aa, bb, dot, reduce)
Calculate the overlap matrix of two batches.
subroutine, public zmesh_batch_normalize(mesh, psib, norm)
Normalize a batch.
subroutine, public zmesh_batch_dotp_self(mesh, aa, dot, reduce)
calculate the overlap matrix of a batch with itself
subroutine, public dmesh_batch_normalize(mesh, psib, norm)
Normalize a batch.
subroutine, public dmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
calculate the vector of dot-products of mesh functions between two batches
This module defines various routines, operating on mesh functions.
real(real64) function, public dmf_dotp_aux(f1, f2)
dot product between two vectors (mesh functions)
subroutine, public mesh_init_mesh_aux(mesh)
Initialise a pointer to the grid/mesh, that is globally exposed, such that low level mesh operations ...
subroutine, public zmesh_interpolation_test(mesh)
subroutine, public dmesh_interpolation_test(mesh)
This module defines the meshes, which are used in Octopus.
pure subroutine, public mesh_r(mesh, ip, rr, origin, coords)
return the distance to the origin for a given grid point
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
character(len=512), private msg
subroutine, public messages_obsolete_variable(namespace, name, rep)
subroutine, public messages_new_line()
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This modules takes care of testing optimizers using standard test functions.
subroutine, public test_optimizers(namespace)
Unit tests for different optimizers.
This module implements unit tests for the mixing methods.
subroutine, public mix_tests_run()
type(mpi_grp_t), public mpi_world
subroutine, public test_mpiwrappers
This module handles the communicators for the various parallelization strategies.
subroutine, public multigrid_end(mgrid)
subroutine, public multigrid_init(mgrid, namespace, space, mesh, der, stencil, mc, nlevels)
type(namespace_t), public global_namespace
subroutine, public orbitalbasis_end(this)
subroutine, public zorbitalbasis_build(this, namespace, ions, mesh, kpt, ndim, skip_s_orb, use_all_orb, verbose)
This routine is an interface for constructing the orbital basis.
subroutine, public dorbitalbasis_build(this, namespace, ions, mesh, kpt, ndim, skip_s_orb, use_all_orb, verbose)
This routine is an interface for constructing the orbital basis.
subroutine, public orbitalbasis_init(this, namespace, periodic_dim)
subroutine, public dorbitalset_add_to_batch(os, ndim, psib, weight)
subroutine, public zorbitalset_add_to_batch(os, ndim, psib, weight)
subroutine, public orbitalset_update_phase(os, dim, kpt, kpoints, spin_polarized, vec_pot, vec_pot_var, kpt_max)
Build the phase correction to the global phase in case the orbital crosses the border of the simulato...
subroutine, public dorbitalset_get_coeff_batch(os, ndim, psib, dot, reduce)
subroutine, public zorbitalset_get_coeff_batch(os, ndim, psib, dot, reduce)
subroutine, public poisson_test(this, space, mesh, latt, namespace, repetitions)
This routine checks the Hartree solver selected in the input file by calculating numerically and anal...
subroutine, public preconditioner_end(this)
subroutine, public preconditioner_init(this, namespace, gr, mc, space)
subroutine, public zproject_psi_batch(mesh, bnd, pj, npj, dim, psib, ppsib)
To optimize the application of the non-local operator in parallel, the projectors are applied in step...
Implementation details for regridding.
This module implements a simple hash table for string valued keys and integer values using the C++ ST...
subroutine, public sihash_insert(h, key, val)
Insert a (key, val) pair into the hash table h.
subroutine, public sihash_init(h)
Initialize a hash table h with size entries. Since we use separate chaining, the number of entries in...
integer function, public sihash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
subroutine, public sihash_end(h)
Free a hash table.
This module is intended to contain "only mathematical" functions and procedures.
This module implements a simple hash table for string valued keys and integer values using the C++ ST...
subroutine, public sphash_init(h)
Initialize a hash table h with size entries. Since we use separate chaining, the number of entries in...
subroutine, public sphash_insert(h, key, val, clone)
Insert a (key, val) pair into the hash table h. If clone=.true., the object will be copied.
subroutine, public sphash_end(h)
Free a hash table.
class(*) function, pointer, public sphash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
pure logical function, public states_are_real(st)
subroutine, public zstates_elec_calc_orth_test(st, namespace, mesh, kpoints)
subroutine, public dstates_elec_calc_orth_test(st, namespace, mesh, kpoints)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_deallocate_wfns(st)
Deallocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public dsubspace_diag(this, namespace, mesh, st, hm, ik, eigenval, diff, nonortho)
Diagonalises the Hamiltonian in the subspace defined by the states.
subroutine, public zsubspace_diag(this, namespace, mesh, st, hm, ik, eigenval, diff, nonortho)
Diagonalises the Hamiltonian in the subspace defined by the states.
Integration tests for ISDF.
subroutine, public test_isdf(namespace, serial)
Set up an electron system, compute some optimal centroid positions, and use these to build a set of I...
subroutine, public test_weighted_kmeans(namespace)
Test weighted kmeans algorithm for a finite system.
This module implements a unit-test like runmode for Octopus.
real(real64) function psi_2s(rr, a0)
subroutine test_helmholtz_decomposition(namespace)
subroutine test_hartree(param, namespace)
subroutine test_derivatives(param, namespace)
subroutine test_subspace_diagonalization(param, namespace)
subroutine, public test_run(namespace)
Components and integration test runner.
subroutine test_density_calc(param, namespace)
real(real64) function psi_1s(rr, a0)
subroutine test_current_density(namespace)
Here we test the different contributions to the total electronic current density.
subroutine test_batch_set_gaussian(psib, mesh)
subroutine test_regridding(namespace)
subroutine test_sphash(namespace)
subroutine test_hamiltonian(param, namespace)
subroutine test_dense_eigensolver()
subroutine test_interpolation(param, namespace)
subroutine multigrid_test_interpolation(mgrid, space)
subroutine test_ion_interaction(namespace)
subroutine test_boundaries(param, namespace)
subroutine test_orthogonalization(param, namespace)
real(real64) function dr_psi_2s(rr, a0)
subroutine test_batch_ops(param, namespace)
complex(real64) function lc_hydrogen_state(rr, alpha, a0)
subroutine test_projector(param, namespace)
subroutine test_dft_u(param, namespace)
subroutine test_prints_info_batch(st, gr, psib, string)
subroutine test_composition_chebyshev(namespace)
Test the composition rule for Chebyshev polynomials.
real(real64) function dr_psi_1s(rr, a0)
subroutine test_linear_solver(namespace)
subroutine test_grid_interpolation()
subroutine set_hydrogen_states(psib, mesh, namespace, alpha, a0)
subroutine test_exponential(param, namespace)
subroutine test_csv_input(namespace)
subroutine test_vecpot_analytical(namespace)
Here, analytical formulation for vector potential and B field are used. Ref: Sangita Sen and Erik I....
type(type_t), public type_cmplx
logical pure function, public type_is_complex(this)
This module defines the unit system, used for input and output.
type(unit_t), public unit_one
some special units required for particular quantities
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Class defining batches of mesh functions.
Overload default constructor.
Class describing the electron system.
Description of the grid, containing information on derivatives, stencil, and symmetries.
This class implements the iteration counter used by the multisystem algorithms. As any iteration coun...
Describes mesh distribution to nodes.
contains the information of the meshes and provides the transfer functions
The states_elec_t class contains all electronic wave functions.
batches of electronic states
subroutine write_clock(operation)
subroutine write_condition_result(condition, result)
real(real64) function values(xx)