95 integer,
parameter,
public :: &
96 MULTIGRID_MX_TO_MA_EQUAL = 1, &
102 type(space_t) :: space
103 type(states_mxll_t) :: st
104 type(hamiltonian_mxll_t) :: hm
106 type(output_t) :: outp
107 type(multicomm_t) :: mc
109 type(mesh_interpolation_t) :: mesh_interpolate
111 type(propagator_mxll_t) :: tr_mxll
112 type(td_write_t) :: write_handler
113 type(c_ptr) :: output_handle
115 complex(real64),
allocatable :: ff_rs_inhom_t1(:,:), ff_rs_inhom_t2(:,:)
116 complex(real64),
allocatable :: rs_state_init(:,:)
117 type(time_interpolation_t),
pointer :: current_interpolation
118 real(real64) :: bc_bounds(2, 3), dt_bounds(2, 3)
119 integer :: energy_update_iter
120 type(restart_t) :: restart_dump
121 type(restart_t) :: restart
123 type(lattice_vectors_t) :: latt
125 type(helmholtz_decomposition_t) :: helmholtz
127 logical :: write_previous_state = .false.
149 procedure maxwell_constructor
156 class(maxwell_t),
pointer :: sys
157 type(namespace_t),
intent(in) :: namespace
158 type(mpi_grp_t),
intent(in) :: grp
173 type(namespace_t),
intent(in) :: namespace
181 this%namespace = namespace
182 call this%init_parallelization(grp)
186 this%space =
space_t(this%namespace)
192 call this%quantities%add(
quantity_t(
"E field", updated_on_demand = .false.))
193 call this%quantities%add(
quantity_t(
"B field", updated_on_demand = .false.))
194 call this%quantities%add(
quantity_t(
"vector potential", updated_on_demand = .false.))
217 select type (interaction)
219 call interaction%init(this%gr)
221 call interaction%init(this%gr, this%st%dim)
222 call interaction%init_space_latt(this%space, this%latt)
226 select type (prop => this%algo)
236 message(1) =
"The chosen propagator does not yet support interaction interpolation"
239 call interaction%init_interpolation(depth, interaction%label, cmplx=.
true.)
241 this%hm%current_density_from_medium = .
true.
243 message(1) =
"Trying to initialize an unsupported interaction by Maxwell."
254 integer(int64) :: index_range(4)
255 integer :: ierr, ip, pos_index, rankmin
263 index_range(1) = this%gr%np_global
264 index_range(2) = this%st%nst
266 index_range(4) = 100000
270 index_range, (/ 5000, 1, 1, 1 /))
272 call mpi_grp_init(this%st%system_grp, this%mc%master_comm)
278 this%st%energy_rate =
m_zero
279 this%st%delta_energy =
m_zero
280 this%st%energy_via_flux_calc =
m_zero
282 this%st%trans_delta_energy =
m_zero
283 this%st%trans_energy_via_flux_calc =
m_zero
284 this%st%plane_waves_energy_rate =
m_zero
285 this%st%plane_waves_delta_energy =
m_zero
286 this%st%plane_waves_energy_via_flux_calc =
m_zero
288 safe_allocate(this%rs_state_init(1:this%gr%np_part, 1:this%st%dim))
289 this%rs_state_init(:,:) =
m_z0
291 this%energy_update_iter = 1
293 call poisson_init(this%st%poisson, this%namespace, this%space, this%gr%der, this%mc, this%gr%stencil)
295 call bc_mxll_init(this%hm%bc, this%namespace, this%space, this%gr, this%st)
296 this%bc_bounds(:,1:3) = this%hm%bc%bc_bounds(:,1:3)
298 this%dt_bounds(2, 1:3) = this%bc_bounds(1, 1:3)
299 this%dt_bounds(1, 1:3) = this%bc_bounds(1, 1:3) - this%gr%der%order * this%gr%spacing(1:3)
305 this%hm%propagation_apply = .
true.
308 do ip = 1, this%st%selected_points_number
309 pos_index =
mesh_nearest_point(this%gr, this%st%selected_points_coordinate(:,ip), dmin, rankmin)
310 if (this%gr%mpi_grp%rank == rankmin)
then
311 this%st%selected_points_map(ip) = pos_index
313 this%st%selected_points_map(ip) = -1
318 this%st%selected_points_number)
319 call accel_write_buffer(this%st%buff_selected_points_map, this%st%selected_points_number, &
320 this%st%selected_points_map)
323 this%hm%plane_waves_apply = .
true.
324 this%hm%spatial_constant_apply = .
true.
330 call zbatch_init(this%st%rs_stateb, 1, 1, this%st%dim, this%gr%np_part)
331 if (this%st%pack_states)
call this%st%rs_stateb%do_pack()
332 call this%st%rs_stateb%copy_to(this%st%rs_state_prevb)
333 call this%st%rs_stateb%copy_to(this%st%inhomogeneousb)
334 if (this%tr_mxll%bc_plane_waves)
then
335 call this%st%rs_stateb%copy_to(this%st%rs_state_plane_wavesb)
341 call this%helmholtz%init(this%namespace, this%gr, this%mc, this%space)
350 real(real64) :: courant
357 select type (algo => this%algo)
366 m_one/this%gr%spacing(3)**2))
369 write(
message(1),
'(a)')
'The timestep is too large compared to the Courant-Friedrichs-Lewy'
370 write(
message(2),
'(a)')
'stability condition. Time propagation might not be stable.'
374 if (
parse_is_defined(this%namespace,
'UserDefinedInitialMaxwellStates'))
then
379 this%st%rs_state(:,:) = this%st%rs_state + this%rs_state_init
380 if (this%tr_mxll%bc_plane_waves)
then
381 this%st%rs_state_plane_waves(:,:) = this%rs_state_init
387 if (this%tr_mxll%bc_constant)
then
389 algo%dt,
m_zero, this%st%rs_state, set_initial_state = .
true.)
394 if (
parse_is_defined(this%namespace,
'UserDefinedInitialMaxwellStates'))
then
395 safe_deallocate_a(this%rs_state_init)
401 call energy_mxll_calc(this%gr, this%st, this%hm, this%hm%energy, this%st%rs_state, &
402 this%st%rs_state_plane_waves)
406 this%st%selected_points_coordinate(:,:), this%st, this%gr)
408 call mxll_set_batch(this%st%rs_stateb, this%st%rs_state, this%gr%np, this%st%dim)
410 if (this%tr_mxll%bc_plane_waves)
then
411 call mxll_set_batch(this%st%rs_state_plane_wavesb, this%st%rs_state_plane_waves, this%gr%np, this%st%dim)
424 character(len=:),
allocatable,
intent(out) :: updated_quantities(:)
426 complex(real64),
allocatable :: charge_density_ext(:)
427 real(real64) :: current_time
430 call profiling_in(trim(this%namespace%get())//
":"//trim(operation%id))
432 current_time = this%iteration%value()
434 select type (algo => this%algo)
438 select case (operation%id)
443 safe_allocate(this%ff_rs_inhom_t1(1:this%gr%np_part, 1:this%hm%dim))
444 safe_allocate(this%ff_rs_inhom_t2(1:this%gr%np_part, 1:this%hm%dim))
447 safe_deallocate_a(this%ff_rs_inhom_t1)
448 safe_deallocate_a(this%ff_rs_inhom_t2)
451 if (this%hm%current_density_ext_flag .or. this%hm%current_density_from_medium)
then
452 call this%get_current(current_time, this%st%rs_current_density_t1)
453 call this%get_current(current_time+algo%dt, this%st%rs_current_density_t2)
460 safe_allocate(charge_density_ext(1:this%gr%np))
463 charge_density_ext =
m_z0
470 safe_deallocate_a(charge_density_ext)
474 this%st%rs_stateb, this%ff_rs_inhom_t1, this%ff_rs_inhom_t2, current_time, algo%dt)
476 updated_quantities = [
character(16) ::
"E field",
"B field",
"vector potential"]
479 if (any(this%hm%bc%bc_ab_type == option__maxwellabsorbingboundaries__cpml))
then
486 if (this%hm%current_density_ext_flag .or. this%hm%current_density_from_medium)
then
487 call this%get_current(current_time, this%st%rs_current_density_t1)
488 call mxll_set_batch(this%st%inhomogeneousb, this%st%rs_current_density_t1, this%gr%np, this%st%dim)
493 current_time, algo%dt, this%iteration%counter())
495 updated_quantities = [
character(16) ::
"E field",
"B field",
"vector potential"]
498 safe_allocate(this%ff_rs_inhom_t1(1:this%gr%np_part, 1:this%hm%dim))
499 if (any(this%hm%bc%bc_ab_type == option__maxwellabsorbingboundaries__cpml))
then
504 safe_deallocate_a(this%ff_rs_inhom_t1)
507 if (this%hm%current_density_ext_flag .or. this%hm%current_density_from_medium)
then
508 call this%get_current(current_time+algo%dt*
m_half, this%st%rs_current_density_t1)
516 current_time, algo%dt)
518 updated_quantities = [
character(16) ::
"E field",
"B field",
"vector potential"]
521 safe_allocate(this%ff_rs_inhom_t1(1:this%gr%np_part, 1:this%hm%dim))
522 safe_allocate(this%ff_rs_inhom_t2(1:this%gr%np_part, 1:this%hm%dim))
523 if (any(this%hm%bc%bc_ab_type == option__maxwellabsorbingboundaries__cpml))
then
528 safe_deallocate_a(this%ff_rs_inhom_t1)
529 safe_deallocate_a(this%ff_rs_inhom_t2)
532 if (this%hm%current_density_ext_flag .or. this%hm%current_density_from_medium)
then
533 call this%get_current(current_time+algo%dt*(
m_half-
sqrt(
m_three)/6.0_real64), this%st%rs_current_density_t1)
534 call this%get_current(current_time+algo%dt*(
m_half+
sqrt(
m_three)/6.0_real64), this%st%rs_current_density_t2)
548 current_time, algo%dt)
550 updated_quantities = [
character(16) ::
"E field",
"B field",
"vector potential"]
563 select case (operation%id)
567 if (this%hm%current_density_ext_flag .or. this%hm%current_density_from_medium .or. &
568 this%tr_mxll%bc_plane_waves .or. this%tr_mxll%bc_constant .or. &
570 message(1) =
"No Maxwell ground state is implemented, and this Maxwell system has a source,"
571 message(2) =
"an incident wave or a user-defined initial field, so its initial field is not"
572 message(3) =
"the stationary one. Remove the source or propagate the system in time instead."
577 message(1) =
"No Maxwell ground state is implemented: the fields keep their initial value"
578 message(2) =
"and the Maxwell system converges after its first ground-state iteration."
585 algo%converged = .
true.
597 call profiling_out(trim(this%namespace%get())//
":"//trim(operation%id))
604 real(real64),
intent(in) :: tol
620 select type (interaction)
624 call interaction%init_from_partner(partner%gr, partner%space, partner%namespace)
626 call interaction%init_from_partner(partner%gr, partner%space, partner%namespace)
628 call interaction%init_from_partner(partner%gr, partner%space, partner%namespace)
630 message(1) =
"Unsupported interaction."
639 class(
maxwell_t),
intent(inout) :: partner
643 complex(real64) :: interpolated_value(3)
644 real(real64),
allocatable :: b_field(:,:), vec_pot(:,:)
647 call profiling_in(trim(partner%namespace%get())//
":"//
"COPY_QUANTITY_INTER")
652 select type (interaction)
654 call mxll_get_batch(partner%st%rs_stateb, partner%st%rs_state, partner%gr%np, partner%st%dim)
656 do ip = 1, interaction%system_np
658 interaction%system_pos(:, ip), interpolated_value(1))
660 interaction%system_pos(:, ip), interpolated_value(2))
662 interaction%system_pos(:, ip), interpolated_value(3))
665 interaction%partner_b_field(:, ip) = interaction%partner_b_field(:, ip)/partner%hm%c_factor
669 call mxll_get_batch(partner%st%rs_stateb, partner%st%rs_state, partner%gr%np, partner%st%dim)
670 select case (interaction%type)
680 call partner%helmholtz%get_long_field(partner%namespace, partner%st%rs_state_long, total_field=partner%st%rs_state)
684 message(1) =
"Unknown type of field requested by interaction."
687 call interaction%do_mapping()
690 call mxll_get_batch(partner%st%rs_stateb, partner%st%rs_state, partner%gr%np, partner%st%dim)
691 safe_allocate(b_field(1:partner%gr%np_part, 1:partner%gr%box%dim))
692 safe_allocate(vec_pot(1:partner%gr%np_part, 1:partner%gr%box%dim))
695 partner%st%mu(1:partner%gr%np), partner%gr%np)
696 b_field(1:partner%gr%np, :) = b_field(1:partner%gr%np, :)/partner%hm%c_factor
698 call partner%helmholtz%get_vector_potential(partner%namespace, vec_pot, trans_field=b_field)
702 interaction%partner_field(1:partner%gr%np,1:partner%gr%box%dim) = &
703 vec_pot(1:partner%gr%np,1:partner%gr%box%dim)
704 safe_deallocate_a(b_field)
705 safe_deallocate_a(vec_pot)
706 call interaction%do_mapping()
709 call mxll_get_batch(partner%st%rs_stateb, partner%st%rs_state, partner%gr%np, partner%st%dim)
711 interaction%partner_field, partner%st%mu(1:partner%gr%np), partner%gr%np)
712 interaction%partner_field(1:partner%gr%np, :) = interaction%partner_field(1:partner%gr%np, :)/partner%hm%c_factor
713 call interaction%do_mapping()
716 message(1) =
"Unsupported interaction."
720 call profiling_out(trim(partner%namespace%get())//
":"//
"COPY_QUANTITY_INTER")
728 real(real64) :: itr_value
731 call profiling_in(trim(this%namespace%get())//
":"//
"OUTPUT_START")
733 select type (algo => this%algo)
735 call mxll_get_batch(this%st%rs_stateb, this%st%rs_state, this%gr%np, this%st%dim)
737 call td_write_mxll_init(this%write_handler, this%namespace, this%iteration%counter(), algo%dt, &
739 if (this%st%fromScratch)
then
740 call td_write_mxll_iter(this%write_handler, this%space, this%gr, this%st, this%hm, this%helmholtz, algo%dt, &
741 this%iteration%counter(), this%namespace)
742 itr_value = this%iteration%value()
744 this%outp, this%iteration%counter(), itr_value)
749 call profiling_out(trim(this%namespace%get())//
":"//
"OUTPUT_START")
757 logical :: stopping, reached_output_interval
758 real(real64) :: itr_value
762 call profiling_in(trim(this%namespace%get())//
":"//
"OUTPUT_WRITE")
764 select type (algo => this%algo)
768 call td_write_mxll_iter(this%write_handler, this%space, this%gr, this%st, this%hm, this%helmholtz, algo%dt, &
769 this%iteration%counter(), this%namespace)
771 reached_output_interval = .false.
773 if (this%outp%output_interval(iout) > 0)
then
774 if (mod(this%iteration%counter(), this%outp%output_interval(iout)) == 0)
then
775 reached_output_interval = .
true.
781 if (reached_output_interval .or. stopping)
then
782 call mxll_get_batch(this%st%rs_stateb, this%st%rs_state, this%gr%np, this%st%dim)
784 itr_value = this%iteration%value()
786 this%outp, this%iteration%counter(), itr_value)
791 call profiling_out(trim(this%namespace%get())//
":"//
"OUTPUT_WRITE")
804 select type (algo => this%algo)
819 integer :: int_counter
824 call iter%start(this%interactions)
825 do while (iter%has_next())
826 select type (interaction => iter%get_next())
828 int_counter = int_counter + 1
832 if (int_counter /= 0 .and. .not.
allocated(this%hm%medium_boxes))
then
833 safe_allocate(this%hm%medium_boxes(1:int_counter))
834 this%hm%calc_medium_box = .
true.
851 call iter%start(this%interactions)
852 do while (iter%has_next())
853 select type (interaction => iter%get_next())
855 if (
allocated(this%hm%medium_boxes) .and. .not. this%hm%medium_boxes_initialized)
then
857 this%hm%medium_boxes(iint) = interaction%medium_box
862 if (
allocated(this%hm%medium_boxes) .and. .not. this%hm%medium_boxes_initialized)
then
864 this%hm%medium_boxes_initialized = .
true.
867 if (this%hm%medium_boxes_initialized .and. this%hm%operator ==
faraday_ampere)
then
868 message(1) =
"A linear medium has been defined in the input file but the Hamiltonian"
869 message(2) =
"type you specified is not capable of dealing with the medium."
870 message(3) =
"Please use MaxwellHamiltonianOperator = faraday_ampere_medium or simple to enable"
871 message(4) =
"the medium propagation."
875 if (.not. this%hm%medium_boxes_initialized .and. &
878 message(1) =
"The variable MaxwellHamiltonianOperator has been defined as faraday_ampere_medium"
879 message(2) =
"in the input file but neither a medium boundary nor a linear medium system"
880 message(3) =
"has been defined. Please either use a different option for"
881 message(4) =
"MaxwellHamiltonianOperator or define a Maxwell medium."
892 integer :: ierr, err, zff_dim, id, id1, id2, ip_in, offset, iout
893 logical :: pml_check, write_previous_state
894 complex(real64),
allocatable :: zff(:,:)
899 call profiling_in(trim(this%namespace%get())//
":"//
"RESTART_WRITE")
903 if (this%grp%is_root())
then
905 if (this%write_handler%out(iout)%write)
then
906 call write_iter_flush(this%write_handler%out(iout)%handle)
911 if (.not. this%restart_dump%skip())
then
912 pml_check = any(this%hm%bc%bc_ab_type(1:3) == option__maxwellabsorbingboundaries__cpml)
914 message(1) =
"Debug: Writing td_maxwell restart."
917 if (this%tr_mxll%bc_plane_waves)
then
918 zff_dim = 2 * this%st%dim
920 zff_dim = 1 * this%st%dim
923 zff_dim = zff_dim + 18
925 select type (prop => this%algo)
927 write_previous_state = .
true.
928 zff_dim = zff_dim + this%st%dim
930 write_previous_state = .false.
934 this%hm%bc%pml%points_number, 3, 3, this%hm%bc%pml%conv_plus)
936 this%hm%bc%pml%points_number, 3, 3, this%hm%bc%pml%conv_minus)
939 call mxll_get_batch(this%st%rs_stateb, this%st%rs_state, this%gr%np, this%st%dim)
940 if (write_previous_state)
then
941 call mxll_get_batch(this%st%rs_state_prevb, this%st%rs_state_prev, this%gr%np, this%st%dim)
944 safe_allocate(zff(1:this%gr%np,1:zff_dim))
947 zff(1:this%gr%np, 1:this%st%dim) = this%st%rs_state(1:this%gr%np, 1:this%st%dim)
948 if (this%tr_mxll%bc_plane_waves)
then
949 call mxll_get_batch(this%st%rs_state_plane_wavesb, this%st%rs_state_plane_waves, &
950 this%gr%np, this%st%dim)
951 zff(1:this%gr%np, this%st%dim+1:this%st%dim+this%st%dim) = &
952 this%st%rs_state_plane_waves(1:this%gr%np, 1:this%st%dim)
953 offset = 2*this%st%dim
962 do ip_in = 1, this%hm%bc%pml%points_number
963 zff(ip_in, offset+id) = this%hm%bc%pml%conv_plus(ip_in, id1, id2)
964 zff(ip_in, offset+9+id) = this%hm%bc%pml%conv_minus(ip_in, id1, id2)
970 if (write_previous_state)
then
971 zff(1:this%gr%np, offset+1:offset+this%st%dim) = &
972 this%st%rs_state_prev(1:this%gr%np, 1:this%st%dim)
975 call states_mxll_dump(this%restart_dump, this%st, this%space, this%gr, zff, zff_dim, err, this%iteration%counter())
976 if (err /= 0) ierr = ierr + 1
978 if (this%hm%current_density_from_medium)
then
980 call iter%start(this%interactions)
981 do while (iter%has_next())
982 interaction => iter%get_next()
983 select type (interaction)
985 call interaction%write_restart(this%gr, this%space, this%restart_dump, err)
988 if (err /= 0) ierr = ierr + 1
991 message(1) =
"Debug: Writing td_maxwell restart done."
994 safe_deallocate_a(zff)
997 message(1) =
"Unable to write time-dependent Maxwell restart information."
1002 call profiling_out(trim(this%namespace%get())//
":"//
"RESTART_WRITE")
1011 integer :: ierr, err, zff_dim, id, id1, id2, ip_in, offset, idir
1012 logical :: pml_check, read_previous_state
1013 complex(real64),
allocatable :: zff(:,:)
1018 call profiling_in(trim(this%namespace%get())//
":"//
"RESTART_READ")
1020 if (.not. this%restart%skip())
then
1022 pml_check = any(this%hm%bc%bc_ab_type(1:3) == option__maxwellabsorbingboundaries__cpml)
1024 if (this%restart%skip())
then
1026 call profiling_out(trim(this%namespace%get())//
":"//
"RESTART_READ")
1031 message(1) =
"Debug: Reading td_maxwell restart."
1034 if (this%tr_mxll%bc_plane_waves)
then
1035 zff_dim = 2 * this%st%dim
1037 zff_dim = 1 * this%st%dim
1040 zff_dim = zff_dim + 18
1042 select type (prop => this%algo)
1044 read_previous_state = .
true.
1045 zff_dim = zff_dim + this%st%dim
1047 read_previous_state = .false.
1050 safe_allocate(zff(1:this%gr%np,1:zff_dim))
1052 call states_mxll_load(this%restart, this%st, this%gr, this%namespace, this%space, zff, &
1053 zff_dim, err, label =
": td_maxwell")
1054 this%st%rs_current_density_restart = .
true.
1056 this%st%rs_state(1:this%gr%np,1:this%st%dim) = zff(1:this%gr%np, 1:this%st%dim)
1057 if (this%tr_mxll%bc_plane_waves)
then
1058 do idir = 1, this%st%dim
1059 call lalg_copy(this%gr%np, zff(:, this%st%dim+idir), this%st%rs_state_plane_waves(:, idir))
1061 offset = 2*this%st%dim
1063 offset = this%st%dim
1070 do ip_in = 1, this%hm%bc%pml%points_number
1071 this%hm%bc%pml%conv_plus(ip_in,id1,id2) = zff(ip_in, offset+ id)
1072 this%hm%bc%pml%conv_minus(ip_in,id1,id2) = zff(ip_in, offset+9+id)
1076 this%hm%bc%pml%conv_plus_old = this%hm%bc%pml%conv_plus
1077 this%hm%bc%pml%conv_minus_old = this%hm%bc%pml%conv_minus
1078 offset = offset + 18
1080 if (read_previous_state)
then
1081 do idir = 1, this%st%dim
1082 call lalg_copy(this%gr%np, zff(:, offset+idir), this%st%rs_state_prev(:, idir))
1090 message(1) =
"Debug: Reading td restart done."
1093 safe_deallocate_a(zff)
1096 call accel_write_buffer(this%hm%bc%pml%buff_conv_plus, this%hm%bc%pml%points_number, 3, 3, &
1097 this%hm%bc%pml%conv_plus)
1098 call accel_write_buffer(this%hm%bc%pml%buff_conv_minus, this%hm%bc%pml%points_number, 3, 3, &
1099 this%hm%bc%pml%conv_minus)
1100 call accel_write_buffer(this%hm%bc%pml%buff_conv_plus_old, this%hm%bc%pml%points_number, 3, 3, &
1101 this%hm%bc%pml%conv_plus_old)
1104 if (this%hm%current_density_from_medium)
then
1106 call iter%start(this%interactions)
1107 do while (iter%has_next())
1108 interaction => iter%get_next()
1109 select type (interaction)
1111 call interaction%read_restart(this%gr, this%space, this%restart, err)
1120 call mxll_set_batch(this%st%rs_stateb, this%st%rs_state, this%gr%np, this%st%dim)
1121 if (read_previous_state)
then
1122 call mxll_set_batch(this%st%rs_state_prevb, this%st%rs_state_prev, this%gr%np, this%st%dim)
1125 if (this%tr_mxll%bc_plane_waves)
then
1126 call mxll_set_batch(this%st%rs_state_plane_wavesb, this%st%rs_state_plane_waves, this%gr%np, this%st%dim)
1129 this%st%fromScratch = .false.
1132 message(1) =
"Unable to read time-dependent Maxwell restart information: Starting from scratch"
1137 call profiling_out(trim(this%namespace%get())//
":"//
"RESTART_READ")
1151 this%kinetic_energy = this%hm%energy%energy
1161 call profiling_in(trim(this%namespace%get())//
":"//
"END_TIMESTEP")
1164 call energy_mxll_calc_batch(this%gr, this%st, this%hm, this%hm%energy, this%st%rs_stateb, this%st%rs_state_plane_wavesb)
1170 call profiling_out(trim(this%namespace%get())//
":"//
"END_TIMESTEP")
1177 real(real64),
intent(in) :: time
1178 complex(real64),
contiguous,
intent(inout) :: current(:, :)
1181 complex(real64),
allocatable :: current_density_ext(:, :)
1185 safe_allocate(current_density_ext(1:this%gr%np, 1:this%st%dim))
1187 if (this%hm%current_density_from_medium)
then
1189 call iter%start(this%interactions)
1190 do while (iter%has_next())
1191 select type (interaction => iter%get_next())
1193 call interaction%interpolate(time, current_density_ext)
1194 call lalg_axpy(this%gr%np, 3, this%hm%current_factor, current_density_ext, current)
1199 if (this%hm%current_density_ext_flag)
then
1201 call lalg_axpy(this%gr%np, 3,
m_one, current_density_ext, current)
1203 safe_deallocate_a(current_density_ext)
1220 safe_deallocate_a(this%rs_state_init)
1225 call this%st%rs_stateb%end()
1226 call this%st%rs_state_prevb%end()
1227 call this%st%inhomogeneousb%end()
1228 if (this%tr_mxll%bc_plane_waves)
then
1229 call this%st%rs_state_plane_wavesb%end()
1236 call this%restart%end()
1237 call this%restart_dump%end()
scale a batch by a constant or vector
constant times a vector plus a vector
Copies a vector x, to a vector y.
pure logical function, public accel_is_enabled()
integer, parameter, public accel_mem_read_only
This module defines the abstract interfact for algorithm factories.
This module implements the basic elements defining algorithms.
character(len=algo_label_len), parameter, public iteration_done
This module implements batches of mesh functions.
subroutine, public zbatch_init(this, dim, st_start, st_end, np, special, packed)
initialize a TYPE_CMPLX valued batch to given size without providing external memory
This module implements common operations on batches of mesh functions.
subroutine, public batch_set_zero(this, np, async)
fill all mesh functions of the batch with zero
This module handles the calculation mode.
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public get_rs_density_ext(st, space, mesh, time, rs_current_density_ext)
subroutine, public external_current_init(st, space, namespace, mesh)
This module implements the field transfer.
real(real64), parameter, public m_zero
real(real64), parameter, public m_fourth
complex(real64), parameter, public m_z0
real(real64), parameter, public m_half
real(real64), parameter, public p_c
Electron gyromagnetic ratio, see Phys. Rev. Lett. 130, 071801 (2023)
real(real64), parameter, public m_one
real(real64), parameter, public m_three
This module implements the underlying real-space grid.
subroutine, public grid_init_stage_1(gr, namespace, space, grp, symm, latt, n_sites, site_position, variable_cell)
First stage of the grid initialization.
subroutine, public grid_init_stage_2(gr, namespace, space, mc, qvector)
Second stage of the grid initialization.
subroutine, public grid_end(gr)
finalize a grid object
subroutine, public hamiltonian_mxll_init(hm, namespace, gr, st)
Initializing the Maxwell Hamiltonian.
integer, parameter, public faraday_ampere
subroutine, public hamiltonian_mxll_end(hm)
integer, parameter, public faraday_ampere_medium
subroutine, public hamiltonian_mxll_update(this, time)
Maxwell Hamiltonian update (here only the time is updated, can maybe be added to another routine)
The Helmholtz decomposition is intended to contain "only mathematical" functions and procedures to co...
This module implements the index, used for the mesh points.
integer, parameter, public mxll_vec_pot_to_matter
integer, parameter, public linear_medium_to_em_field
integer, parameter, public lorentz_force
integer, parameter, public mxll_b_field_to_matter
integer, parameter, public mxll_e_field_to_matter
integer, parameter, public current_to_mxll_field
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
System information (time, memory, sysname)
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public bc_mxll_init(bc, namespace, space, gr, st)
subroutine, public inner_and_outer_points_mapping(mesh, st, bounds, periodic_dim)
Inner points (inside bounds(1, :)) and boundary points of the Maxwell grid. Periodic axes have no bou...
subroutine, public surface_grid_points_mapping(mesh, st, bounds)
subroutine, public bc_mxll_initialize_pml_simple(bc, space, gr, c_factor, dt)
integer, parameter, public mxll_bc_medium
subroutine maxwell_update_interactions_start(this)
subroutine maxwell_exec_end_of_timestep_tasks(this)
subroutine maxwell_init_interaction(this, interaction)
subroutine maxwell_output_start(this)
subroutine maxwell_update_interactions_finish(this)
class(maxwell_t) function, pointer maxwell_constructor(namespace, grp)
subroutine maxwell_init_interaction_as_partner(partner, interaction)
subroutine maxwell_output_finish(this)
subroutine maxwell_restart_write_data(this)
logical function maxwell_do_algorithmic_operation(this, operation, updated_quantities)
integer, parameter, public multigrid_mx_to_ma_large
subroutine maxwell_get_current(this, time, current)
subroutine, public maxwell_init(this, namespace, grp)
subroutine maxwell_initialize(this)
subroutine maxwell_output_write(this)
logical function maxwell_is_tolerance_reached(this, tol)
subroutine maxwell_init_parallelization(this)
subroutine maxwell_update_kinetic_energy(this)
logical function maxwell_restart_read_data(this)
subroutine maxwell_finalize(this)
subroutine maxwell_copy_quantities_to_interaction(partner, interaction)
subroutine, public mesh_interpolation_init(this, mesh)
This module defines the meshes, which are used in Octopus.
integer(int64) function, public mesh_global_index_from_coords(mesh, ix)
This function returns the true global index of the point for a given vector of integer coordinates.
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.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
character(len=512), private msg
subroutine, public messages_warning(no_lines, all_nodes, 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_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module implements the basic minimizer framework.
character(len=algo_label_len), parameter, public gs_scf_start
character(len=algo_label_len), parameter, public gs_scf_finish
character(len=algo_label_len), parameter, public gs_scf_iteration
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
This module handles the communicators for the various parallelization strategies.
subroutine, public multicomm_end(mc)
subroutine, public multicomm_init(mc, namespace, base_grp, mode_para, n_processes, index_range, min_range)
create index and domain communicators
Maxwell-field-to-matter interactions.
integer, parameter, public mxll_field_trans
integer, parameter, public mxll_field_long
integer, parameter, public mxll_field_total
this module contains the low-level part of the output system
subroutine, public output_mxll_init(outp, namespace, space)
this module contains the output system
logical function, public parse_is_defined(namespace, name)
subroutine, public poisson_init(this, namespace, space, der, mc, stencil, qtot, label, solver, verbose, force_serial, force_cmplx, fft_library, fft_batch_size, single_precision)
subroutine, public poisson_end(this)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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.
character(len=algo_label_len), parameter, public exp_gauss1_start
character(len=algo_label_len), parameter, public exp_gauss1_finish
character(len=algo_label_len), parameter, public exp_gauss1_extrapolate
character(len=algo_label_len), parameter, public exp_gauss1_propagate
character(len=algo_label_len), parameter, public exp_gauss2_finish
character(len=algo_label_len), parameter, public exp_gauss2_propagate
character(len=algo_label_len), parameter, public exp_gauss2_extrapolate
character(len=algo_label_len), parameter, public exp_gauss2_start
character(len=algo_label_len), parameter, public expmid_extrapolate
character(len=algo_label_len), parameter, public expmid_finish
character(len=algo_label_len), parameter, public expmid_start
character(len=algo_label_len), parameter, public expmid_propagate
character(len=algo_label_len), parameter, public leapfrog_propagate
character(len=algo_label_len), parameter, public leapfrog_finish
character(len=algo_label_len), parameter, public leapfrog_start
subroutine, public transform_rs_densities(hm, mesh, rs_current_density, ff_density, sign)
subroutine, public energy_mxll_calc_batch(gr, st, hm, energy_mxll, rs_fieldb, rs_field_plane_wavesb)
integer, parameter, public rs_trans_forward
subroutine, public mxll_propagate_leapfrog(hm, namespace, gr, st, tr, time, dt, counter)
subroutine, public mxll_propagation_step(hm, namespace, gr, space, st, tr, rs_stateb, ff_rs_inhom_t1, ff_rs_inhom_t2, time, dt)
subroutine, public spatial_constant_calculation(constant_calc, st, gr, hm, time, dt, delay, rs_state, set_initial_state)
subroutine, public set_medium_rs_state(st, gr, hm)
subroutine, public mxll_propagate_expgauss1(hm, namespace, gr, st, tr, time, dt)
Exponential propagation scheme with Gauss collocation points, s=1.
subroutine, public energy_mxll_calc(gr, st, hm, energy_mxll, rs_field, rs_field_plane_waves)
subroutine, public mxll_propagate_expgauss2(hm, namespace, gr, st, tr, time, dt)
Exponential propagation scheme with Gauss collocation points, s=2.
subroutine, public propagator_mxll_init(gr, namespace, st, hm, tr)
This module implements the basic propagator framework.
character(len=algo_label_len), parameter, public store_current_status
This module defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
Implementation details for regridding.
integer, parameter, public restart_type_dump
logical function, public clean_stop(mpi_grp)
returns true if a file named stop exists
integer, parameter, public restart_td
integer, parameter, public restart_type_load
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public mxll_set_batch(rs_stateb, rs_state, np, dim, offset)
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 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 states_mxll_init(st, namespace, space)
subroutine, public get_electric_field_state(rs_state, mesh, electric_field, ep_field, np)
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)
subroutine, public states_mxll_load(restart, st, mesh, namespace, space, zff, zff_dim, ierr, iter, lowest_missing, label, verbose)
subroutine, public states_mxll_dump(restart, st, space, mesh, zff, zff_dim, ierr, iter, verbose)
subroutine, public states_mxll_read_user_def(namespace, space, mesh, der, st, bc, user_def_rs_state)
This module implements the abstract system type.
subroutine, public system_end(this)
integer, parameter, public out_maxwell_max
subroutine, public td_write_mxll_end(writ)
subroutine, public td_write_mxll_init(writ, namespace, iter, dt, grp)
subroutine, public td_write_mxll_free_data(namespace, space, gr, st, hm, helmholtz, outp, iter, time)
subroutine, public td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
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.
Descriptor of one algorithmic operation.
Class to transfer a current to a Maxwell field.
These class extend the list and list iterator to make an interaction list.
abstract interaction class
surrogate interaction class to avoid circular dependencies between modules.
Lorenz force between a systems of particles and an electromagnetic field.
Class describing Maxwell systems.
Abstract class implementing minimizers.
This is defined even when running serial.
class to transfer a Maxwell B field to a matter system
class to transfer a Maxwell electric field to a medium
class to transfer a Maxwell vector potential to a medium
Implements the an exponential RK scheme with Gauss collocation points, s=1 see also Hochbruck,...
Implements the an exponential RK scheme with Gauss collocation points, s=2 see also Hochbruck,...
Implements the explicit exponential midpoint propagator (without predictor-corrector)
Implements a propagator for the leap frog algorithm.
Abstract class implementing propagators.
Systems (system_t) can expose quantities that can be used to calculate interactions with other system...
Abstract class for systems.