39 use,
intrinsic :: iso_fortran_env
68 real(real64),
allocatable :: vmagnus(:, :, :)
74 procedure magnus4_operator_constructor
82 subroutine td_magnus(hm, ext_partners, gr, st, tr, namespace, time, dt)
83 type(hamiltonian_elec_t),
intent(inout) :: hm
84 type(partner_list_t),
intent(in) :: ext_partners
85 type(grid_t),
intent(in) :: gr
86 type(states_elec_t),
intent(inout) :: st
87 type(propagator_base_t),
intent(inout) :: tr
88 type(namespace_t),
intent(in) :: namespace
89 real(real64),
intent(in) :: time
90 real(real64),
intent(in) :: dt
93 real(real64) :: atime(2)
94 real(real64),
allocatable :: vaux(:, :, :), vmagnus(:, :, :), pot(:)
95 type(lasers_t),
pointer :: lasers
96 class(operator_t),
pointer :: op
102 safe_allocate(vaux(1:gr%np, 1:st%d%nspin, 1:2))
103 safe_allocate(vmagnus(1:gr%np, 1:st%d%nspin, 1:2))
119 if(
associated(lasers))
then
120 do i = 1, lasers%no_lasers
123 safe_allocate(pot(1:gr%np))
126 do is = 1, st%d%nspin
127 vaux(:, is, j) = vaux(:, is, j) + pot(:)
129 safe_deallocate_a(pot)
131 write(
message(1),
'(a)')
'The Magnus propagator cannot be used with magnetic fields, or'
132 write(
message(2),
'(a)')
'with an electric field described in the velocity gauge.'
139 vmagnus(:, :, 2) =
m_half*(vaux(:, :, 1) + vaux(:, :, 2))
140 vmagnus(:, :, 1) = (
sqrt(
m_three)/12.0_real64)*dt*(vaux(:, :, 2) - vaux(:, :, 1))
144 safe_deallocate_p(op)
146 safe_deallocate_a(vaux)
147 safe_deallocate_a(vmagnus)
152 type(namespace_t),
target,
intent(in) :: namespace
153 class(mesh_t),
target,
intent(in) :: mesh
154 class(hamiltonian_abst_t),
target,
intent(in) :: hm
155 real(real64),
intent(in) :: vmagnus(:, :, :)
156 type(magnus4_operator_t),
pointer :: this
161 call this%init(namespace, mesh, hm)
165 assert(
size(vmagnus, 1) >= mesh%np)
166 assert(
size(vmagnus, 2) == hm%d%nspin)
167 assert(
size(vmagnus, 3) == 2)
169 write(
message(1),
'(a)')
'Magnus operators only implemented for electrons at the moment'
172 safe_allocate_source(this%vmagnus, vmagnus)
179 class(
batch_t),
intent(inout) :: psib
180 class(
batch_t),
intent(inout) :: hpsib
187 select type(hm => this%hm)
196 assert(psib%nst == hpsib%nst)
198 ispin = hm%d%get_spin_index(psib%ik)
200 call hpsib%copy_to(auxpsib, copy_data=.false.)
201 call hpsib%copy_to(aux2psib, copy_data=.false.)
208 call auxpsib%copy_data_to(this%mesh%np, hpsib)
211 call batch_mul(this%mesh%np, hm%abs_boundaries%mf(1:this%mesh%np), psib, aux2psib)
214 call batch_mul(this%mesh%np, this%vmagnus(1:this%mesh%np, ispin, 2), psib, aux2psib)
218 call batch_mul(this%mesh%np, this%vmagnus(1:this%mesh%np, ispin, 1), auxpsib, aux2psib)
222 call batch_mul(this%mesh%np, this%vmagnus(1:this%mesh%np, ispin, 1), psib, auxpsib)
230 message(1) =
"Internal error: imcompatible batch_t in magnus4_operator_apply for argument hpsib."
234 message(1) =
"Internal error: imcompatible batch_t in magnus4_operator_apply for argument psib."
244 subroutine td_cfmagnus4(ks, namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners, iter)
245 type(
v_ks_t),
target,
intent(inout) :: ks
249 type(
grid_t),
target,
intent(in) :: gr
252 real(real64),
intent(in) :: time
253 real(real64),
intent(in) :: dt
255 type(
ions_t),
intent(inout) :: ions
257 integer,
intent(in) :: iter
259 real(real64) :: alpha1, alpha2, c1, c2, t1, t2
260 real(real64),
allocatable :: vhxc1(:, :), vhxc2(:, :)
263 message(1) =
"The commutator-free Magnus expansion cannot be used with moving ions, cell dynamics, or gauge fields"
270 call td_explicit_runge_kutta4(ks, namespace, space, hm, gr, st, time, dt, ions_dyn, ions, ext_partners)
280 t1 = time - dt + c1*dt
281 t2 = time - dt + c2*dt
283 safe_allocate(vhxc1(1:gr%np, 1:st%d%nspin))
284 safe_allocate(vhxc2(1:gr%np, 1:st%d%nspin))
289 hm%ks_pot%vhxc(:, :) =
m_two * (alpha2 * vhxc1(:, :) + alpha1 * vhxc2(:, :))
294 hm%ks_pot%vhxc(:, :) =
m_two * (alpha1 * vhxc1(:, :) + alpha2 * vhxc2(:, :))
302 safe_deallocate_a(vhxc1)
303 safe_deallocate_a(vhxc2)
batchified version of the BLAS axpy routine:
double sqrt(double __x) __attribute__((__nothrow__
integer, parameter, public imaginary_absorbing
This module implements batches of mesh functions.
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)
type(lasers_t) function, pointer, public list_get_lasers(partners)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
integer, parameter, public independent_particles
Theory level.
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.
This module defines an abstract class for Hamiltonians.
integer, parameter, public term_non_local_potential
integer, parameter, public term_kinetic
subroutine, public zhamiltonian_elec_apply_batch(hm, namespace, mesh, psib, hpsib, terms, set_bc)
subroutine, public hamiltonian_elec_update_with_ext_pot(this, mesh, space, ext_partners, time, mu)
This is an extension of "hamiltonian_elec_update_pot" to be used by the CFM4 propagator....
subroutine, public zhamiltonian_elec_external(this, mesh, psib, vpsib)
This module defines classes and functions for interaction partners.
A module to handle KS potential, without the external potential.
integer, parameter, public e_field_electric
integer, parameter, public e_field_vector_potential
subroutine, public laser_potential(laser, mesh, pot, time)
integer pure elemental function, public laser_kind(laser)
integer, parameter, public e_field_magnetic
This module defines the meshes, which are used in Octopus.
subroutine, public messages_not_implemented(feature, namespace)
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 potential_interpolation_interpolate(potential_interpolation, order, time, dt, t, vhxc, vtau)
subroutine, public propagation_ops_elec_fuse_density_exp_apply(te, namespace, st, gr, hm, dt, dt2, op)
subroutine, public propagation_ops_elec_exp_apply(te, namespace, st, mesh, hm, dt, op)
subroutine, public td_cfmagnus4(ks, namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners, iter)
Commutator-free Magnus propagator of order 4.
subroutine magnus4_operator_apply(this, psib, hpsib)
subroutine, public td_magnus(hm, ext_partners, gr, st, tr, namespace, time, dt)
Magnus propagator.
type(magnus4_operator_t) function, pointer magnus4_operator_constructor(namespace, mesh, hm, vmagnus)
subroutine, public td_explicit_runge_kutta4(ks, namespace, space, hm, gr, st, time, dt, ions_dyn, ions, ext_partners, qcchi)
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Class defining batches of mesh functions.
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.
batches of electronic states