;+ ; Name: therm_energy_plasma ; ; Purpose: Calculate the thermal energy in ergs of plasma at a given temperature and emission measure for a ; given volume. U = 3*k * sqrt(Em * Vactual) * T where ; k is Boltzmann's constant, 1.3806488e−16 erg K^(-1) ; Em is the emission measure in cm^(-3) ; Vactual is the actual Volume in cm^3 (calculated as measured volume times a filling factor) ; T is the temperature in K ; ; Input arguments: ; em - emission measure in 10^49 cm^(-3) ; temp - temperature in K (or keV if t_in_kev is set) ; Note: both em and temp can be scalar or array (must have same number of elements) ; ; Input keywords: ; volume - Measured volume of plasma in cm^3. Default is 10^27. ; filling - filling factor to guess actual volume, Vactual = Vmeasured*filling. Default is 1. ; t_in_kev - if set, temp input is in keV ; ; Output: Returns thermal energy in ergs ; ; Example: ; print,therm_energy_plasma(1.,2.,/t_in_kev) ; 9.6093149e+029 ; ; Written: 8-Jul-2014, Kim Tolbert and Brian Dennis ;- function therm_energy_plasma, em, temp, volume=volume, filling=filling, t_in_kev=t_in_kev checkvar, volume, 1.e27 checkvar, filling, 1.0 threek = 3. * 1.3806488e-16 temperature = keyword_set(t_in_kev) ? temp * 1.16e7 : temp u = threek * sqrt(1.d49 * em * volume * filling) * temperature return, u end