32  use, 
intrinsic :: iso_fortran_env
 
   73  integer, 
public, 
parameter ::   &
 
   83    real(real64),      
allocatable :: vpsl(:)
 
   85    type(projector_t), 
allocatable :: proj(:)
 
   90    real(real64), 
allocatable     :: e_field(:)
 
   91    real(real64), 
allocatable     :: v_ext(:)
 
   92    real(real64), 
allocatable     :: b_field(:)
 
   93    real(real64), 
allocatable     :: a_static(:,:)
 
   98    real(real64) :: gyromagnetic_ratio
 
  101    real(real64) :: so_strength
 
  105    real(real64), 
allocatable :: fii(:, :)
 
  106    real(real64), 
allocatable :: vdw_forces(:, :)
 
  107    real(real64), 
allocatable :: photon_forces(:)
 
  110    real(real64) :: vdw_stress(3, 3)
 
  112    real(real64), 
allocatable, 
private :: local_potential(:,:)
 
  113    logical,            
private :: local_potential_precalculated
 
  115    logical,                  
private :: have_density
 
  116    type(poisson_t), 
pointer, 
private :: poisson_solver
 
  118    logical              :: nlcc = .false.   
 
  124  subroutine epot_init(ep, namespace, gr, ions, psolver, ispin, xc_family, kpoints)
 
  125    type(epot_t),                       
intent(out)   :: ep
 
  126    type(namespace_t),                  
intent(in)    :: namespace
 
  127    type(grid_t),                       
intent(in)    :: gr
 
  128    type(ions_t),                       
intent(inout) :: ions
 
  129    type(poisson_t),  
target,           
intent(in)    :: psolver
 
  130    integer,                            
intent(in)    :: ispin
 
  131    integer,                            
intent(in)    :: xc_family
 
  132    type(kpoints_t),                    
intent(in)    :: kpoints
 
  166    do ispec = 1, ions%nspecies
 
  167      call ions%species(ispec)%s%init_potential(namespace, 
mesh_gcutoff(gr), filter)
 
  170    safe_allocate(ep%vpsl(1:gr%np))
 
  214    call parse_variable(namespace, 
'RelativisticCorrection', norel, ep%reltype)
 
  219      message(1) = 
"The spin-orbit term can only be applied when using spinors." 
  223    if(ep%reltype == 
spin_orbit .and. kpoints%use_symmetries) 
then 
  240      ep%so_strength = 
m_one 
  243    safe_allocate(ep%proj(1:ions%natoms))
 
  245    ep%natoms = ions%natoms
 
  246    ep%non_local = .false.
 
  249    safe_allocate(ep%fii(1:ions%space%dim, 1:ions%natoms))
 
  252    safe_allocate(ep%vdw_forces(1:ions%space%dim, 1:ions%natoms))
 
  255    safe_allocate(ep%photon_forces(1:ions%space%dim))
 
  258    ep%local_potential_precalculated = .false.
 
  261    ep%have_density = .false.
 
  262    do ia = 1, ions%nspecies
 
  264        ep%have_density = .
true.
 
  269    if (ep%have_density) 
then 
  270      ep%poisson_solver => psolver
 
  272      nullify(ep%poisson_solver)
 
  277    do ia = 1, ions%nspecies
 
  278      ep%nlcc = (ep%nlcc .or. ions%species(ia)%s%is_ps_with_nlcc())
 
  286    type(
epot_t), 
intent(inout) :: ep
 
  292    if (ep%have_density) 
then 
  293      nullify(ep%poisson_solver)
 
  296    safe_deallocate_a(ep%local_potential)
 
  297    safe_deallocate_a(ep%fii)
 
  298    safe_deallocate_a(ep%vdw_forces)
 
  299    safe_deallocate_a(ep%vpsl)
 
  300    safe_deallocate_a(ep%photon_forces)
 
  303    safe_deallocate_a(ep%e_field)
 
  304    safe_deallocate_a(ep%v_ext)
 
  305    safe_deallocate_a(ep%b_field)
 
  306    safe_deallocate_a(ep%a_static)
 
  308    do iproj = 1, ep%natoms
 
  313    assert(
allocated(ep%proj))
 
  314    safe_deallocate_a(ep%proj)
 
  322    type(
epot_t),             
intent(inout) :: ep
 
  324    class(
mesh_t),    
target, 
intent(in)    :: mesh
 
  325    type(
ions_t),     
target, 
intent(inout) :: ions
 
  329    type(
ps_t), 
pointer :: ps
 
  339      ions%natoms, ions%pos, mesh%box%bounding_box_l, ep%eii, ep%fii)
 
  342    do ia = 1, ions%natoms
 
  343      select type(spec=>ions%atom(ia)%species)
 
  346        call projector_init(ep%proj(ia), spec, namespace, st_d%dim, ep%reltype)
 
  350    do ia = ions%atoms_dist%start, ions%atoms_dist%end
 
  352      select type(spec=>ions%atom(ia)%species)
 
  355        call submesh_init(ep%proj(ia)%sphere, ions%space, mesh, ions%latt, ions%pos(:, ia), ps%rc_max)
 
  359    if (ions%atoms_dist%parallel) 
then 
  360      do ia = 1, ions%natoms
 
  362        select type(spec=>ions%atom(ia)%species)
 
  365          call submesh_broadcast(ep%proj(ia)%sphere, ions%space, mesh, ions%pos(:, ia), ps%rc_max, &
 
  366            ions%atoms_dist%node(ia), ions%atoms_dist%mpi_grp)
 
  371    do ia = 1, ions%natoms
 
  372      select type(spec=>ions%atom(ia)%species)
 
  386    class(
space_t),       
intent(in)    :: space
 
  389    has_density = species%has_density .or. (species%is_ps() .and. space%is_periodic())
 
  395    type(
epot_t),             
intent(in)    :: ep
 
  396    type(namespace_t),        
intent(in)    :: namespace
 
  397    class(space_t),           
intent(in)    :: space
 
  398    type(lattice_vectors_t),  
intent(in)    :: latt
 
  399    class(mesh_t),            
intent(in)    :: mesh
 
  400    class(species_t), 
target, 
intent(in)    :: species
 
  401    real(real64),             
intent(in)    :: pos(1:space%dim)
 
  402    integer,                  
intent(in)    :: iatom
 
  403    real(real64), 
contiguous,        
intent(inout) :: vpsl(:)
 
  406    real(real64) :: radius
 
  407    real(real64), 
allocatable :: vl(:), rho(:)
 
  408    type(submesh_t)  :: sphere
 
  409    type(ps_t), 
pointer :: ps
 
  412    call profiling_in(
"EPOT_LOCAL")
 
  414    if (ep%local_potential_precalculated) 
then 
  417        vpsl(ip) = vpsl(ip) + ep%local_potential(ip, iatom)
 
  424      safe_allocate(vl(1:mesh%np))
 
  427        safe_allocate(rho(1:mesh%np))
 
  429        call species_get_long_range_density(species, namespace, space, latt, pos, mesh, rho, sphere)
 
  431        if (poisson_solver_is_iterative(ep%poisson_solver)) 
then 
  434          vl(1:mesh%np) = m_zero
 
  437        call dpoisson_solve(ep%poisson_solver, namespace, vl, rho, all_nodes = .false.)
 
  439        safe_deallocate_a(rho)
 
  443        call species_get_local(species, namespace, space, latt, pos, mesh, vl)
 
  447      call lalg_axpy(mesh%np, m_one, vl, vpsl)
 
  448      safe_deallocate_a(vl)
 
  452      class is(pseudopotential_t)
 
  456        radius = ps%vl%x_threshold*1.05_real64
 
  457        if (.not. submesh_compatible(sphere, radius, pos, minval(mesh%spacing(1:space%dim)))) 
then 
  458          call submesh_end(sphere)
 
  459          call submesh_init(sphere, space, mesh, latt, pos, radius)
 
  461        safe_allocate(vl(1:sphere%np))
 
  465          if(sphere%r(ip) <= radius) 
then 
  466            vl(ip) = spline_eval(ps%vl, sphere%r(ip))
 
  470        call submesh_add_to_mesh(sphere, vl, vpsl)
 
  472        safe_deallocate_a(vl)
 
  476      call submesh_end(sphere)
 
  480    call profiling_out(
"EPOT_LOCAL")
 
  486    type(
epot_t),      
intent(inout) :: ep
 
  487    type(namespace_t), 
intent(in)    :: namespace
 
  488    type(grid_t),      
intent(in)    :: gr
 
  489    type(ions_t),      
intent(in)    :: ions
 
  495    if (.not. 
allocated(ep%local_potential)) 
then 
  496      safe_allocate(ep%local_potential(1:gr%np, 1:ions%natoms))
 
  499    ep%local_potential_precalculated = .false.
 
  501    do iatom = 1, ions%natoms
 
  502      ep%local_potential(1:gr%np, iatom) = m_zero
 
  504        ions%pos(:, iatom), iatom, ep%local_potential(1:gr%np, iatom))
 
  506    ep%local_potential_precalculated = .
true.
 
  514    type(
epot_t), 
intent(in)  :: ep
 
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public spinors
logical function, public epot_have_external_potentials(ep)
logical pure function, public local_potential_has_density(space, species)
integer, parameter, public spin_orbit
integer, parameter, public scalar_relativistic_zora
subroutine, public epot_end(ep)
integer, parameter, public fully_relativistic_zora
subroutine, public epot_precalc_local_potential(ep, namespace, gr, ions)
subroutine, public epot_local_potential(ep, namespace, space, latt, mesh, species, pos, iatom, vpsl)
subroutine, public epot_init(ep, namespace, gr, ions, psolver, ispin, xc_family, kpoints)
subroutine, public epot_generate(ep, namespace, mesh, ions, st_d)
real(real64), parameter, public p_g
real(real64), parameter, public m_zero
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
subroutine, public ion_interaction_calculate(this, space, latt, atom, natoms, pos, lsize, energy, force, energy_components, force_components)
Top level routine for computing electrostatic energies and forces between ions.
This module defines the meshes, which are used in Octopus.
real(real64) function, public mesh_gcutoff(mesh)
mesh_gcutoff returns the "natural" band limitation of the grid mesh, in terms of the maximum G vector...
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
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 messages_input_error(namespace, var, details, row, column)
This module handles the communicators for the various parallelization strategies.
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.
subroutine, public projector_build(p, ps, so_strength)
logical elemental function, public projector_is(p, type)
subroutine, public projector_init(p, pseudo, namespace, dim, reltype)
subroutine, public projector_end(p)
logical elemental function, public projector_is_null(p)
integer, parameter, public ps_filter_ts
integer, parameter, public ps_filter_none
integer, parameter, public proj_none
subroutine, public spline_filter_mask_init()
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public submesh_broadcast(this, space, mesh, center, radius, root, mpi_grp)
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.
This module defines the unit system, used for input and output.
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
Describes mesh distribution to nodes.
An abstract class for species. Derived classes include jellium, all electron, and pseudopotential spe...
class for organizing spins and k-points