54 use,
intrinsic :: iso_fortran_env
106 real(real64) :: shift_aux
107 type(derivatives_t),
pointer :: der_aux => null()
108 type(preconditioner_t) :: prec_aux
118 type(namespace_t),
intent(in) :: namespace
120 type(test_parameters_t) :: param
127 call param%init_from_file(namespace)
210 call parse_variable(namespace,
'TestMode', option__testmode__hartree, test_mode)
220 select case (test_mode)
221 case (option__testmode__hartree)
223 case (option__testmode__derivatives)
225 case (option__testmode__orthogonalization)
227 case (option__testmode__interpolation)
229 case (option__testmode__ion_interaction)
231 case (option__testmode__projector)
233 case (option__testmode__dft_u)
235 case (option__testmode__hamiltonian_apply)
237 case (option__testmode__density_calc)
239 case (option__testmode__exp_apply)
241 case (option__testmode__boundaries)
243 case (option__testmode__subspace_diag)
245 case (option__testmode__batch_ops)
247 case (option__testmode__clock)
249 case (option__testmode__linear_solver)
251 case (option__testmode__cgal)
253 case (option__testmode__dense_eigensolver)
255 case (option__testmode__grid_interpolation)
257 case (option__testmode__iihash)
259 case (option__testmode__sihash)
261 case (option__testmode__sphash)
263 case (option__testmode__mpiwrappers)
265 case (option__testmode__regridding)
267 case (option__testmode__helmholtz_decomposition)
269 case (option__testmode__vecpot_analytical)
271 case (option__testmode__current_density)
273 case (option__testmode__mixing_tests)
275 case (option__testmode__optimizers)
277 case (option__testmode__weighted_kmeans)
279 case (option__testmode__csv_input)
281 case (option__testmode__composition_chebyshev)
283 case (option__testmode__lalg_adv)
285 case (option__testmode__isdf_serial)
287 case (option__testmode__isdf)
305 sys =>
electrons_t(namespace, generate_epot=.false.)
307 call poisson_test(sys%hm%psolver, sys%space, sys%gr, sys%ions%latt, namespace, param%repetitions)
308 safe_deallocate_p(sys)
325 sys =>
electrons_t(namespace, generate_epot=.false.)
328 call helmholtz%init(namespace, sys%gr, sys%mc, sys%space)
331 write(
message(1),
'(a)')
"Helmholtz decomposition: beginning Hertzian dipole test"
335 write(
message(1),
'(a)')
"Helmholtz decomposition: beginning Gaussian test"
337 call gaussian_test(helmholtz, sys%gr, sys%namespace, sys%space)
339 safe_deallocate_p(sys)
346 use,
intrinsic :: iso_c_binding, only: c_ptr
350 real(real64),
allocatable :: rho(:), x(:),
center(:)
351 real(real64) :: rr, alpha, beta, res
354 real(real64),
parameter :: threshold = 1.e-7_real64
355 type(c_ptr) :: userdata(0)
361 sys =>
electrons_t(namespace, generate_epot=.false.)
367 shift_aux = 0.25_real64
375 alpha =
m_four * sys%gr%spacing(1)
376 beta =
m_one / (alpha**sys%space%dim *
sqrt(
m_pi)**sys%space%dim)
378 safe_allocate(
center(1:sys%space%dim))
381 safe_allocate(rho(1:sys%gr%np))
385 rho(ip) = beta*
exp(-(rr/alpha)**2)
388 safe_allocate(x(1:sys%gr%np))
394 write(
message(1),
'(a,i6,a)')
"Info: CG converged with ", iter,
" iterations."
395 write(
message(2),
'(a,e14.6)')
"Info: The residue is ", res
396 write(
message(3),
'(a,e14.6)')
"Info: Norm solution CG ",
dmf_nrm2(sys%gr, x)
401 safe_deallocate_a(rho)
402 safe_deallocate_p(sys)
417 use,
intrinsic :: iso_c_binding, only: c_ptr
418 real(real64),
contiguous,
intent(in) :: x(:)
419 real(real64),
contiguous,
intent(out) :: Hx(:)
420 type(c_ptr),
intent(in) :: userdata(:)
422 real(real64),
allocatable :: tmpx(:)
426 safe_allocate(tmpx(1:
mesh_aux%np_part))
431 safe_deallocate_a(tmpx)
443 complex(real64),
allocatable :: psi(:, :)
449 call messages_write(
'Info: Testing the nonlocal part of the pseudopotential with SOC')
454 sys =>
electrons_t(namespace, generate_epot=.false.)
463 call sys%st%group%psib(1, 1)%copy_to(epsib)
467 do itime = 1, param%repetitions
469 sys%hm%ep%natoms, 2, sys%st%group%psib(1, 1), epsib)
472 safe_allocate(psi(1:sys%gr%np, 1:sys%st%d%dim))
473 do itime = 1, epsib%nst
475 write(
message(1),
'(a,i1,3x, f12.6)')
"Norm state ", itime,
zmf_nrm2(sys%gr, 2, psi)
478 safe_deallocate_a(psi)
482 safe_deallocate_p(sys)
494 integer :: itime, ist
496 real(real64),
allocatable :: ddot(:,:,:), dweight(:,:)
497 complex(real64),
allocatable :: zdot(:,:,:), zweight(:,:)
510 sys =>
electrons_t(namespace, generate_epot=.false.)
515 if (sys%st%pack_states)
call sys%st%pack()
517 call sys%st%group%psib(1, 1)%copy_to(epsib2, copy_data = .
true.)
520 if (.not. sys%hm%phase%is_allocated())
then
521 call sys%st%group%psib(1, 1)%copy_to(epsib, copy_data = .
true.)
523 call sys%st%group%psib(1, 1)%copy_to(epsib)
524 call sys%hm%phase%apply_to(sys%gr, sys%gr%np, &
525 .false., epsib, src=sys%st%group%psib(1, 1))
526 epsib2%has_phase = .
true.
532 call dorbitalbasis_build(basis, sys%namespace, sys%ions, sys%gr, sys%st%d%kpt, sys%st%d%dim, &
533 sys%hm%phase%is_allocated(), .false., .false.)
534 safe_allocate(dweight(1:basis%orbsets(1)%norbs, 1:epsib%nst_linear))
535 safe_allocate(ddot(1:sys%st%d%dim, 1:basis%orbsets(1)%norbs, 1:epsib%nst))
537 call zorbitalbasis_build(basis, sys%namespace, sys%ions, sys%gr, sys%st%d%kpt, sys%st%d%dim, &
538 sys%hm%phase%is_allocated(), .false., .false.)
540 safe_allocate(zweight(1:basis%orbsets(1)%norbs, 1:epsib%nst_linear))
541 safe_allocate(zdot(1:sys%st%d%dim, 1:basis%orbsets(1)%norbs, 1:epsib%nst))
544 if (sys%hm%phase%is_allocated())
then
550 do itime = 1, param%repetitions
565 if (epsib%is_packed())
then
566 call epsib%do_unpack(force = .
true.)
569 do ist = 1, epsib%nst
571 write(
message(1),
'(a,i2,3x,e13.6)')
"Dotp state ", ist, ddot(1,1,ist)
573 write(
message(1),
'(a,i2,2(3x,e13.6))')
"Dotp state ", ist, zdot(1,1,ist)
581 safe_deallocate_a(dweight)
582 safe_deallocate_a(zweight)
583 safe_deallocate_a(ddot)
584 safe_deallocate_a(zdot)
590 safe_deallocate_p(sys)
602 integer :: itime, terms
621 call parse_variable(namespace,
'TestHamiltonianApply', option__testhamiltonianapply__term_all, terms)
622 if (terms == 0) terms = huge(1)
627 call messages_write(
'Info: Testing the application of the Hamiltonian')
632 sys =>
electrons_t(namespace, generate_epot=.false.)
639 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
642 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
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)
648 if (sys%hm%apply_packed())
then
649 call sys%st%group%psib(1, 1)%do_pack()
650 call hpsib%do_pack(copy = .false.)
653 do itime = 1, param%repetitions
663 if (hpsib%is_packed())
then
664 call hpsib%do_unpack(force = .
true.)
669 call hpsib%end(copy = .false.)
671 safe_deallocate_p(sys)
694 sys =>
electrons_t(namespace, generate_epot=.false.)
699 if (sys%st%pack_states)
call sys%st%pack()
701 do itime = 1, param%repetitions
705 write(
message(1),
'(a,3x, f12.6)')
"Norm density ",
dmf_nrm2(sys%gr, sys%st%rho(:,1))
709 safe_deallocate_p(sys)
732 sys =>
electrons_t(namespace, generate_epot=.false.)
737 if (sys%st%pack_states)
call sys%st%pack()
739 do itime = 1, param%repetitions
740 call boundaries_set(sys%gr%der%boundaries, sys%gr, sys%st%group%psib(1, 1))
746 safe_deallocate_p(sys)
760 integer,
allocatable :: degree(:)
768 call messages_write(
'Info: Testing Chebyshev filtering and its composition rule')
778 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
781 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
784 safe_allocate(degree(1:sys%st%group%nblocks))
794 call parse_variable(namespace,
'TestCompositionOrder', 2, degree_n)
806 call dchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
808 call zchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
812 call messages_write(
'Info: Result after calling 2n-th order filtering')
818 call sys%st%group%psib(1, 1)%copy_to(psib, copy_data=.
true.)
821 call dchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
822 call dchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
824 call zchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
825 call zchebyshev_filter(namespace, sys%gr, sys%st, sys%hm, degree, bounds, 1, normalize=.false.)
836 safe_deallocate_a(degree)
837 safe_deallocate_p(bounds)
841 safe_deallocate_p(sys)
866 sys =>
electrons_t(namespace, generate_epot=.false.)
873 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
876 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
880 if (sys%hm%apply_packed())
then
881 call sys%st%group%psib(1, 1)%do_pack()
884 do itime = 1, param%repetitions
885 call te%apply_batch(sys%namespace, sys%gr, sys%hm, sys%st%group%psib(1, 1), 1e-3_real64)
891 safe_deallocate_p(sys)
905 real(real64),
allocatable :: diff(:)
916 sys =>
electrons_t(namespace, generate_epot=.false.)
922 if (sys%st%pack_states .and. sys%hm%apply_packed())
call sys%st%pack()
925 call v_ks_calc(sys%ks, sys%namespace, sys%space, sys%hm, sys%st, sys%ions, sys%ext_partners)
927 call sdiag%init(sys%namespace, sys%st)
929 safe_allocate(diff(1:sys%st%nst))
931 do itime = 1, param%repetitions
933 call dsubspace_diag(sdiag, sys%namespace, sys%gr, sys%st, sys%hm, 1, sys%st%eigenval(:, 1), diff)
935 call zsubspace_diag(sdiag, sys%namespace, sys%gr, sys%st, sys%hm, 1, sys%st%eigenval(:, 1), diff)
939 safe_deallocate_a(diff)
944 safe_deallocate_p(sys)
956 integer :: itime, ops, ops_default, ist, jst, nst
958 real(real64),
allocatable :: tmp(:)
959 real(real64),
allocatable :: ddotv(:)
960 complex(real64),
allocatable :: zdotv(:)
961 real(real64),
allocatable :: ddot(:,:), df(:,:), dweight(:), dpoints(:,:,:)
962 complex(real64),
allocatable :: zdot(:,:), zf(:,:), zweight(:), zpoints(:,:,:)
963 integer :: sp, block_size, size
992 option__testbatchops__ops_axpy + &
993 option__testbatchops__ops_scal + &
994 option__testbatchops__ops_nrm2 + &
995 option__testbatchops__ops_dotp_matrix + &
996 option__testbatchops__ops_dotp_self + &
997 option__testbatchops__ops_dotp_vector + &
998 option__testbatchops__ops_ax_function_py + &
999 option__testbatchops__ops_get_points
1010 sys =>
electrons_t(namespace, generate_epot=.false.)
1011 call sys%init_parallelization(
mpi_world)
1015 if (sys%st%pack_states)
call sys%st%pack()
1017 if (
bitand(ops, option__testbatchops__ops_axpy) /= 0)
then
1018 message(1) =
'Info: Testing axpy'
1021 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1022 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1024 do itime = 1, param%repetitions
1025 call batch_axpy(sys%gr%np, 0.1_real64, xx, yy)
1033 if (
bitand(ops, option__testbatchops__ops_scal) /= 0)
then
1034 message(1) =
'Info: Testing scal'
1037 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1038 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1040 do itime = 1, param%repetitions
1049 if (
bitand(ops, option__testbatchops__ops_nrm2) /= 0)
then
1050 message(1) =
'Info: Testing nrm2'
1053 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1054 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1056 safe_allocate(tmp(1:xx%nst))
1058 do itime = 1, param%repetitions
1061 do itime = 1, xx%nst
1062 write(
message(1),
'(a,i1,3x,e23.16)')
"Nrm2 norm state ", itime, tmp(itime)
1066 safe_deallocate_a(tmp)
1072 if (
bitand(ops, option__testbatchops__ops_dotp_matrix) /= 0)
then
1074 message(1) =
'Info: Testing dotp_matrix'
1077 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1078 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1080 nst = sys%st%group%psib(1, 1)%nst
1083 safe_allocate(ddot(1:nst, 1:nst))
1084 do itime = 1, param%repetitions
1090 write(
message(jst),
'(a,2i3,3x,e23.16)')
'Dotp_matrix states', ist, jst, ddot(ist,jst)
1094 safe_deallocate_a(ddot)
1096 safe_allocate(zdot(1:nst, 1:nst))
1097 do itime = 1, param%repetitions
1103 write(
message(jst),
'(a,2i3,3x,2(e23.16,1x))')
'Dotp_matrix states', ist, jst, zdot(ist,jst)
1107 safe_deallocate_a(zdot)
1114 if (
bitand(ops, option__testbatchops__ops_dotp_vector) /= 0)
then
1116 message(1) =
'Info: Testing dotp_vector'
1119 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1120 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1122 nst = sys%st%group%psib(1, 1)%nst
1125 safe_allocate(ddotv(1:nst))
1126 do itime = 1, param%repetitions
1131 write(
message(ist),
'(a,i3,3x,e23.16)')
'Dotp_vector state', ist, ddotv(ist)
1134 safe_deallocate_a(ddotv)
1136 safe_allocate(zdotv(1:nst))
1137 do itime = 1, param%repetitions
1142 write(
message(ist),
'(a,i3,3x,2(e23.16,1x))')
'Dotp_vector state', ist, zdotv(ist)
1145 safe_deallocate_a(zdotv)
1152 if (
bitand(ops, option__testbatchops__ops_dotp_self) /= 0)
then
1154 message(1) =
'Info: Testing dotp_self'
1157 call sys%st%group%psib(1, 1)%copy_to(xx, copy_data = .
true.)
1159 nst = sys%st%group%psib(1, 1)%nst
1162 safe_allocate(ddot(1:nst, 1:nst))
1163 do itime = 1, param%repetitions
1169 write(
message(jst),
'(a,2i3,3x,e23.16)')
'Dotp_self states', ist, jst, ddot(ist,jst)
1173 safe_deallocate_a(ddot)
1175 safe_allocate(zdot(1:nst, 1:nst))
1176 do itime = 1, param%repetitions
1182 write(
message(jst),
'(a,2i3,3x,2(e23.16,1x))')
'Dotp_self states', ist, jst, zdot(ist,jst)
1186 safe_deallocate_a(zdot)
1192 if (
bitand(ops, option__testbatchops__ops_ax_function_py) /= 0)
then
1193 message(1) =
'Info: Testing ax_function_py'
1196 call sys%st%group%psib(1, 1)%copy_to(yy, copy_data = .
true.)
1199 safe_allocate(df(sys%gr%np, sys%st%d%dim))
1200 safe_allocate(dweight(1:sys%st%group%psib(1, 1)%nst_linear))
1201 dweight = 0.1_real64
1204 do itime = 1, param%repetitions
1207 safe_deallocate_a(df)
1208 safe_deallocate_a(dweight)
1210 safe_allocate(zf(sys%gr%np, sys%st%d%dim))
1211 safe_allocate(zweight(1:sys%st%group%psib(1, 1)%nst_linear))
1212 zweight = cmplx(0.1_real64,
m_zero, real64)
1215 do itime = 1, param%repetitions
1218 safe_deallocate_a(zf)
1225 if (
bitand(ops, option__testbatchops__ops_get_points) /= 0)
then
1230 call sys%st%group%psib(1, 1)%copy_to(yy)
1236 safe_allocate(dpoints(1:sys%st%nst, 1:sys%st%d%dim, 1:block_size))
1238 do itime = 1, param%repetitions
1239 do sp = 1, sys%gr%np, block_size
1240 size = min(block_size, sys%gr%np - sp + 1)
1245 safe_deallocate_a(dpoints)
1251 safe_allocate(zpoints(1:sys%st%nst, 1:sys%st%d%dim, 1:block_size))
1253 do itime = 1, param%repetitions
1254 do sp = 1, sys%gr%np, block_size
1255 size = min(block_size, sys%gr%np - sp + 1)
1260 safe_deallocate_a(dpoints)
1271 safe_deallocate_p(sys)
1285 sys =>
electrons_t(namespace, generate_epot=.false.)
1286 call sys%init_parallelization(
mpi_world)
1288 message(1) =
'Info: Testing the finite-differences derivatives.'
1292 if (param%type == option__testtype__all .or. param%type == option__testtype__real)
then
1293 call dderivatives_test(sys%gr%der, sys%namespace, param%repetitions, param%min_blocksize, param%max_blocksize)
1296 if (param%type == option__testtype__all .or. param%type == option__testtype__complex)
then
1297 call zderivatives_test(sys%gr%der, sys%namespace, param%repetitions, param%min_blocksize, param%max_blocksize)
1300 safe_deallocate_p(sys)
1319 sys =>
electrons_t(namespace, generate_epot=.false.)
1320 call sys%init_parallelization(
mpi_world)
1322 message(1) =
'Info: Testing orthogonalization.'
1326 if (param%type == option__testtype__all .or. param%type == option__testtype__real)
then
1327 message(1) =
'Info: Real wave-functions.'
1329 do itime = 1, param%repetitions
1334 if (param%type == option__testtype__all .or. param%type == option__testtype__complex)
then
1335 message(1) =
'Info: Complex wave-functions.'
1337 do itime = 1, param%repetitions
1342 safe_deallocate_p(sys)
1357 sys =>
electrons_t(namespace, generate_epot=.false.)
1358 call sys%init_parallelization(
mpi_world)
1360 if (param%type == option__testtype__all .or. param%type == option__testtype__real)
then
1369 if (param%type == option__testtype__all .or. param%type == option__testtype__complex)
then
1371 call messages_write(
'Info: Testing complex interpolation routines')
1379 safe_deallocate_p(sys)
1394 sys =>
electrons_t(namespace, generate_epot=.false.)
1395 call sys%init_parallelization(
mpi_world)
1397 call ion_interaction_test(sys%space, sys%ions%latt, sys%ions%atom, sys%ions%natoms, sys%ions%pos, &
1398 sys%gr%box%bounding_box_l, namespace, sys%mc)
1400 safe_deallocate_p(sys)
1409 type(
grid_t),
intent(in) :: gr
1410 class(
batch_t),
intent(inout) :: psib
1411 character(*),
optional,
intent(in) :: string
1414 complex(real64),
allocatable :: zpsi(:, :)
1415 real(real64),
allocatable :: dpsi(:, :)
1417 character(80) :: string_
1424 safe_allocate(dpsi(1:gr%np, 1:st%d%dim))
1426 safe_allocate(zpsi(1:gr%np, 1:st%d%dim))
1429 do itime = 1, psib%nst
1432 write(
message(1),
'(a,i2,3x,e23.16)')
"Norm state "//trim(string_)//
" ", itime,
dmf_nrm2(gr, st%d%dim, dpsi)
1435 write(
message(1),
'(a,i2,3x,e23.16)')
"Norm state "//trim(string_)//
" ", itime,
zmf_nrm2(gr, st%d%dim, zpsi)
1441 safe_deallocate_a(dpsi)
1443 safe_deallocate_a(zpsi)
1459 write(
message(1),
'(a)')
" Operation Counter Time Global step"
1474 call clock%set(
clock_t(time_step=
m_four, initial_iteration=1))
1478 write(
message(1),
'(a)')
" Clock comparisons:"
1481 other_clock =
clock_t(time_step=
m_one, initial_iteration=5)
1493 character(len=*),
intent(in) :: operation
1495 write(
message(1),
'(a17,1x,i6,1x,f10.1,1x,i16)') operation, clock%counter(), clock%value(), clock%global_step()
1500 character(len=*),
intent(in) :: condition
1501 logical,
intent(in) :: result
1503 write(
message(1),
'(a10," = ",i1," (",l1,")")') condition, abs(transfer(result, 0)), result
1520 message(1) =
"cgal_polyhedron_point_inside"
1532 integer :: N, ii, jj, N_list(4), i_N
1533 real(real64),
allocatable :: matrix(:, :), eigenvectors(:, :), eigenvalues(:), test(:)
1534 real(real64),
allocatable :: differences(:)
1538 n_list = [15, 32, 100, 500]
1542 safe_allocate(matrix(1:n, 1:n))
1543 safe_allocate(eigenvectors(1:n, 1:n))
1544 safe_allocate(eigenvalues(1:n))
1545 safe_allocate(test(1:n))
1546 safe_allocate(differences(1:n))
1552 matrix(ii, jj) = ii * jj
1557 eigenvectors(1:n, 1:n) = matrix(1:n, 1:n)
1561 test(:) = matmul(matrix, eigenvectors(:, ii)) - eigenvalues(ii) * eigenvectors(:, ii)
1562 differences(ii) = sum(abs(test)) / sum(abs(eigenvectors(:, ii)))
1564 write(
message(1),
"(A, I3, A, E13.6)")
"Parallel solver - N: ", n, &
1565 ", average difference: ", sum(differences)/n
1569 eigenvectors(1:n, 1:n) = matrix(1:n, 1:n)
1573 test(:) = matmul(matrix, eigenvectors(:, ii)) - eigenvalues(ii) * eigenvectors(:, ii)
1574 differences(ii) = sum(abs(test)) / sum(abs(eigenvectors(:, ii)))
1576 write(
message(1),
"(A, I3, A, E13.6)")
"Serial solver - N: ", n, &
1577 ", average difference: ", sum(differences)/n
1580 safe_deallocate_a(matrix)
1581 safe_deallocate_a(eigenvectors)
1582 safe_deallocate_a(eigenvalues)
1583 safe_deallocate_a(test)
1584 safe_deallocate_a(differences)
1591 class(
batch_t),
intent(inout) :: psib
1592 class(
mesh_t),
intent(in) :: mesh
1594 real(real64),
allocatable :: dff(:)
1595 complex(real64),
allocatable :: zff(:)
1597 real(real64) :: da, db, dc
1598 complex(real64) :: za, zb, zc
1603 da =
m_one/mesh%box%bounding_box_l(1)
1609 za = da +
m_zi*0.01_real64
1610 zb = db*
exp(
m_zi*0.345_real64)
1611 zc = dc -
m_zi*50.0_real64
1613 safe_allocate(zff(1:mesh%np))
1614 do ist = 1, psib%nst_linear
1618 zff(ip) = zb*
exp(-za*sum(mesh%x(ip, :)**2)) + zc
1623 safe_deallocate_a(zff)
1625 safe_allocate(dff(1:mesh%np))
1626 do ist = 1, psib%nst_linear
1630 dff(ip) = db*
exp(-da*sum(mesh%x(ip, :)**2)) + dc
1635 safe_deallocate_a(dff)
1649 call sys%init_parallelization(
mpi_world)
1652 sys%gr%stencil, sys%mc, nlevels=3)
1658 safe_deallocate_p(sys)
1674 write(
message(1),*)
'hash[1] :', found,
value
1678 write(
message(1),*)
'hash[2] :', found,
value
1682 write(
message(1),*)
'hash[3] :', found,
value
1694 integer ::
value, sum
1703 write(
message(1),*)
'hash["one"]: ', found,
value
1707 write(
message(1),*)
'hash["two"]: ', found,
value
1711 write(
message(1),*)
'hash["three"]: ', found,
value
1718 do while (it%has_next())
1719 value = it%get_next()
1721 write(
message(1),
'(I3,A,I5)') counter,
': hash[...] = ',
value
1723 counter = counter + 1
1725 write(
message(1),*)
'counter = ', counter
1726 write(
message(2),*)
'sum = ', sum
1748 class(*),
pointer :: value
1750 integer :: count_clock, count_space
1752 safe_allocate(clock_2)
1766 write(
message(1),*)
'hash["one"]: ', found,
value%counter()
1769 write(
message(1),*)
'hash["one"]: ', found,
value%short_info()
1772 write(
message(1),*)
'wrong type. found = ', found
1779 write(
message(1),*)
'hash["two"]: ', found,
value%counter()
1782 write(
message(1),*)
'hash["two"]: ', found,
value%short_info()
1785 write(
message(1),*)
'wrong type. found = ',found
1789 safe_deallocate_a(clock_2)
1794 write(
message(1),*)
'hash["three"]: ', found,
value%counter()
1797 write(
message(1),*)
'hash["three"]: ', found,
value%short_info()
1800 write(
message(1),*)
'wrong type. found = ',found
1809 do while (it%has_next())
1810 value => it%get_next()
1813 count_clock = count_clock + 1
1815 count_space = count_space + 1
1819 write(
message(1), *)
'Count_clock = ', count_clock
1820 write(
message(2), *)
'Count_space = ', count_space
1833 real(real64),
allocatable :: ff_A(:), ff_A_reference(:), ff_B(:), ff_B_reference(:), diff_A(:), diff_B(:)
1834 real(real64) :: norm_ff, norm_diff
1843 call sysa%init_parallelization(
mpi_world)
1844 call sysb%init_parallelization(
mpi_world)
1847 safe_allocate(ff_a(1:sysa%gr%np))
1848 safe_allocate(ff_a_reference(1:sysa%gr%np))
1849 safe_allocate(diff_a(1:sysa%gr%np))
1850 safe_allocate(ff_b(1:sysb%gr%np))
1851 safe_allocate(ff_b_reference(1:sysb%gr%np))
1852 safe_allocate(diff_b(1:sysb%gr%np))
1854 do ip = 1, sysa%gr%np
1855 ff_a_reference(ip) =
values(sysa%gr%x(ip, :))
1857 do ip = 1, sysb%gr%np
1858 ff_b_reference(ip) =
values(sysb%gr%x(ip, :))
1862 regridding =>
regridding_t(sysb%gr, sysa%gr, sysa%space, sysa%namespace)
1863 call regridding%do_transfer(ff_b, ff_a_reference)
1864 safe_deallocate_p(regridding)
1867 do ip = 1, sysb%gr%np
1869 ff_b_reference(ip) =
m_zero
1872 diff_b(ip) = abs(ff_b_reference(ip) - ff_b(ip))
1875 norm_ff =
dmf_nrm2(sysb%gr, ff_b_reference)
1876 norm_diff =
dmf_nrm2(sysb%gr, diff_b)
1878 write(
message(1),
'(a, E14.6)')
"Forward: difference of reference to mapped function (rel.): ", &
1883 sysb%gr, ff_b_reference,
unit_one, ierr)
1887 sysa%gr, ff_a_reference,
unit_one, ierr)
1890 regridding =>
regridding_t(sysa%gr, sysb%gr, sysb%space, sysb%namespace)
1891 call regridding%do_transfer(ff_a, ff_b_reference)
1892 safe_deallocate_p(regridding)
1894 do ip = 1, sysa%gr%np
1896 ff_a_reference(ip) =
m_zero
1899 diff_a(ip) = abs(ff_a_reference(ip) - ff_a(ip))
1902 norm_ff =
dmf_nrm2(sysa%gr, ff_a_reference)
1903 norm_diff =
dmf_nrm2(sysa%gr, diff_a)
1905 write(
message(1),
'(a, E14.6)')
"Backward: difference of reference to mapped function (rel.): ", &
1910 sysa%gr, ff_a_reference,
unit_one, ierr)
1914 sysb%gr, ff_b_reference,
unit_one, ierr)
1916 safe_deallocate_a(ff_a)
1917 safe_deallocate_a(ff_a_reference)
1918 safe_deallocate_a(ff_b)
1919 safe_deallocate_a(ff_b_reference)
1920 safe_deallocate_a(diff_a)
1921 safe_deallocate_a(diff_b)
1922 safe_deallocate_p(sysa)
1923 safe_deallocate_p(sysb)
1929 real(real64) function values(xx)
1930 real(real64),
intent(in) :: xx(:)
1931 real(real64) :: xx0(1:size(xx, dim=1))
1932 real(real64),
parameter :: aa =
m_half
1933 real(real64),
parameter :: bb =
m_four
1937 values = bb *
exp(-aa*sum((xx-xx0)**2))
1947 type(namespace_t),
intent(in) :: namespace
1949 class(maxwell_t),
pointer :: maxwell_system
1951 real(real64),
allocatable :: magnetic_field(:,:)
1952 real(real64),
allocatable :: vector_potential_mag(:,:)
1953 real(real64),
allocatable :: vector_potential_analytical(:,:)
1954 real(real64),
allocatable :: delta(:,:)
1955 real(real64) :: exp_factor
1959 real(real64) :: sigma
1960 integer :: ip, j, ierr, nn
1961 integer(int64) :: out_how
1962 character(len=MAX_PATH_LEN) :: fname, fname2, fname3
1965 maxwell_system => maxwell_t(namespace)
1966 sigma = maxwell_system%gr%box%bounding_box_l(1)/10_real64
1967 call maxwell_system%init_parallelization(mpi_world)
1969 safe_allocate(magnetic_field(1:maxwell_system%gr%np_part, 1:3))
1970 safe_allocate(vector_potential_mag(1:maxwell_system%gr%np_part, 1:3))
1971 safe_allocate(vector_potential_analytical(1:maxwell_system%gr%np_part, 1:3))
1972 safe_allocate(delta(1:maxwell_system%gr%np, 1:3))
1985 call parse_variable(namespace,
'TestVectorPotentialType', option__testvectorpotentialtype__bounded, nn)
1988 case (option__testvectorpotentialtype__bounded)
1989 do ip = 1, maxwell_system%gr%np_part
1990 xx = maxwell_system%gr%x(ip, 1)
1991 yy = maxwell_system%gr%x(ip, 2)
1992 zz = maxwell_system%gr%x(ip, 3)
1993 exp_factor =
exp((-xx**2 - yy**2 - zz**2)*1/(2*sigma**2))
1994 magnetic_field(ip, 1) = exp_factor*yy*(1 - (-xx**2 + yy**2)/(3*sigma**2) - zz**2/(3*sigma**2))
1995 magnetic_field(ip, 2) = exp_factor * xx * (1 + (-xx**2 + yy**2)/(3*sigma**2) - zz**2/(3*sigma**2))
1996 magnetic_field(ip, 3) = exp_factor * 2 * xx * yy * zz * 1/(3*sigma**2)
1998 vector_potential_analytical(ip, 1) = m_third * xx * zz * exp_factor
1999 vector_potential_analytical(ip, 2) = - m_third * yy * zz * exp_factor
2000 vector_potential_analytical(ip, 3) = m_third * (-xx**2 + yy**2) * exp_factor
2002 case (option__testvectorpotentialtype__unbounded)
2004 do ip = 1, maxwell_system%gr%np_part
2005 magnetic_field(ip, 1) = maxwell_system%gr%x(ip, 2)
2006 magnetic_field(ip, 2) = maxwell_system%gr%x(ip, 1)
2007 magnetic_field(ip, 3) = m_zero
2009 vector_potential_analytical(ip, 1) = m_third * maxwell_system%gr%x(ip, 1) * maxwell_system%gr%x(ip, 3)
2010 vector_potential_analytical(ip, 2) = - m_third * maxwell_system%gr%x(ip, 2) * maxwell_system%gr%x(ip, 3)
2011 vector_potential_analytical(ip, 3) = - m_third * (maxwell_system%gr%x(ip, 1)**2 - maxwell_system%gr%x(ip, 2)**2)
2014 call maxwell_system%helmholtz%get_vector_potential(namespace, vector_potential_mag, magnetic_field)
2018 do ip = 1, maxwell_system%gr%np
2019 delta(ip,j) = vector_potential_analytical(ip, j) - vector_potential_mag(ip, j)
2024 write(message(j),*)
'j, norm2(delta)', j, norm2(delta(:,j))
2026 call messages_info(3)
2028 write(fname,
'(a)')
'deviation_from_analytical_formulation'
2029 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, maxwell_system%space, maxwell_system%gr, &
2030 delta, unit_one, ierr)
2031 write(fname2,
'(a)')
'vector_potential_analytical'
2032 call io_function_output_vector(out_how ,
'./' , trim(fname2), namespace, maxwell_system%space, maxwell_system%gr, &
2033 vector_potential_analytical, unit_one, ierr)
2034 write(fname3,
'(a)')
'vector_potential_mag'
2035 call io_function_output_vector(out_how ,
'./' , trim(fname3), namespace, maxwell_system%space, maxwell_system%gr, &
2036 vector_potential_mag, unit_one, ierr)
2038 safe_deallocate_a(magnetic_field)
2039 safe_deallocate_a(vector_potential_mag)
2040 safe_deallocate_a(vector_potential_analytical)
2041 safe_deallocate_a(delta)
2042 safe_deallocate_p(maxwell_system)
2048 type(multigrid_t),
intent(in) :: mgrid
2049 class(space_t),
intent(in) :: space
2051 real(real64),
allocatable :: guess0(:), res0(:), guess1(:)
2052 type(mesh_t),
pointer :: mesh0, mesh1
2053 real(real64) :: delta, xx(3,2), alpha, beta, rr
2054 integer :: nn, ip, ierr
2058 message(1) =
'Info: Testing the grid interpolation.'
2060 call messages_info(2)
2062 mesh0 => mgrid%level(0)%mesh
2063 mesh1 => mgrid%level(1)%mesh
2065 safe_allocate(guess0(1:mesh0%np_part))
2066 safe_allocate(res0(1:mesh0%np_part))
2067 safe_allocate(guess1(1:mesh1%np_part))
2069 alpha = m_four*mesh0%spacing(1)
2070 beta = m_one / (alpha**space%dim *
sqrt(m_pi)**space%dim)
2085 call mesh_r(mesh0, ip, rr, origin = xx(:, nn))
2086 guess0(ip) = guess0(ip) + (-1)**nn * beta*
exp(-(rr/alpha)**2)
2090 call dio_function_output (io_function_fill_how(
'AxisX'),
".",
"interpolation_target", global_namespace, &
2091 space, mesh0, guess0, unit_one, ierr)
2092 call dio_function_output (io_function_fill_how(
'AxisZ'),
".",
"interpolation_target", global_namespace, &
2093 space, mesh0, guess0, unit_one, ierr)
2094 call dio_function_output (io_function_fill_how(
'PlaneZ'),
".",
"interpolation_target", global_namespace, &
2095 space, mesh0, guess0, unit_one, ierr)
2102 call dmultigrid_fine2coarse(mgrid%level(1)%tt, mgrid%level(0)%der, mesh1, guess0, guess1, injection)
2104 call dmultigrid_coarse2fine(mgrid%level(1)%tt, mgrid%level(1)%der, mesh0, guess1, res0)
2106 call dio_function_output (io_function_fill_how(
'AxisX'),
".",
"interpolation_result", global_namespace, &
2107 space, mesh0, res0, unit_one, ierr)
2108 call dio_function_output (io_function_fill_how(
'AxisZ'),
".",
"interpolation_result", global_namespace, &
2109 space, mesh0, res0, unit_one, ierr)
2110 call dio_function_output (io_function_fill_how(
'PlaneZ'),
".",
"interpolation_result", global_namespace, &
2111 space, mesh0, res0, unit_one, ierr)
2113 delta = dmf_nrm2(mesh0, guess0(1:mesh0%np)-res0(1:mesh0%np))
2114 write(message(1),
'(a,e13.6)')
'Interpolation test (abs.) = ', delta
2120 call dmultigrid_fine2coarse(mgrid%level(1)%tt, mgrid%level(0)%der, mesh1, guess0, guess1, fullweight)
2122 call dmultigrid_coarse2fine(mgrid%level(1)%tt, mgrid%level(1)%der, mesh0, guess1, res0)
2124 call dio_function_output (io_function_fill_how(
'AxisX'),
".",
"restriction_result", global_namespace, &
2125 space, mesh0, res0, unit_one, ierr)
2126 call dio_function_output (io_function_fill_how(
'AxisZ'),
".",
"restriction_result", global_namespace, &
2127 space, mesh0, res0, unit_one, ierr)
2128 call dio_function_output (io_function_fill_how(
'PlaneZ'),
".",
"restriction_result", global_namespace, &
2129 space, mesh0, res0, unit_one, ierr)
2131 delta = dmf_nrm2(mesh0, guess0(1:mesh0%np)-res0(1:mesh0%np))
2132 write(message(2),
'(a,e13.6)')
'Restriction test (abs.) = ', delta
2133 call messages_info(2)
2135 safe_deallocate_a(guess0)
2136 safe_deallocate_a(res0)
2137 safe_deallocate_a(guess1)
2145 type(namespace_t),
intent(in) :: namespace
2146 type(electrons_t),
pointer :: sys
2148 type(current_t) :: current
2149 character(len=MAX_PATH_LEN) :: fname
2150 integer :: ierr, ip, idir
2151 integer(int64) :: out_how
2152 real(real64),
allocatable :: current_para_ref(:,:), current_dia_ref(:,:), current_mag_ref(:,:), delta(:)
2153 real(real64) :: xx(3), rr, a0, mag_curr, sin_thet, sin_phi, cos_phi, vec_pot_slope
2154 complex(real64) :: alpha
2156 sys => electrons_t(namespace, generate_epot=.false.)
2157 call sys%init_parallelization(mpi_world)
2159 alpha = (0.0_real64, 0.5_real64)
2161 vec_pot_slope = 0.4_real64
2163 call states_elec_allocate_wfns(sys%st, sys%gr, wfs_type = type_cmplx)
2166 call current_init(current, namespace)
2168 call hamiltonian_elec_epot_generate(sys%hm, sys%namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, sys%st)
2170 safe_allocate(sys%hm%hm_base%vector_potential(1:3, 1:sys%gr%np))
2172 sys%hm%hm_base%vector_potential = m_zero
2173 do ip = 1, sys%gr%np
2174 xx = sys%gr%x(ip, 1:3)
2175 sys%hm%hm_base%vector_potential(2, ip) = vec_pot_slope * xx(1) / p_c
2178 call states_elec_allocate_current(sys%st, sys%space, sys%gr)
2179 call density_calc(sys%st, sys%gr, sys%st%rho)
2181 call current_calculate(current, namespace, sys%gr, sys%hm, sys%space, sys%st)
2183 safe_allocate(current_para_ref(1:sys%gr%np,1:3))
2184 safe_allocate(current_dia_ref(1:sys%gr%np,1:3))
2185 safe_allocate(current_mag_ref(1:sys%gr%np,1:3))
2186 safe_allocate(delta(1:sys%gr%np))
2189 current_para_ref(:,:) = m_zero
2190 do ip = 1, sys%gr%np
2191 call mesh_r(sys%gr, ip, rr)
2192 xx = sys%gr%x(ip, 1:3)
2193 if (rr > r_small)
then
2195 psi_1s(rr, a0) *
dr_psi_2s(rr, a0) ) * aimag(alpha) / (1 + abs(alpha)**2) * xx(1:3) / rr
2199 write(fname,
'(a)')
'current_para'
2200 out_how = io_function_fill_how(
"PlaneZ")
2201 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2202 sys%st%current_para(:,:,1), unit_one, ierr)
2204 write(fname,
'(a)')
'current_para-ref'
2205 out_how = io_function_fill_how(
"PlaneZ")
2206 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2207 current_para_ref(:,:), unit_one, ierr)
2211 delta(:) = current_para_ref(1:sys%gr%np, idir) - sys%st%current_para(1:sys%gr%np, idir, 1)
2212 write(message(idir),*)
'idir =',idir,
', norm2(delta paramagnetic)',norm2(delta)
2214 call messages_info(3)
2217 current_dia_ref(:,:) = m_zero
2218 do ip = 1, sys%gr%np
2219 call mesh_r(sys%gr, ip, rr)
2220 current_dia_ref(ip,1:3) = - sys%hm%hm_base%vector_potential(1:3,ip) *&
2224 write(fname,
'(a)')
'current_dia'
2225 out_how = io_function_fill_how(
"PlaneZ")
2226 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2227 sys%st%current_dia(:,:,1), unit_one, ierr)
2229 write(fname,
'(a)')
'current_dia-ref'
2230 out_how = io_function_fill_how(
"PlaneZ")
2231 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2232 current_dia_ref(:,:), unit_one, ierr)
2236 delta(:) = current_dia_ref(1:sys%gr%np, idir) - sys%st%current_dia(1:sys%gr%np, idir, 1)
2237 write(message(idir),*)
'idir =',idir,
', norm2(delta diamagnetic)',norm2(delta)
2239 call messages_info(3)
2242 call current_calculate_mag(sys%gr%der, sys%st)
2245 current_mag_ref(:,:) = m_zero
2246 do ip = 1, sys%gr%np
2247 call mesh_r(sys%gr, ip, rr)
2248 xx = sys%gr%x(ip, 1:3)
2249 if (norm2(xx(1:2)) > r_small .and. rr > r_small)
then
2250 sin_thet = norm2(xx(1:2)) / rr
2251 sin_phi = xx(2) / norm2(xx(1:2))
2252 cos_phi = xx(1) / norm2(xx(1:2))
2256 current_mag_ref(ip,1) = m_half * mag_curr * sin_thet * sin_phi / (1+abs(alpha)**2)
2257 current_mag_ref(ip,2) = -m_half * mag_curr * sin_thet * cos_phi / (1+abs(alpha)**2)
2261 write(fname,
'(a)')
'current_mag'
2262 out_how = io_function_fill_how(
"PlaneZ")
2263 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2264 sys%st%current_mag(:,:,1), unit_one, ierr)
2266 write(fname,
'(a)')
'current_mag-ref'
2267 out_how = io_function_fill_how(
"PlaneZ")
2268 call io_function_output_vector(out_how ,
'./' , trim(fname), namespace, sys%space, sys%gr, &
2269 current_mag_ref(:,:), unit_one, ierr)
2273 delta(:) = current_mag_ref(1:sys%gr%np, idir) - sys%st%current_mag(1:sys%gr%np, idir, 1)
2274 write(message(idir),*)
'idir =',idir,
', norm2(delta magnetization)',norm2(delta)
2276 call messages_info(3)
2278 safe_deallocate_a(current_para_ref)
2279 safe_deallocate_a(current_dia_ref)
2280 safe_deallocate_a(current_mag_ref)
2281 safe_deallocate_a(delta)
2282 safe_deallocate_p(sys)
2288 class(batch_t),
intent(inout) :: psib
2289 class(mesh_t),
intent(in) :: mesh
2290 type(namespace_t),
intent(in) :: namespace
2291 complex(real64),
intent(in) :: alpha
2292 real(real64),
intent(in) :: a0
2294 complex(real64),
allocatable :: zff(:)
2301 safe_allocate(zff(1:mesh%np))
2302 if (type_is_complex(psib%type()))
then
2304 call mesh_r(mesh, ip, rr)
2306 call batch_set_state(psib, 1, mesh%np, zff)
2308 safe_deallocate_a(zff)
2310 write(message(1),*)
"States should be complex for the linear combination of hydrogenic states to work"
2311 call messages_info(1, namespace=namespace)
2318 real(real64),
intent(in) :: a0, rr
2319 complex(real64),
intent(in) :: alpha
2325 real(real64) function psi_1s(rr, a0)
2326 real(real64),
intent(in) :: a0, rr
2332 real(real64) function psi_2s(rr, a0)
2333 real(real64),
intent(in) :: a0, rr
2335 psi_2s =
sqrt(m_two) * a0**(-m_three/m_two) * (m_one - rr/(m_two * a0)) *
exp(-rr/(m_two * a0)) &
2336 / (m_two *
sqrt(m_pi))
2339 real(real64) function dr_psi_1s(rr, a0)
2340 real(real64),
intent(in) :: a0, rr
2345 real(real64) function dr_psi_2s(rr, a0)
2346 real(real64),
intent(in) :: a0, rr
2349 a0**(-m_five/m_two) *
exp(-rr/(m_two * a0)) / (
sqrt(m_two) * m_two *
sqrt(m_pi))
2354 type(namespace_t),
intent(in) :: namespace
2357 integer(int64) :: i, j, k
2358 integer(int64) :: dims(3)
2359 character(len=MAX_PATH_LEN) :: fname
2361 real(real64),
allocatable :: ff(:)
2371 call parse_variable(namespace,
'TestCSVFileName',
"", fname)
2373 message(1) =
"Attempting to probe "//trim(fname)
2374 call messages_info(1, namespace=namespace)
2376 call io_csv_get_info(fname, dims, ierr)
2378 message(1) =
"Probing successful."
2379 write(message(2),
'("found dimensions: ",3I20)') dims
2380 call messages_info(2, namespace=namespace)
2382 write(message(1),
'("Probing failed. ierr = ",I5)') ierr
2383 call messages_fatal(1, namespace=namespace)
2386 safe_allocate(ff(1:dims(1)*dims(2)*dims(3)))
2388 message(1) =
"Attempting to read "//trim(fname)
2389 call messages_info(1, namespace=namespace)
2391 call dread_csv(fname, dims(1)*dims(2)*dims(3), ff, ierr)
2393 message(1) =
"Reading successful."
2394 call messages_info(1, namespace=namespace)
2396 do k=1, min(4_int64, dims(3))
2397 do j=1, min(4_int64, dims(2))
2398 write(message(j),
'("data ",2I5, 1X, 4F8.2)') k, j, &
2399 (ff(i + dims(1)*(j-1) + dims(1)* dims(2)*(k-1)), i=1, min(4_int64, dims(1)))
2401 write(message(int(j, int32)),
'("")')
2402 call messages_info(int(j, int32), namespace=namespace)
2406 message(1) =
"Reading failed."
2407 call messages_fatal(1, namespace=namespace)
2410 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:
constant times a vector plus a vector
Copies a vector x, to a vector y.
scales a vector by a constant
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.
subroutine, public dderivatives_test(this, namespace, repetitions, min_blocksize, max_blocksize)
unit test for derivatives
subroutine, public dderivatives_lapl(der, ff, op_ff, ghost_update, set_bc, factor)
apply the Laplacian to a mesh function
subroutine, public zderivatives_test(this, namespace, repetitions, min_blocksize, max_blocksize)
unit test for derivatives
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_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
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.
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.
class(mesh_t), pointer, public mesh_aux
Globally-scoped pointer to the mesh instance.
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_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.
subroutine set_der_aux(der)
real(real64) function psi_2s(rr, a0)
subroutine test_helmholtz_decomposition(namespace)
subroutine test_hartree(param, namespace)
subroutine test_derivatives(param, namespace)
subroutine laplacian_op(x, hx, userdata)
Computes .
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 representing derivatives
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)