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))
 
  106    if (mesh%parallel_in_domains) 
then 
  107      call mesh%allreduce(mm)
 
  110    safe_deallocate_a(md)
 
  112    pop_sub(states_elec_magnetic_moment)
 
  118    class(mesh_t),               
intent(in) :: mesh
 
  119    type(states_elec_t),         
intent(in) :: st
 
  120    type(ions_t),                
intent(in) :: ions
 
  121    type(boundaries_t),          
intent(in) :: boundaries
 
  122    real(real64),                
intent(in) :: lmm_r
 
  123    integer,           
optional, 
intent(in) :: iunit
 
  124    type(namespace_t), 
optional, 
intent(in) :: namespace
 
  127    real(real64) :: mm(max(mesh%box%dim, 3))
 
  128    real(real64), 
allocatable :: lmm(:,:)
 
  133    safe_allocate(lmm(1:max(mesh%box%dim, 3), 1:ions%natoms))
 
  136    message(1) = 
'Total Magnetic Moment:' 
  139      write(
message(1), 
'(a,f10.6)') 
' mz = ', mm(3)
 
  141    else if (st%d%ispin == 
spinors) 
then  
  142      write(
message(1), 
'(1x,3(a,f10.6,3x))') 
'mx = ', mm(1),
'my = ', mm(2),
'mz = ', mm(3)
 
  146    write(
message(1), 
'(a,a,a,f7.3,a)') 
'Local Magnetic Moments (sphere radius [', &
 
  150      write(
message(1),
'(a,6x,14x,a)') 
' Ion',
'mz' 
  152      do ia = 1, ions%natoms
 
  153        write(
message(1),
'(i4,a10,f15.6)') ia, trim(ions%atom(ia)%species%get_label()), lmm(3, ia)
 
  156    else if (st%d%ispin == 
spinors) 
then  
  157      write(
message(1),
'(a,8x,13x,a,13x,a,13x,a)') 
' Ion',
'mx',
'my',
'mz' 
  159      do ia = 1, ions%natoms
 
  160        write(
message(1),
'(i4,a10,9f15.6)') ia, trim(ions%atom(ia)%species%get_label()), lmm(:, ia)
 
  165    safe_deallocate_a(lmm)
 
  172    class(
mesh_t),        
intent(in)  :: mesh
 
  174    type(
ions_t),         
intent(in)  :: ions
 
  176    real(real64),         
intent(in)  :: rho(:,:)
 
  177    real(real64),         
intent(in)  :: rr
 
  178    real(real64),         
intent(out) :: lmm(max(mesh%box%dim, 3), ions%natoms)
 
  180    integer :: ia, idir, is
 
  181    real(real64), 
allocatable :: md(:, :)
 
  183    real(real64) :: cosqr, sinqr
 
  184    complex(real64), 
allocatable :: phase_spiral(:)
 
  188    safe_allocate(md(1:mesh%np, 1:max(mesh%box%dim, 3)))
 
  192    do ia = 1, ions%natoms
 
  193      call submesh_init(sphere, ions%space, mesh, ions%latt, ions%pos(:, ia), rr)
 
  195      if (boundaries%spiral) 
then 
  196        safe_allocate(phase_spiral(1:sphere%np))
 
  198          phase_spiral(is) = 
exp(+
m_zi*sum((sphere%rel_x(:,is) + sphere%center - mesh%x(sphere%map(is),:)) &
 
  199            *boundaries%spiral_q(1:mesh%box%dim)))
 
  202        if (mesh%box%dim>= 3) 
then 
  208            cosqr = real(phase_spiral(is), real64)
 
  209            sinqr = aimag(phase_spiral(is))
 
  210            lmm(1,ia) = lmm(1,ia)+md(sphere%map(is),1)*cosqr - md(sphere%map(is),2)*sinqr
 
  211            lmm(2,ia) = lmm(2,ia)+md(sphere%map(is),1)*sinqr + md(sphere%map(is),2)*cosqr
 
  213          lmm(1,ia) = lmm(1,ia)*mesh%volume_element
 
  214          lmm(2,ia) = lmm(2,ia)*mesh%volume_element
 
  217          assert(.not. boundaries%spiral)
 
  220        safe_deallocate_a(phase_spiral)
 
  222        do idir = 1, max(mesh%box%dim, 3)
 
  230    if (mesh%parallel_in_domains) 
then 
  231      call mesh%allreduce(lmm)
 
  234    safe_deallocate_a(md)
 
  241    class(
mesh_t),       
intent(in)  :: mesh
 
  243    real(real64),        
intent(in)  :: qq(:)
 
  244    complex(real64),     
intent(out) :: trans_mag(6)
 
  247    complex(real64), 
allocatable :: tmp(:,:)
 
  248    real(real64), 
allocatable :: md(:, :)
 
  249    complex(real64) :: expqr
 
  255    safe_allocate(tmp(1:mesh%np, 1:6))
 
  256    safe_allocate(md(1:mesh%np, 1:max(mesh%box%dim, 3)))
 
  260      expqr = 
exp(-
m_zi*sum(mesh%x(ip, 1:mesh%box%dim)*qq(1:mesh%box%dim)))
 
  261      tmp(ip,1) = expqr*md(ip,1)
 
  262      tmp(ip,2) = expqr*md(ip,2)
 
  263      tmp(ip,3) = expqr*md(ip,3)
 
  264      tmp(ip,4) = conjg(expqr)*md(ip,1)
 
  265      tmp(ip,5) = conjg(expqr)*md(ip,2)
 
  266      tmp(ip,6) = conjg(expqr)*md(ip,3)
 
  275    safe_deallocate_a(md)
 
  276    safe_deallocate_a(tmp)
 
  287  subroutine magnetic_induced(namespace, gr, st, psolver, kpoints, a_ind, b_ind)
 
  289    type(
grid_t),         
intent(in)    :: gr
 
  293    real(real64), 
contiguous,    
intent(out)   :: a_ind(:, :)
 
  294    real(real64), 
contiguous,    
intent(out)   :: b_ind(:, :)
 
  299    real(real64), 
allocatable :: jj(:, :, :)
 
  312    safe_allocate(jj(1:gr%np_part, 1:gr%der%dim, 1:st%d%nspin))
 
  316    if (st%d%nspin > 1) 
then 
  317      do idir = 1, gr%der%dim
 
  318        jj(:, idir, 1) = jj(:, idir, 1) + jj(:, idir, 2)
 
  323    do idir = 1, gr%der%dim
 
  324      call dpoisson_solve(psolver, namespace, a_ind(:, idir), jj(:, idir, 1))
 
  329    a_ind(1:gr%np, 1:gr%der%dim) = - a_ind(1:gr%np, 1:gr%der%dim) / 
p_c 
  333    safe_deallocate_a(jj)
 
  338    integer,                  
intent(in) :: iunit
 
  339    class(
mesh_t),            
intent(in) :: mesh
 
  340    real(real64),             
intent(in) :: vxc(:,:)
 
  343    real(real64), 
allocatable :: torque(:,:)
 
  344    real(real64) :: tt(3)
 
  348    safe_allocate(torque(1:mesh%np, 1:3))
 
  357      write(iunit, 
'(a)') 
'Total xc torque:' 
  358      write(iunit, 
'(1x,3(a,es10.3,3x))') 
'Tx = ', tt(1),
'Ty = ', tt(2),
'Tz = ', tt(3)
 
  361    safe_deallocate_a(torque)
 
  368    class(
mesh_t),            
intent(in) :: mesh
 
  369    real(real64),             
intent(in) :: vxc(:,:)
 
  371    real(real64),          
intent(inout) :: torque(:,:)
 
  373    real(real64) :: mag(3), bxc(3)
 
  381      mag(1) =  
m_two * st%rho(ip, 3)
 
  382      mag(2) = -
m_two * st%rho(ip, 4)
 
  383      mag(3) = st%rho(ip, 1) - st%rho(ip, 2)
 
  384      bxc(1) = -
m_two * vxc(ip, 3)
 
  385      bxc(2) =  
m_two * vxc(ip, 4)
 
  386      bxc(3) = -(vxc(ip, 1) - vxc(ip, 2))
 
  387      torque(ip, 1) = mag(2) * bxc(3) - mag(3) * bxc(2)
 
  388      torque(ip, 2) = mag(3) * bxc(1) - mag(1) * bxc(3)
 
  389      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.
 
complex(real64) function, public zmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
 
real(real64) function, public dmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
 
This module defines the meshes, which are used in Octopus.
 
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
 
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
 
logical function mpi_grp_is_root(grp)
 
type(mpi_grp_t), public mpi_world
 
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel)
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 ...