Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Julia ODE example #251

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Added a Julia ODE example #251

merged 1 commit into from
Aug 26, 2024

Conversation

B-rando1
Copy link
Collaborator

This should help with #3918. It took a bit of trial and error to understand how the library works, but it makes sense now that I've got it working.

You can run the code by calling make run RUNARGS=input.txt, and the results will be stored in output.txt. Note that you need DifferentialEquations.jl installed in your Julia workspace (see here for an install guide).

The output is basically identical to Python's (source code here). It deviates a little bit, but the first ~10 digits are the same.

Copy link
Collaborator

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. But I'll let @smiths do the merge, as this is his repo.

@smiths
Copy link
Owner

smiths commented Aug 16, 2024

@B-rando1, the code looks good, but I don't want to merge until I can run it. I followed your instructions for the Differential Equations package, but it doesn't seem to have loaded properly. I don't have time to debug it now. My Julia version is 1.10.4. DifferentialEquations is v7.13.0. Here is a portion of the error message that I get:

ERROR: LoadError: TypeError: in new, expected Union{}, got a value of type SparseArrays.SparseMatrixCSC{Float64, Int64}
Stacktrace:
 [1] Sparspak.SpkSparseSolver.SparseSolver(p::SparseArrays.SparseMatrixCSC{Float64, Int64}, slvr::Sparspak.SpkSparseBase._SparseBase{Int64, Float64}, n::Int64, ma::Int64, na::Int64, mc::Int64, nc::Int64, _inmatrixdone::Bool, _orderdone::Bool, _symbolicdone::Bool, _factordone::Bool, _trisolvedone::Bool, _refinedone::Bool, _condestdone::Bool)
   @ Sparspak.SpkSparseSolver ~/.julia/packages/Sparspak/oqBYl/src/SparseMethod/SpkSparseSolver.jl:18
 [2] Sparspak.SpkSparseSolver.SparseSolver(m::SparseArrays.SparseMatrixCSC{Float64, Int64})
   @ Sparspak.SparseCSCInterface ~/.julia/packages/Sparspak/oqBYl/src/SparseCSCInterface/SparseCSCInterface.jl:189
 [3] sparspaklu(m::SparseArrays.SparseMatrixCSC{Float64, Int64}; factorize::Bool)
   @ Sparspak.SparseCSCInterface ~/.julia/packages/Sparspak/oqBYl/src/SparseCSCInterface/SparseCSCInterface.jl:219
 [4] top-level scope
   @ ~/.julia/packages/LinearSolve/WmS9C/src/factorization.jl:1336
 [5] include(x::String)
   @ LinearSolve ~/.julia/packages/LinearSolve/WmS9C/src/LinearSolve.jl:1
 [6] top-level scope
   @ ~/.julia/packages/LinearSolve/WmS9C/src/LinearSolve.jl:127
 [7] top-level scope
   @ stdin:3
in expression starting at /Users/smiths/.julia/packages/LinearSolve/WmS9C/src/factorization.jl:1336
in expression starting at /Users/smiths/.julia/packages/LinearSolve/WmS9C/src/LinearSolve.jl:1
in expression starting at stdin:3

@B-rando1
Copy link
Collaborator Author

Hmm, that's odd. I'm on Julia v1.10.3, with DifferentialEquations v7.13.0.

My Julia configuration doesn't have Sparspak installed, so it's surprising that you're getting an error with it. I'm not exactly sure what would be going on there.

  • You could try updating all of your packages to see if one of them was out-of-date.
  • I guess if you want, you could try removing Sparspak to see if it defaults to the same thing as mine. Although, mine still worked even after I installed Sparspak, so I'm not sure if that will work.
  • I'm guessing we want to use DP5, since it is consistent with the other ODE solvers. If you want though, you could try leaving it blank or using Tsit5 (apparently it's similar to DP5 but faster) to see if it works with a different solver.

Other than that, I'm not really sure what you can try. I checked their issue tracker, but didn't see anything related to this. I hope you can get it working!

@smiths
Copy link
Owner

smiths commented Aug 26, 2024

I figured out the problem. The homebrew version of Julia is not very good. 😄 I uninstalled by homebrew version of Julia and installed the regular version. After installing the differential equation package the code ran without any problems. 😄

@smiths smiths merged commit b28ba8e into master Aug 26, 2024
@smiths smiths deleted the JuliaODE branch August 26, 2024 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants