Hi everyone,
I’m new to Julia language, this is my first time asking a question, so please forgive me if there is any mistake in my question format.
I have been working on discretizing a PDE system by using MethodOfLines.jl. I have two different spatial domains. The thing is I want to discretize the z
domain by 50 points and z_sub
domain by 5 points. When I attempt to discretize the z_sub
domain to just 5 points, I encounter an index error, specifically ERROR: BoundsError: attempt to access 5-element Vector{SymbolicUtils.BasicSymbolic{Real}} at index [50]
.
I’ve set up a system of PDEs with the following domains:
t_min = z_min = 0.0
z_max = p.film_thickness
t_max = 30.0
z_sub_min = p.film_thickness
z_sub_max = p.film_thickness + p.thickness_substrate
The discretization that causes the error is:
discretization = MOLFiniteDifference([z=>50,z_sub=>5],t,approx_order=2)
The boundary conditions for the system include:
bcs = [
...
T(t,z_max) ~ T_sub(t,z_sub_min),
p.κ*Dz(T(t,z_max)) ~ p.κ_sub*Dz_sub(T_sub(t,z_sub_min)),
...
]
@named pdesys = PDESystem(eq,bcs,domains,[z,z_sub,t],[I(t,z),Id(t,z),λ_0(t,z),Vm(t,z),Z(t,z),Is(t,z),T(t,z),T_sub(t,z_sub)])
discretization = MOLFiniteDifference([z=>50,z_sub=>55],t,approx_order=2)
Interestingly, when I define the number of discretization points of the z_sub
domain >50 (more than z
domain points), I have not received any error. Is there a way to work around this? Because I want to discretize my z_sub
domain by 5 points and z
to 50.
Full error traceback:
julia> discretization = MOLFiniteDifference([z=>50,z_sub=>5],t,approx_order=2)
MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}(Dict{Num, Int64}(z_sub => 5, z => 50), t, 2, UpwindScheme(1), MethodOfLines.CenterAlignedGrid(), true, false, MethodOfLines.ScalarizedDiscretization(), true, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}())
julia> @time prob_two = discretize(pdesys,discretization)
┌ Warning: The system contains interface boundaries, which are not compatible with system transformation. The system will not be transformed. Please post an issue if you need this feature.
└ @ MethodOfLines C:\Users\bozdoc\.julia\packages\MethodOfLines\uGynQ\src\system_parsing\pde_system_transformation.jl:39
ERROR: BoundsError: attempt to access 5-element Vector{SymbolicUtils.BasicSymbolic{Real}} at index [50]
Stacktrace:
[1] getindex
@ .\essentials.jl:13 [inlined]
[2] getindex(::Vector{SymbolicUtils.BasicSymbolic{Real}}, ::CartesianIndex{1})
@ Base .\multidimensional.jl:668
[3] (::MethodOfLines.var"#38#39"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, CartesianIndex{1}, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}})(u::SymbolicUtils.BasicSymbolic{Real})
@ MethodOfLines .\none:0
[4] iterate
@ .\generator.jl:47 [inlined]
[5] collect_to!(dest::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, SymbolicUtils.BasicSymbolic{Real}}}, itr::Base.Generator{Vector{SymbolicUtils.BasicSymbolic{Real}}, MethodOfLines.var"#38#39"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, CartesianIndex{1}, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}}}, offs::Int64, st::Int64)
@ Base .\array.jl:840
[6] collect_to_with_first!(dest::Vector{Pair{SymbolicUtils.BasicSymbolic{Real}, SymbolicUtils.BasicSymbolic{Real}}}, v1::Pair{SymbolicUtils.BasicSymbolic{Real}, SymbolicUtils.BasicSymbolic{Real}}, itr::Base.Generator{Vector{SymbolicUtils.BasicSymbolic{Real}}, MethodOfLines.var"#38#39"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, CartesianIndex{1}, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}}}, st::Int64)
@ Base .\array.jl:818
[7] collect(itr::Base.Generator{Vector{SymbolicUtils.BasicSymbolic{Real}}, MethodOfLines.var"#38#39"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, CartesianIndex{1}, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}}})
@ Base .\array.jl:792
[8] varmaps(s::MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, depvars::Vector{SymbolicUtils.BasicSymbolic{Real}}, II::CartesianIndex{1}, indexmap::Dict{SymbolicUtils.BasicSymbolic{Real}, Int64})
@ MethodOfLines C:\Users\bozdoc\.julia\packages\MethodOfLines\uGynQ\src\discretization\discretize_vars.jl:220
[9] (::MethodOfLines.var"#440#442"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, Vector{Any}, PDEBase.HigherOrderInterfaceBoundary, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}, Equation})(II::CartesianIndex{1})
@ MethodOfLines C:\Users\bozdoc\.julia\packages\MethodOfLines\uGynQ\src\discretization\generate_bc_eqs.jl:175
[10] iterate
@ .\generator.jl:47 [inlined]
[11] _collect(c::Vector{CartesianIndex{1}}, itr::Base.Generator{Vector{CartesianIndex{1}}, MethodOfLines.var"#440#442"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, Vector{Any}, PDEBase.HigherOrderInterfaceBoundary, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}, Equation}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base .\array.jl:802
[12] collect_similar(cont::Vector{CartesianIndex{1}}, itr::Base.Generator{Vector{CartesianIndex{1}}, MethodOfLines.var"#440#442"{MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, Vector{Any}, PDEBase.HigherOrderInterfaceBoundary, Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}, Equation}})
@ Base .\array.jl:711
[13] map(f::Function, A::Vector{CartesianIndex{1}})
@ Base .\abstractarray.jl:3263
[14] generate_bc_eqs(s::MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, boundaryvalfuncs::Vector{Any}, boundary::PDEBase.HigherOrderInterfaceBoundary, interiormap::MethodOfLines.InteriorMap, indexmap::Dict{SymbolicUtils.BasicSymbolic{Real}, Int64})
@ MethodOfLines C:\Users\bozdoc\.julia\packages\MethodOfLines\uGynQ\src\discretization\generate_bc_eqs.jl:173
[15] generate_bc_eqs!(disc_state::PDEBase.EquationState, s::MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, boundaryvalfuncs::Vector{Any}, interiormap::MethodOfLines.InteriorMap, boundary::PDEBase.HigherOrderInterfaceBoundary)
@ MethodOfLines C:\Users\bozdoc\.julia\packages\MethodOfLines\uGynQ\src\discretization\generate_bc_eqs.jl:27
[16] discretize_equation!(disc_state::PDEBase.EquationState, pde::Equation, interiormap::MethodOfLines.InteriorMap, eqvar::SymbolicUtils.BasicSymbolic{Real}, bcmap::Dict{SymbolicUtils.BasicSymbolic{SymbolicUtils.FnType{Tuple, Real}}, Dict{SymbolicUtils.BasicSymbolic{Real}, Vector{Any}}}, depvars::Vector{Any}, s::MethodOfLines.DiscreteSpace{2, 8, MethodOfLines.CenterAlignedGrid}, derivweights::MethodOfLines.DifferentialDiscretizer{Pair{SymbolicUtils.BasicSymbolic{Real}, Vector{Int64}}, Dict{Function, MethodOfLines.DerivativeOperator{Float64, Nothing, false, Float64, StaticArraysCore.SVector{3, Float64}, S2, S3, Nothing, Nothing} where {S2, S3}}, UpwindScheme}, indexmap::Dict{SymbolicUtils.BasicSymbolic{Real}, Int64}, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})
@ MethodOfLines C:\Users\bozdoc\.julia\packages\MethodOfLines\uGynQ\src\scalar_discretization.jl:9
[17] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})
@ PDEBase C:\Users\bozdoc\.julia\packages\PDEBase\2OwkC\src\symbolic_discretize.jl:79
[18] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}; analytic::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ PDEBase C:\Users\bozdoc\.julia\packages\PDEBase\2OwkC\src\discretization_state.jl:58
[19] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})
@ PDEBase C:\Users\bozdoc\.julia\packages\PDEBase\2OwkC\src\discretization_state.jl:55
[20] top-level scope
@ .\timing.jl:273 [inlined]
[21] top-level scope
@ .\REPL[66]:0