From 5d277a180ba7e302c71a2951ea4c2cedc0a31828 Mon Sep 17 00:00:00 2001 From: islent Date: Sun, 6 Oct 2024 18:54:05 +0800 Subject: [PATCH] rename ExponentialDisc, cancel disc shifting --- src/AstroIC.jl | 4 ++-- src/disk.jl | 16 +++++++++++----- src/precompile.jl | 4 ++-- test/disk.jl | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/AstroIC.jl b/src/AstroIC.jl index d9939df..ca0e8f3 100644 --- a/src/AstroIC.jl +++ b/src/AstroIC.jl @@ -37,7 +37,7 @@ export PlummerStarCluster, GasCloud, - ExponentialDisk, + ExponentialDisc, Bulge, solarsystem, @@ -73,7 +73,7 @@ Generate initial conditions in `units` # Usable IC configs - `PlummerStarCluster` - `GasCloud` -- `ExponentialDisk` +- `ExponentialDisc` $_common_keywords """ diff --git a/src/disk.jl b/src/disk.jl index 13a29ea..b5077f5 100644 --- a/src/disk.jl +++ b/src/disk.jl @@ -2,7 +2,7 @@ $(TYPEDEF) $(TYPEDFIELDS) """ -mutable struct ExponentialDisk{I, Len, MASS} <: InitialConditionConfig +mutable struct ExponentialDisc{I, Len, MASS} <: InitialConditionConfig collection::Collection NumSamples::I @@ -19,7 +19,7 @@ $(TYPEDSIGNATURES) - `collection` particle type - `NumSamples` amount of particles """ -function ExponentialDisk(; +function ExponentialDisc(; collection::Collection = STAR, NumSamples::Int64 = 1000, TotalMass::Number = 1.0e10u"Msun", @@ -27,10 +27,10 @@ function ExponentialDisk(; 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, @@ -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, @@ -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 diff --git a/src/precompile.jl b/src/precompile.jl index 13518c7..4e2f8df 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -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) diff --git a/test/disk.jl b/test/disk.jl index 70d99e6..da4c732 100644 --- a/test/disk.jl +++ b/test/disk.jl @@ -1,5 +1,5 @@ @testset "Disk" begin - config = ExponentialDisk( + config = ExponentialDisc( collection = STAR, NumSamples = 100, TotalMass = 1.0e8u"Msun",