store_photons Subroutine

public subroutine store_photons(pos, vi, photons, spectra, passive)

Store photons in spectra

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(in), dimension(3):: pos

Position of neutral

real(kind=Float64), intent(in), dimension(3):: vi

Velocitiy of neutral [cm/s]

real(kind=Float64), intent(in) :: photons

Photons from colrad [Ph/(s*cm^3)]

real(kind=Float64), intent(inout), dimension(:,:):: spectra
logical, intent(in), optional :: passive

Indicates whether photon is passive FIDA


Calls

proc~~store_photons~~CallsGraph proc~store_photons store_photons proc~get_indices get_indices proc~store_photons->proc~get_indices proc~uvw_to_xyz uvw_to_xyz proc~store_photons->proc~uvw_to_xyz proc~spectrum spectrum proc~store_photons->proc~spectrum proc~get_passive_grid_indices get_passive_grid_indices proc~store_photons->proc~get_passive_grid_indices proc~get_fields get_fields proc~store_photons->proc~get_fields proc~get_fields->proc~uvw_to_xyz proc~calc_perp_vectors calc_perp_vectors proc~get_fields->proc~calc_perp_vectors proc~in_plasma in_plasma proc~get_fields->proc~in_plasma proc~xyz_to_uvw xyz_to_uvw proc~get_fields->proc~xyz_to_uvw proc~in_plasma->proc~xyz_to_uvw proc~cyl_to_uvw cyl_to_uvw proc~in_plasma->proc~cyl_to_uvw interface~interpol_coeff interpol_coeff proc~in_plasma->interface~interpol_coeff proc~cyl_interpol3d_coeff cyl_interpol3D_coeff interface~interpol_coeff->proc~cyl_interpol3d_coeff proc~interpol1d_coeff interpol1D_coeff interface~interpol_coeff->proc~interpol1d_coeff proc~interpol2d_coeff_arr interpol2D_coeff_arr interface~interpol_coeff->proc~interpol2d_coeff_arr proc~interpol2d_coeff interpol2D_coeff interface~interpol_coeff->proc~interpol2d_coeff proc~cyl_interpol3d_coeff_arr cyl_interpol3D_coeff_arr interface~interpol_coeff->proc~cyl_interpol3d_coeff_arr proc~interpol1d_coeff_arr interpol1D_coeff_arr interface~interpol_coeff->proc~interpol1d_coeff_arr proc~cyl_interpol3d_coeff->proc~interpol2d_coeff proc~interpol2d_coeff_arr->proc~interpol2d_coeff proc~cyl_interpol3d_coeff_arr->proc~cyl_interpol3d_coeff proc~cyl_interpol3d_coeff_arr->proc~interpol2d_coeff proc~interpol1d_coeff_arr->proc~interpol1d_coeff

Called by

proc~~store_photons~~CalledByGraph proc~store_photons store_photons proc~dcx_spec dcx_spec proc~dcx_spec->proc~store_photons proc~halo_spec halo_spec proc~halo_spec->proc~store_photons proc~cold_spec cold_spec proc~cold_spec->proc~store_photons proc~nbi_spec nbi_spec proc~nbi_spec->proc~store_photons proc~store_bes_photons store_bes_photons proc~store_bes_photons->proc~store_photons proc~store_fida_photons store_fida_photons proc~store_fida_photons->proc~store_photons program~fidasim fidasim program~fidasim->proc~dcx_spec program~fidasim->proc~halo_spec program~fidasim->proc~cold_spec program~fidasim->proc~nbi_spec

Contents

Source Code


Source Code

subroutine store_photons(pos, vi, photons, spectra, passive)
    !+ Store photons in `spectra`
    real(Float64), dimension(3), intent(in)      :: pos
        !+ Position of neutral
    real(Float64), dimension(3), intent(in)      :: vi
        !+ Velocitiy of neutral [cm/s]
    real(Float64), intent(in)                    :: photons
        !+ Photons from [[libfida:colrad]] [Ph/(s*cm^3)]
    real(Float64), dimension(:,:), intent(inout) :: spectra
    logical, intent(in), optional                :: passive
        !+ Indicates whether photon is passive FIDA

    real(Float64), dimension(n_stark) :: lambda, intensity
    real(Float64) :: dlength, sigma_pi
    type(LocalEMFields) :: fields
    integer(Int32), dimension(3) :: ind
    real(Float64), dimension(3) :: pos_xyz, lens_xyz, cyl, vp
    type(LOSInters) :: inter
    integer :: ichan,i,j,bin,nchan
    logical :: pas = .False.

    if(present(passive)) pas = passive

    if(pas) then
        cyl(1) = sqrt(pos(1)*pos(1) + pos(2)*pos(2))
        cyl(2) = pos(3)
        cyl(3) = atan2(pos(2), pos(1))
        call get_passive_grid_indices(cyl,ind)
        inter = spec_chords%cyl_inter(ind(1),ind(2),ind(3))
        call uvw_to_xyz(pos, pos_xyz)
    else
        call get_indices(pos,ind)
        inter = spec_chords%inter(ind(1),ind(2),ind(3))
        pos_xyz = pos
    endif

    nchan = inter%nchan
    if(nchan.eq.0) return

    call get_fields(fields,pos=pos_xyz)

    loop_over_channels: do j=1,nchan
        ichan = inter%los_elem(j)%id
        dlength = inter%los_elem(j)%length
        sigma_pi = spec_chords%los(ichan)%sigma_pi
        if(pas) then
            call uvw_to_xyz(spec_chords%los(ichan)%lens_uvw,lens_xyz)
        else
            lens_xyz = spec_chords%los(ichan)%lens
        endif
        vp = pos_xyz - lens_xyz
        call spectrum(vp,vi,fields,sigma_pi,photons, &
                      dlength,lambda,intensity)

        loop_over_stark: do i=1,n_stark
            bin=floor((lambda(i)-inputs%lambdamin)/inputs%dlambda) + 1
            if (bin.lt.1) cycle loop_over_stark
            if (bin.gt.inputs%nlambda) cycle loop_over_stark
            !$OMP ATOMIC UPDATE
            spectra(bin,ichan) = spectra(bin,ichan) + intensity(i)
            !$OMP END ATOMIC
        enddo loop_over_stark
    enddo loop_over_channels

end subroutine store_photons