yes
these are the packages installed:
Status ~/.julia/environments/v1.8/Project.toml
[093aae92] BSplineKit v0.16.5
[336ed68f] CSV v0.10.11
[35d6a980] ColorSchemes v3.24.0
[a93c6f00] DataFrames v1.6.1
⌃ [0c46a032] DifferentialEquations v7.10.0
[f6369f11] ForwardDiff v0.10.36
[4345ca2d] Loess v0.6.3
[2fda8390] LsqFit v0.15.0
⌃ [961ee093] ModelingToolkit v8.70.0
[76087f3c] NLopt v1.0.0
⌅ [8913a72c] NonlinearSolve v1.10.1
[429524aa] Optim v1.7.8
[1dea7af3] OrdinaryDiffEq v6.58.0
[58dd65bb] Plotly v0.4.1
[91a5bcdd] Plots v1.39.0
⌃ [c3e4b0f8] Pluto v0.19.9
[7f904dfe] PlutoUI v0.7.52
[f3b207a7] StatsPlots v0.15.6
[24249f21] SymPy v1.1.14
[fdbf4ff8] XLSX v0.10.0
[10745b16] Statistics
Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use status --outdated
I use most of them.
What’s holding back ModelingToolkit / DifferentialEquations? Which is the one that hasn’t been updated?
Not exactly sure, when I try updating it, this is what I get:
(@v1.8) pkg> update ModelingToolkit
Updating registry at ~/.julia/registries/General.toml
Installed TranscodingStreams ─ v0.10.1
Installed LinearSolve ──────── v2.11.0
Installed FillArrays ───────── v1.7.0
No Changes to ~/.julia/environments/v1.8/Project.toml
Updating ~/.julia/environments/v1.8/Manifest.toml
[1a297f60] ↑ FillArrays v1.6.1 ⇒ v1.7.0
[7ed4a6bd] ↑ LinearSolve v2.10.0 ⇒ v2.11.0
[731186ca] ↓ RecursiveArrayTools v2.39.0 ⇒ v2.38.10
[3bb67fe8] ↑ TranscodingStreams v0.10.0 ⇒ v0.10.1
Precompiling project…
33 dependencies successfully precompiled in 103 seconds. 336 already precompiled.
Clean up your global environment and it will be easier to debug.
I tried updating using workspace() but it did not work, and I tried restart repl, it doesn’t seem to work, is there another way to clear the global environment?
I meant your global package environment.
I tried this, is this good enough?
julia> using Pkg
julia> using Dates
julia> Pkg.gc(;collect_delay=Dates.Day(0))
Active manifest files: 14 found
Active artifact files: 124 found
Active scratchspaces: 5 found
Deleted 240 package installations (228.822 MiB)
Deleted 45 artifact installations (555.484 MiB)
Deleted 5 scratchspaces (1.385 KiB)
By cleaning up Chris meant removing unneeded packages which might introduce incompatibilities preventing packages from updating.
The easiest thing to do is probably to just work in a clean environment (i.e. ] activate .
in the folder in which you’re saving your code as well) and then add only the packages you need for this analysis to that environment. See here:
I highly recommend making a clean environment and adding packages. If you just add the differential equation solver, it will be fine. What random thing is causing problems? I don’t know, I’ve never used XLSX. But do it incrementally. Add only the packages you need.
When you add something that pulls other packages back, take a look at it. That package is doing bad things. Avoid that package if you can.
This is how I created a new environment:
begin
import Pkg
Pkg.activate(“.”)
Pkg.add(“MethodOfLines”)
Pkg.add(“Symbolics”)
Pkg.add(“DomainSets”)
using MethodOfLines
using ModelingToolkit
using OrdinaryDiffEq
using NonlinearSolve
using PlutoUI
using DifferentialEquations
using Plots
using XLSX
using Symbolics
using DomainSets
end
I am still facing the same error
Are you still in the same folder? You shouldn’t have been able to do e.g. using Plots
since you only added three new packages. Go into a new folder and make sure your directory is set to there, then perform those steps. You can check to see if your environment is empty by seeing if there’s anything in ] st
. e.g. an empty project shows no packages
(jl_tDbHjK) pkg> st
Status `C:\Users\User\AppData\Local\Temp\jl_tDbHjK\Project.toml` (empty project)
You can also test in a temporary environment if you prefer. After restarting your session to ensure no packages are being reused, you can do
julia> import Pkg
julia> Pkg.activate(; temp = true)
Activating new project at `C:\Users\User\AppData\Local\Temp\jl_eZE42P`
julia> Base.active_project() # make sure
"C:\\Users\\User\\AppData\\Local\\Temp\\jl_eZE42P\\Project.toml"
julia> Pkg.add("MethodOfLines")
(and so on). Then run your test code again, including packages one at a time and running your test code after each new add
and using
.
I am currently trying to solve 2 differential equations with 2 common variables, this is the code:
begin
# Parameters, variables, and derivatives for system 1
@parameters ts xs xf
@variables Ts(..) Tf(..)
Dts = Differential(ts)
Dxs = Differential(xs)
Dxxs = Differential(xs)^2
Dxf= Differential(xf)
Dxxf= Differential(xf)^2
# MOL Discretization parameters for system 1
x_max1 = L
x_min1 = 0
t_min1 = 0
t_max1 = 6737
nc1 = 20
x_num1 = range(x_min1, x_max1, length=nc1)
dxs = (x_max1 - x_min1) / (nc1 - 1)
# MOL Discretization parameters for system 2
x_max2 = L
x_min2 = 0
t_min2 = 0
t_max2 = 6737
nc2 = 20
x_num2 = range(x_min2, x_max2, length=nc2)
dxf = (x_max2 - x_min2) / (nc2 - 1)
# PDE equation for system 1
eq1 = ((52000 * exp(-1.24e-5 * Ts(ts, xs)) / (Ts(ts, xs) + 437)) / 1000) * Dxxs(Ts(ts, xs)) + ((h * A * ((Ts(ts, xs)) - Tf(ts, xf))) / (vol)) ~ ρs * Cps * Dts(Ts(ts, xs))
# Boundary conditions for system 1
bcs1 = [Ts(t_min1, xs) ~ Tamb,
((52000 * exp(-1.24e-5 * Ts(ts, xs)) / (Ts(ts, xs) + 437)) / 1000) * Dxs(Ts(ts, x_max1)) ~ 0,
A * ((52000 * exp(-1.24e-5 * Ts(ts, xs)) / (Ts(ts, xs) + 437)) / 1000) * Dxs(Ts(ts, x_min1)) ~
-(ϵ * σ * (Ts(ts, x_min1)^4) - (Tamb)^4) - h * A * ((Ts(ts, x_min1)) - Tamb)]
# Space and time domain for system 1
domains1 = [ts ∈ Interval(t_min1, t_max1),
xs ∈ Interval(x_min1, x_max1)]
# ODE system for system 1
@named pdesys1 = PDESystem([eq1], bcs1, domains1, [ts, xs], [Ts])
# MOL parameters for system 1
order1 = 2
discretization1 = MOLFiniteDifference([xs => dxs, xf=> dxf], ts, approx_order=order1)
# Convert the ODE problem for system 1
prob1 = discretize(pdesys1, discretization1)
sol1 = solve(prob1, saveat=3)
T_exp1 = sol1.u[Ts]
# PDE equation for system 2
eq2 = Cpf * ρf * V * Dxf(Tf(ts, xf)) ~ -Cpf * ρf * Dtf(Tf(ts, xf)) +
((h * A * ((Ts(ts, xs)) - Tf(ts, xf))) / (vol))
# Boundary conditions for system 2
bcs2 = [Tf(t_min2, xf) ~ Tamb,
kf * Dxf(Tf(ts, x_max2)) ~ 0,
A * kf * Dxf(Tf(ts, x_min2)) ~ -h * A * ((Tf(ts, x_min2)) - Tamb)]
# Space and time domain for system 2
domains2 = [ts ∈ Interval(t_min2, t_max2),
xf ∈ Interval(x_min2, x_max2)]
# ODE system for system 2
@named pdesys2 = PDESystem([eq2], bcs2, domains2, [ts, xf], [Tf(ts, xf)])
# MOL parameters for system 2
order2 = 2
discretization2 = MOLFiniteDifference([xf => dxf, xs => dxs], approx_order=order2)
# Convert the ODE problem for system 2
prob2 = discretize(pdesys2, discretization2)
sol2 = solve(prob2, saveat=3)
T_exp2 = sol2.u[Tf]
end
This is the error I am getting:
Sym doesn’t have a operation or arguments!
- error(::String)@error.jl:35
- error_sym()@types.jl:78
- operation@types.jl:108 [inlined]
- operation(::Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}})@variable.jl:240
- chain_flatten_array_variables(::Vector{Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}}})@make_pdesys_compatible.jl:6
- make_pdesys_compatible(::ModelingToolkit.PDESystem)@make_pdesys_compatible.jl:32
- symbolic_discretize(::ModelingToolkit.PDESystem, ::MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})@symbolic_discretize.jl:11
- var"#discretize#73"(::Nothing, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.discretize), ::ModelingToolkit.PDESystem, ::MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})@discretization_state.jl:58
- discretize(::ModelingToolkit.PDESystem, ::MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})@discretization_state.jl:55
- top-level scope@Local: 52
Would appreciate your help!
I got the error: L
is not defined.
Perhaps try installing specific versions of packages?
] add DifferentialEquations@7.11.0 ModelingToolkit@8.73.1 MethodOfLines@0.10.4
You can see the working combination in MethodOfLines.jl
’s docs.
L is defined above in a different cell. I also installed the versions of packages you suggested, but I am still getting the same error. If you see an issue with how I wrote my equations and defined my variables, and parameters, please let me know!
now that I am trying to solve the equations:
begin
# MOL parameters for system 1
order1 = 2
discretization1 = MOLFiniteDifference([xs => dxs, xf=> dxf], t, approx_order=order1)
# Convert the ODE problem for system 2
prob1 = discretize(pdesys1, discretization1)
sol1 = solve(prob1, saveat=3)
# T_exp1 = sol1.u[Ts, Tf]
Ts_values = sol1(Ts).u
Tf_values = sol1(Tf).u
end
I get this error and I believe that 2 dimensions of t are needed, I am unsure of how to formate it for this package: “Solution has length 1 in dimension t. Interpolation will not be possible for variable Tf(t, xf). Solution return code is InitialFailure.”