@jonniedie @lrnv @juliohm @nilshg Sure, Iāll happily share more details about the nature of my task and hopefully it will provide sufficient information for someone to prescribe a solution.
I want to numerically solve the following linear differential equation in plasma physics that calculates the distribution in a collisional plasma, known as the BGK equation:
s
denotes the particle species (e.g. protons, electrons, etc.), v_ss
denotes the collisional frequency (this will be a constant, letās say 1 for now), and F denotes a Maxwellian distribution (which is mathematically a chi distribution) that remains constant through time. The idea is that first, you can discretize this equation like I have done here explicitly:
v_col = 1
dt = 10^(-5) # timestep
t = range(0, 1.0, step=dt)
f_s = Vector{Uniform{Float64}}(undef, length(t)+1)
f_s[1] = Uniform(0,1)
F_s = Chi(3)
for it in 1:length(t)
f_s[it + 1] = dt*v_col*(F_s - f_s[it]) + f_s[it]
end
Then, you pick a distribution for f_s(0)
(I am trying a uniform distribution first) and as you timestep through this equation, eventually what should happen is that the distribution f_s
should relax into a Maxwellian F_s
, which is what I am trying to show.
Before choosing this however, it is clear that two distributions have to be added or subtracted (F_s - f_s[it])
. At the moment, when running this snippet, this error pops up
MethodError: no method matching -(::Chi{Float64}, ::Uniform{Float64})
Closest candidates are:
-(::UnivariateDistribution, ::Real) at C:\Users\Acer\.julia\packages\Distributions\Fl5RM\src\univariate\locationscale.jl:139
-(::ChainRulesCore.AbstractThunk, ::Any) at C:\Users\Acer\.julia\packages\ChainRulesCore\sHMAp\src\tangent_types\thunks.jl:30
-(::ChainRulesCore.ZeroTangent, ::Any) at C:\Users\Acer\.julia\packages\ChainRulesCore\sHMAp\src\tangent_arithmetic.jl:101
...
I was wondering if someone has the best solution for this case. Perhaps this includes extraneous physics information, but I hope this addresses @lrnv 's request.