init_spectral Function

private function init_spectral(mus, mua, hgg, n, flux) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), allocatable :: mus(:,:)
real(kind=wp), intent(in), allocatable :: mua(:,:)
real(kind=wp), intent(in), allocatable :: hgg(:,:)
real(kind=wp), intent(in), allocatable :: n(:,:)
real(kind=wp), intent(in), allocatable :: flux(:,:)

Return Value type(spectral)


Source Code

    type(spectral) function init_spectral(mus, mua, hgg, n, flux) result(res)

        real(kind=wp), allocatable, intent(in) :: mus(:, :), mua(:, :), hgg(:, :), n(:, :), flux(:, :)
        
        real(kind=wp) :: wave, tmp

        !setup cdfs
        res%flux = piecewise1D(flux)

        res%mus_a = piecewise1D(mus)
        res%mua_a = piecewise1D(mua)
        res%hgg_a = piecewise1D(hgg)
        res%n_a = piecewise1D(n)

        !sample wavelength so we can sample from other optical properties at the correct points
        call res%flux%sample(wave,  tmp)
        ! sample optical properties
        call res%mus_a%sample(res%mus, wave)
        call res%mua_a%sample(res%mua, wave)
        call res%hgg_a%sample(res%hgg, wave)
        res%g2 = res%hgg**2
        call res%n_a%sample(res%n, wave)

        res%kappa =  res%mus + res%mua
        if(res%mua < 1e-9_wp)then          
            res%albedo = 1.
        else
            res%albedo = res%mus / res%kappa
        end if
    end function init_spectral