Skip to content

Commit 4217643

Browse files
committed
More fixes and updates for new versions of PoissonSolvers, GeometricEquations, and GeometricIntegrators.
1 parent 12ec4f6 commit 4217643

File tree

9 files changed

+24
-30
lines changed

9 files changed

+24
-30
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
3131
AdaptiveRejectionSampling = "0.1"
3232
BSplineKit = "0.14, 0.15, 0.16, 0.17"
3333
DifferentialEquations = "7"
34-
GeometricEquations = "0.14"
34+
GeometricEquations = "0.16"
3535
GeometricIntegrators = "0.13"
3636
HDF5 = "0.15, 0.16, 0.17"
3737
LaTeXStrings = "1.2, 1.3"
3838
OffsetArrays = "1"
3939
Parameters = "0.12"
4040
ParticleMethods = "0.1"
4141
Plots = "1"
42-
PoissonSolvers = "0.3"
42+
PoissonSolvers = "0.3.5"
4343
ProgressMeter = "1"
4444
Sobol = "1.5"
4545
SpecialFunctions = "2"

scripts/lenard_bernstein.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,3 @@ anim = @animate for i in 1:step:length(sol)
6868
end
6969
println("saving animation")
7070
gif(anim,"lenard_bernstein.gif",fps=2)
71-

scripts/lenard_bernstein_conservative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ anim = @animate for n in 1:step:size(z,2)
7979
end
8080

8181
# save animation to file
82-
gif(anim, "lenard_bernstein_conservative_anim.gif", fps=10)
82+
gif(anim, "lenard_bernstein_conservative.gif", fps=10)

scripts/vlasov_poisson.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# import libraries
32
using PoissonSolvers
43
using VlasovMethods
@@ -15,7 +14,7 @@ domain = (0.0, 1.0)
1514
h5file = "vlasov_poisson.hdf5"
1615

1716
# create and initialize particle distribution function
18-
dist = initialize!(ParticleDistribution(1, 1, npart), Normal())
17+
dist = initialize!(ParticleDistribution(1, 1, npart), NormalDistribution())
1918
# dist = initialize!(ParticleDistribution(1, 1, npart), BumpOnTail())
2019

2120
# create electrostatic potential
@@ -70,5 +69,4 @@ anim = @animate for n in axes(z,3)
7069
end
7170

7271
# save animation to file
73-
gif(anim, "vlasov_poisson_anim.gif", fps=10)
74-
72+
gif(anim, "vlasov_poisson.gif", fps=10)

src/methods/splitting.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ function run!(method::SplittingMethod, h5file)
3333
h5z = create_dataset(h5, "z", eltype(z₀), ((nd, np, ntime(method.equation)+1), (nd, np, -1)), chunk=(nd,np,1))
3434
copy_to_hdf5(h5z, z₀, 0)
3535

36-
Integrators.initialize!(method.integrator)
36+
GeometricIntegrators.Integrators.initialize!(method.integrator)
3737

3838
# loop over time steps showing progress bar
3939
try
4040
@showprogress 5 for n in 1:ntime(method.equation)
41-
Integrators.integrate!(method.integrator)
41+
GeometricIntegrators.integrate!(method.integrator)
4242
copy_to_hdf5(h5z, method.integrator.solstep.q, n)
4343
end
4444
finally

src/models/lenard_bernstein.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ function GeometricIntegrator(model::LenardBernstein{1,1}, tspan::Tuple, tstep::R
7676
parameters = params)
7777

7878
# create integrator
79-
int = Integrators.Integrator(equ, Integrators.RK438())
80-
# int = Integrators.Integrator(equ, Integrators.CrankNicolson())
79+
int = GeometricIntegrators.GeometricIntegrator(equ, GeometricIntegrators.RK438())
80+
# int = GeometricIntegrators.GeometricIntegrator(equ, GeometricIntegrators.CrankNicolson())
8181

8282
# put together splitting method
8383
GeometricIntegrator(model, equ, int)

src/models/vlasov_poisson.jl

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11

2-
struct VlasovPoisson{XD, VD, DT <: DistributionFunction{XD,VD}, PT <: Potential, RT <: AbstractVector} <: VlasovModel
2+
struct VlasovPoisson{XD, VD, DT <: DistributionFunction{XD,VD}, PT <: Potential} <: VlasovModel
33
distribution::DT
44
potential::PT
5-
rhs::RT
65

76
function VlasovPoisson(dist::DistributionFunction{XD,VD}, potential) where {XD,VD}
8-
rhs = zero(potential.coefficients)
9-
new{XD, VD, typeof(dist), typeof(potential), typeof(rhs)}(dist, potential, rhs)
7+
new{XD, VD, typeof(dist), typeof(potential)}(dist, potential)
108
end
119
end
1210

1311

1412
function update_potential!(model::VlasovPoisson)
15-
projection!(model.rhs, model.potential, model.distribution)
16-
PoissonSolvers.update!(model.potential, model.rhs)
13+
projection!(model.potential, model.distribution)
14+
PoissonSolvers.update!(model.potential)
1715
end
1816

1917

@@ -42,8 +40,8 @@ function v_advection!(ż, t, z, params)
4240
end
4341
end
4442

45-
# Vector field for Lorentz force
46-
function v_lorentz_force!(ż, t, z, params)
43+
# Vector field for acceleration
44+
function v_acceleration!(ż, t, z, params)
4745
update_potential!(params.model)
4846
for i in axes(ż, 2)
4947
ż[1,i] = 0
@@ -60,7 +58,7 @@ function s_advection!(z, t, z̄, t̄, params)
6058
end
6159

6260
# Solution for Lorentz force
63-
function s_lorentz_force!(z, t, z̄, t̄, params)
61+
function s_acceleration!(z, t, z̄, t̄, params)
6462
update_potential!(params.model)
6563
for i in axes(z, 2)
6664
z[1,i] = z̄[1,i]
@@ -72,20 +70,19 @@ end
7270
# The problem is setup such that one solution step pushes all particles.
7371
# While this allows for a simple implementation, it is not well-suited
7472
# for parallelisation.
75-
# Have a look at the CollisionalVlasovPoisson model for an alternative approach.
7673
function SplittingMethod(model::VlasovPoisson{1, 1, <: ParticleDistribution}, tspan::Tuple, tstep::Real)
7774
# collect parameters
7875
params == model.potential, model = model)
7976

8077
# create geometric problem
8178
equ = GeometricEquations.SODEProblem(
82-
(v_advection!, v_lorentz_force!),
83-
(s_advection!, s_lorentz_force!),
79+
(v_advection!, v_acceleration!),
80+
(s_advection!, s_acceleration!),
8481
tspan, tstep, copy(model.distribution.particles.z);
8582
parameters = params)
8683

8784
# create integrator
88-
int = Integrators.Integrator(equ, Integrators.Strang())
85+
int = GeometricIntegrators.GeometricIntegrator(equ, GeometricIntegrators.Strang())
8986

9087
# put together splitting method
9188
SplittingMethod(model, equ, int)

src/projections/potential.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
function projection!(out, potential::PoissonSolvers.Potential{<:PeriodicBSplineBasis}, distribution::ParticleDistribution)
3-
b = Splines.PeriodicVector(out)
2+
function projection!(potential::PoissonSolvers.Potential{<:PeriodicBSplineBasis}, distribution::ParticleDistribution)
3+
b = Splines.PeriodicVector(potential.rhs)
44
b .= 0
55

66
basis = potential.basis
@@ -18,5 +18,5 @@ function projection!(out, potential::PoissonSolvers.Potential{<:PeriodicBSplineB
1818
end
1919
end
2020

21-
return out
21+
return potential
2222
end

test/projections_tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ using VlasovMethods: projection!
2222
dist.particles.w .= (ones(npart) ./ npart)'
2323

2424
rhs = zero(potential.coefficients)
25-
projection!(rhs, potential, dist)
25+
projection!(potential, dist)
2626

27-
ρ = Spline(potential.basis, potential.solver.Mfac \ rhs)
27+
ρ = Spline(potential.basis, potential.solver.Mfac \ potential.rhs)
2828

2929
x = domain[begin]:0.1:domain[end]
3030

0 commit comments

Comments
 (0)