63 class(mesh_t),
intent(in) :: mesh
64 type(states_elec_dim_t),
intent(in) :: std
65 real(real64),
intent(in) :: rho(:,:)
66 real(real64),
intent(out) :: md(:,:)
70 select case (std%ispin)
76 md(1:mesh%np, 3) = rho(1:mesh%np, 1) - rho(1:mesh%np, 2)
79 md(1:mesh%np, 1) =
m_two*rho(1:mesh%np, 3)
80 md(1:mesh%np, 2) = -
m_two*rho(1:mesh%np, 4)
81 md(1:mesh%np, 3) = rho(1:mesh%np, 1) - rho(1:mesh%np, 2)
90 class(mesh_t),
intent(in) :: mesh
91 type(states_elec_t),
intent(in) :: st
92 real(real64),
intent(in) :: rho(:,:)
93 real(real64),
intent(out) :: mm(3)
95 real(real64),
allocatable :: md(:,:)
97 push_sub(states_elec_magnetic_moment)
99 safe_allocate(md(1:mesh%np, 1:3))
104 safe_deallocate_a(md)
106 pop_sub(states_elec_magnetic_moment)
112 class(mesh_t),
intent(in) :: mesh
113 type(states_elec_t),
intent(in) :: st
114 type(ions_t),
intent(in) :: ions
115 type(boundaries_t),
intent(in) :: boundaries
116 real(real64),
intent(in) :: lmm_r
117 integer,
optional,
intent(in) :: iunit
118 type(namespace_t),
optional,
intent(in) :: namespace
121 real(real64) :: mm(max(mesh%box%dim, 3))
122 real(real64),
allocatable :: lmm(:,:)
127 safe_allocate(lmm(1:max(mesh%box%dim, 3), 1:ions%natoms))
130 message(1) =
'Total Magnetic Moment:'
133 write(
message(1),
'(a,f10.6)')
' mz = ', mm(3)
135 else if (st%d%ispin ==
spinors)
then
136 write(
message(1),
'(1x,3(a,f10.6,3x))')
'mx = ', mm(1),
'my = ', mm(2),
'mz = ', mm(3)
140 write(
message(1),
'(a,a,a,f7.3,a)')
'Local Magnetic Moments (sphere radius [', &
144 write(
message(1),
'(a,6x,14x,a)')
' Ion',
'mz'
146 do ia = 1, ions%natoms
147 write(
message(1),
'(i4,a10,f15.6)') ia, trim(ions%atom(ia)%species%get_label()), lmm(3, ia)
150 else if (st%d%ispin ==
spinors)
then
151 write(
message(1),
'(a,8x,13x,a,13x,a,13x,a)')
' Ion',
'mx',
'my',
'mz'
153 do ia = 1, ions%natoms
154 write(
message(1),
'(i4,a10,9f15.6)') ia, trim(ions%atom(ia)%species%get_label()), lmm(:, ia)
159 safe_deallocate_a(lmm)
166 class(
mesh_t),
intent(in) :: mesh
168 type(
ions_t),
intent(in) :: ions
170 real(real64),
intent(in) :: rho(:,:)
171 real(real64),
intent(in) :: rr
172 real(real64),
intent(out) :: lmm(max(mesh%box%dim, 3), ions%natoms)
174 integer :: ia, idir, is
175 real(real64),
allocatable :: md(:, :)
177 real(real64) :: cosqr, sinqr
178 complex(real64),
allocatable :: phase_spiral(:)
182 safe_allocate(md(1:mesh%np, 1:max(mesh%box%dim, 3)))
186 do ia = 1, ions%natoms
187 call submesh_init(sphere, ions%space, mesh, ions%latt, ions%pos(:, ia), rr)
189 if (boundaries%spiral)
then
190 safe_allocate(phase_spiral(1:sphere%np))
192 phase_spiral(is) =
exp(+
m_zi*sum((sphere%rel_x(:,is) + sphere%center - mesh%x(sphere%map(is),:)) &
193 *boundaries%spiral_q(1:mesh%box%dim)))
196 if (mesh%box%dim>= 3)
then
202 cosqr = real(phase_spiral(is), real64)
203 sinqr = aimag(phase_spiral(is))
204 lmm(1,ia) = lmm(1,ia)+md(sphere%map(is),1)*cosqr - md(sphere%map(is),2)*sinqr
205 lmm(2,ia) = lmm(2,ia)+md(sphere%map(is),1)*sinqr + md(sphere%map(is),2)*cosqr
207 lmm(1,ia) = lmm(1,ia)*mesh%volume_element
208 lmm(2,ia) = lmm(2,ia)*mesh%volume_element
211 assert(.not. boundaries%spiral)
214 safe_deallocate_a(phase_spiral)
216 do idir = 1, max(mesh%box%dim, 3)
224 call mesh%allreduce(lmm)
226 safe_deallocate_a(md)
233 class(
mesh_t),
intent(in) :: mesh
235 real(real64),
intent(in) :: qq(:)
236 complex(real64),
intent(out) :: trans_mag(6)
239 complex(real64),
allocatable :: tmp(:,:)
240 real(real64),
allocatable :: md(:, :)
241 complex(real64) :: expqr
247 safe_allocate(tmp(1:mesh%np, 1:6))
248 safe_allocate(md(1:mesh%np, 1:max(mesh%box%dim, 3)))
252 expqr =
exp(-
m_zi*sum(mesh%x(ip, 1:mesh%box%dim)*qq(1:mesh%box%dim)))
253 tmp(ip,1) = expqr*md(ip,1)
254 tmp(ip,2) = expqr*md(ip,2)
255 tmp(ip,3) = expqr*md(ip,3)
256 tmp(ip,4) = conjg(expqr)*md(ip,1)
257 tmp(ip,5) = conjg(expqr)*md(ip,2)
258 tmp(ip,6) = conjg(expqr)*md(ip,3)
263 safe_deallocate_a(md)
264 safe_deallocate_a(tmp)
275 subroutine magnetic_induced(namespace, gr, st, psolver, kpoints, a_ind, b_ind)
277 type(
grid_t),
intent(in) :: gr
281 real(real64),
contiguous,
intent(out) :: a_ind(:, :)
282 real(real64),
contiguous,
intent(out) :: b_ind(:, :)
287 real(real64),
allocatable :: jj(:, :, :)
300 safe_allocate(jj(1:gr%np_part, 1:gr%der%dim, 1:st%d%nspin))
304 if (st%d%nspin > 1)
then
305 do idir = 1, gr%der%dim
306 jj(:, idir, 1) = jj(:, idir, 1) + jj(:, idir, 2)
311 do idir = 1, gr%der%dim
312 call dpoisson_solve(psolver, namespace, a_ind(:, idir), jj(:, idir, 1))
317 a_ind(1:gr%np, 1:gr%der%dim) = - a_ind(1:gr%np, 1:gr%der%dim) /
p_c
321 safe_deallocate_a(jj)
326 integer,
intent(in) :: iunit
327 class(
mesh_t),
intent(in) :: mesh
328 real(real64),
intent(in) :: vxc(:,:)
331 real(real64),
allocatable :: torque(:,:)
332 real(real64) :: tt(3)
336 safe_allocate(torque(1:mesh%np, 1:3))
343 write(iunit,
'(a)')
'Total xc torque:'
344 write(iunit,
'(1x,3(a,es10.3,3x))')
'Tx = ', tt(1),
'Ty = ', tt(2),
'Tz = ', tt(3)
347 safe_deallocate_a(torque)
354 class(
mesh_t),
intent(in) :: mesh
355 real(real64),
intent(in) :: vxc(:,:)
357 real(real64),
intent(inout) :: torque(:,:)
359 real(real64) :: mag(3), bxc(3)
367 mag(1) =
m_two * st%rho(ip, 3)
369 mag(3) = st%rho(ip, 1) - st%rho(ip, 2)
370 bxc(1) = -
m_two * vxc(ip, 3)
371 bxc(2) =
m_two * vxc(ip, 4)
372 bxc(3) = -(vxc(ip, 1) - vxc(ip, 2))
373 torque(ip, 1) = mag(2) * bxc(3) - mag(3) * bxc(2)
374 torque(ip, 2) = mag(3) * bxc(1) - mag(1) * bxc(3)
375 torque(ip, 3) = mag(1) * bxc(2) - mag(2) * bxc(1)
double exp(double __x) __attribute__((__nothrow__
Module implementing boundary conditions in Octopus.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_curl(der, ff, op_ff, ghost_update, set_bc)
apply the curl operator to a vector of mesh functions
integer, parameter, public unpolarized
Parameters...
integer, parameter, public spinors
integer, parameter, public spin_polarized
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
complex(real64), parameter, public m_zi
real(real64), parameter, public p_c
Electron gyromagnetic ratio, see Phys. Rev. Lett. 130, 071801 (2023)
This module implements the underlying real-space grid.
subroutine, public magnetic_local_moments(mesh, st, ions, boundaries, rho, rr, lmm)
subroutine, public write_magnetic_moments(mesh, st, ions, boundaries, lmm_r, iunit, namespace)
subroutine, public calc_xc_torque(mesh, vxc, st, torque)
subroutine, public magnetic_moment(mesh, st, rho, mm)
subroutine, public magnetic_total_magnetization(mesh, st, qq, trans_mag)
subroutine, public write_total_xc_torque(iunit, mesh, vxc, st)
subroutine, public magnetic_density(mesh, std, rho, md)
subroutine, public magnetic_induced(namespace, gr, st, psolver, kpoints, a_ind, b_ind)
This subroutine receives as input a current, and produces as an output the vector potential that it i...
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
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)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
Calculates the Poisson equation. Given the density returns the corresponding potential.
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_calc_quantities(gr, st, kpoints, nlcc, kinetic_energy_density, paramagnetic_current, density_gradient, density_laplacian, gi_kinetic_energy_density, st_end)
calculated selected quantities
real(real64) function, public dsm_integrate_frommesh(mesh, sm, ff, reduce)
subroutine, public submesh_end(this)
subroutine, public submesh_init(this, space, mesh, latt, center, rc)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
This class contains information about the boundary conditions.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
A submesh is a type of mesh, used for the projectors in the pseudopotentials It contains points on a ...