DART-Ray
Modules | Functions/Subroutines | Variables
sed_routines.f90 File Reference

Modules

module  sed_routines
 Contains all the subroutines to calculate the stellar and dust emission SEDs.
 

Functions/Subroutines

subroutine sed_routines::calc_sed
 Calculates stellar or dust emission SED from the i_obs() arrays. If keyword print_sed is not set TRUE, then it just returns. More...
 
subroutine sed_routines::create_sed_arr
 Allocates sed arrays sed_arr(), sed_arr_dir(), sed_arr_sca(). More...
 
subroutine sed_routines::calc_sed_arrays
 ! Sums up the i_obs at different wavelengths to obtain the total output sed in the input directions. Used only for the "sed" algorithm. More...
 
subroutine sed_routines::sum_i_obs (il, sed_arr)
 Sums i_obs arrays to obtain emission SED. More...
 
subroutine sed_routines::set_dust_emission
 Calculates the dust emission luminosity density and stores it into dens_stars_arr(). More...
 
subroutine sed_routines::check_dens_stars_arr
 Compare the newly calculated dens_stars_arr() with dens_stars_arr_prev(). If the relative difference is smaller than conv_en_lim(), it assigns TRUE to cnflag_dust(), thus stopping the dust heating iterations. It not, it subtracts from dens_stars_arr() the luminosity already processed in the previous dust heating iterations and it updates dens_stars_arr_prev(). More...
 
subroutine sed_routines::convert_ufield_ifield
 Calculates the constant factor conv_ufield_ifield(). Then transforms the stellar emission radiation field energy density u_final_uv_opt() into the integrated radiation field intensity in units of W/m^2/m. More...
 
subroutine sed_routines::calc_dens_dustem
 Calculates the dust emission luminosity density in the case of the effective grain mode. More...
 
subroutine sed_routines::calc_dens_dustem_equ
 Calculates the equilibrium emission for the grain mixture case. More...
 
subroutine sed_routines::allocate_sto_arrays
 Allocates arrays used within the stochastically heated dust emission routines calc_dens_dustem_sto() and calc_dens_dustem_sto_lib(). More...
 
subroutine sed_routines::deallocate_sto_arrays
 Deallocates arrays used within the stochastically heated dust emission routines calc_dens_dustem_sto() and calc_dens_dustem_sto_lib(). More...
 
subroutine sed_routines::calc_dens_dustem_sto
 Calculates the stochastically heated emission at each position. More...
 
subroutine sed_routines::calc_dens_dustem_sto_lib
 Calculates the stochastically heated emission at each position using the SED adaptive library approach of Natale et al.(2015). More...
 
subroutine sed_routines::calc_t_dust_equil (qabs_arr, dust_size, rf_stars, rf_dust, t_dust, abs_en)
 Calculates the equilibrium dust temperature given the absorption Q coefficient, the radiation field intensity of the stellar emission and of the dust emission in [W/m/m^2]. The input qabs_arr coefficient can also have units [e.g. m^2], as for the effective grain emission calculation, without changing the output equilibrium temperature. The output absorbed energy abs_en is in units of W/m^2 times the units of the input qabs_arr. More...
 
subroutine sed_routines::calc_rd_arr (dust_size)
 Calculates the moments of the dosage function (see Voit 1991, ApJ, 379, 122, needed for the dust stochastically heated calculation). More...
 
subroutine sed_routines::set_units_dens_stars_arr
 Sets the units of dens_stars_arr() in the dust RT algorithms. These units are W/m/pc^3 where meters refers to the wavelength. More...
 
real(kind=real64) function sed_routines::abs_en_diff (t_dust, kabs_arr_planck, abs_en, em_int)
 Calculates the difference between absorbed and emitted energy given the temperature T_dust. More...
 
real(kind=real64) function sed_routines::bplanck (T_source, la)
 Returns black body specific intensity in W/m^2/m/sr at wavelength la [m] and for temperature T_source [K] (SI units) More...
 
subroutine sed_routines::set_lambda_arr_si
 Sets the lambda array in the mks units ( lambda_arr_SI()). It also sets delta_lambda_bin(), delta_lambda_bin_stars() and delta_lambda_bin_dust(). More...
 
real(kind=real64) function sed_routines::zbrent_tdust (kabs_arr_planck, abs_en)
 Finds equilibrium dust temperature using Brent's method (modified version of the Van Wijngaarden–Dekker–Brent Method, see Numerical recipes in Fortran 77, Press et al.). More...
 
subroutine sed_routines::prepare_dust_model
 Reads the input dust model files. Derive the dust model optical properties used in the calculation, interpolated at the same wavelengths as in lambda_arr() and same grain sizes as in the input grain size distributions. More...
 
subroutine sed_routines::load_opacity_param
 Loads the Qabs, Qsca, Qext and gsca factors from the tables in the dust opacity directory (from the TRUST benchmark project) and interpolate them to the input wavelength grid. Note that a further interpolation is needed to match the grain sizes to the values of the input tables. This is done in interpolate_q_grain_fa(). More...
 
subroutine sed_routines::load_fa_arr
 Loads the grain size distribution from the standard TRUST tables or from user provided files. More...
 
subroutine sed_routines::interpolate_q_grain_fa
 Interpolate the qabs, qsca, qext and gsca arrays to the same grain sizes of the input grain size distribution tables. More...
 
subroutine sed_routines::load_ct_ht_tables
 Loads specific enthalphy and specific heat capacity as a function of grain temperature from the input tables. In the standard mode, the tables are those provided in the TRUST RT benchmark project. Alternatively input tables can also be used, provided that they are in the same form as the TRUST tables. More...
 
subroutine sed_routines::value_locate (val, array, ig0, ig1, reverse_order)
 Finds indeces of an array corresponding to the array value bin containing the input value val(). Note that the array should normally be sorted in ascending order. In case val is lower than array(0), it returns the indeces of the first two elements. If val is higher than array(size(array)-1), it returns indeces of last two elements. The input array can be in the reversing order if the reverse_order keyword is set TRUE. More...
 
subroutine sed_routines::lin_interpolate (y0, y1, x0, x1, x, y)
 Interpolates linearly at a position x within the bin [x0,x1] given the boundary values y0=f(x0) and y1=f(x1). y0 and y1 are defined as arrays, so the subroutine can be used for multiple values provided that the x coordinates x0, x1 and x are the same. More...
 
subroutine sed_routines::calc_total_opacity
 Calculates integrated opacity coefficients kabs_arr(), ksca_arr(), kext_arr() and scattering phase function parameter gsca_arr() from the tabulated opacity parameters and the input grain size distributions. The resulting values for the integrated coefficients depends slightly on the specific interpolation scheme. For this reason, we add the option to upload these values from an input file as well using the keyword load_av_opacities() and file_int_opacities(). In this case, the code checks that the values obtained by this routine and those uploaded through the input file file_av_opacities() do not vary more than 5%. This is necessary to guarantee consistency between the dust emission and the stellar emission calculations within a few percents. More...
 
subroutine sed_routines::read_av_opacities
 If keyword input_av_opacities is TRUE, it reads input table of integrated/averaged opacity coefficients kext(), kabs(), kext() and scattering phase function gsca. Interpolates factors to input wavelength grid lambda_arr() and to reference wavelength lambda_ref(). Checks values are within 5% of those derived directly by integration/average of grain opacities coefficients. More...
 
subroutine sed_routines::calc_planck_av_qabs
 Calculates planck averaged Qabs for the grains in the input grain size distributions and for a set of temperatures. More...
 
subroutine sed_routines::calc_photon_energy
 Calculates energy of photons as a function of wavelength for the set of wavelength stored in lambda_arr_SI. The energy is in [J]. More...
 
subroutine sed_routines::calc_gaussian_fe (t_dust, ic, ig)
 Calculates pt() in the large grain energy approximation (see section 4.4 Voit 1991). In case 1) the mean photon energy is very small compared to the grain equilibrium energy and 2) the width of the Gaussian approximation is more than 10% the equilibrium dust temperature, the code assign large_grain_energy = .FALSE. So the stochastically heated emission is calculated numerically from the current grain size to smaller sizes. More...
 
subroutine sed_routines::calc_full_fe (ic, ig)
 Calculates the temperature probability distribution pt() using the numerical method of Gahathakurta & Draine 1989 with the modification of Voit 1991 (section 4.5). More...
 
subroutine sed_routines::make_log_array (xmin, xmax, xarr)
 Makes array of values between xmin and xmax, equally spaced in logarithmic space. More...
 
subroutine sed_routines::make_delta_array (xarr, delta_xarr_bin)
 Makes array of bin sizes that can be used for integration. More...
 
subroutine sed_routines::convert_e_arr_to_t_arr (E_arr, T_arr, ic, ig)
 Converts grain enthalpy array into temperature array. More...
 
subroutine sed_routines::interpolate_qabs_arr_planck (T_arr, qp_arr, ic, ig)
 Interpolates Planck averaged emissivity table at the set of input temperatures. More...
 
subroutine sed_routines::calc_integrals_photon_abs_rate (dust_size)
 Calculates integrals of the photon absorbtion rate from a minimum lambda up to all the other possible values. More...
 
subroutine sed_routines::calc_transition_matrices
 Calculates transitions matrices AA() and BB(). More...
 
subroutine sed_routines::calc_edot_arr (dust_size, T_arr)
 Calculates cooling rate at all temperatures in Tarr. It also calculates continuous cooling term BB(i,i+1). More...
 
subroutine sed_routines::calc_dosage_function_moment_integrals
 Calculates dosage function by differentiating the integrals of the photon absorption rate. These integrals are stored in the Rd_integrated array for the energies corresponding to the wavelength grid. The dosage function has to be calculated at the energies corresponding to the enthalpy difference for the levels defined by the grain temperature grid. So, first an interpolation of the Rd_integrated array is necessary. Then differentiation. Then calculation of moments of dosage function is performed up to all energies corresponding to the energy bins. More...
 
subroutine sed_routines::interpolate_array (num, xarr_in, yarr_in, xarr_out, yarr_out)
 Performs linear interpolation for all the values in the arrays xarr_out and yarr_out given the values in the arrays xarr_in and yarr_in. More...
 
subroutine sed_routines::interpolate_rd_integrated (num, delta_E_arr_in, rd_interpol_in)
 Interpolates Rd_integrated() array at the energies corresponding to the transitions between grain enthalphy levels. More...
 
subroutine sed_routines::make_linear_array (xmin, xmax, xarr)
 Makes array of values between xmin and xmax, equally spaced in linear space. More...
 
subroutine sed_routines::convert_t_arr_to_e_arr (T_arr, E_arr, ic, ig)
 Converts temperature array into grain enthalpy array (reverse of convert_E_arr_to_T_arr). More...
 
subroutine sed_routines::prepare_stellar_emission_library
 Reads and interpolates stellar emission library defined in the input (see file_stellar_library() and stellar_library()). More...
 
subroutine sed_routines::interpolate_lum_to_mass_lib
 Interpolates the values of the stellar luminosity-to-mass ratio in lum_to_mass_lib() to the wavelengths in the wavelength grid lambda_arr(). It stores the values in lum_to_mass_int() and deallocate lum_to_mass_lib(). More...
 
subroutine sed_routines::bilinear_interpolation (xarr, yarr, farr, x, y, fout)
 Performs bilinear interpolation given the function farr, evaluated at the points (x1,y1), (x2,y1), (x1, y2), (x2,y2), and the output value coordinates (x,y). More...
 
subroutine sed_routines::set_star_particle_luminosity (lambda_in)
 Sets stellar particle luminosities star_lum() for an input wavelength lambda_in. More...
 
subroutine sed_routines::find_lambda_index (lambda_in, il)
 Finds index in lambda_arr corresponding to the input wavelength lambda_in. More...
 
subroutine sed_routines::bin_rad_field
 Calculates integrals of the stellar emission radiation field spectra in the UV (<4430 A) and optical (> 4430) and assign each cell to a 2-dim bin of radiation field total intensity. Used in the SED library approach for the stochastically heated dust emission. More...
 

Variables

real(kind=real64), parameter sed_routines::t0 =0
 
real(kind=real64), parameter sed_routines::t1 =1E4
 
real(kind=real64), parameter sed_routines::tol =1E-8
 
real(kind=real64) sed_routines::conv_ufield_ifield
 
real(kind=real64), dimension(:), allocatable sed_routines::phot_energy
 
real(kind=real64), dimension(:), allocatable sed_routines::abs_int_rad_stars
 
real(kind=real64), dimension(:), allocatable sed_routines::abs_int_rad_dust
 
real(kind=real64), dimension(0:2) sed_routines::rd_arr
 
logical sed_routines::large_grain_energy
 
real(kind=real64) sed_routines::emin
 
real(kind=real64) sed_routines::emax
 
real(kind=real64) sed_routines::tmin
 
real(kind=real64) sed_routines::tmin_prev
 
real(kind=real64) sed_routines::tmax
 
real(kind=real64) sed_routines::tmax_prev
 
real(kind=real64), dimension(:), allocatable sed_routines::e_arr
 
real(kind=real64), dimension(:), allocatable sed_routines::t_arr
 
real(kind=real64), dimension(:), allocatable sed_routines::pt
 
real(kind=real64), dimension(:), allocatable sed_routines::qp_arr
 
real(kind=real64), dimension(:), allocatable sed_routines::delta_e_arr_bin
 
integer, parameter sed_routines::n_temp_pt = 300
 
real(kind=real64), dimension(:), allocatable sed_routines::rd_integrated
 
real(kind=real64), dimension(:,:), allocatable sed_routines::aa
 
real(kind=real64), dimension(:,:), allocatable sed_routines::bb
 
real(kind=real64), dimension(:), allocatable sed_routines::re0
 
real(kind=real64), dimension(:), allocatable sed_routines::re1
 
real(kind=real64), dimension(:), allocatable sed_routines::re2
 
real(kind=real64), dimension(:), allocatable sed_routines::edot_arr
 
real(kind=real64), dimension(:), allocatable sed_routines::tot_dust_em
 
real(kind=real64), dimension(:,:), allocatable sed_routines::dust_em_arr_fa
 
real(kind=real64), dimension(:), allocatable sed_routines::int_rf_uv
 
real(kind=real64), dimension(:), allocatable sed_routines::int_rf_opt
 
real(kind=real64), dimension(:), allocatable sed_routines::rf_uv_arr
 
real(kind=real64), dimension(:), allocatable sed_routines::rf_opt_arr
 
real(kind=real64), dimension(:,:,:), allocatable sed_routines::u_av_uv_opt
 
real(kind=real64), dimension(:,:,:), allocatable sed_routines::u_av_dust
 
real(kind=real64), dimension(:,:), allocatable sed_routines::count_spectra_uv_opt