84 logical :: pack_states
85 logical :: parallel_in_states = .false.
86 integer,
public :: nst
87 logical,
public :: packed
89 complex(real64),
allocatable :: rs_state_plane_waves(:,:)
90 complex(real64),
allocatable :: rs_state(:,:)
91 complex(real64),
allocatable :: rs_state_prev(:,:)
92 complex(real64),
allocatable :: rs_state_trans(:,:)
93 complex(real64),
allocatable :: rs_state_long(:,:)
94 complex(real64),
allocatable :: rs_current_density_t1(:,:)
95 complex(real64),
allocatable :: rs_current_density_t2(:,:)
97 logical :: rs_current_density_restart = .false.
98 complex(real64),
allocatable :: rs_current_density_restart_t1(:,:)
99 complex(real64),
allocatable :: rs_current_density_restart_t2(:,:)
101 type(batch_t) :: rs_stateb
102 type(batch_t) :: rs_state_prevb
103 type(batch_t) :: inhomogeneousb
104 type(batch_t) :: rs_state_plane_wavesb
106 real(real64),
allocatable :: ep(:)
107 real(real64),
allocatable :: mu(:)
109 integer,
allocatable :: rs_state_fft_map(:,:,:)
110 integer,
allocatable :: rs_state_fft_map_inv(:,:)
112 real(real64) :: energy_rate
113 real(real64) :: delta_energy
114 real(real64) :: energy_via_flux_calc
116 real(real64) :: trans_energy_rate
117 real(real64) :: trans_delta_energy
118 real(real64) :: trans_energy_via_flux_calc
120 real(real64) :: plane_waves_energy_rate
121 real(real64) :: plane_waves_delta_energy
122 real(real64) :: plane_waves_energy_via_flux_calc
124 real(real64) :: poynting_vector_box_surface(1:2,1:3,1:3) =
m_zero
125 real(real64) :: poynting_vector_box_surface_plane_waves(1:2,1:3,1:3) =
m_zero
126 real(real64) :: electric_field_box_surface(1:2,1:3,1:3) =
m_zero
127 real(real64) :: electric_field_box_surface_plane_waves(1:2,1:3,1:3) =
m_zero
128 real(real64) :: magnetic_field_box_surface(1:2,1:3,1:3) =
m_zero
129 real(real64) :: magnetic_field_box_surface_plane_waves(1:2,1:3,1:3) =
m_zero
131 logical :: rs_state_const_external = .false.
132 complex(real64),
allocatable :: rs_state_const(:)
133 complex(real64),
allocatable :: rs_state_const_amp(:,:)
134 type(tdf_t),
allocatable :: rs_state_const_td_function(:)
136 integer :: inner_points_number
137 integer,
allocatable :: inner_points_map(:)
138 logical,
allocatable :: inner_points_mask(:)
139 integer :: boundary_points_number
140 integer,
allocatable :: boundary_points_map(:)
141 logical,
allocatable :: boundary_points_mask(:)
142 type(accel_mem_t) :: buff_inner_points_map, buff_boundary_points_map
144 integer :: surface_points_number(3)
145 integer,
allocatable :: surface_points_map(:,:,:)
146 real(real64) :: surface_element(3)
148 integer :: surface_grid_rows_number(3)
149 integer,
allocatable :: surface_grid_points_number(:,:,:)
150 integer(int64),
allocatable :: surface_grid_points_map(:,:,:,:,:)
151 integer,
allocatable :: surface_grid_center(:,:,:,:)
152 real(real64) :: surface_grid_element(3)
154 type(mesh_plane_t) :: surface(2,3)
156 integer :: selected_points_number
157 real(real64),
allocatable :: selected_points_coordinate(:,:)
158 complex(real64),
allocatable :: selected_points_rs_state(:,:)
159 complex(real64),
allocatable :: selected_points_rs_state_long(:,:)
160 complex(real64),
allocatable :: selected_points_rs_state_trans(:,:)
161 integer,
allocatable :: selected_points_map(:)
162 type(accel_mem_t) :: buff_selected_points_map
163 real(real64) :: rs_state_trans_var
165 real(real64),
allocatable :: grid_rho(:,:)
166 complex(real64),
allocatable :: kappa_psi(:,:)
168 character(len=1024),
allocatable :: user_def_e_field(:)
169 character(len=1024),
allocatable :: user_def_b_field(:)
171 integer :: energy_incident_waves_calc_iter
172 logical :: energy_incident_waves_calc
175 integer :: external_current_number
176 integer,
allocatable :: external_current_modus(:)
177 character(len=1024),
allocatable :: external_current_string(:,:)
178 real(real64),
allocatable :: external_current_amplitude(:,:,:)
179 type(
tdf_t),
allocatable :: external_current_td_function(:)
180 type(
tdf_t),
allocatable :: external_current_td_phase(:)
181 real(real64),
allocatable :: external_current_omega(:)
182 real(real64),
allocatable :: external_current_phase(:)
185 character(len=1024),
allocatable :: user_def_states(:,:,:)
186 logical :: fromscratch = .
true.
195 logical :: scalapack_compatible
197 integer :: st_start, st_end
198 integer,
allocatable :: node(:)
201 integer :: transverse_field_mode
205 integer,
public,
parameter :: &
218 integer :: idim, nlines, ncols, il
219 real(real64),
allocatable :: pos(:)
220 integer :: ix_max, iy_max, iz_max
228 assert(space%dim == 3)
232 safe_allocate(st%user_def_e_field(1:st%dim))
233 safe_allocate(st%user_def_b_field(1:st%dim))
239 safe_allocate(st%node(1:st%nst))
240 st%node(1:st%nst) = 0
243 st%parallel_in_states = .false.
273 safe_allocate(pos(1:st%dim))
274 st%selected_points_number = 1
275 if (
parse_block(namespace,
'MaxwellFieldsCoordinate', blk) == 0)
then
277 st%selected_points_number = nlines
278 safe_allocate(st%selected_points_coordinate(1:st%dim,1:nlines))
279 safe_allocate(st%selected_points_rs_state(1:st%dim,1:nlines))
280 safe_allocate(st%selected_points_rs_state_long(1:st%dim,1:nlines))
281 safe_allocate(st%selected_points_rs_state_trans(1:st%dim,1:nlines))
282 safe_allocate(st%selected_points_map(1:nlines))
285 if (ncols < 3 .or. ncols > 3)
then
286 message(1) =
'MaxwellFieldCoordinate must have 3 columns.'
292 st%selected_points_coordinate(:,il) = pos
293 st%selected_points_rs_state(:,il) =
m_z0
294 st%selected_points_rs_state_long(:,il) =
m_z0
295 st%selected_points_rs_state_trans(:,il) =
m_z0
299 safe_allocate(st%selected_points_coordinate(1:st%dim, 1))
300 safe_allocate(st%selected_points_rs_state(1:st%dim, 1))
301 safe_allocate(st%selected_points_rs_state_long(1:st%dim, 1))
302 safe_allocate(st%selected_points_rs_state_trans(1:st%dim, 1))
303 safe_allocate(st%selected_points_map(1))
304 st%selected_points_coordinate(:,:) =
m_zero
305 st%selected_points_rs_state(:,:) =
m_z0
306 st%selected_points_rs_state_long(:,:) =
m_z0
307 st%selected_points_rs_state_trans(:,:) =
m_z0
308 st%selected_points_map(:) = -1
311 safe_deallocate_a(pos)
313 st%surface_grid_rows_number(1) = 3
314 ix_max = st%surface_grid_rows_number(1)
315 st%surface_grid_rows_number(2) = 3
316 iy_max = st%surface_grid_rows_number(2)
317 st%surface_grid_rows_number(3) = 3
318 iz_max = st%surface_grid_rows_number(3)
320 safe_allocate(st%surface_grid_center(1:2, 1:st%dim, 1:ix_max, 1:iy_max))
321 safe_allocate(st%surface_grid_points_number(1:st%dim, 1:ix_max, 1:iy_max))
335 st%transverse_field_mode)
347 class(
mesh_t),
intent(in) :: mesh
354 safe_allocate(st%rs_state(1:mesh%np_part, 1:st%dim))
355 st%rs_state(:,:) =
m_z0
357 safe_allocate(st%rs_state_prev(1:mesh%np_part, 1:st%dim))
358 st%rs_state_prev(:,:) =
m_z0
360 safe_allocate(st%rs_state_trans(1:mesh%np_part, 1:st%dim))
361 st%rs_state_trans(:,:) =
m_z0
363 safe_allocate(st%rs_state_long(1:mesh%np_part, 1:st%dim))
364 st%rs_state_long(:,:) =
m_z0
366 safe_allocate(st%rs_state_plane_waves(1:mesh%np_part, 1:st%dim))
367 st%rs_state_plane_waves(:,:) =
m_z0
369 safe_allocate(st%rs_current_density_t1(1:mesh%np, 1:st%dim))
370 st%rs_current_density_t1 =
m_z0
372 safe_allocate(st%rs_current_density_t2(1:mesh%np, 1:st%dim))
373 st%rs_current_density_t2 =
m_z0
375 safe_allocate(st%rs_current_density_restart_t1(1:mesh%np_part, 1:st%dim))
376 st%rs_current_density_restart_t1 =
m_z0
378 safe_allocate(st%rs_current_density_restart_t2(1:mesh%np_part, 1:st%dim))
379 st%rs_current_density_restart_t2 =
m_z0
381 safe_allocate(st%ep(1:mesh%np_part))
382 safe_allocate(st%mu(1:mesh%np_part))
400 safe_deallocate_a(st%rs_state)
401 safe_deallocate_a(st%rs_state_prev)
402 safe_deallocate_a(st%rs_state_trans)
403 safe_deallocate_a(st%selected_points_coordinate)
404 safe_deallocate_a(st%selected_points_rs_state)
405 safe_deallocate_a(st%selected_points_rs_state_long)
406 safe_deallocate_a(st%selected_points_rs_state_trans)
407 safe_deallocate_a(st%rs_current_density_t1)
408 safe_deallocate_a(st%rs_current_density_t2)
409 safe_deallocate_a(st%rs_state_long)
410 safe_deallocate_a(st%rs_current_density_restart_t1)
411 safe_deallocate_a(st%rs_current_density_restart_t2)
412 safe_deallocate_a(st%user_def_e_field)
413 safe_deallocate_a(st%user_def_b_field)
415 safe_deallocate_a(st%rs_state_const)
416 safe_deallocate_a(st%rs_state_const_td_function)
417 safe_deallocate_a(st%rs_state_const_amp)
418 safe_deallocate_a(st%rs_state_plane_waves)
420 safe_deallocate_a(st%surface_grid_center)
421 safe_deallocate_a(st%surface_grid_points_number)
422 safe_deallocate_a(st%surface_grid_points_map)
423 safe_deallocate_a(st%inner_points_map)
424 safe_deallocate_a(st%boundary_points_map)
425 safe_deallocate_a(st%inner_points_mask)
426 safe_deallocate_a(st%boundary_points_mask)
427 safe_deallocate_a(st%ep)
428 safe_deallocate_a(st%mu)
437 safe_deallocate_a(st%external_current_modus)
438 safe_deallocate_a(st%external_current_string)
439 safe_deallocate_a(st%external_current_amplitude)
440 safe_deallocate_a(st%external_current_td_function)
441 safe_deallocate_a(st%external_current_omega)
442 safe_deallocate_a(st%external_current_td_phase)
445 safe_deallocate_a(st%node)
454 subroutine build_rs_vector(e_vector, b_vector, rs_sign, rs_vector, ep_element, mu_element)
455 real(real64),
intent(in) :: e_vector(:), b_vector(:)
456 complex(real64),
intent(inout) :: rs_vector(:)
457 integer,
intent(in) :: rs_sign
458 real(real64),
optional,
intent(in) :: ep_element
459 real(real64),
optional,
intent(in) :: mu_element
463 if (
present(ep_element) .and.
present(mu_element))
then
473 subroutine build_rs_state(e_field, b_field, rs_sign, rs_state, mesh, ep_field, mu_field, np)
474 real(real64),
intent(in) :: e_field(:,:), b_field(:,:)
475 complex(real64),
intent(inout) :: rs_state(:,:)
476 integer,
intent(in) :: rs_sign
477 class(
mesh_t),
intent(in) :: mesh
478 real(real64),
optional,
intent(in) :: ep_field(:)
479 real(real64),
optional,
intent(in) :: mu_field(:)
480 integer,
optional,
intent(in) :: np
491 if (
present(ep_field) .and.
present(mu_field))
then
492 rs_state(ip, :) =
sqrt(ep_field(ip)/
m_two) * e_field(ip, :) &
509 real(real64),
intent(in) :: current_state(:,:)
510 class(
mesh_t),
intent(in) :: mesh
511 complex(real64),
intent(inout) :: rs_current_state(:,:)
512 real(real64),
optional,
intent(in) :: ep_field(:)
513 integer,
optional,
intent(in) :: np
515 integer :: ip, idim, np_, ff_dim
522 ff_dim =
size(current_state, dim=2)
524 if (
present(ep_field))
then
527 rs_current_state(ip, idim) =
m_one/
sqrt(
m_two*ep_field(ip)) * current_state(ip, idim)
545 complex(real64),
intent(in) :: rs_state_vector(:)
546 real(real64),
intent(out) :: electric_field_vector(:)
547 real(real64),
optional,
intent(in) :: ep_element
551 if (
present(ep_element))
then
552 electric_field_vector(:) =
sqrt(
m_two/ep_element) * real(rs_state_vector(:), real64)
554 electric_field_vector(:) =
sqrt(
m_two/
p_ep) * real(rs_state_vector(:), real64)
562 complex(real64),
intent(in) :: rs_state_vector(:)
563 integer,
intent(in) :: rs_sign
564 real(real64),
intent(out) :: magnetic_field_vector(:)
565 real(real64),
optional,
intent(in) :: mu_element
569 if (
present(mu_element))
then
570 magnetic_field_vector(:) =
sqrt(
m_two*mu_element) * rs_sign * aimag(rs_state_vector(:))
572 magnetic_field_vector(:) =
sqrt(
m_two*
p_mu) * rs_sign * aimag(rs_state_vector(:))
580 complex(real64),
intent(in) :: rs_state(:,:)
581 class(
mesh_t),
intent(in) :: mesh
582 real(real64),
intent(out) :: electric_field(:,:)
583 real(real64),
optional,
intent(in) :: ep_field(:)
584 integer,
optional,
intent(in) :: np
595 if (
present(ep_field))
then
596 electric_field(ip, :) =
sqrt(
m_two/ep_field(ip)) * real(rs_state(ip, :), real64)
598 electric_field(ip,:) =
sqrt(
m_two/
p_ep) * real(rs_state(ip, :), real64)
611 complex(real64),
intent(in) :: rs_state(:,:)
612 class(
mesh_t),
intent(in) :: mesh
613 integer,
intent(in) :: rs_sign
614 real(real64),
intent(out) :: magnetic_field(:,:)
615 real(real64),
optional,
intent(in) :: mu_field(:)
616 integer,
optional,
intent(in) :: np
626 if (
present(mu_field))
then
628 magnetic_field(ip, :) =
sqrt(
m_two*mu_field(ip)) * rs_sign * aimag(rs_state(ip, :))
632 magnetic_field(ip, :) =
sqrt(
m_two*
p_mu) * rs_sign * aimag(rs_state(ip, :))
645 complex(real64),
intent(inout) :: rs_state_point(:,:)
646 complex(real64),
intent(in) :: rs_state(:,:)
647 real(real64),
intent(in) :: pos(:,:)
649 class(
mesh_t),
intent(in) :: mesh
651 integer :: ip, pos_index, rankmin
653 complex(real64),
allocatable :: ztmp(:)
657 safe_allocate(ztmp(1:
size(rs_state, dim=2)))
659 do ip = 1, st%selected_points_number
661 if (mesh%mpi_grp%rank == rankmin)
then
662 ztmp(:) = rs_state(pos_index, :)
664 if (mesh%parallel_in_domains)
then
665 call mesh%mpi_grp%bcast(ztmp, st%dim, mpi_double_complex, rankmin)
667 rs_state_point(:, ip) = ztmp(:)
670 safe_deallocate_a(ztmp)
679 complex(real64),
contiguous,
intent(inout) :: rs_state_point(:,:)
680 type(
batch_t),
intent(in) :: rs_stateb
682 class(
mesh_t),
intent(in) :: mesh
685 complex(real64) :: rs_state_tmp(1:st%dim, 1:st%selected_points_number)
688 integer(int64),
dimension(3) :: gsizes, bsizes
692 rs_state_tmp(:,:) =
m_z0
694 select case (rs_stateb%status())
696 do ip_in = 1, st%selected_points_number
697 ip = st%selected_points_map(ip_in)
699 rs_state_tmp(1:st%dim, ip_in) = rs_stateb%zff_linear(ip, 1:st%dim)
703 do ip_in = 1, st%selected_points_number
704 ip = st%selected_points_map(ip_in)
706 rs_state_tmp(1:st%dim, ip_in) = rs_stateb%zff_pack(1:st%dim, ip)
713 st%selected_points_number*st%dim)
725 gsizes, bsizes, kernel)
729 call accel_read_buffer(buff_points, st%dim, st%selected_points_number, rs_state_tmp)
733 call mesh%mpi_grp%allreduce(rs_state_tmp, rs_state_point, st%selected_points_number*st%dim, mpi_double_complex, mpi_sum)
740 type(
grid_t),
intent(in) :: gr
741 real(real64),
contiguous,
intent(inout) :: field(:,:)
742 real(real64),
contiguous,
intent(inout) :: field_div(:)
743 logical,
intent(in) :: charge_density
750 field_div =
p_ep * field_div
758 subroutine get_poynting_vector(mesh, st, rs_state, rs_sign, poynting_vector, ep_field, mu_field)
759 class(
mesh_t),
intent(in) :: mesh
761 complex(real64),
intent(in) :: rs_state(:,:)
762 integer,
intent(in) :: rs_sign
763 real(real64),
intent(out) :: poynting_vector(:,:)
764 real(real64),
optional,
intent(in) :: ep_field(:)
765 real(real64),
optional,
intent(in) :: mu_field(:)
770 if (
present(ep_field) .and.
present(mu_field))
then
772 poynting_vector(ip, 1:3) =
m_one/mu_field(ip) *
sqrt(
m_two/ep_field(ip)) &
775 rs_sign*aimag(rs_state(ip,1:3)))
779 poynting_vector(ip, 1:3) =
m_one/st%mu(ip) *
sqrt(
m_two/st%ep(ip)) &
782 rs_sign*aimag(rs_state(ip, 1:3)))
792 type(
mesh_t),
intent(in) :: mesh
793 real(real64),
intent(in) :: poynting_vector(:,:)
794 real(real64),
intent(out) :: orbital_angular_momentum(:,:)
801 orbital_angular_momentum(ip,1:3) =
dcross_product(real(mesh%x(1:3, ip), real64) , &
802 poynting_vector(ip, 1:3))
810 type(
batch_t),
intent(inout) :: rs_stateb
811 complex(real64),
contiguous,
intent(in) :: rs_state(:, :)
812 integer,
intent(in) :: np
813 integer,
intent(in) :: dim
814 integer,
optional,
intent(in) :: offset
816 integer :: offset_, idir
822 do idir = offset_, offset_ + dim - 1
831 type(
batch_t),
intent(in) :: rs_stateb
832 complex(real64),
contiguous,
intent(out) :: rs_state(:, :)
833 integer,
intent(in) :: np
834 integer,
intent(in) :: dim
835 integer,
optional,
intent(in) :: offset
837 integer :: offset_, idir
843 do idir = offset_, offset_ + dim - 1
861 select case (st%transverse_field_mode)
863 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
865 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
866 st%rs_state_trans = st%rs_state - st%rs_state_long
868 message(1) =
'Unknown transverse field calculation mode.'
There are several ways how to call batch_set_state and batch_get_state:
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
subroutine, public accel_free_buffer(this, async)
subroutine, public accel_kernel_start_call(this, file_name, kernel_name, flags)
integer, parameter, public accel_mem_read_write
pure logical function, public accel_is_enabled()
This module implements batches of mesh functions.
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
This module implements common operations on batches of mesh functions.
This module provides the BLACS processor grid.
subroutine, public blacs_proc_grid_end(this)
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_div(der, ff, op_ff, ghost_update, set_bc, to_cartesian)
apply the divergence operator to a vector of mesh functions
subroutine, public distributed_end(this)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public p_mu
real(real64), parameter, public p_ep
complex(real64), parameter, public m_z0
complex(real64), parameter, public m_zi
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
The Helmholtz decomposition is intended to contain "only mathematical" functions and procedures to co...
This module is intended to contain "only mathematical" functions and procedures.
pure real(real64) function, dimension(1:3), public dcross_product(a, b)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
integer function, public mesh_nearest_point(mesh, pos, dmin, rankmin)
Returns the index of the point which is nearest to a given vector position pos.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
type(mpi_comm), parameter, public mpi_comm_undefined
used to indicate a communicator has not been initialized
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
This module handles the communicators for the various parallelization strategies.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
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.
This module handles spin dimensions of the states and the k-point distribution.
This module handles groups of electronic batches and their parallel distribution.
subroutine, public mxll_set_batch(rs_stateb, rs_state, np, dim, offset)
subroutine, public get_orbital_angular_momentum(mesh, poynting_vector, orbital_angular_momentum)
integer, parameter, public transverse_from_helmholtz
subroutine, public get_rs_state_at_point(rs_state_point, rs_state, pos, st, mesh)
subroutine, public get_electric_field_vector(rs_state_vector, electric_field_vector, ep_element)
subroutine, public build_rs_vector(e_vector, b_vector, rs_sign, rs_vector, ep_element, mu_element)
subroutine, public get_transverse_rs_state(helmholtz, st, namespace)
subroutine, public mxll_get_batch(rs_stateb, rs_state, np, dim, offset)
subroutine, public get_rs_state_batch_selected_points(rs_state_point, rs_stateb, st, mesh)
subroutine, public states_mxll_end(st)
subroutine, public states_mxll_allocate(st, mesh)
Allocates the Maxwell states defined within a states_mxll_t structure.
subroutine, public build_rs_current_state(current_state, mesh, rs_current_state, ep_field, np)
integer, parameter, public transverse_as_total_minus_long
subroutine, public build_rs_state(e_field, b_field, rs_sign, rs_state, mesh, ep_field, mu_field, np)
subroutine, public states_mxll_init(st, namespace, space)
subroutine, public get_electric_field_state(rs_state, mesh, electric_field, ep_field, np)
subroutine, public get_poynting_vector(mesh, st, rs_state, rs_sign, poynting_vector, ep_field, mu_field)
subroutine, public get_divergence_field(gr, field, field_div, charge_density)
subroutine, public get_magnetic_field_state(rs_state, mesh, rs_sign, magnetic_field, mu_field, np)
subroutine, public get_magnetic_field_vector(rs_state_vector, rs_sign, magnetic_field_vector, mu_element)
type(type_t), parameter, public type_cmplx
type(type_t), parameter, public type_integer
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.
type(unit_system_t), public units_inp
the units systems for reading and writing
Class defining batches of mesh functions.
Distribution of N instances over mpi_grpsize processes, for the local rank mpi_grprank....
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.
This is defined even when running serial.