Package chianti :: Module sources
[hide private]
[frames] | no frames]

Source Code for Module chianti.sources

 1  import numpy as np 
 2  import chianti.constants as const 
3 -class blackStar:
4 '''temperature in K, radius is the stellar radius in cm '''
5 - def __init__(self, temperature, radius):
6 self.Temperature = temperature 7 self.Radius = radius
8 - def incident(self, distance, energy):
9 ''' distance in cm and energy in erg''' 10 print((' distance %10.2e energy '%(energy))) 11 bb = blackbody(self.Temperature, energy) 12 out = const.pi*(self.Radius/distance)**2*bb['photons'] 13 self.Incident = bb
14 # 15 # --------------------------------------------------------------------- 16 #
17 -def blackbody(temperature, variable, hnu=1):
18 ''' to calculate the black body photon distribution as a function of energy in erg (hnu = 1) or as a function 19 of wavelength (Angstroms) (hnu=0) 20 photons cm^-2 s^-1 str^-1 ergs^-1''' 21 if hnu: 22 energy = variable 23 bb =(2./(const.planck*(const.hc**2)))*energy**2/(np.exp(energy/(const.boltzmann*temperature)) - 1.) 24 return {'photons':bb, 'temperature':temperature, 'energy':energy} 25 else: 26 wvl = 1.e-8*variable 27 bb = ((2.*const.pi*const.light)/wvl**4)/(np.exp(const.hc/(wvl*const.boltzmann*temperature)) - 1.) 28 return {'photons':bb, 'temperature':temperature, 'wvl':wvl}
29