Further on there is another example for all implemented density models of the Milky-Way
In [2]:
from crpropa import *
In [3]:
CD = ConstantDensity(1,2,0.5)
to see the output option we check the density at a random position
the output options are:
In [4]:
position = Vector3d(2,1,3)
n_tot = CD.getDensity(position)
n_HI = CD.getHIDensity(position)
n_HII = CD.getHIIDensity(position)
n_H2 = CD.getH2Density(position)
n_nucl = CD.getNucleonDensity(position)
print('total density n = %f' %n_tot)
print('HI density n_HI = %f' %n_HI)
print('HII density n_HII = %f' %n_HII)
print('H2 density n_H2 = %f' %n_H2)
print('nucleon density n_nucl = %f' %n_nucl)
In [7]:
#see the actual configuration
print('HI: %s, HII: %s, H2: %s, \n \n' %(CD.getIsForHI(), CD.getIsForHII(), CD.getIsForH2()))
# change activity
CD.setHI(False)
# change activity and density number
CD.setHII(False, 1.5)
# change density number
CD.setH2(1.3)
# see the changes in the Description
print(CD.getDescription())
In [8]:
n_tot = CD.getDensity(position)
n_HI = CD.getHIDensity(position)
n_HII = CD.getHIIDensity(position)
n_H2 = CD.getH2Density(position)
n_nucl = CD.getNucleonDensity(position)
print('total density n = %f' %n_tot)
print('HI density n_HI = %f' %n_HI)
print('HII density n_HII = %f' %n_HII)
print('H2 density n_H2 = %f' %n_H2)
print('nucleon density n_nucl = %f' %n_nucl)
In [10]:
CD1 = ConstantDensity(0,2,0) # for use HII
CD2 = ConstantDensity(3,1,2.5) # for use HI, H2
CUS = DensityList()
# first deactivate not wanted parts
CD1.setHI(False)
CD1.setH2(False)
CD2.setHII(False)
# add density
CUS.addDensity(CD1)
CUS.addDensity(CD2)
# get output
n_tot = CUS.getDensity(position)
n_HI = CUS.getHIDensity(position)
n_HII = CUS.getHIIDensity(position)
n_H2 = CUS.getH2Density(position)
n_nucl = CUS.getNucleonDensity(position)
print('total density n = %f' %n_tot)
print('HI density n_HI = %f' %n_HI)
print('HII density n_HII = %f' %n_HII)
print('H2 density n_H2 = %f' %n_H2)
print('nucleon density n_nucl = %f' %n_nucl)
In [11]:
#set wanted density
CD1 = ConstantDensity(1,3,4)
CD2 = ConstantDensity(1.5,2,3.3)
DL = DensityList()
# add density to list
DL.addDensity(CD1)
DL.addDensity(CD2)
# see output
n_tot = DL.getDensity(position)
n_HI = DL.getHIDensity(position)
n_HII = DL.getHIIDensity(position)
n_H2 = DL.getH2Density(position)
n_nucl = DL.getNucleonDensity(position)
print('total density n = %f' %n_tot)
print('HI density n_HI = %f' %n_HI)
print('HII density n_HII = %f' %n_HII)
print('H2 density n_H2 = %f' %n_H2)
print('nucleon density n_nucl = %f' %n_nucl)
In [12]:
In [ ]: