Closed dere4 closed 2 years ago
Truncated error message:
julia> run_sim(9e-8, 2); ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}) Closest candidates are: (::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:200 (::Type{T})(::T) where T<:Number at boot.jl:760 (::Type{T})(::VectorizationBase.Double{T}) where T<:Union{Float16, Float32, Float64, VectorizationBase.Vec{var"#s33", var"#s32"} where {var"#s33", var"#s32"<:Union{Float16, Float32, Float64}}, VectorizationBase.VecUnroll{var"#s31", var"#s30", var"#s29", V} where {var"#s31", var"#s30", var"#s29"<:Union{Float16, Float32, Float64}, V<:Union{Bool, Float16, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, SIMDTypes.Bit, VectorizationBase.AbstractSIMD{var"#s30", var"#s29"}}}} at C:\Users\Paul.julia\packages\VectorizationBase\xHOp9\src\special\double.jl:84 ... Stacktrace: [1] convert(#unused#::Type{Float64}, x::ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}) @ Base .\number.jl:7 [2] setindex!(A::Matrix{Float64}, x::ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}, i1::Int64) @ Base .\array.jl:843 [3] setindex! @ .\subarray.jl:335 [inlined] [4] compute_edge_states!(UL::SubArray{Float64, 1, Matrix{Float64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}, UR::SubArray{Float64, 1, Matrix{Float64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}, U::SubArray{ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}, 1, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}, scheme::HallThruster.HyperbolicScheme{typeof(HallThruster.upwind_electron!), typeof(identity)}) @ HallThruster c:\Users\Paul\pepl\HallThruster.jl\src\flux.jl:149 [5] update_imp!(dU::Matrix{ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}}, U::Matrix{ForwardDiff.Dual{ForwardDiff.Tag{SciMLBase.UJacobianWrapper{SciMLBase.ODEFunction{true, typeof(HallThruster.update_imp!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Float64, NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}}, Float64}, Float64, 12}}, params::NamedTuple{(:cache, :fluids, :fluid_ranges, :species_range_dict, :z_cell, :z_edge, :cell_volume, :source_term!, :reactions, :scheme, :BCs, :dt, :source_potential!, :boundary_potential!, :landmark), Tuple{NamedTuple{(:F, :UL, :UR, :Q, :A, :b, :ϕ, :Tev, :pe, :ne, :B, :νan, :νc, :μ), Tuple{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Vector{Float64}, Tridiagonal{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, Vector{HallThruster.Fluid}, Vector{UnitRange{Int64}}, Dict{Symbol, UnitRange{Int64}}, Vector{Float64}, Vector{Float64}, Float64, typeof(source!), Vector{HallThruster.IonizationReaction{HallThruster.LinearInterpolation{Float64, Float64}}}, HallThruster.HyperbolicScheme{typeof(HallThruster.HLLE!), typeof(identity)}, Tuple{HallThruster.Dirichlet, HallThruster.Neumann}, Float64, typeof(source_potential!), typeof(boundary_potential!), Nothing}}, t::Float64) @ HallThruster c:\Users\Paul\pepl\HallThruster.jl\src\simulation.jl:186
lmk if you'd like the full error message but it is very long. If you run the code you will see the same I think anyways.
Also I have way too many functions now for initial conditions and stuff cause I had the energy separately originally, will merge that once it is running which should improve organisation.
Added another row to state vector for electron energy equation. Doing fluids and electron energy source term explicitly, while having convective term in energy equ. implicitly. Runs when compute_edge_states!, and compute_fluxes_electrons! are commented out in the implicit update function, however when they are there I get a method error. Added error message in comment.
My first try was to add this line after problem definition: tmp_prob = remake(prob, u0=convert.(eltype(params),prob.u0), p=params) and then solve tmp_prob. is still there in simulation.jl line 313 but did not solve the problem. same issue as before.
Also tried different solvers, but problem shows up for all split solvers. https://diffeq.sciml.ai/stable/solvers/split_ode_solve/#split_ode_solve https://diffeq.sciml.ai/stable/types/split_ode_types/
similar issues have been reported here: https://github.com/JuliaDiff/ForwardDiff.jl/issues/397 https://discourse.julialang.org/t/forward-differentiation-and-differential-equations/21002/3 https://diffeq.sciml.ai/stable/analysis/sensitivity/#sensitivity https://discourse.julialang.org/t/dual-forwarddiff-type-error-when-jump-tries-autodiff-user-defined-function/25639 https://discourse.julialang.org/t/forwarddiff-using-on-functions-that-are-defined-on-floats64/18226
and btw here some examples with SplitODEProblem https://tutorials.sciml.ai/html/exercises/02-workshop_solutions.html