You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changing the grid spacing leads to the error: ERROR: ArgumentError: Equations (1152), states (1140), and initial conditions (1140) are of different lengths. To allow a different number of equations than states use kwarg check_length=false. Stacktrace: from the function discretize.
Expected behavior
PDE system gets discretized as normal and ModelingToolkit.jl can produce a solution.
Minimal Reproducible Example 👇
using OrdinaryDiffEq, ModelingToolkit, MethodOfLines, DomainSets
using LinearAlgebra
# Parameters, variables, and derivatives@parameters t x y
@variablesu(..)
Dt =Differential(t)
Dtt =Differential(t)^2
Dxx =Differential(x)^2
Dyy =Differential(y)^2# 1D PDE and boundary conditionsfunctionsource(t, x, y)
val =sin(10t)
returnifelse(x ==0.5, ifelse(y ==0.5, ifelse(t >0.2, val, 0), 0), 0)
end
eq =Dtt(u(t, x, y)) ~ (Dxx(u(t, x, y)) +Dyy(u(t, x, y))) +source(t, x, y)
bcs = [u(0, x, y) ~0.0,
Dt(u(0, x, y)) ~0.0,
u(t, x, 0) ~0.0,
u(t, 0, y) ~0.0,
u(t, x, 1) ~0.0,
u(t, 1, y) ~0.0]
# Space and time domains
domains = [t ∈Interval(0.0, 2.0),
x ∈Interval(0.0, 1.0),
y ∈Interval(0.0, 1.0),]
# PDE system@named pdesys =PDESystem(eq, bcs, domains, [t, x, y], [u(t, x, y)])
# Method of lines discretization
dx =0.05
order =2
discretization =MOLFiniteDifference([x => dx, y => dx], t, approx_order = order)
# Convert the PDE problem into an ODE problem
prob =discretize(pdesys,discretization)
# Solve ODE problemusing OrdinaryDiffEq
sol =solve(prob, Tsit5())
# Plot results and compare with exact solution
discrete_x = sol[x]
discrete_t = sol[t]
solu = sol[u(t, x, y)]
using Plots
@giffor iframe ineachslice(solu, dims =1)
heatmap(iframe, label="Solution", )#clims=(0.0,0.00250))end
Error & Stacktrace ⚠️
Change dx in the example above to dx = 0.04 and observe the error below.
ERROR: ArgumentError: Equations (1152), states (1140), and initial conditions (1140) are of different lengths. To allow a different number of equations than states use kwarg check_length=false.
Stacktrace:
[1] check_eqs_u0(eqs::Vector{…}, dvs::Vector{…}, u0::Vector{…}; check_length::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/abstractsystem.jl:1871
[2] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{…}, parammap::SciMLBase.NullParameters; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:837
[3] (ODEProblem{…})(sys::ODESystem, u0map::Vector{…}, tspan::Tuple{…}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:936
[4] ODEProblem
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:929 [inlined]
[5] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair}, tspan::Tuple{Float64, Float64})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:929
[6] (ODEProblem{true})(::ODESystem, ::Vector{Pair}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:916
[7] (ODEProblem{true})(::ODESystem, ::Vector{Pair}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:915
[8] ODEProblem(::ODESystem, ::Vector{Pair}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:912
[9] ODEProblem(::ODESystem, ::Vector{Pair}, ::Vararg{Any})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/Gpzyo/src/systems/diffeqs/abstractodesystem.jl:911
[10] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; analytic::Nothing, kwargs::@Kwargs{})
@ PDEBase ~/.julia/packages/PDEBase/Aqj4G/src/discretization_state.jl:74
[11] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/Aqj4G/src/discretization_state.jl:55
[12] top-level scope
@ ~/Projects/Toolbox.jl/src/acoustic2D.jl:42
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
Describe the bug 🐞
Changing the grid spacing leads to the error:
ERROR: ArgumentError: Equations (1152), states (1140), and initial conditions (1140) are of different lengths. To allow a different number of equations than states use kwarg check_length=false. Stacktrace:
from the functiondiscretize
.Expected behavior
PDE system gets discretized as normal and ModelingToolkit.jl can produce a solution.
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Change
dx
in the example above todx = 0.04
and observe the error below.Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
The text was updated successfully, but these errors were encountered: