I want to solve the following differential equation:
\frac{dv}{d\xi} = 2 (\frac{v}{\xi}) \frac{1-v^{2}}{1-v \xi} \frac{1}{(\mu/c)^{2}-1}
I have a boundary condition at the endpoint,
v(\xi_{d}) = \frac{\xi_{d}-c}{1-c\xi_{d}}
The integration period should be (c, \xi_{d}). Here, c = 1/\sqrt{3} while,
\xi_{d} = \frac{1/\sqrt{3} + \sqrt{\alpha^2 + 2\alpha/3}}{1+\alpha}
I want to plot the solution, v(\xi), against \xi for \alpha = 0.01, 1, 10.
My issue lies with how to encode the boundary condition into the problem. This is what I have been trying:
using Symbolics, Plots, DifferentialEquations
c = 1/sqrt(3)
function velo!(u, p, t)
μ = (t-u)/(1-u*t)
du = 2(u*((1-u^2)/(1-u*t)))/(t*((μ/cₛ)^2-1))
end
α = 1
ϵ = 0.0001
F1 = ((1/sqrt(3) + sqrt(α^2 + 2*α*(1/3)))/(1+α)) - ϵ
F2 = (F1 - 1/sqrt(3))/(1-F1/sqrt(3))
function bc2b!(res, u, p)
res = u - F2
end
tspan = (c, F1)
prob = BVProblem(velo!, bc2b!, [0], tspan)
sol = solve(prob)
This gives me the following error:
MethodError: no method matching -(::Int64, ::Vector{Float64})
For element-wise subtraction, use broadcasting with dot syntax: scalar .- array
Closest candidates are:
-(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8})
@ Base int.jl:85
-(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}
@ Base int.jl:86
-(::Union{Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8}, ::VectorizationBase.VecUnroll{N, W, T, VectorizationBase.MM{W, X, T}}) where {N, W, T<:Union{Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8}, X}
@ VectorizationBase C:\Users\shiha\.julia\packages\VectorizationBase\0dXyA\src\base_defs.jl:103
...
Now, I know that this error means I have got to use the @
notation, but I am not sure where this should be since I haven’t used any arrays. I expect that the problem is probably due to wrong usage of the BVProblem
method - but this is my first time using it and I didn’t understand the documentation completely.
Any help would be appreciated!
Note: At \xi = \xi_{d}, the derivative diverges. Therefore, I want to solve close to the endpoint - not exactly at the endpoint. This is why I have the \epsilon there.