JuliaGNI / GeometricProblems.jl

Example problems for GeometricIntegrators.jl
MIT License
5 stars 0 forks source link

Test LotkaVolterra4dLagrangian #47

Open finmod opened 1 year ago

finmod commented 1 year ago

Can you give a reference in the docs for this problem?

Also, the problem is now formulated in math terms using Symbolics.jl and moving away from MTK.jl. I suggest using and testing modelingtoolkitize to preserve the generality of GeometricProblems.

michakraus commented 1 year ago

We are planning to revise the whole GeometricProblems package, including adding proper docs and references for all problems. We are currently working on a "new" package https://github.com/JuliaGNI/EulerLagrange.jl to be able to add new problems more easily by providing just the Lagrangian or Hamiltonian and generating all the code automatically. LotkaVolterra4dLagrangian has been a kind of proof-of-principle for this endeavor.

Unfortunately, I am not aware of a reference for the Lagrangian formulation for the Lotka-Volterra problem in 4d (or rather arbitrary even dimensions). I cooked this up some time ago by analogy with the 2d Lagrangian...

finmod commented 1 year ago

EulerLagrange.jl is a great initiative to setting up n-dimensional systems in a blink and without coding mistakes. It should be general enough to formulate problems with Lagrange-D'Alembert principle and nonholonomic constraints as in: https://www.fields.utoronto.ca/programs/scientific/12-13/Marsden/presentations/MartindeDiego.pdf

michakraus commented 1 year ago

Yes, that is no problem at all and only requires implementing a proper type for Lagrange-d'Alembert systems. We are currently working on adding support for parameters in the Lagrangian and code generation for discrete Lagrangians, with Lagrange-d'Alembert and Hamilton-Pontryagin systems planned for the future.

finmod commented 7 months ago

@michakraus I noted today the EulerLagrange extension to DegerateLagrangian. Great! The test of EulerLagrange passes.

However, when I tried to test GeometricProblems to see if DegenerateLagrangian works there on LotkaVolterra4dLagrangian , the test fails.

[9a962f9c] DataAPI v1.15.0 [864edb3b] DataStructures v0.18.16 [e2d170a0] DataValueInterfaces v1.0.0 [55939f99] DecFP v1.3.2 [8bb1440f] DelimitedFiles v1.9.1 [163ba53b] DiffResults v1.1.0 [b552c78f] DiffRules v1.15.1 [b4f34e82] Distances v0.10.11 [31c24e10] Distributions v0.25.107 [ffbed154] DocStringExtensions v0.9.3 [e30172f5] Documenter v1.2.1 [5b8099bc] DomainSets v0.6.7 [fa6b7ba4] DualNumbers v0.6.8 [7c1d4256] DynamicPolynomials v0.5.3 [4e289a0a] EnumX v1.0.4 [e2ba6199] ExprTools v0.1.10 [7a1cc6ca] FFTW v1.7.2 [442a2c76] FastGaussQuadrature v1.0.1 [057dd010] FastTransforms v0.15.16 [1a297f60] FillArrays v1.9.3 [6a86dc24] FiniteDiff v2.22.0 [59287772] Formatting v0.4.2 [f6369f11] ForwardDiff v0.10.36 [069b7b12] FunctionWrappers v1.1.3 [77dc65aa] FunctionWrappersWrappers v0.1.3 [46192b85] GPUArraysCore v0.1.5 [a8297547] GenericFFT v0.1.6 [14197337] GenericLinearAlgebra v0.3.11 [9a0b12b7] GeometricBase v0.9.1 [c85262ba] GeometricEquations v0.14.3 [dcce2d33] GeometricIntegrators v0.13.0 [18cb22b4] GeometricProblems v0.5.7 [7843afe4] GeometricSolutions v0.3.19 [d7ba0133] Git v1.3.0 [f67ccb44] HDF5 v0.17.1 [34004b35] HypergeometricFunctions v0.3.23 [b5f81e59] IOCapture v0.2.3 [615f187c] IfElse v0.1.1 [4858937d] InfiniteArrays v0.13.4 [e1ba4f0e] Infinities v0.1.8 [8197267c] IntervalSets v0.7.8 [92d709cd] IrrationalConstants v0.2.2 [c8e1da08] IterTools v1.10.0 [82899510] IteratorInterfaceExtensions v1.0.0 [692b3bcd] JLLWrappers v1.5.0 [682c06a0] JSON v0.21.4 [b964fa9f] LaTeXStrings v1.3.1 [2ee39098] LabelledArrays v1.15.0 [984bce1d] LambertW v0.4.6 [23fbe1c1] Latexify v0.16.1 [0e77f7df] LazilyInitializedFields v1.2.2 [50d2b5c4] Lazy v0.15.1 [5078a376] LazyArrays v1.8.3 [d3d80556] LineSearches v7.2.0 [2ab3a3ac] LogExpFunctions v0.3.26 [3da0fdf6] MPIPreferences v0.1.10 [1914dd2f] MacroTools v0.5.12 [d0879d2d] MarkdownAST v0.1.2 [a3b82374] MatrixFactorizations v2.1.0 [442fdcdd] Measures v0.3.2 [e1d29d7a] Missings v1.1.0 [102ac46a] MultivariatePolynomials v0.5.4 [d8a4904e] MutableArithmetics v1.4.0 [d41bc354] NLSolversBase v7.8.3 [2774e3e8] NLsolve v4.5.1 [77ba4419] NaNMath v1.0.2 [6fe1bfb0] OffsetArrays v1.13.0 [bac558e1] OrderedCollections v1.6.3 [90014a1f] PDMats v0.11.31 [d96e819e] Parameters v0.12.3 [69de0a69] Parsers v2.8.1 [f27b6e38] Polynomials v4.0.6 [d236fae5] PreallocationTools v0.4.17 [aea7be01] PrecompileTools v1.2.0 [21216c6a] Preferences v1.4.1 [08abe8d2] PrettyTables v2.3.1 [92933f4c] ProgressMeter v1.9.0 [1fd47b50] QuadGK v2.9.3 [a08977f5] QuadratureRules v0.1.6 [c4ea9172] QuasiArrays v0.11.4 [3cdcf5f2] RecipesBase v1.3.4 [731186ca] RecursiveArrayTools v3.5.2 [189a3867] Reexport v1.2.2 [2792f1a3] RegistryInstances v0.1.0 [ae029012] Requires v1.3.0 [79098fc4] Rmath v0.7.1 [fb486d5c] RungeKutta v0.5.13 [7e49a35a] RuntimeGeneratedFunctions v0.5.12 [1bc83da4] SafeTestsets v0.1.0 [0bca4576] SciMLBase v2.18.0 [c0aeaf25] SciMLOperators v0.3.7 [efcf1570] Setfield v1.1.1 [36b790f5] SimpleSolvers v0.3.3 [a2af1166] SortingAlgorithms v1.2.1 [276daf66] SpecialFunctions v2.3.1 [90137ffa] StaticArrays v1.9.0 [1e83bf80] StaticArraysCore v1.4.2 [82ae8749] StatsAPI v1.7.0 [2913bbd2] StatsBase v0.34.2 [4c63d2b9] StatsFuns v1.3.0 [892a3eda] StringManipulation v0.3.4 [2efcf032] SymbolicIndexingInterface v0.3.3 [d1185830] SymbolicUtils v1.5.0 [0c5d862f] Symbolics v5.16.0 [3783bdb8] TableTraits v1.0.1 [bd369af6] Tables v1.11.1 [a759f4b9] TimerOutputs v0.5.23 [c751599d] ToeplitzMatrices v0.8.3 [410a4b4d] Tricks v0.1.8 [781d530d] TruncatedStacktraces v1.4.0 [3a884ed6] UnPack v1.0.2 [a7c27f48] Unityper v0.1.6 [47200ebd] DecFP_jll v2.0.3+1 [2e619515] Expat_jll v2.5.0+0 [f5851436] FFTW_jll v3.3.10+0 [34b6f7d7] FastTransforms_jll v0.6.2+0 [f8c6e375] Git_jll v2.43.0+0 [0234f1f7] HDF5_jll v1.14.3+0 [1d5cc7b8] IntelOpenMP_jll v2024.0.2+0 [1d63c593] LLVMOpenMP_jll v15.0.7+0 [94ce4f54] Libiconv_jll v1.17.0+0 [856f044c] MKL_jll v2024.0.0+0 [7cb0a576] MPICH_jll v4.1.2+1 [f1f71cc9] MPItrampoline_jll v5.3.1+1 [9237b28f] MicrosoftMPI_jll v10.1.4+1 [fe0851c0] OpenMPI_jll v4.1.6+0 [458c3c95] OpenSSL_jll v3.0.12+0 [efe28fd5] OpenSpecFun_jll v0.5.5+0 [f50d1b31] Rmath_jll v0.4.0+0 [477f73a3] libaec_jll v1.0.6+1 [0dad84c5] ArgTools v1.1.1 [56f22d72] Artifacts [2a0f44e3] Base64 [ade2ca70] Dates [8ba89e20] Distributed [f43a241f] Downloads v1.6.0 [7b1f6079] FileWatching [9fa8497b] Future [b77e0a4c] InteractiveUtils [4af54fe1] LazyArtifacts [b27032c2] LibCURL v0.6.4 [76f85450] LibGit2 [8f399da3] Libdl [37e2e46d] LinearAlgebra [56ddb016] Logging [d6f4376e] Markdown [a63ad114] Mmap [ca575930] NetworkOptions v1.2.0 [44cfe95a] Pkg v1.10.0 [de0858da] Printf [3fa0cd96] REPL [9a3f8284] Random [ea8e919c] SHA v0.7.0 [9e88b42a] Serialization [1a1011a3] SharedArrays [6462fe0b] Sockets [2f01184e] SparseArrays v1.10.0 [10745b16] Statistics v1.10.0 [4607b0f0] SuiteSparse [fa267f1f] TOML v1.0.3 [a4e569a6] Tar v1.10.0 [8dfed614] Test [cf7118a7] UUIDs [4ec0a83e] Unicode [e66e0078] CompilerSupportLibraries_jll v1.0.5+1 [781609d7] GMP_jll v6.2.1+6 [deac9b47] LibCURL_jll v8.4.0+0 [e37daf67] LibGit2_jll v1.6.4+0 [29816b5a] LibSSH2_jll v1.11.0+1 [3a97d323] MPFR_jll v4.2.0+1 [c8ffd9c3] MbedTLS_jll v2.28.2+1 [14a3606d] MozillaCACerts_jll v2023.1.10 [4536629a] OpenBLAS_jll v0.3.23+2 [05823500] OpenLibm_jll v0.8.1+2 [efcefdf7] PCRE2_jll v10.42.0+1 [bea87d4a] SuiteSparse_jll v7.2.1+1 [83775a58] Zlib_jll v1.2.13+1 [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. Precompiling project... 38 dependencies successfully precompiled in 113 seconds. 168 already precompiled. Testing Running tests... Test Summary: | Pass Total Time Harmonic Oscillator | 21 21 49.7s Test Summary: | Pass Total Time Lorenz Attractor | 2 2 7.4s Test Summary: | Pass Total Time Lotka-Volterra 2D | 5 5 32.8s Test Summary: | Pass Total Time Lotka-Volterra 2D with singular Lagrangian | 5 5 24.4s Test Summary: | Pass Total Time Lotka-Volterra 2D with symmetric Lagrangian | 5 5 24.9s Test Summary: | Pass Total Time Lotka-Volterra 2D with symmetric Lagrangian with gauge terms | 5 5 25.3s Test Summary: | Pass Total Time Lotka-Volterra 3D | 6 6 8.9s Test Summary: | Pass Total Time Lotka-Volterra 4D | 5 5 34.5s Lotka-Volterra 4D (Lagrangian) : Error During Test at C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\lotka_volterra_4d_lagrangian_tests.jl:12 Got exception outside of a @test UndefVarError: inject_registered_module_functions not defined Stacktrace: [1] getproperty @ .\Base.jl:31 [inlined] [2] macro expansion @ C:\Users\Denis.julia\packages\RuntimeGeneratedFunctions\Yo8zx\src\RuntimeGeneratedFunctions.jl:125 [inlined] [3] get_functions(A::Matrix{Rational{Int64}}, B::Matrix{Int64}, a::Vector{Float64}, b::Vector{Float64}) @ GeometricProblems.LotkaVolterra4dLagrangian C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\src\lotka_volterra_4d_lagrangian.jl:175 [4] lotka_volterra_4d_ode(q₀::Vector{Float64}, A::Matrix{Rational{Int64}}, B::Matrix{Int64}; tspan::Tuple{Float64, Float64}, tstep::Float64, parameters::@NamedTuple{a₁::Float64, a₂::Float64, a₃::Float64, a₄::Float64, b₁::Float64, b₂::Float64, b₃::Float64, b₄::Float64}) @ GeometricProblems.LotkaVolterra4dLagrangian C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\src\lotka_volterra_4d_lagrangian.jl:197 [5] lotka_volterra_4d_ode (repeats 2 times) @ GeometricProblems.LotkaVolterra4dLagrangian C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\src\lotka_volterra_4d_lagrangian.jl:195 [inlined] [6] lotka_volterra_4d_ode() @ GeometricProblems.LotkaVolterra4dLagrangian C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\src\lotka_volterra_4d_lagrangian.jl:195 [7] macro expansion @ C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\lotka_volterra_4d_lagrangian_tests.jl:13 [inlined] [8] macro expansion @ C:\Users\Denis.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Test\src\Test.jl:1577 [inlined] [9] top-level scope @ C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\lotka_volterra_4d_lagrangian_tests.jl:13 [10] include(mod::Module, _path::String) @ Base .\Base.jl:495 [11] include(x::String) @ Main.var"##Lotka-Volterra 4D (Lagrangian) #233" C:\Users\Denis.julia\packages\SafeTestsets\raUNr\src\SafeTestsets.jl:28 [12] macro expansion @ C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\runtests.jl:12 [inlined] [13] macro expansion @ C:\Users\Denis.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Test\src\Test.jl:1577 [inlined] [14] macro expansion @ C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\runtests.jl:12 [inlined] [15] top-level scope @ C:\Users\Denis.julia\packages\SafeTestsets\raUNr\src\SafeTestsets.jl:30 [16] eval(m::Module, e::Any) @ Core .\boot.jl:385 [17] top-level scope @ C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\runtests.jl:28 [18] include(fname::String) @ Base.MainInclude .\client.jl:489 [19] top-level scope @ none:6 [20] eval @ Core .\boot.jl:385 [inlined] [21] exec_options(opts::Base.JLOptions) @ Base .\client.jl:291 [22] _start() @ Base .\client.jl:552 Test Summary: | Error Total Time Lotka-Volterra 4D (Lagrangian) | 1 1 57.5s Lotka-Volterra 4D (Lagrangian) | 1 1 56.3s ERROR: LoadError: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken. in expression starting at C:\Users\Denis.julia\packages\GeometricProblems\9rOhq\test\runtests.jl:12 ERROR: Package GeometricProblems errored during testing

(@v1.10) pkg>

michakraus commented 7 months ago

Thanks for reporting. This is due to some changes in Symbolics.jl. I already fixed this last week, but so far it is only in main. I have not yet triggered a release as there is also a problem with the docs... I will try to take care of this asap.