85 logical :: pack_states
86 logical :: parallel_in_states = .false.
87 integer,
public :: nst
88 logical,
public :: packed
90 complex(real64),
allocatable :: rs_state_plane_waves(:,:)
91 complex(real64),
allocatable :: rs_state(:,:)
92 complex(real64),
allocatable :: rs_state_prev(:,:)
93 complex(real64),
allocatable :: rs_state_trans(:,:)
94 complex(real64),
allocatable :: rs_state_long(:,:)
95 complex(real64),
allocatable :: rs_current_density_t1(:,:)
96 complex(real64),
allocatable :: rs_current_density_t2(:,:)
98 logical :: rs_current_density_restart = .false.
99 complex(real64),
allocatable :: rs_current_density_restart_t1(:,:)
100 complex(real64),
allocatable :: rs_current_density_restart_t2(:,:)
102 type(batch_t) :: rs_stateb
103 type(batch_t) :: rs_state_prevb
104 type(batch_t) :: inhomogeneousb
105 type(batch_t) :: rs_state_plane_wavesb
107 real(real64),
allocatable :: ep(:)
108 real(real64),
allocatable :: mu(:)
110 integer,
allocatable :: rs_state_fft_map(:,:,:)
111 integer,
allocatable :: rs_state_fft_map_inv(:,:)
113 real(real64) :: energy_rate
114 real(real64) :: delta_energy
115 real(real64) :: energy_via_flux_calc
117 real(real64) :: trans_energy_rate
118 real(real64) :: trans_delta_energy
119 real(real64) :: trans_energy_via_flux_calc
121 real(real64) :: plane_waves_energy_rate
122 real(real64) :: plane_waves_delta_energy
123 real(real64) :: plane_waves_energy_via_flux_calc
125 real(real64) :: poynting_vector_box_surface(1:2,1:3,1:3) =
m_zero
126 real(real64) :: poynting_vector_box_surface_plane_waves(1:2,1:3,1:3) =
m_zero
127 real(real64) :: electric_field_box_surface(1:2,1:3,1:3) =
m_zero
128 real(real64) :: electric_field_box_surface_plane_waves(1:2,1:3,1:3) =
m_zero
129 real(real64) :: magnetic_field_box_surface(1:2,1:3,1:3) =
m_zero
130 real(real64) :: magnetic_field_box_surface_plane_waves(1:2,1:3,1:3) =
m_zero
132 logical :: rs_state_const_external = .false.
133 complex(real64),
allocatable :: rs_state_const(:)
134 complex(real64),
allocatable :: rs_state_const_amp(:,:)
135 type(tdf_t),
allocatable :: rs_state_const_td_function(:)
137 integer :: inner_points_number
138 integer,
allocatable :: inner_points_map(:)
139 logical,
allocatable :: inner_points_mask(:)
140 integer :: boundary_points_number
141 integer,
allocatable :: boundary_points_map(:)
142 logical,
allocatable :: boundary_points_mask(:)
143 type(accel_mem_t) :: buff_inner_points_map, buff_boundary_points_map
145 integer :: surface_points_number(3)
146 integer,
allocatable :: surface_points_map(:,:,:)
147 real(real64) :: surface_element(3)
149 integer :: surface_grid_rows_number(3)
150 integer,
allocatable :: surface_grid_points_number(:,:,:)
151 integer(int64),
allocatable :: surface_grid_points_map(:,:,:,:,:)
152 integer,
allocatable :: surface_grid_center(:,:,:,:)
153 real(real64) :: surface_grid_element(3)
155 type(mesh_plane_t) :: surface(2,3)
157 integer :: selected_points_number
158 real(real64),
allocatable :: selected_points_coordinate(:,:)
159 complex(real64),
allocatable :: selected_points_rs_state(:,:)
160 complex(real64),
allocatable :: selected_points_rs_state_long(:,:)
161 complex(real64),
allocatable :: selected_points_rs_state_trans(:,:)
162 integer,
allocatable :: selected_points_map(:)
163 type(accel_mem_t) :: buff_selected_points_map
164 real(real64) :: rs_state_trans_var
166 real(real64),
allocatable :: grid_rho(:,:)
167 complex(real64),
allocatable :: kappa_psi(:,:)
169 character(len=1024),
allocatable :: user_def_e_field(:)
170 character(len=1024),
allocatable :: user_def_b_field(:)
172 integer :: energy_incident_waves_calc_iter
173 logical :: energy_incident_waves_calc
176 integer :: external_current_number
177 integer,
allocatable :: external_current_modus(:)
178 character(len=1024),
allocatable :: external_current_string(:,:)
179 real(real64),
allocatable :: external_current_amplitude(:,:,:)
180 type(
tdf_t),
allocatable :: external_current_td_function(:)
181 type(
tdf_t),
allocatable :: external_current_td_phase(:)
182 real(real64),
allocatable :: external_current_omega(:)
183 real(real64),
allocatable :: external_current_phase(:)
186 character(len=1024),
allocatable :: user_def_states(:,:,:)
187 logical :: fromscratch = .
true.
196 logical :: scalapack_compatible
198 integer :: st_start, st_end
199 integer,
allocatable :: node(:)
202 integer :: transverse_field_mode
206 integer,
public,
parameter :: &
219 integer :: idim, nlines, ncols, il
220 real(real64),
allocatable :: pos(:)
221 integer :: ix_max, iy_max, iz_max
229 assert(space%dim == 3)
233 safe_allocate(st%user_def_e_field(1:st%dim))
234 safe_allocate(st%user_def_b_field(1:st%dim))
240 safe_allocate(st%node(1:st%nst))
241 st%node(1:st%nst) = 0
244 st%parallel_in_states = .false.
274 safe_allocate(pos(1:st%dim))
275 st%selected_points_number = 1
276 if (
parse_block(namespace,
'MaxwellFieldsCoordinate', blk) == 0)
then
278 st%selected_points_number = nlines
279 safe_allocate(st%selected_points_coordinate(1:st%dim,1:nlines))
280 safe_allocate(st%selected_points_rs_state(1:st%dim,1:nlines))
281 safe_allocate(st%selected_points_rs_state_long(1:st%dim,1:nlines))
282 safe_allocate(st%selected_points_rs_state_trans(1:st%dim,1:nlines))
283 safe_allocate(st%selected_points_map(1:nlines))
286 if (ncols < 3 .or. ncols > 3)
then
287 message(1) =
'MaxwellFieldCoordinate must have 3 columns.'
293 st%selected_points_coordinate(:,il) = pos
294 st%selected_points_rs_state(:,il) =
m_z0
295 st%selected_points_rs_state_long(:,il) =
m_z0
296 st%selected_points_rs_state_trans(:,il) =
m_z0
300 safe_allocate(st%selected_points_coordinate(1:st%dim, 1))
301 safe_allocate(st%selected_points_rs_state(1:st%dim, 1))
302 safe_allocate(st%selected_points_rs_state_long(1:st%dim, 1))
303 safe_allocate(st%selected_points_rs_state_trans(1:st%dim, 1))
304 safe_allocate(st%selected_points_map(1))
305 st%selected_points_coordinate(:,:) =
m_zero
306 st%selected_points_rs_state(:,:) =
m_z0
307 st%selected_points_rs_state_long(:,:) =
m_z0
308 st%selected_points_rs_state_trans(:,:) =
m_z0
309 st%selected_points_map(:) = -1
312 safe_deallocate_a(pos)
314 st%surface_grid_rows_number(1) = 3
315 ix_max = st%surface_grid_rows_number(1)
316 st%surface_grid_rows_number(2) = 3
317 iy_max = st%surface_grid_rows_number(2)
318 st%surface_grid_rows_number(3) = 3
319 iz_max = st%surface_grid_rows_number(3)
321 safe_allocate(st%surface_grid_center(1:2, 1:st%dim, 1:ix_max, 1:iy_max))
322 safe_allocate(st%surface_grid_points_number(1:st%dim, 1:ix_max, 1:iy_max))
336 st%transverse_field_mode)
348 class(
mesh_t),
intent(in) :: mesh
355 safe_allocate(st%rs_state(1:mesh%np_part, 1:st%dim))
356 st%rs_state(:,:) =
m_z0
358 safe_allocate(st%rs_state_prev(1:mesh%np_part, 1:st%dim))
359 st%rs_state_prev(:,:) =
m_z0
361 safe_allocate(st%rs_state_trans(1:mesh%np_part, 1:st%dim))
362 st%rs_state_trans(:,:) =
m_z0
364 safe_allocate(st%rs_state_long(1:mesh%np_part, 1:st%dim))
365 st%rs_state_long(:,:) =
m_z0
367 safe_allocate(st%rs_state_plane_waves(1:mesh%np_part, 1:st%dim))
368 st%rs_state_plane_waves(:,:) =
m_z0
370 safe_allocate(st%rs_current_density_t1(1:mesh%np, 1:st%dim))
371 st%rs_current_density_t1 =
m_z0
373 safe_allocate(st%rs_current_density_t2(1:mesh%np, 1:st%dim))
374 st%rs_current_density_t2 =
m_z0
376 safe_allocate(st%rs_current_density_restart_t1(1:mesh%np_part, 1:st%dim))
377 st%rs_current_density_restart_t1 =
m_z0
379 safe_allocate(st%rs_current_density_restart_t2(1:mesh%np_part, 1:st%dim))
380 st%rs_current_density_restart_t2 =
m_z0
382 safe_allocate(st%ep(1:mesh%np_part))
383 safe_allocate(st%mu(1:mesh%np_part))
401 safe_deallocate_a(st%rs_state)
402 safe_deallocate_a(st%rs_state_prev)
403 safe_deallocate_a(st%rs_state_trans)
404 safe_deallocate_a(st%selected_points_coordinate)
405 safe_deallocate_a(st%selected_points_rs_state)
406 safe_deallocate_a(st%selected_points_rs_state_long)
407 safe_deallocate_a(st%selected_points_rs_state_trans)
408 safe_deallocate_a(st%rs_current_density_t1)
409 safe_deallocate_a(st%rs_current_density_t2)
410 safe_deallocate_a(st%rs_state_long)
411 safe_deallocate_a(st%rs_current_density_restart_t1)
412 safe_deallocate_a(st%rs_current_density_restart_t2)
413 safe_deallocate_a(st%user_def_e_field)
414 safe_deallocate_a(st%user_def_b_field)
416 safe_deallocate_a(st%rs_state_const)
417 safe_deallocate_a(st%rs_state_const_td_function)
418 safe_deallocate_a(st%rs_state_const_amp)
419 safe_deallocate_a(st%rs_state_plane_waves)
421 safe_deallocate_a(st%surface_grid_center)
422 safe_deallocate_a(st%surface_grid_points_number)
423 safe_deallocate_a(st%surface_grid_points_map)
424 safe_deallocate_a(st%inner_points_map)
425 safe_deallocate_a(st%boundary_points_map)
426 safe_deallocate_a(st%inner_points_mask)
427 safe_deallocate_a(st%boundary_points_mask)
428 safe_deallocate_a(st%ep)
429 safe_deallocate_a(st%mu)
438 safe_deallocate_a(st%external_current_modus)
439 safe_deallocate_a(st%external_current_string)
440 safe_deallocate_a(st%external_current_amplitude)
441 safe_deallocate_a(st%external_current_td_function)
442 safe_deallocate_a(st%external_current_omega)
443 safe_deallocate_a(st%external_current_td_phase)
446 safe_deallocate_a(st%node)
455 subroutine build_rs_vector(e_vector, b_vector, rs_sign, rs_vector, ep_element, mu_element)
456 real(real64),
intent(in) :: e_vector(:), b_vector(:)
457 complex(real64),
intent(inout) :: rs_vector(:)
458 integer,
intent(in) :: rs_sign
459 real(real64),
optional,
intent(in) :: ep_element
460 real(real64),
optional,
intent(in) :: mu_element
464 if (
present(ep_element) .and.
present(mu_element))
then
474 subroutine build_rs_state(e_field, b_field, rs_sign, rs_state, mesh, ep_field, mu_field, np)
475 real(real64),
intent(in) :: e_field(:,:), b_field(:,:)
476 complex(real64),
intent(inout) :: rs_state(:,:)
477 integer,
intent(in) :: rs_sign
478 class(
mesh_t),
intent(in) :: mesh
479 real(real64),
optional,
intent(in) :: ep_field(:)
480 real(real64),
optional,
intent(in) :: mu_field(:)
481 integer,
optional,
intent(in) :: np
492 if (
present(ep_field) .and.
present(mu_field))
then
493 rs_state(ip, :) =
sqrt(ep_field(ip)/
m_two) * e_field(ip, :) &
510 real(real64),
intent(in) :: current_state(:,:)
511 class(
mesh_t),
intent(in) :: mesh
512 complex(real64),
intent(inout) :: rs_current_state(:,:)
513 real(real64),
optional,
intent(in) :: ep_field(:)
514 integer,
optional,
intent(in) :: np
516 integer :: ip, idim, np_, ff_dim
523 ff_dim =
size(current_state, dim=2)
525 if (
present(ep_field))
then
528 rs_current_state(ip, idim) =
m_one/
sqrt(
m_two*ep_field(ip)) * current_state(ip, idim)
546 complex(real64),
intent(in) :: rs_state_vector(:)
547 real(real64),
intent(out) :: electric_field_vector(:)
548 real(real64),
optional,
intent(in) :: ep_element
552 if (
present(ep_element))
then
553 electric_field_vector(:) =
sqrt(
m_two/ep_element) * real(rs_state_vector(:), real64)
555 electric_field_vector(:) =
sqrt(
m_two/
p_ep) * real(rs_state_vector(:), real64)
563 complex(real64),
intent(in) :: rs_state_vector(:)
564 integer,
intent(in) :: rs_sign
565 real(real64),
intent(out) :: magnetic_field_vector(:)
566 real(real64),
optional,
intent(in) :: mu_element
570 if (
present(mu_element))
then
571 magnetic_field_vector(:) =
sqrt(
m_two*mu_element) * rs_sign * aimag(rs_state_vector(:))
573 magnetic_field_vector(:) =
sqrt(
m_two*
p_mu) * rs_sign * aimag(rs_state_vector(:))
581 complex(real64),
intent(in) :: rs_state(:,:)
582 class(
mesh_t),
intent(in) :: mesh
583 real(real64),
intent(out) :: electric_field(:,:)
584 real(real64),
optional,
intent(in) :: ep_field(:)
585 integer,
optional,
intent(in) :: np
596 if (
present(ep_field))
then
597 electric_field(ip, :) =
sqrt(
m_two/ep_field(ip)) * real(rs_state(ip, :), real64)
599 electric_field(ip,:) =
sqrt(
m_two/
p_ep) * real(rs_state(ip, :), real64)
612 complex(real64),
intent(in) :: rs_state(:,:)
613 class(
mesh_t),
intent(in) :: mesh
614 integer,
intent(in) :: rs_sign
615 real(real64),
intent(out) :: magnetic_field(:,:)
616 real(real64),
optional,
intent(in) :: mu_field(:)
617 integer,
optional,
intent(in) :: np
627 if (
present(mu_field))
then
629 magnetic_field(ip, :) =
sqrt(
m_two*mu_field(ip)) * rs_sign * aimag(rs_state(ip, :))
633 magnetic_field(ip, :) =
sqrt(
m_two*
p_mu) * rs_sign * aimag(rs_state(ip, :))
646 complex(real64),
intent(inout) :: rs_state_point(:,:)
647 complex(real64),
intent(in) :: rs_state(:,:)
648 real(real64),
intent(in) :: pos(:,:)
650 class(
mesh_t),
intent(in) :: mesh
652 integer :: ip, pos_index, rankmin
654 complex(real64),
allocatable :: ztmp(:)
658 safe_allocate(ztmp(1:
size(rs_state, dim=2)))
660 do ip = 1, st%selected_points_number
662 if (mesh%mpi_grp%rank == rankmin)
then
663 ztmp(:) = rs_state(pos_index, :)
665 if (mesh%parallel_in_domains)
then
666 call mesh%mpi_grp%bcast(ztmp, st%dim, mpi_double_complex, rankmin)
668 rs_state_point(:, ip) = ztmp(:)
671 safe_deallocate_a(ztmp)
680 complex(real64),
contiguous,
intent(inout) :: rs_state_point(:,:)
681 type(
batch_t),
intent(in) :: rs_stateb
683 class(
mesh_t),
intent(in) :: mesh
686 complex(real64) :: rs_state_tmp(1:st%dim, 1:st%selected_points_number)
689 integer(int64),
dimension(3) :: gsizes, bsizes
693 rs_state_tmp(:,:) =
m_z0
695 select case (rs_stateb%status())
697 do ip_in = 1, st%selected_points_number
698 ip = st%selected_points_map(ip_in)
700 rs_state_tmp(1:st%dim, ip_in) = rs_stateb%zff_linear(ip, 1:st%dim)
704 do ip_in = 1, st%selected_points_number
705 ip = st%selected_points_map(ip_in)
707 rs_state_tmp(1:st%dim, ip_in) = rs_stateb%zff_pack(1:st%dim, ip)
714 st%selected_points_number*st%dim)
726 gsizes, bsizes, kernel)
730 call accel_read_buffer(buff_points, st%dim, st%selected_points_number, rs_state_tmp)
734 call mesh%mpi_grp%allreduce(rs_state_tmp, rs_state_point, st%selected_points_number*st%dim, mpi_double_complex, mpi_sum)
741 type(
grid_t),
intent(in) :: gr
742 real(real64),
contiguous,
intent(inout) :: field(:,:)
743 real(real64),
contiguous,
intent(inout) :: field_div(:)
744 logical,
intent(in) :: charge_density
751 field_div =
p_ep * field_div
759 subroutine get_poynting_vector(mesh, st, rs_state, rs_sign, poynting_vector, ep_field, mu_field)
760 class(
mesh_t),
intent(in) :: mesh
762 complex(real64),
intent(in) :: rs_state(:,:)
763 integer,
intent(in) :: rs_sign
764 real(real64),
intent(out) :: poynting_vector(:,:)
765 real(real64),
optional,
intent(in) :: ep_field(:)
766 real(real64),
optional,
intent(in) :: mu_field(:)
771 if (
present(ep_field) .and.
present(mu_field))
then
773 poynting_vector(ip, 1:3) =
m_one/mu_field(ip) *
sqrt(
m_two/ep_field(ip)) &
776 rs_sign*aimag(rs_state(ip,1:3)))
780 poynting_vector(ip, 1:3) =
m_one/st%mu(ip) *
sqrt(
m_two/st%ep(ip)) &
783 rs_sign*aimag(rs_state(ip, 1:3)))
793 type(
mesh_t),
intent(in) :: mesh
794 real(real64),
intent(in) :: poynting_vector(:,:)
795 real(real64),
intent(out) :: orbital_angular_momentum(:,:)
802 orbital_angular_momentum(ip,1:3) =
dcross_product(real(mesh%x(1:3, ip), real64) , &
803 poynting_vector(ip, 1:3))
811 type(
batch_t),
intent(inout) :: rs_stateb
812 complex(real64),
contiguous,
intent(in) :: rs_state(:, :)
813 integer,
intent(in) :: np
814 integer,
intent(in) :: dim
815 integer,
optional,
intent(in) :: offset
817 integer :: offset_, idir
823 do idir = offset_, offset_ + dim - 1
832 type(
batch_t),
intent(in) :: rs_stateb
833 complex(real64),
contiguous,
intent(out) :: rs_state(:, :)
834 integer,
intent(in) :: np
835 integer,
intent(in) :: dim
836 integer,
optional,
intent(in) :: offset
838 integer :: offset_, idir
844 do idir = offset_, offset_ + dim - 1
862 select case (st%transverse_field_mode)
864 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
866 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
867 st%rs_state_trans = st%rs_state - st%rs_state_long
869 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), public type_cmplx
type(type_t), 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.