36 use,
intrinsic :: iso_fortran_env
68 class(mesh_t),
pointer,
private :: mesh_p
69 type(hamiltonian_elec_t),
pointer,
private :: hm_p
70 type(states_elec_t),
pointer,
private :: st_p
71 type(propagator_base_t),
pointer,
private :: tr_p
72 type(namespace_t),
pointer,
private :: namespace_p
73 type(electron_space_t),
pointer,
private :: space_p
74 type(partner_list_t),
pointer,
private :: ext_partners_p
75 integer,
private :: dim_op
76 real(real64),
private :: t_op, dt_op
77 real(real64),
allocatable,
private :: vhxc1_op(:, :), vhxc2_op(:, :), vpsl1_op(:), vpsl2_op(:)
78 logical :: move_ions_op
82 subroutine td_explicit_runge_kutta4(ks, namespace, space, hm, gr, st, time, dt, ions_dyn, ions, ext_partners, qcchi)
83 type(v_ks_t),
target,
intent(inout) :: ks
84 type(namespace_t),
intent(in) :: namespace
85 type(electron_space_t),
intent(in) :: space
86 type(hamiltonian_elec_t),
target,
intent(inout) :: hm
87 type(grid_t),
target,
intent(in) :: gr
88 type(states_elec_t),
target,
intent(inout) :: st
89 real(real64),
intent(in) :: time
90 real(real64),
intent(in) :: dt
91 type(ion_dynamics_t),
intent(inout) :: ions_dyn
92 type(ions_t),
intent(inout) :: ions
93 type(partner_list_t),
intent(in) :: ext_partners
94 type(opt_control_state_t),
optional,
target,
intent(inout) :: qcchi
96 type(states_elec_t),
pointer :: chi
97 real(real64),
pointer :: q(:, :), p(:, :)
99 integer :: np_part, np, kp1, kp2, st1, st2, nspin, ik, ist, iatom, ib
100 complex(real64),
allocatable :: zphi(:, :, :, :), zchi(:, :, :, :), dvpsi(:, :, :)
101 type(states_elec_t) :: hst, stphi, inh, hchi, stchi
102 logical :: propagate_chi
103 real(real64),
allocatable :: pos0(:, :), vel0(:, :), &
104 posk(:, :), velk(:, :), &
105 pos(:, :), vel(:, :), &
106 posfinal(:, :), velfinal(:, :), &
107 pos0t(:, :), vel0t(:, :), &
108 poskt(:, :), velkt(:, :), &
109 post(:, :), velt(:, :), &
110 posfinalt(:, :), velfinalt(:, :), &
115 propagate_chi =
present(qcchi)
116 if (propagate_chi)
then
130 safe_allocate(zphi(1:np_part, 1:st%d%dim, st1:st2, kp1:kp2))
131 if (propagate_chi)
then
132 safe_allocate(zchi(1:np_part, 1:st%d%dim, st1:st2, kp1:kp2))
135 safe_allocate(pos(1:ions%space%dim, 1:ions%natoms))
136 safe_allocate(vel(1:ions%space%dim, 1:ions%natoms))
137 safe_allocate(pos0(1:ions%space%dim, 1:ions%natoms))
138 safe_allocate(vel0(1:ions%space%dim, 1:ions%natoms))
139 safe_allocate(posk(1:ions%space%dim, 1:ions%natoms))
140 safe_allocate(velk(1:ions%space%dim, 1:ions%natoms))
141 safe_allocate(posfinal(1:ions%space%dim, 1:ions%natoms))
142 safe_allocate(velfinal(1:ions%space%dim, 1:ions%natoms))
144 if (propagate_chi)
then
145 safe_allocate(post(1:ions%space%dim, 1:ions%natoms))
146 safe_allocate(velt(1:ions%space%dim, 1:ions%natoms))
147 safe_allocate(pos0t(1:ions%space%dim, 1:ions%natoms))
148 safe_allocate(vel0t(1:ions%space%dim, 1:ions%natoms))
149 safe_allocate(poskt(1:ions%space%dim, 1:ions%natoms))
150 safe_allocate(velkt(1:ions%space%dim, 1:ions%natoms))
151 safe_allocate(posfinalt(1:ions%space%dim, 1:ions%natoms))
152 safe_allocate(velfinalt(1:ions%space%dim, 1:ions%natoms))
153 safe_allocate(coforce(1:ions%natoms, 1:ions%space%dim))
161 if (propagate_chi)
then
173 if (propagate_chi)
then
174 do iatom = 1, ions%natoms
175 pos0t(1:ions%space%dim, iatom) = q(iatom, 1:ions%space%dim)
176 vel0t(1:ions%space%dim, iatom) = p(iatom, 1:ions%space%dim) / ions%mass(iatom)
189 if (propagate_chi)
then
195 if (propagate_chi)
then
201 call f_psi(time - dt)
202 if (propagate_chi)
call f_chi(time - dt)
211 if (propagate_chi)
then
215 do ik = stphi%d%kpt%start, stphi%d%kpt%end
216 do ib = stphi%group%block_start, stphi%group%block_end
218 if (propagate_chi)
then
225 pos = pos0 +
m_half * posk
226 vel = vel0 +
m_half * velk
227 if (propagate_chi)
then
228 post = pos0t +
m_half * poskt
229 velt = vel0t +
m_half * velkt
242 if (propagate_chi)
then
246 do ik = stphi%d%kpt%start, stphi%d%kpt%end
247 do ib = stphi%group%block_start, stphi%group%block_end
249 if (propagate_chi)
then
256 pos = pos0 +
m_half * posk
257 vel = vel0 +
m_half * velk
258 if (propagate_chi)
then
259 post = pos0t +
m_half * poskt
260 velt = vel0t +
m_half * velkt
274 if (propagate_chi)
then
278 do ik = stphi%d%kpt%start, stphi%d%kpt%end
279 do ib = stphi%group%block_start, stphi%group%block_end
280 call batch_axpy(gr%np, -
m_zi*dt, hst%group%psib(ib, ik), stphi%group%psib(ib, ik))
281 if (propagate_chi)
then
282 call batch_axpy(gr%np, -
m_zi*dt, hchi%group%psib(ib, ik), stchi%group%psib(ib, ik))
290 if (propagate_chi)
then
297 if (propagate_chi)
call f_chi(time)
311 call ions%update_kinetic_energy()
313 if (propagate_chi)
then
314 do iatom = 1, ions%natoms
315 q(iatom, 1:ions%space%dim) = posfinalt(1:ions%space%dim, iatom)
316 p(iatom, 1:ions%space%dim) = ions%mass(iatom) * velfinalt(1:ions%space%dim, iatom)
323 safe_deallocate_a(zphi)
324 if (propagate_chi)
then
327 safe_deallocate_a(zchi)
334 safe_deallocate_a(pos)
335 safe_deallocate_a(vel)
336 safe_deallocate_a(pos0)
337 safe_deallocate_a(vel0)
338 safe_deallocate_a(posk)
339 safe_deallocate_a(velk)
340 safe_deallocate_a(posfinal)
341 safe_deallocate_a(velfinal)
343 if (propagate_chi)
then
344 safe_deallocate_a(post)
345 safe_deallocate_a(velt)
346 safe_deallocate_a(pos0t)
347 safe_deallocate_a(vel0t)
348 safe_deallocate_a(poskt)
349 safe_deallocate_a(velkt)
350 safe_deallocate_a(posfinalt)
351 safe_deallocate_a(velfinalt)
352 safe_deallocate_a(coforce)
359 subroutine f_psi(tau)
360 real(real64),
intent(in) :: tau
369 call v_ks_calc(ks, namespace, space, hm, stphi, ions, ext_partners, &
371 time = tau, calc_energy = .false., calc_eigenval = .false.)
373 call hm%update(gr, namespace, space, ext_partners, time = tau)
380 real(real64),
intent(in) :: tau
382 call forces_calculate(gr, namespace, ions, hm, ext_partners, stphi, ks, t = tau, dt = dt)
383 do iatom = 1, ions%natoms
384 posk(:, iatom) = dt * vel(:, iatom)
385 velk(:, iatom) = dt * ions%tot_force(:, iatom) / ions%mass(iatom)
387 if (propagate_chi)
then
389 do iatom = 1, ions%natoms
390 poskt(:, iatom) = dt * velt(:, iatom)
391 velkt(:, iatom) = dt * coforce(iatom, :) / ions%mass(iatom)
396 subroutine f_chi(tau)
397 real(real64),
intent(in) :: tau
419 do ib = 1, st%group%block_start, st%group%block_end
420 call batch_axpy(np,
m_zi, hm%inh_st%group%psib(ib, ik), hchi%group%psib(ib, ik))
428 complex(real64),
allocatable :: psi(:, :), inhpsi(:, :)
434 safe_allocate(psi(1:gr%np_part, 1:st%d%dim))
435 safe_allocate(inhpsi(1:gr%np_part, 1:st%d%dim))
436 safe_allocate(dvpsi(1:gr%np_part, 1:st%d%dim, 1:space%dim))
444 do iatom = 1, ions%natoms
445 do idir = 1, space%dim
447 call pert%setup_atom(iatom)
448 call pert%setup_dir(idir)
449 call pert%zapply(namespace, space, gr, hm, ik, psi(:, :), dvpsi(:, :, idir))
450 dvpsi(:, :, idir) = - dvpsi(:, :, idir)
451 inhpsi(1:gr%np, 1:stphi%d%dim) = inhpsi(1:gr%np, 1:stphi%d%dim) &
452 + st%occ(ist, ik)*post(idir, iatom)*dvpsi(1:gr%np, 1:stphi%d%dim, idir)
453 safe_deallocate_p(pert)
465 safe_deallocate_a(psi)
466 safe_deallocate_a(inhpsi)
467 safe_deallocate_a(dvpsi)
473 real(real64),
intent(in) :: epsilon
475 do ik = stphi%d%kpt%start, stphi%d%kpt%end
476 do ib = stphi%group%block_start, stphi%group%block_end
477 call batch_axpy(gr%np, -
m_zi*dt*epsilon, hst%group%psib(ib, ik), st%group%psib(ib, ik))
478 if (propagate_chi)
then
479 call batch_axpy(gr%np, -
m_zi*dt*epsilon, hchi%group%psib(ib, ik), chi%group%psib(ib, ik))
485 posfinal = posfinal + posk * epsilon
486 velfinal = velfinal + velk * epsilon
487 if (propagate_chi)
then
488 posfinalt = posfinalt + poskt * epsilon
489 velfinalt = velfinalt + velkt * epsilon
497 subroutine td_runge_kutta2(ks, namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners)
498 type(
v_ks_t),
target,
intent(inout) :: ks
502 type(
grid_t),
target,
intent(in) :: gr
505 real(real64),
intent(in) :: time
506 real(real64),
intent(in) :: dt
508 type(
ions_t),
intent(inout) :: ions
511 integer :: np_part, np, kp1, kp2, st1, st2, nspin, ik, ist, idim, j, ip
514 complex(real64),
allocatable :: zphi(:, :, :, :)
515 complex(real64),
allocatable :: zpsi(:), rhs(:)
516 complex(real64),
allocatable :: k2(:, :, :, :), oldk2(:, :, :, :), rhs1(:, :, :, :)
517 complex(real64),
allocatable :: inhpsi(:)
537 sp_parallel = st%parallel_in_states .or. st%d%kpt%parallel
545 namespace_p => namespace
547 ext_partners_p => ext_partners
549 t_op = time - dt/
m_two
552 safe_allocate(k2(1:np_part, 1:st%d%dim, st1:st2, kp1:kp2))
553 safe_allocate(oldk2(1:np_part, 1:st%d%dim, st1:st2, kp1:kp2))
554 safe_allocate(zphi(1:gr%np_part, st%d%dim, st1:st2, kp1:kp2))
555 safe_allocate(rhs1(1:np_part, 1:st%d%dim, st1:st2, kp1:kp2))
556 safe_allocate(rhs(1:tr%tdsk_size))
557 safe_allocate(zpsi(1:tr%tdsk_size))
558 safe_allocate(vhxc1_op(1:np, 1:nspin))
559 safe_allocate(vpsl1_op(1:np))
577 call zhamiltonian_elec_apply_single(hm_p, namespace, mesh_p, zphi(:, :, ist, ik), rhs1(:, :, ist, ik), ist, ik)
591 safe_allocate(inhpsi(1:gr%np))
594 do idim = 1, st%d%dim
597 rhs1(ip, idim, ist, ik) = rhs1(ip, idim, ist, ik) + dt * inhpsi(ip)
602 safe_deallocate_a(inhpsi)
619 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
621 calc_energy = .false., calc_eigenval = .false.)
627 vpsl1_op = hm%ep%vpsl
651 do idim = 1, st%d%dim
652 rhs(j:j+np-1) = rhs1(1:np, idim, ist, ik)
662 do idim = 1, st%d%dim
663 zpsi(j:j+np-1) = k2(1:np, idim, ist, ik)
676 do idim = 1, st%d%dim
677 k2(1:np, idim, ist, ik) = zpsi(j:j+np-1)
686 do idim = 1, st%d%dim
687 dres = dres + (
zmf_nrm2(gr, k2(:, idim, ist, ik) - oldk2(:, idim, ist, ik), reduce = .false.))**2
694 if (
sqrt(dres) < tr%scf_threshold)
exit
706 safe_deallocate_a(k2)
707 safe_deallocate_a(oldk2)
708 safe_deallocate_a(zphi)
709 safe_deallocate_a(rhs1)
710 safe_deallocate_a(zpsi)
711 safe_deallocate_a(rhs)
712 safe_deallocate_a(vhxc1_op)
713 safe_deallocate_a(vpsl1_op)
720 subroutine td_runge_kutta4(ks, namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners)
721 type(
v_ks_t),
target,
intent(inout) :: ks
725 type(
grid_t),
target,
intent(in) :: gr
728 real(real64),
intent(in) :: time
729 real(real64),
intent(in) :: dt
731 type(
ions_t),
intent(inout) :: ions
734 integer :: idim, ip, ist, ik, j, kp1, kp2, st1, st2, nspin
736 complex(real64),
allocatable :: inhpsi(:)
737 complex(real64),
allocatable :: zpsi(:), rhs(:)
738 complex(real64),
allocatable :: zphi(:, :, :, :)
741 real(real64) :: a(2, 2), c(2), b(2)
742 complex(real64),
allocatable :: k1(:, :, :, :), k2(:, :, :, :), oldk1(:, :, :, :), &
743 oldk2(:, :, :, :), yn1(:, :, :, :), yn2(:, :, :, :), &
744 rhs1(:, :, :, :), rhs2(:, :, :, :)
770 sp_parallel = st%parallel_in_states .or. st%d%kpt%parallel
778 namespace_p => namespace
780 ext_partners_p => ext_partners
782 t_op = time - dt/
m_two
785 safe_allocate(vhxc1_op(1:gr%np, 1:nspin))
786 safe_allocate(vhxc2_op(1:gr%np, 1:nspin))
787 safe_allocate(vpsl1_op(1:gr%np))
788 safe_allocate(vpsl2_op(1:gr%np))
789 safe_allocate(k1(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
790 safe_allocate(k2(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
791 safe_allocate(oldk1(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
792 safe_allocate(oldk2(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
793 safe_allocate(yn1(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
794 safe_allocate(yn2(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
795 safe_allocate(rhs1(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
796 safe_allocate(rhs2(1:gr%np_part, 1:st%d%dim, st1:st2, kp1:kp2))
797 safe_allocate(rhs(1:tr%tdsk_size))
798 safe_allocate(zpsi(1:tr%tdsk_size))
799 safe_allocate(zphi(1:gr%np_part, st%d%dim, st1:st2, kp1:kp2))
815 yn1 = zphi + a(1, 1) * k1 + a(1, 2) * k2
816 yn2 = zphi + a(2, 1) * k1 + a(2, 2) * k2
825 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
827 calc_energy = .false., calc_eigenval = .false.)
832 vpsl1_op = hm%ep%vpsl
838 t_op = time - dt + c(1) * dt
842 call zhamiltonian_elec_apply_single(hm_p, namespace, mesh_p, zphi(:, :, ist, ik), rhs1(:, :, ist, ik), ist, ik)
844 safe_allocate(inhpsi(1:gr%np))
845 do idim = 1, st%d%dim
848 rhs1(ip, idim, ist, ik) = rhs1(ip, idim, ist, ik) +
m_zi * inhpsi(ip)
851 safe_deallocate_a(inhpsi)
855 rhs1 = -
m_zi * dt * rhs1
867 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
869 calc_energy = .false., calc_eigenval = .false.)
874 vpsl2_op = hm%ep%vpsl
880 t_op = time - dt + c(2) * dt
884 call zhamiltonian_elec_apply_single(hm_p, namespace, mesh_p, zphi(:, :, ist, ik), rhs2(:, :, ist, ik), ist, ik)
886 safe_allocate(inhpsi(1:gr%np))
887 do idim = 1, st%d%dim
890 rhs2(ip, idim, ist, ik) = rhs2(ip, idim, ist, ik) +
m_zi * inhpsi(ip)
893 safe_deallocate_a(inhpsi)
897 rhs2 = -
m_zi * dt * rhs2
905 do idim = 1, st%d%dim
906 call lalg_copy(gr%np, rhs1(1:gr%np, idim, ist, ik), rhs(j:j+gr%np-1))
913 do idim = 1, st%d%dim
914 call lalg_copy(gr%np, rhs2(1:gr%np, idim, ist, ik), rhs(j:j+gr%np-1))
924 do idim = 1, st%d%dim
925 call lalg_copy(gr%np, k1(1:gr%np, idim, ist, ik), zpsi(j:j+gr%np-1))
932 do idim = 1, st%d%dim
933 call lalg_copy(gr%np, k2(1:gr%np, idim, ist, ik), zpsi(j:j+gr%np-1))
947 do idim = 1, st%d%dim
948 call lalg_copy(gr%np, zpsi(j:j+gr%np-1), k1(1:gr%np, idim, ist, ik))
955 do idim = 1, st%d%dim
956 call lalg_copy(gr%np, zpsi(j:j+gr%np-1), k2(1:gr%np, idim, ist, ik))
965 do idim = 1, st%d%dim
966 dres = dres + (
zmf_nrm2(gr, k1(:, idim, ist, ik) - oldk1(:, idim, ist, ik)))**2
967 dres = dres + (
zmf_nrm2(gr, k2(:, idim, ist, ik) - oldk2(:, idim, ist, ik)))**2
974 if (
sqrt(dres) < tr%scf_threshold)
exit
978 zphi = zphi + b(1) * k1 + b(2) * k2
987 safe_deallocate_a(rhs1)
988 safe_deallocate_a(rhs2)
989 safe_deallocate_a(k1)
990 safe_deallocate_a(k2)
991 safe_deallocate_a(oldk1)
992 safe_deallocate_a(oldk2)
993 safe_deallocate_a(yn1)
994 safe_deallocate_a(yn2)
995 safe_deallocate_a(vhxc1_op)
996 safe_deallocate_a(vhxc2_op)
997 safe_deallocate_a(vpsl1_op)
998 safe_deallocate_a(vpsl2_op)
999 safe_deallocate_a(zpsi)
1000 safe_deallocate_a(rhs)
1007 subroutine td_rk4op(xre, xim, yre, yim)
1008 real(real64),
intent(in) :: xre(:)
1009 real(real64),
intent(in) :: xim(:)
1010 real(real64),
intent(out) :: yre(:)
1011 real(real64),
intent(out) :: yim(:)
1013 integer :: idim, j, ik, ist, kp1, kp2, st1, st2, dim, k, jj
1014 complex(real64),
allocatable :: zpsi(:, :)
1015 complex(real64),
allocatable :: opzpsi(:, :)
1016 real(real64) :: a(2, 2), c(2)
1017 integer :: np_part, np
1021 np_part = mesh_p%np_part
1025 kp1 = st_p%d%kpt%start
1026 kp2 = st_p%d%kpt%end
1029 safe_allocate(zpsi(1:np_part, 1:dim))
1030 safe_allocate(opzpsi(1:np_part, 1:dim))
1042 hm_p%vhxc = vhxc1_op
1043 if (move_ions_op) hm_p%ep%vpsl = vpsl1_op
1046 k = np * (kp2 - kp1 + 1) * (st2 - st1 + 1) * dim + 1
1051 zpsi(1:np, idim) = a(1, 1) * cmplx(xre(j:j+np-1), xim(j:j+np-1), real64) + &
1052 a(1, 2) * cmplx(xre(k:k+np-1), xim(k:k+np-1), real64)
1060 yre(jj:jj+np-1) = xre(jj:jj+np-1) + real(
m_zi * dt_op * opzpsi(1:np, idim), real64)
1061 yim(jj:jj+np-1) = xim(jj:jj+np-1) + aimag(
m_zi * dt_op * opzpsi(1:np, idim))
1067 hm_p%vhxc = vhxc2_op
1068 if (move_ions_op) hm_p%ep%vpsl = vpsl2_op
1071 k = np * (kp2 - kp1 + 1) * (st2 - st1 + 1) * dim + 1
1076 zpsi(1:np, idim) = a(2, 1) * cmplx(xre(j:j+np-1), xim(j:j+np-1), real64) + &
1077 a(2, 2) * cmplx(xre(k:k+np-1), xim(k:k+np-1), real64)
1085 yre(jj:jj+np-1) = xre(jj:jj+np-1) + real(
m_zi * dt_op * opzpsi(1:np, idim), real64)
1086 yim(jj:jj+np-1) = xim(jj:jj+np-1) + aimag(
m_zi * dt_op * opzpsi(1:np, idim))
1092 safe_deallocate_a(zpsi)
1093 safe_deallocate_a(opzpsi)
1101 subroutine td_rk4opt(xre, xim, yre, yim)
1102 real(real64),
intent(in) :: xre(:)
1103 real(real64),
intent(in) :: xim(:)
1104 real(real64),
intent(out) :: yre(:)
1105 real(real64),
intent(out) :: yim(:)
1107 integer :: idim, j, ik, ist, kp1, kp2, st1, st2, dim, k, jj
1108 complex(real64),
allocatable :: zpsi(:, :)
1109 complex(real64),
allocatable :: opzpsi(:, :)
1110 real(real64) :: a(2, 2), c(2)
1111 integer :: np_part, np
1115 np_part = mesh_p%np_part
1119 kp1 = st_p%d%kpt%start
1120 kp2 = st_p%d%kpt%end
1123 safe_allocate(zpsi(1:np_part, 1:dim))
1124 safe_allocate(opzpsi(1:np_part, 1:dim))
1136 hm_p%vhxc = vhxc1_op
1137 if (move_ions_op) hm_p%ep%vpsl = vpsl1_op
1142 k = np * (kp2 - kp1 + 1) * (st2 - st1 + 1) * dim + 1
1147 zpsi(1:np, idim) = a(1, 1) * cmplx(xre(j:j+np-1), -xim(j:j+np-1), real64) + &
1148 a(1, 2) * cmplx(xre(k:k+np-1), -xim(k:k+np-1), real64)
1156 yre(jj:jj+np-1) = xre(jj:jj+np-1) + real(
m_zi * dt_op * opzpsi(1:np, idim), real64)
1157 yim(jj:jj+np-1) = xim(jj:jj+np-1) - aimag(
m_zi * dt_op * opzpsi(1:np, idim))
1163 hm_p%vhxc = vhxc2_op
1164 if (move_ions_op) hm_p%ep%vpsl = vpsl2_op
1169 k = np * (kp2 - kp1 + 1) * (st2 - st1 + 1) * dim + 1
1174 zpsi(1:np, idim) = a(2, 1) * cmplx(xre(j:j+np-1), -xim(j:j+np-1), real64) + &
1175 a(2, 2) * cmplx(xre(k:k+np-1), -xim(k:k+np-1), real64)
1183 yre(jj:jj+np-1) = xre(jj:jj+np-1) + real(
m_zi * dt_op * opzpsi(1:np, idim), real64)
1184 yim(jj:jj+np-1) = xim(jj:jj+np-1) - aimag(
m_zi * dt_op * opzpsi(1:np, idim))
1190 safe_deallocate_a(zpsi)
1191 safe_deallocate_a(opzpsi)
1199 subroutine td_rk2op(xre, xim, yre, yim)
1200 real(real64),
intent(in) :: xre(:)
1201 real(real64),
intent(in) :: xim(:)
1202 real(real64),
intent(out) :: yre(:)
1203 real(real64),
intent(out) :: yim(:)
1205 integer :: np_part, np, st1, st2, kp1, kp2, dim, idim, ik, ist, jj, j
1206 complex(real64),
allocatable :: zpsi(:, :)
1207 complex(real64),
allocatable :: opzpsi(:, :)
1208 complex(real64),
allocatable :: zpsi_(:, :, :, :)
1212 np_part = mesh_p%np_part
1216 kp1 = st_p%d%kpt%start
1217 kp2 = st_p%d%kpt%end
1220 safe_allocate(zpsi(1:np_part, 1:dim))
1221 safe_allocate(opzpsi(1:np_part, 1:dim))
1222 safe_allocate(zpsi_(1:np_part, 1:dim, st1:st2, kp1:kp2))
1227 hm_p%vhxc = vhxc1_op
1228 if (move_ions_op) hm_p%ep%vpsl = vpsl1_op
1238 zpsi_(1:np, idim, ist, ik) = cmplx(xre(j:j+np-1), xim(j:j+np-1), real64)
1243 call oct_exchange_prepare(hm_p%oct_exchange, mesh_p, zpsi_, hm_p%xc, hm_p%psolver, namespace_p)
1251 zpsi(1:np, idim) = cmplx(xre(j:j+np-1), xim(j:j+np-1), real64)
1256 yre(jj:jj+np-1) = xre(jj:jj+np-1) + real(
m_zi * dt_op *
m_half * opzpsi(1:np, idim), real64)
1257 yim(jj:jj+np-1) = xim(jj:jj+np-1) + aimag(
m_zi * dt_op *
m_half * opzpsi(1:np, idim))
1269 zpsi(1:np, idim) = cmplx(xre(j:j+np-1), xim(j:j+np-1), real64)
1276 yre(jj:jj+np-1) = yre(jj:jj+np-1) + real(
m_zi * dt_op *
m_half * opzpsi(1:np, idim), real64)
1277 yim(jj:jj+np-1) = yim(jj:jj+np-1) + aimag(
m_zi * dt_op *
m_half * opzpsi(1:np, idim))
1284 safe_deallocate_a(zpsi)
1285 safe_deallocate_a(opzpsi)
1294 subroutine td_rk2opt(xre, xim, yre, yim)
1295 real(real64),
intent(in) :: xre(:)
1296 real(real64),
intent(in) :: xim(:)
1297 real(real64),
intent(out) :: yre(:)
1298 real(real64),
intent(out) :: yim(:)
1300 integer :: np_part, np, st1, st2, kp1, kp2, dim, idim, ik, ist, jj, j
1301 complex(real64),
allocatable :: zpsi(:, :)
1302 complex(real64),
allocatable :: opzpsi(:, :)
1303 complex(real64),
allocatable :: zpsi_(:, :, :, :)
1307 np_part = mesh_p%np_part
1311 kp1 = st_p%d%kpt%start
1312 kp2 = st_p%d%kpt%end
1315 safe_allocate(zpsi(1:np_part, 1:dim))
1316 safe_allocate(opzpsi(1:np_part, 1:dim))
1317 safe_allocate(zpsi_(1:np_part, 1:dim, st1:st2, kp1:kp2))
1322 hm_p%vhxc = vhxc1_op
1323 if (move_ions_op) hm_p%ep%vpsl = vpsl1_op
1333 zpsi_(1:np, idim, ist, ik) = cmplx(xre(j:j+np-1), -xim(j:j+np-1), real64)
1338 call oct_exchange_prepare(hm_p%oct_exchange, mesh_p, zpsi_, hm_p%xc, hm_p%psolver, namespace_p)
1346 zpsi(1:np, idim) = cmplx(xre(j:j+np-1), -xim(j:j+np-1), real64)
1352 yre(jj:jj+np-1) = xre(jj:jj+np-1) + real(
m_zi * dt_op *
m_half * opzpsi(1:np, idim), real64)
1353 yim(jj:jj+np-1) = xim(jj:jj+np-1) - aimag(
m_zi * dt_op *
m_half * opzpsi(1:np, idim))
1365 zpsi(1:np, idim) = cmplx(xre(j:j+np-1), xim(j:j+np-1), real64)
1372 yre(jj:jj+np-1) = yre(jj:jj+np-1) + real(
m_zi * dt_op *
m_half * opzpsi(1:np, idim), real64)
1373 yim(jj:jj+np-1) = yim(jj:jj+np-1) - aimag(
m_zi * dt_op *
m_half * opzpsi(1:np, idim))
1380 safe_deallocate_a(zpsi)
1381 safe_deallocate_a(opzpsi)
batchified version of the BLAS axpy routine:
Copies a vector x, to a vector y.
double sqrt(double __x) __attribute__((__nothrow__
This module implements common operations on batches of mesh functions.
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.
logical function, public list_has_gauge_field(partners)
subroutine, public forces_costate_calculate(gr, namespace, ions, hm, psi, chi, ff, qq)
subroutine, public forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, vhxc_old, t, dt)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_third
real(real64), parameter, public m_fourth
complex(real64), parameter, public m_z0
complex(real64), parameter, public m_zi
real(real64), parameter, public m_half
real(real64), parameter, public m_one
real(real64), parameter, public m_three
This module implements the underlying real-space grid.
subroutine, public hamiltonian_elec_set_inh(hm, st)
subroutine, public hamiltonian_elec_adjoint(hm)
subroutine, public zhamiltonian_elec_apply_single(hm, namespace, mesh, psi, hpsi, ist, ik, terms, set_bc, set_phase)
integer, parameter, public independent_particles
subroutine, public hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
subroutine, public zhamiltonian_elec_apply_all(hm, namespace, mesh, st, hst)
subroutine, public hamiltonian_elec_remove_inh(hm)
pure logical function, public hamiltonian_elec_inh_term(hm)
subroutine, public hamiltonian_elec_not_adjoint(hm)
This module defines classes and functions for interaction partners.
subroutine, public ion_dynamics_restore_state(this, ions, state)
subroutine, public ion_dynamics_propagate(this, ions, time, dt, namespace)
subroutine, public ion_dynamics_save_state(this, ions, state)
logical pure function, public ion_dynamics_ions_move(this)
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, hm_base, phase, energy)
This module defines various routines, operating on mesh functions.
logical, public sp_parallel
type(mpi_grp_t), public sp_grp
This module defines the meshes, which are used in Octopus.
subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
logical function, public oct_exchange_enabled(this)
subroutine, public oct_exchange_remove(this)
subroutine, public oct_exchange_set(this, st, mesh)
subroutine, public oct_exchange_operator(this, namespace, mesh, hpsi, ist, ik)
subroutine, public oct_exchange_prepare(this, mesh, psi, xc, psolver, namespace)
This module holds the "opt_control_state_t" datatype, which contains a quantum-classical state.
real(real64) function, dimension(:, :), pointer, public opt_control_point_p(ocs)
real(real64) function, dimension(:, :), pointer, public opt_control_point_q(ocs)
type(states_elec_t) function, pointer, public opt_control_point_qs(ocs)
subroutine, public potential_interpolation_get(potential_interpolation, np, nspin, i, vhxc, vtau)
subroutine, public propagation_ops_elec_update_hamiltonian(namespace, space, st, mesh, hm, ext_partners, time)
subroutine, public td_runge_kutta2(ks, namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners)
subroutine, public td_runge_kutta4(ks, namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners)
subroutine td_rk2op(xre, xim, yre, yim)
operator for the RK2 propagator
subroutine td_rk4op(xre, xim, yre, yim)
operators for Crank-Nicolson scheme
subroutine, public td_explicit_runge_kutta4(ks, namespace, space, hm, gr, st, time, dt, ions_dyn, ions, ext_partners, qcchi)
subroutine td_rk2opt(xre, xim, yre, yim)
operator for the RK2 propagator
subroutine td_rk4opt(xre, xim, yre, yim)
Transpose of H (called e.g. by bi-conjugate gradient solver)
subroutine, public zsparskit_solver_run(namespace, sk, op, opt, sol, rhs)
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
subroutine update_state(epsilon)
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
The states_elec_t class contains all electronic wave functions.