Skip to content

Commit

Permalink
rename ExponentialDisc, cancel disc shifting
Browse files Browse the repository at this point in the history
  • Loading branch information
islent committed Oct 6, 2024
1 parent 4cf4975 commit 5d277a1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/AstroIC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export

PlummerStarCluster,
GasCloud,
ExponentialDisk,
ExponentialDisc,
Bulge,

solarsystem,
Expand Down Expand Up @@ -73,7 +73,7 @@ Generate initial conditions in `units`
# Usable IC configs
- `PlummerStarCluster`
- `GasCloud`
- `ExponentialDisk`
- `ExponentialDisc`
$_common_keywords
"""
Expand Down
16 changes: 11 additions & 5 deletions src/disk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$(TYPEDEF)
$(TYPEDFIELDS)
"""
mutable struct ExponentialDisk{I, Len, MASS} <: InitialConditionConfig
mutable struct ExponentialDisc{I, Len, MASS} <: InitialConditionConfig
collection::Collection
NumSamples::I

Expand All @@ -19,18 +19,18 @@ $(TYPEDSIGNATURES)
- `collection` particle type
- `NumSamples` amount of particles
"""
function ExponentialDisk(;
function ExponentialDisc(;
collection::Collection = STAR,
NumSamples::Int64 = 1000,
TotalMass::Number = 1.0e10u"Msun",
ScaleRadius::Number = 2.0u"kpc",
ScaleHeight::Number = 0.02u"kpc",
HoleRadius::Number = 0.0u"kpc",
)
return ExponentialDisk(collection, NumSamples, TotalMass, ScaleRadius, ScaleHeight, HoleRadius)
return ExponentialDisc(collection, NumSamples, TotalMass, ScaleRadius, ScaleHeight, HoleRadius)
end

function Base.show(io::IO, config::ExponentialDisk)
function Base.show(io::IO, config::ExponentialDisc)
print(io,
"Config of Exponential Disk Initial Conditions:",
"\n Particle Collection: ", config.collection,
Expand Down Expand Up @@ -144,7 +144,7 @@ end
$(TYPEDSIGNATURES)
"""
function generate(config::ExponentialDisk, units = uAstro;
function generate(config::ExponentialDisc, units = uAstro;
RotationCurve = nothing,
MaxRadius = 5 * config.ScaleRadius,
MaxHeight = MaxRadius,
Expand Down Expand Up @@ -211,6 +211,12 @@ function generate(config::ExponentialDisk, units = uAstro;
spl = Spline1D(ustrip.(uLen, xc), ustrip.(uVel, vc); k, bc)
v = spl(ustrip.(uLen, R)) * uVel
vel = rotational_velocity.(pos.x, pos.y, v, rotational_ratio)

# Cancel out shifting
v0 = mean(vel)
vel = vel .- v0
uVel = getuVel(units)
vel = uconvert.(uVel, vel)
end

# Packing
Expand Down
4 changes: 2 additions & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
@compile_workload begin
NumSamples = 5
data = generate(PlummerStarCluster(; NumSamples))
data = generate(ExponentialDisk(; NumSamples))
data = generate(ExponentialDisk(; NumSamples, HoleRadius = 0.2u"kpc"))
data = generate(ExponentialDisc(; NumSamples))
data = generate(ExponentialDisc(; NumSamples, HoleRadius = 0.2u"kpc"))
data = generate(Bulge(; NumSamples))
data = generate(Bulge(; NumSamples), RotationCurve = ([0.0, 5.0, 10.0]*u"kpc", [0.0, 200.0, 230.0]*u"km/s"))
p = sum(data.Pos)
Expand Down
2 changes: 1 addition & 1 deletion test/disk.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testset "Disk" begin
config = ExponentialDisk(
config = ExponentialDisc(
collection = STAR,
NumSamples = 100,
TotalMass = 1.0e8u"Msun",
Expand Down

0 comments on commit 5d277a1

Please sign in to comment.