37  use, 
intrinsic :: iso_fortran_env
 
   75    integer,  
allocatable :: helicity(:)
 
   76    integer,  
allocatable :: m_order(:)
 
   77    real(real64),    
allocatable :: amp(:)
 
   78    real(real64),    
allocatable :: theta_k(:)
 
   79    real(real64),    
allocatable :: omega(:)
 
   80    real(real64),    
allocatable :: shift(:,:)
 
   81    logical,  
allocatable :: envelope(:)
 
   82    integer,  
allocatable :: lin_dir(:)
 
   90    integer                          :: points_number
 
   91    integer,             
allocatable :: points_map(:)
 
   93    integer,             
allocatable :: modus(:)
 
   95    integer,             
allocatable :: field_type(:)
 
   96    character(len=1024), 
allocatable :: e_field_string(:,:)
 
   97    real(real64),        
allocatable :: k_vector(:,:)
 
   98    real(real64),        
allocatable :: v_vector(:,:)
 
   99    complex(real64),     
allocatable :: e_field(:,:)
 
  100    real(real64),        
allocatable :: pw_phase(:)
 
  101    type(mxf_t),         
allocatable :: mx_function(:)
 
  103    logical                          :: output_from_point = .false. 
 
  104    real(real64), 
allocatable        :: selected_point_coordinate(:)
 
  105    real(real64), 
allocatable        :: selected_point_field(:)
 
  106    real(real64)                     :: c_factor
 
  107    type(accel_mem_t)                :: buff_map
 
  108    type(bessel_beam_t)              :: bessel
 
  123    class(external_waves_t), 
pointer :: this
 
  124    type(namespace_t), 
intent(in) :: namespace
 
  127    character(len=:), 
allocatable :: quantities(:)
 
  133    this%namespace = namespace_t(
"ExternalSource", parent=namespace)
 
  135    message(1) = 
'Plane-wave is currently always 3D and non-periodic.' 
  139    quantities = [
character(16) :: 
"E field", 
"vector potential", 
"B field"]
 
  140    do iq = 1, 
size(quantities)
 
  141      call this%quantities%add(
quantity_t(quantities(iq), always_available = .
true., &
 
  142        updated_on_demand = .
true., iteration = 
clock_t()))
 
  153    class(external_waves_t),    
intent(in)    :: partner
 
  154    class(interaction_surrogate_t), 
intent(inout) :: interaction
 
  158    select type (interaction)
 
  168      message(1) = 
"Unsupported interaction." 
  177    character(len=*),         
intent(in)    :: label
 
  182    case (
"E field", 
"B field", 
"vector potential")
 
  203    select type(interaction)
 
  205      quantity => partner%quantities%get(
"E field")
 
  208        interaction%system_field)
 
  209      call interaction%do_mapping()
 
  212      quantity => partner%quantities%get(
"vector potential")
 
  213      interaction%system_field = 
m_zero 
  215        "vector potential", interaction%system_field)
 
  216      call interaction%do_mapping()
 
  219      quantity => partner%quantities%get(
"B field")
 
  220      interaction%system_field = 
m_zero 
  221      call external_waves_eval(partner, quantity%iteration%value(), interaction%system_gr, 
"B field", &
 
  222        interaction%system_field, der=interaction%system_gr%der)
 
  223      call interaction%do_mapping()
 
  226      message(1) = 
"Incompatible interaction." 
  237    type(namespace_t),     
intent(in)     :: namespace
 
  239    logical :: has_source
 
  250    call parse_variable(namespace, 
'AnalyticalExternalSource', .false., has_source)
 
  264    type(namespace_t),         
intent(in)    :: namespace
 
  266    integer              :: il, nlines, ncols, iex_norm, idim
 
  267    integer, 
parameter   :: sys_dim = 3
 
  268    real(real64)         :: k_vector(sys_dim), velocity(sys_dim), x_pos(sys_dim)
 
  269    real(real64)         :: x_norm, dummy(sys_dim), k_dot_e , test_limit, k_norm, output_pos(3)
 
  270    complex(real64)      :: e_field(sys_dim)
 
  271    character(len=1024)  :: k_string(sys_dim)
 
  272    character(len=1), 
dimension(sys_dim), 
parameter :: dims = [
"x", 
"y", 
"z"]
 
  273    character(len=1024)  :: mxf_expression
 
  279    test_limit = 10.0e-9_real64
 
  297    if (
parse_block(namespace, 
'ExternalSourceBesselOutput', blk) == 0) 
then 
  299      if (nlines > 1 ) 
then 
  300        message(2) = 
'ExternalSource output is limited to one point.' 
  304      if (ncols /= 3 ) 
then 
  305        message(1) = 
'ExternalSourceBesselOutput must have 3 columns.' 
  308      external_waves%output_from_point= .
true.
 
  309      safe_allocate(external_waves%selected_point_coordinate(1:3))
 
  310      safe_allocate(external_waves%selected_point_field(1:3))
 
  315      external_waves%selected_point_coordinate(1:3) = output_pos(1:3)
 
  316      external_waves%selected_point_field(1:3)  = 
m_zero 
  320      external_waves%out_file  = 
io_open(
'bessel_source_at_point', namespace=namespace, action=
'write')
 
  321      write(external_waves%out_file, 
'(12a) ')  
'#    Time (a.u.)    ' , 
'  Field-x  ' , 
'  Field-y  ' , 
'   Field-z   ' 
  324      external_waves%output_from_point= .false.
 
  369    if (
parse_block(namespace, 
'MaxwellIncidentWaves', blk) == 0) 
then 
  376      external_waves%number = nlines
 
  377      safe_allocate(external_waves%modus(1:nlines))
 
  378      safe_allocate(external_waves%e_field_string(1:3, 1:nlines))
 
  379      safe_allocate(external_waves%e_field(1:3, 1:nlines))
 
  380      safe_allocate(external_waves%k_vector(1:3, 1:nlines))
 
  381      safe_allocate(external_waves%v_vector(1:3, 1:nlines))
 
  382      safe_allocate(external_waves%mx_function(1:nlines))
 
  383      safe_allocate(external_waves%field_type(1:nlines))
 
  384      safe_allocate(external_waves%pw_phase(1:nlines))
 
  385      external_waves%pw_phase = 
m_zero 
  387      call external_waves%bessel%init(nlines, 3)
 
  391        if ((ncols < 5) .or. (ncols > 9)) 
then 
  392          message(1) = 
'Each line in the MaxwellIncidentWaves block must have five to nine columns.' 
  401        if (external_waves%modus(il) == option__maxwellincidentwaves__plane_wave_parser) 
then 
  404            call parse_block_string( blk, il - 1, 3 + idim + 1, external_waves%e_field_string(idim, il))
 
  406          write(
message(1), 
'(a,i2,a) ') 
'Substituting electromagnetic incident wave ', il, 
' with the expressions: ' 
  409            write(
message(idim), 
'(6a)')     
'  Wave vector k('//dims(idim)//
')   = ', trim(k_string(idim))
 
  410            write(
message(idim+1), 
'(2a)')     
'  E-field('//dims(idim)//
') for t_0 = ', &
 
  411              trim(external_waves%e_field_string(idim, il))
 
  426          k_norm = norm2(k_vector)
 
  428          velocity(:)    = k_vector(:) / k_norm * 
p_c * external_waves%c_factor
 
  429          external_waves%k_vector(:,il) = k_vector(:)
 
  430          external_waves%v_vector(:,il) = velocity(:)
 
  432        else if (external_waves%modus(il) == option__maxwellincidentwaves__plane_wave_mx_function) 
then 
  438          write(
message(1), 
'(a,i2) ') 
'Substituting electromagnetic incident wave ', il
 
  439          write(
message(2), 
'(a)'    ) 
'with the expression: ' 
  443            write(
message(idim), 
'(a,f9.4,sp,f9.4,"i")') 
'  E-field('//trim(dims(idim))//
') complex amplitude  = ', &
 
  444              real(e_field(idim)), aimag(e_field(idim))
 
  446          write(
message(4), 
'(2a)'    )      
'  Maxwell wave function name = ', trim(mxf_expression)
 
  449          call mxf_read(external_waves%mx_function(il), namespace, trim(mxf_expression), iex_norm)
 
  450          if (iex_norm /= 0) 
then 
  451            write(
message(1),
'(3A)') 
'Ex_norm in the ""', trim(mxf_expression), &
 
  452              '"" field defined in the MaxwellIncidentWaves block' 
  458          k_vector(1:3) = external_waves%mx_function(il)%k_vector(1:3)
 
  459          k_norm = norm2(k_vector)
 
  461          k_dot_e = real(dot_product(k_vector, e_field), real64)
 
  462          if (abs(k_dot_e) > test_limit) 
then 
  463            write(
message(1), 
'(a) ') 
'The wave vector k or its electric field are not perpendicular. ' 
  464            write(
message(2), 
'(a,f8.3,a)' ) 
'Their dot product yields the magnitude', abs(k_dot_e) , 
' while' 
  465            write(
message(3), 
'(a,f8.3,a)' ) 
'tolerance is ', test_limit ,
'.' 
  468          if (k_norm < 1e-10) 
then 
  469            message(1) = 
'The k vector is not set correctly: |k|~0 .' 
  473          external_waves%e_field(:,il)  = e_field(:)
 
  474          external_waves%k_vector(:,il) = k_vector(:)
 
  475          external_waves%v_vector(:,il) = k_vector(:) / k_norm * 
p_c * external_waves%c_factor
 
  477        else if (external_waves%modus(il) == option__maxwellincidentwaves__bessel_function) 
then 
  485            external_waves%bessel%envelope(il) = .
true.
 
  486            call mxf_read(external_waves%mx_function(il), namespace, trim(mxf_expression), iex_norm)
 
  492          write(
message(1), 
'(a,i2) ') 
'Incident Bessel Beam', il
 
  495          if (abs(external_waves%bessel%helicity(il)) /= 1) 
then 
  496            write(
message(1),
'(A)') 
'Helicity has to be either +1 or -1 !' 
  500          write(
message(1), 
'(a,f5.3)'    )  
' Bessel Amplitude ', external_waves%bessel%amp(il)
 
  501          write(
message(2), 
'(a,i2)'    )  
' Bessel Order m', external_waves%bessel%m_order(il)
 
  502          write(
message(3), 
'(a,f5.3)'    )  
' Bessel Frequency ', external_waves%bessel%omega(il)
 
  503          write(
message(4), 
'(a,i2)'    )  
' Bessel Helicity ', external_waves%bessel%helicity(il)
 
  504          write(
message(5), 
'(a,f5.3)'    )  
' Bessel Opening Angle ', external_waves%bessel%theta_k(il)
 
  507          if (external_waves%bessel%lin_dir(il)/= 0) 
then 
  508            write(
message(5), 
'(a,i2)'    )  
' Bessel is Linearly Polarized in Direction : ', external_waves%bessel%lin_dir(il)
 
  519      external_waves%number = 0
 
  537    if (
parse_block(namespace, 
'BesselBeamAxisShift', blk) == 0) 
then 
  540      if (ncols /= 3 ) 
then 
  541        message(1) = 
'BesselBeamAxisShift must have 3 columns.' 
  565    if (external_waves%output_from_point) 
then 
  566      call io_close(external_waves%out_file)
 
  567      safe_deallocate_a(external_waves%selected_point_coordinate)
 
  568      safe_deallocate_a(external_waves%selected_point_field)
 
  571    safe_deallocate_a(external_waves%bessel%shift)
 
  572    safe_deallocate_a(external_waves%points_map)
 
  573    safe_deallocate_a(external_waves%modus)
 
  574    safe_deallocate_a(external_waves%e_field_string)
 
  575    safe_deallocate_a(external_waves%k_vector)
 
  576    safe_deallocate_a(external_waves%v_vector)
 
  577    safe_deallocate_a(external_waves%e_field)
 
  578    safe_deallocate_a(external_waves%mx_function)
 
  579    safe_deallocate_a(external_waves%pw_phase)
 
  590  subroutine external_waves_eval(external_waves, time, mesh, type_of_field, out_field_total, der)
 
  592    real(real64),              
intent(in)    :: time
 
  593    class(
mesh_t),             
intent(in)    :: mesh
 
  594    character(len=*),          
intent(in)    :: type_of_field
 
  595    real(real64),              
intent(out)   :: out_field_total(:, :)
 
  605    call plane_waves_eval(external_waves, time, mesh, type_of_field, out_field_total, der=der)
 
  606    call bessel_source_eval(external_waves, time, mesh, type_of_field, out_field_total, der=der)
 
  615  subroutine plane_waves_eval(external_waves, time, mesh, type_of_field, out_field_total, der)
 
  617    real(real64),              
intent(in)    :: time
 
  618    class(
mesh_t),             
intent(in)    :: mesh
 
  619    character(len=*),          
intent(in)    :: type_of_field
 
  620    real(real64),              
intent(out)   :: out_field_total(:, :)
 
  624    real(real64), 
allocatable   :: pw_field(:,:), ztmp(:,:), b_field_aux(:,:)
 
  626    integer, 
allocatable :: indices_pw_parser(:)
 
  627    integer, 
allocatable :: indices_mx_ftc(:)
 
  628    integer :: n_plane_waves, n_points
 
  634    indices_pw_parser = pack([(wn, wn = 1,external_waves%number)], &
 
  635      external_waves%modus == option__maxwellincidentwaves__plane_wave_parser)
 
  637    indices_mx_ftc = pack([(wn, wn = 1,external_waves%number)], &
 
  638      external_waves%modus == option__maxwellincidentwaves__plane_wave_mx_function)
 
  640    n_plane_waves = 
size(indices_pw_parser) + 
size(indices_mx_ftc)
 
  642    p_c_ = 
p_c * external_waves%c_factor
 
  644    if (n_plane_waves == 0) 
then 
  652      safe_allocate(ztmp(mesh%np, 
size(out_field_total, dim=2)))
 
  653      n_points = mesh%np_part
 
  657    safe_allocate(pw_field(n_points, 
size(out_field_total, dim=2)))
 
  661    do wn = 1, external_waves%number
 
  663      select case(external_waves%modus(wn))
 
  664      case (option__maxwellincidentwaves__plane_wave_parser)
 
  667      case (option__maxwellincidentwaves__plane_wave_mx_function)
 
  671      select case (external_waves%field_type(wn))
 
  675        select case (type_of_field)
 
  677          out_field_total(1:mesh%np,:) = out_field_total(1:mesh%np,:) + pw_field(1:mesh%np,:)
 
  678        case (
"vector potential")
 
  681          safe_allocate(b_field_aux(1:mesh%np, 1:mesh%box%dim))
 
  682          call get_pw_b_field(external_waves, mesh, wn, pw_field, b_field_aux)
 
  683          out_field_total(:,:) = out_field_total(:,:) + b_field_aux(:,:)
 
  684          safe_deallocate_a(b_field_aux)
 
  689        select case (type_of_field)
 
  692        case (
"vector potential")
 
  693          out_field_total(1:mesh%np,:) = out_field_total(1:mesh%np,:) - 
m_one/p_c_ * pw_field(1:mesh%np,1:3)
 
  695          call dderivatives_curl(der, pw_field(1:mesh%np_part,1:3), ztmp(1:mesh%np,1:3), set_bc = .false.)
 
  696          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) - 
m_one/p_c_ * ztmp(1:mesh%np, 1:3)
 
  702    safe_deallocate_a(pw_field)
 
  703    safe_deallocate_a(ztmp)
 
  714    integer,                   
intent(in)    :: wn
 
  715    real(real64),              
intent(in)    :: time
 
  716    class(
mesh_t),             
intent(in)    :: mesh
 
  717    integer,                   
intent(in)    :: n_points
 
  718    real(real64),              
intent(out)   :: pw_field(:,:)
 
  720    real(real64)         :: x_prop(3), x_norm
 
  721    real(real64)         :: velocity_time(3)
 
  722    real(real64)         :: parsed_field(3)
 
  723    real(real64)         :: dummy(3)
 
  726    velocity_time(:) = external_waves%v_vector(1:3, wn) * time
 
  729        external_waves%e_field_string(idim, wn))
 
  731        x_prop = mesh%x(ip, :) - velocity_time
 
  732        x_norm = norm2(x_prop(1:3))
 
  733        pw_field(ip, idim) = parsed_field(idim)
 
  743    integer,                   
intent(in)    :: wn
 
  744    real(real64),              
intent(in)    :: time
 
  745    class(
mesh_t),             
intent(in)    :: mesh
 
  746    integer,                   
intent(in)    :: n_points
 
  747    real(real64),              
intent(out)   :: pw_field(:,:)
 
  749    real(real64)         :: x_prop(3), x_norm
 
  750    real(real64)         :: velocity_time(3)
 
  751    complex(real64)      :: efield_ip(3)
 
  752    complex(real64)      :: e0(3)
 
  755    velocity_time(:) = external_waves%v_vector(1:3, wn) * time
 
  756    e0(:) = external_waves%e_field(1:3, wn)
 
  758      x_prop = mesh%x(ip, :) - velocity_time
 
  759      x_norm = norm2(x_prop(1:3))
 
  760      efield_ip = 
mxf(external_waves%mx_function(wn), x_prop, external_waves%pw_phase(wn))
 
  761      pw_field(ip, :) = real(e0(1:3) * efield_ip, real64)
 
  768  subroutine get_pw_b_field(external_waves, mesh, pwidx, e_field, b_field)
 
  770    class(
mesh_t),           
intent(in)  :: mesh
 
  771    real(real64),            
intent(in)  :: e_field(:,:)
 
  772    real(real64),            
intent(out) :: b_field(:,:)
 
  773    integer,                 
intent(in)  :: pwidx
 
  775    real(real64)   :: k_vector(3), k_vector_abs
 
  776    real(real64)   :: velocity(3)
 
  778    complex(real64)   :: e0(3)
 
  781    velocity = external_waves%v_vector(1:3, pwidx)
 
  782    k_vector = external_waves%k_vector(1:3, pwidx)
 
  783    k_vector_abs = norm2(k_vector(1:3))
 
  784    e0 = external_waves%e_field(1:3, pwidx)
 
  785    p_c_ = 
p_c * external_waves%c_factor
 
  789      b_field(ip, :) = 
m_one/(p_c_ * k_vector_abs) * dcross_product(k_vector, e_field(ip, :))
 
  796  subroutine bessel_source_eval(external_waves, time, mesh, type_of_field, out_field_total, der)
 
  798    real(real64),              
intent(in)    :: time
 
  799    class(
mesh_t),             
intent(in)    :: mesh
 
  800    character(len=*),          
intent(in)    :: type_of_field
 
  801    real(real64),              
intent(out)   :: out_field_total(:, :)
 
  804    real(real64)         :: dmin, omega, k_vector(3), c_factor
 
  805    integer              :: iline, wn, pos_index, n_points, rankmin
 
  806    real(real64), 
allocatable   :: shift(:,:)
 
  807    complex(real64), 
allocatable   :: bessel_field_total(:,:), ztmp(:,:), vec_pot(:,:)
 
  808    integer, 
allocatable :: indices_bessel_ftc(:)
 
  809    type(
mxf_t)          :: envelope_mxf
 
  815    indices_bessel_ftc = pack([(wn, wn = 1,external_waves%number)], &
 
  816      external_waves%modus == option__maxwellincidentwaves__bessel_function)
 
  818    if (
size(indices_bessel_ftc) == 0) 
then 
  825    if (
allocated(external_waves%bessel%shift) .and. &
 
  826      size(external_waves%bessel%shift(:,1)) /= 
size(indices_bessel_ftc)) 
then 
  827      message(1) = 
'Number of BesselBeamAxisShift defined in input file' 
  828      message(2) = 
'does not match the number of Bessel beams.' 
  832    safe_allocate(shift(
size(indices_bessel_ftc), 3))
 
  833    if (
allocated(external_waves%bessel%shift)) 
then 
  834      shift = external_waves%bessel%shift
 
  839    if (type_of_field == 
"B field") 
then 
  841      safe_allocate(vec_pot(mesh%np_part, 
size(out_field_total, dim=2)))
 
  842      safe_allocate(ztmp(
size(out_field_total, dim=1), 
size(out_field_total, dim=2)))
 
  843      n_points = mesh%np_part 
 
  849    safe_allocate(bessel_field_total(1:n_points, 1:3))
 
  850    bessel_field_total = 
m_zero 
  852    do iline = 1, 
size(indices_bessel_ftc)
 
  853      wn = indices_bessel_ftc(iline)
 
  854      omega = external_waves%bessel%omega(wn)
 
  855      k_vector = external_waves%mx_function(wn)%k_vector
 
  856      c_factor =  external_waves%c_factor
 
  857      envelope_mxf = external_waves%mx_function(wn)
 
  859      call external_waves%bessel%function(wn, shift, mesh, n_points, time, k_vector, c_factor, envelope_mxf, bessel_field_total)
 
  861      select case (external_waves%field_type(wn))
 
  865        select case (type_of_field)
 
  867          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) + real(
m_zi*omega*bessel_field_total(1:mesh%np,1:3))
 
  868        case (
"vector potential")
 
  871          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) - 
m_one/
p_c * real(bessel_field_total(1:mesh%np,1:3))
 
  873          call zderivatives_curl(der, bessel_field_total(1:mesh%np_part,1:3), ztmp(1:mesh%np,1:3), set_bc = .false.)
 
  874          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) - 
m_one/
p_c * real(ztmp(1:mesh%np, 1:3))
 
  879        select case (type_of_field)
 
  881          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) + real(bessel_field_total(1:mesh%np,1:3))
 
  882        case (
"vector potential")
 
  885          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) - 
m_one/
p_c * &
 
  886            real(bessel_field_total(1:mesh%np,1:3)/M_zI/omega)
 
  888          vec_pot(1:mesh%np_part,1:3) = - 
m_one/
p_c * real(bessel_field_total(1:mesh%np_part,1:3)/m_zi/omega)
 
  889          call zderivatives_curl(der, vec_pot(1:mesh%np_part,1:3), ztmp(1:mesh%np,1:3), set_bc = .false.)
 
  890          out_field_total(1:mesh%np,1:3) = out_field_total(1:mesh%np,1:3) - real(ztmp(1:mesh%np, 1:3))
 
  896    if (external_waves%output_from_point) 
then 
  897      pos_index = 
mesh_nearest_point(mesh, external_waves%selected_point_coordinate(1:3), dmin, rankmin)
 
  898      if (mesh%mpi_grp%rank == rankmin) 
then 
  899        external_waves%selected_point_field(:) = out_field_total(pos_index,:)
 
  900        write(external_waves%out_file, 
"(4F14.8, 4x)") time, external_waves%selected_point_field(:)
 
  904    safe_deallocate_a(shift)
 
  905    safe_deallocate_a(ztmp)
 
  906    safe_deallocate_a(vec_pot)
 
  907    safe_deallocate_a(bessel_field_total)
 
  916  subroutine bessel_beam_function(this, iline, shift, mesh, n_points, time, k_vector, c_factor, envelope_mxf, bessel_field)
 
  918    integer, 
intent(in)       :: iline
 
  919    real(real64),   
intent(in)       :: shift(:,:), time, k_vector(3), c_factor
 
  920    class(
mesh_t), 
intent(in) :: mesh
 
  921    integer, 
intent(in)       :: n_points
 
  922    type(
mxf_t), 
intent(in)   :: envelope_mxf
 
  923    complex(real64),   
intent(out)      :: bessel_field(:,:)
 
  925    real(real64)   :: pos(3), temp, temp2, temp3, rho, phi_rho, wigner(3)
 
  926    real(real64)   :: hel, theta, omega, amp, kappa, proj, k_norm, velocity_time(3), x_prop(3)
 
  927    complex(real64)   :: efield_ip(3)
 
  928    real(real64)   :: bessel_plus, bessel_minus
 
  929    integer :: ip, mm, pol
 
  931    assert(iline <= 
size(this%omega))
 
  932    hel = real(this%helicity(iline), real64)
 
  933    theta = this%theta_k(iline)
 
  934    mm = this%m_order(iline)
 
  936    omega = this%omega(iline)
 
  937    proj = omega * 
cos(theta) / 
p_c              
  938    kappa = 
sqrt(omega**2 - (proj* 
p_c)**2)     
 
  941    wigner(2) = 0.5 * (1 + hel * 
cos(theta))    
 
  942    wigner(3) = 0.5 * (1 - hel * 
cos(theta))    
 
  943    proj = omega * 
cos(theta) / 
p_c              
  944    pol = this%lin_dir(iline)  
 
  947      pos(:) = mesh%x(ip, :) -  shift(iline,:)
 
  948      rho = norm2(pos(1:2))
 
  949      phi_rho = 
atan2(pos(2) , pos(1))
 
  950      temp = proj * pos(3) + phi_rho * (mm + 1) - omega*time 
 
  951      temp2 = proj * pos(3) + phi_rho * (mm - 1) - omega*time
 
  952      temp3 = proj * pos(3) + phi_rho * mm - omega*time
 
  958        bessel_field(ip, 1) = amp * (
exp(
m_zi*temp) * wigner(3) * bessel_plus + 
exp(
m_zi*temp2) * wigner(2) * bessel_minus)
 
  962        bessel_field(ip, 2) = 
m_zi * amp * (-
exp(
m_zi*temp) * wigner(3) * bessel_plus + &
 
  963          exp(
m_zi*temp2) * wigner(2) * bessel_minus)
 
  970      if (this%envelope(iline)) 
then 
  971        k_norm = norm2(k_vector)
 
  972        velocity_time = k_vector * 
p_c * c_factor * time  / k_norm
 
  973        x_prop(:) = pos(:) - velocity_time(:)
 
  975        bessel_field(ip, :) = bessel_field(ip, :) * real(efield_ip, real64)
 
  985    integer, 
intent(in) :: nlines
 
  986    integer, 
intent(in) :: dim
 
  988    safe_allocate(this%amp(1: nlines))
 
  989    safe_allocate(this%omega(1:nlines))
 
  990    safe_allocate(this%theta_k(1:nlines))
 
  991    safe_allocate(this%m_order(1:nlines))
 
  992    safe_allocate(this%helicity(1:nlines))
 
  993    safe_allocate(this%shift(1:nlines, 1:dim))
 
  994    safe_allocate(this%envelope(1:nlines))
 
  995    safe_allocate(this%lin_dir(1:nlines))
 
 1003    this%envelope = .false.
 
 1011    safe_deallocate_a(this%amp)
 
 1012    safe_deallocate_a(this%omega)
 
 1013    safe_deallocate_a(this%theta_k)
 
 1014    safe_deallocate_a(this%m_order)
 
 1015    safe_deallocate_a(this%helicity)
 
 1016    safe_deallocate_a(this%shift)
 
 1017    safe_deallocate_a(this%lin_dir)
 
 1018    safe_deallocate_a(this%envelope)
 
double exp(double __x) __attribute__((__nothrow__
 
double sin(double __x) __attribute__((__nothrow__
 
double cos(double __x) __attribute__((__nothrow__
 
double atan2(double __y, double __x) __attribute__((__nothrow__
 
subroutine, public accel_release_buffer(this, async)
 
pure logical function, public accel_is_enabled()
 
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
 
subroutine, public zderivatives_curl(der, ff, op_ff, ghost_update, set_bc)
apply the curl operator to a vector of mesh functions
 
subroutine, public dderivatives_curl(der, ff, op_ff, ghost_update, set_bc)
apply the curl operator to a vector of mesh functions
 
subroutine, public load_external_waves(partners, namespace)
 
subroutine bessel_beam_function(this, iline, shift, mesh, n_points, time, k_vector, c_factor, envelope_mxf, bessel_field)
. Evaluation of the Bessel beam expression
 
subroutine, public bessel_source_eval(external_waves, time, mesh, type_of_field, out_field_total, der)
Calculation of Bessel beam from parsed formula.
 
subroutine external_waves_update_quantity(this, label)
 
subroutine pw_mx_function_evaluation(external_waves, wn, time, mesh, n_points, pw_field)
Evaluate expression for plane wave that uses predefeined Maxwell function.
 
subroutine bessel_beam_init(this, nlines, dim)
. Initialization of Bessel beam arrays
 
subroutine external_waves_copy_quantities_to_interaction(partner, interaction)
 
subroutine, public external_waves_eval(external_waves, time, mesh, type_of_field, out_field_total, der)
Calculation of external waves from parsed formula.
 
class(external_waves_t) function, pointer external_waves_constructor(namespace)
 
subroutine, public external_waves_end(external_waves)
 
subroutine pw_parsed_evaluation(external_waves, wn, time, mesh, n_points, pw_field)
Evaluate expression for plane wave parsing the provided formula.
 
subroutine plane_waves_eval(external_waves, time, mesh, type_of_field, out_field_total, der)
Calculation of plane waves from parsed formula.
 
subroutine get_pw_b_field(external_waves, mesh, pwidx, e_field, b_field)
Calculation of magnetic field for a plane wave.
 
subroutine external_waves_init_interaction_as_partner(partner, interaction)
 
subroutine, public external_waves_init(external_waves, namespace)
Here, plane wave is evaluated from analytical formulae on grid.
 
subroutine bessel_beam_finalize(this)
. Finalize Bessel beam arrays
 
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)
 
real(real64), parameter, public m_one
 
This module implements the underlying real-space grid.
 
This module implements the index, used for the mesh points.
 
integer, parameter, public mxll_vec_pot_to_matter
 
integer, parameter, public mxll_b_field_to_matter
 
integer, parameter, public mxll_e_field_to_matter
 
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
 
This module defines classes and functions for interaction partners.
 
subroutine, public io_close(iunit, grp)
 
subroutine, public io_mkdir(fname, namespace, parents)
 
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
 
integer, parameter, public e_field_electric
 
integer, parameter, public e_field_vector_potential
 
complex(real64) function mxf_envelope_eval(f, x)
Evaluation of envelope itself.
 
subroutine, public mxf_read(f, namespace, function_name, ierr)
This function initializes "f" from the MXFunctions block.
 
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.
 
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
 
subroutine, public messages_not_implemented(feature, namespace)
 
character(len=512), private msg
 
subroutine, public messages_warning(no_lines, all_nodes, namespace)
 
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)
 
Some general things and nomenclature:
 
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
 
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 defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
 
subroutine, public conv_to_c_string(str)
converts to c string
 
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 representing derivatives
 
abstract class for general interaction partners
 
surrogate interaction class to avoid circular dependencies between modules.
 
Lorenz force between a systems of particles and an electromagnetic field.
 
Describes mesh distribution to nodes.
 
class to transfer a Maxwell B field to a matter system
 
class to transfer a Maxwell field to a medium
 
class to transfer a Maxwell vector potential to a medium
 
Systems (system_t) can expose quantities that can be used to calculate interactions with other system...