Skip to content

Commit 50d6778

Browse files
committed
generate_milkyway_baryon_particles
1 parent d44307a commit 50d6778

5 files changed

Lines changed: 84 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ DataFrames = "1"
3737
Dierckx = "0.5"
3838
Distributions = "0.25"
3939
DocStringExtensions = "0.8, 0.9"
40-
Measurements = "2.14.1"
40+
Measurements = "2"
4141
Optim = "1"
4242
PhysicalConstants = "0.2"
4343
PhysicalParticles = "1"

src/AstroIC.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export load_SPARC_Xray_ETGs_data, load_SPARC_rotating_ETGs_data, load_SPARC_rota
8585

8686
include("data/MilkyWay.jl")
8787
export load_MW_RC_Eilers2019, load_MW_RC_Mroz2019, load_MW_RC_stddev_W21, load_MW_RC_DS_W21
88+
export generate_milkyway_baryon_particles
8889

8990
include("precompile.jl")
9091

src/data/MilkyWay.jl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,81 @@ function load_MW_RC_DS_W21(filename = joinpath(@__DIR__, "MilkyWay/MW_dsvel-W21-
3232
dfDS_W21 = DataFrame(CSV.File(filename; header = false, skipto=3, delim="\t", ignorerepeated = true))
3333
rename!(dfDS_W21, [:r, :v_b, :v_CDM, :v_QUMOND, :v_MOG])
3434
return dfDS_W21
35+
end
36+
37+
"""
38+
generate_milkyway_baryon_particles(Np)
39+
40+
Generate Milky Way baryon particles (bulge, thin/thick discs, HI/HII gas).
41+
"""
42+
function generate_milkyway_baryon_particles(Np)
43+
TotalMass_bulge = 8.5708e9u"Msun"
44+
TotalMass_thin = uconvert(u"Msun", 2pi * 1003.12u"Msun/pc^2" * (2.42u"kpc")^2) # 3.691165259383738e10 M⊙
45+
TotalMass_thick = uconvert(u"Msun", 2pi * 167.93u"Msun/pc^2" * (3.17u"kpc")^2) # 1.0602949202938915e10 M⊙
46+
TotalMass_HI = 1.0674e10u"Msun"
47+
TotalMass_HII = 1.2303e9u"Msun"
48+
TotalMass_baryons = TotalMass_bulge + TotalMass_thin + TotalMass_thick + TotalMass_HI + TotalMass_HII
49+
50+
NumSamples_bulge = ceil(Int, TotalMass_bulge/TotalMass_baryons * Np)
51+
NumSamples_thin = ceil(Int, TotalMass_thin/TotalMass_baryons * Np)
52+
NumSamples_thick = ceil(Int, TotalMass_thick/TotalMass_baryons * Np)
53+
NumSamples_HI = ceil(Int, TotalMass_HI/TotalMass_baryons * Np)
54+
NumSamples_HII = Np - NumSamples_bulge - NumSamples_thin - NumSamples_thick - NumSamples_HI
55+
56+
if iszero(NumSamples_HII)
57+
error("Number of HII particles is zero. Try increase number of particles")
58+
end
59+
60+
@info "NumSamples of bulge: $(NumSamples_bulge)"
61+
@info "NumSamples of thin: $(NumSamples_thin)"
62+
@info "NumSamples of thick: $(NumSamples_thick)"
63+
@info "NumSamples of HI: $(NumSamples_HI)"
64+
@info "NumSamples of HII: $(NumSamples_HII)"
65+
66+
particles_bulge = generate(Bulge(;
67+
collection = STAR,
68+
NumSamples = NumSamples_bulge,
69+
TotalMass = TotalMass_bulge,
70+
ScaleRadius = 0.075u"kpc",
71+
CutRadius = 2.1u"kpc",
72+
q = 0.5,
73+
α = 1.8,
74+
))
75+
76+
particles_stellar_thin = generate(ExponentialDisc(;
77+
collection = STAR,
78+
NumSamples = NumSamples_thin,
79+
TotalMass = TotalMass_thin,
80+
ScaleRadius = 2.42u"kpc",
81+
ScaleHeight = 0.3u"kpc",
82+
); RotationCurve = nothing)
83+
84+
particles_stellar_thick = generate(ExponentialDisc(;
85+
collection = STAR,
86+
NumSamples = NumSamples_thick,
87+
TotalMass = TotalMass_thick,
88+
ScaleRadius = 3.17u"kpc",
89+
ScaleHeight = 0.9u"kpc",
90+
); RotationCurve = nothing)
91+
92+
particles_gas_HI = generate(ExponentialDisc(;
93+
collection = STAR,
94+
NumSamples = NumSamples_HI,
95+
TotalMass = TotalMass_HI,
96+
ScaleRadius = 7.0u"kpc",
97+
ScaleHeight = 0.085u"kpc",
98+
HoleRadius = 4.0u"kpc",
99+
))
100+
101+
particles_gas_HII = generate(ExponentialDisc(;
102+
collection = STAR,
103+
NumSamples = NumSamples_HII,
104+
TotalMass = TotalMass_HII,
105+
ScaleRadius = 1.5u"kpc",
106+
ScaleHeight = 0.045u"kpc",
107+
HoleRadius = 12.0u"kpc",
108+
))
109+
110+
particles = [particles_bulge; particles_stellar_thin; particles_stellar_thick; particles_gas_HI; particles_gas_HII]
111+
return particles
35112
end

src/precompile.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@
3131
load_MW_RC_Mroz2019()
3232
load_MW_RC_stddev_W21()
3333
load_MW_RC_DS_W21()
34+
35+
generate_milkyway_baryon_particles(500)
3436
end
3537
end

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ include("solarsystem.jl")
3636
@test !isnothing(load_MW_RC_Mroz2019())
3737
@test !isnothing(load_MW_RC_stddev_W21())
3838
@test !isnothing(load_MW_RC_DS_W21())
39+
40+
particles = generate_milkyway_baryon_particles(500)
41+
@test length(particles) == 500
3942
end

0 commit comments

Comments
 (0)