SciML / ModelingToolkit.jl

An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations
https://mtk.sciml.ai/dev/
Other
1.42k stars 206 forks source link

JumpSystem equations must contain MassActionJumps, ConstantRateJumps, or VariableRateJumps #2098

Closed arnold-c closed 1 year ago

arnold-c commented 1 year ago

I am trying to run the example from the documentation and unfortunately running into the error JumpSystem equations must contain MassActionJumps, ConstantRateJumps, or VariableRateJumps. Code below:

using ModelingToolkit, DiffEqJump

@parameters β γ
@variables t S(t) I(t) R(t)
rate₁   = β*S*I
affect₁ = [S ~ S - 1, I ~ I + 1]
rate₂   = γ*I
affect₂ = [I ~ I - 1, R ~ R + 1]
j₁      = ConstantRateJump(rate₁,affect₁)
j₂      = ConstantRateJump(rate₂,affect₂)
j₃      = MassActionJump(2*β+γ, [R => 1], [S => 1, R => -1])
@named js      = JumpSystem([j₁,j₂,j₃], t, [S,I,R], [β,γ])

This is the line causing the error.

julia> @named js      = JumpSystem([j₁,j₂,j₃], t, [S,I,R], [β,γ])
ERROR: JumpSystem equations must contain MassActionJumps, ConstantRateJumps, or VariableRateJumps.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] JumpSystem(eqs::Vector{DiffEqJump.AbstractJump}, iv::Num, states::Vector{Num}, ps::Vector{Num}; observed::Vector{Equation}, systems::Vector{JumpSystem}, default_u0::Dict{Any, Any}, default_p::Dict{Any, Any}, defaults::Dict{Any, Any}, name::Symbol, connector_type::Nothing, checks::Bool, continuous_events::Nothing, discrete_events::Nothing, metadata::Nothing, gui_metadata::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/QxF9d/src/systems/jumps/jumpsystem.jl:151
 [3] top-level scope
   @ ~/.julia/packages/ModelingToolkit/QxF9d/src/systems/abstractsystem.jl:968

I tried this with both v 1.8.2 and 1.9.0-beta4, both within and outside of projects, and got the same error each time.

Any help would be appreciated.

Thanks

`] st -m` ``` (project) pkg> st -m Status `~/Documents/Repos/project/Manifest.toml` [c3fe647b] AbstractAlgebra v0.27.10 [1520ce14] AbstractTrees v0.4.4 [79e6a3ab] Adapt v3.5.0 [ec485272] ArnoldiMethod v0.2.0 [4fba245c] ArrayInterface v7.1.0 [30b0a656] ArrayInterfaceCore v0.1.29 [e2ed5e7c] Bijections v0.1.4 [62783981] BitTwiddlingConvenienceFunctions v0.1.5 [2a0fbf3d] CPUSummary v0.2.2 [00ebfdb7] CSTParser v3.3.6 [49dc2e85] Calculus v0.5.1 [d360d2e6] ChainRulesCore v1.15.7 [9e997f8a] ChangesOfVariables v0.1.6 [fb6a15b2] CloseOpenIntervals v0.1.12 [861a8166] Combinatorics v1.0.2 [a80b9123] CommonMark v0.8.10 [38540f10] CommonSolve v0.2.3 [bbf7d656] CommonSubexpressions v0.3.0 [34da2185] Compat v4.6.0 [b152e2b5] CompositeTypes v0.1.3 [187b0558] ConstructionBase v1.4.1 [adafc99b] CpuId v0.3.1 [a8cc5b0e] Crayons v4.1.1 [9a962f9c] DataAPI v1.14.0 [864edb3b] DataStructures v0.18.13 [e2d170a0] DataValueInterfaces v1.0.0 [b429d917] DensityInterface v0.4.0 [2b5f629d] DiffEqBase v6.120.0 [459566f4] DiffEqCallbacks v2.26.0 [c894b116] DiffEqJump v8.6.3 [163ba53b] DiffResults v1.1.0 [b552c78f] DiffRules v1.13.0 [b4f34e82] Distances v0.10.7 [31c24e10] Distributions v0.25.81 [ffbed154] DocStringExtensions v0.9.3 ⌅ [5b8099bc] DomainSets v0.5.15 [fa6b7ba4] DualNumbers v0.6.8 [7c1d4256] DynamicPolynomials v0.4.6 [4e289a0a] EnumX v1.0.4 [e2ba6199] ExprTools v0.1.8 [7034ab61] FastBroadcast v0.2.5 [1a297f60] FillArrays v0.13.7 [6a86dc24] FiniteDiff v2.18.0 [59287772] Formatting v0.4.2 [f6369f11] ForwardDiff v0.10.34 [069b7b12] FunctionWrappers v1.1.3 [77dc65aa] FunctionWrappersWrappers v0.1.3 [46192b85] GPUArraysCore v0.1.4 [c27321d9] Glob v1.3.0 [86223c79] Graphs v1.8.0 ⌅ [0b43b601] Groebner v0.2.11 [d5909c97] GroupsCore v0.4.0 [34004b35] HypergeometricFunctions v0.3.11 [615f187c] IfElse v0.1.1 [d25df0c9] Inflate v0.1.3 [18e54dd8] IntegerMathUtils v0.1.0 ⌅ [8197267c] IntervalSets v0.7.3 [3587e190] InverseFunctions v0.1.8 [92d709cd] IrrationalConstants v0.2.0 [82899510] IteratorInterfaceExtensions v1.0.0 [692b3bcd] JLLWrappers v1.4.1 [682c06a0] JSON v0.21.3 [98e50ef6] JuliaFormatter v1.0.24 [ccbc3e58] JumpProcesses v9.5.0 [b964fa9f] LaTeXStrings v1.3.0 [2ee39098] LabelledArrays v1.14.0 [984bce1d] LambertW v0.4.6 [23fbe1c1] Latexify v0.15.18 [10f19ff3] LayoutPointers v0.1.14 [50d2b5c4] Lazy v0.15.1 [d3d80556] LineSearches v7.2.0 [2ab3a3ac] LogExpFunctions v0.3.23 [1914dd2f] MacroTools v0.5.10 [d125e4d3] ManualMemory v0.1.8 [e1d29d7a] Missings v1.1.0 [961ee093] ModelingToolkit v8.47.0 [46d2c3a1] MuladdMacro v0.2.4 [102ac46a] MultivariatePolynomials v0.4.7 [d8a4904e] MutableArithmetics v1.2.3 [d41bc354] NLSolversBase v7.8.3 [2774e3e8] NLsolve v4.5.1 [77ba4419] NaNMath v1.0.2 [bac558e1] OrderedCollections v1.4.1 [90014a1f] PDMats v0.11.16 [d96e819e] Parameters v0.12.3 [69de0a69] Parsers v2.5.7 [e409e4f3] PoissonRandom v0.4.3 [f517fe37] Polyester v0.7.3 [1d0040c9] PolyesterWeave v0.2.1 [d236fae5] PreallocationTools v0.4.12 [21216c6a] Preferences v1.3.0 [27ebfcd6] Primes v0.5.3 [1fd47b50] QuadGK v2.8.1 [fb686558] RandomExtensions v0.4.3 [e6cf234a] RandomNumbers v1.5.3 [3cdcf5f2] RecipesBase v1.3.3 [731186ca] RecursiveArrayTools v2.38.0 [189a3867] Reexport v1.2.2 [ae029012] Requires v1.3.0 [79098fc4] Rmath v0.7.1 [7e49a35a] RuntimeGeneratedFunctions v0.5.5 [94e857df] SIMDTypes v0.1.0 [0bca4576] SciMLBase v1.86.3 [c0aeaf25] SciMLOperators v0.1.22 [efcf1570] Setfield v1.1.1 [727e6d20] SimpleNonlinearSolve v0.1.13 [699a6c99] SimpleTraits v0.9.4 [66db9d55] SnoopPrecompile v1.0.3 [a2af1166] SortingAlgorithms v1.1.0 [276daf66] SpecialFunctions v2.2.0 [aedffcd0] Static v0.8.4 [0d7ed370] StaticArrayInterface v1.2.1 [90137ffa] StaticArrays v1.5.16 [1e83bf80] StaticArraysCore v1.4.0 [82ae8749] StatsAPI v1.5.0 [2913bbd2] StatsBase v0.33.21 [4c63d2b9] StatsFuns v1.2.0 [7792a7ef] StrideArraysCore v0.4.8 [2efcf032] SymbolicIndexingInterface v0.2.1 [d1185830] SymbolicUtils v1.0.3 [0c5d862f] Symbolics v5.1.0 [3783bdb8] TableTraits v1.0.1 [bd369af6] Tables v1.10.0 [8290d209] ThreadingUtilities v0.5.1 [a759f4b9] TimerOutputs v0.5.22 [0796e94c] Tokenize v0.5.25 [a2a6695c] TreeViews v0.3.0 [410a4b4d] Tricks v0.1.6 [5c2747f8] URIs v1.4.2 [3a884ed6] UnPack v1.0.2 [1986cc42] Unitful v1.12.3 [a7c27f48] Unityper v0.1.2 [700de1a5] ZygoteRules v0.2.2 [efe28fd5] OpenSpecFun_jll v0.5.5+0 [f50d1b31] Rmath_jll v0.4.0+0 [0dad84c5] ArgTools v1.1.1 [56f22d72] Artifacts [2a0f44e3] Base64 [ade2ca70] Dates [8ba89e20] Distributed [f43a241f] Downloads v1.6.0 [7b1f6079] FileWatching [9fa8497b] Future [b77e0a4c] InteractiveUtils [b27032c2] LibCURL v0.6.3 [76f85450] LibGit2 [8f399da3] Libdl [37e2e46d] LinearAlgebra [56ddb016] Logging [d6f4376e] Markdown [a63ad114] Mmap [ca575930] NetworkOptions v1.2.0 [44cfe95a] Pkg v1.8.0 [de0858da] Printf [3fa0cd96] REPL [9a3f8284] Random [ea8e919c] SHA v0.7.0 [9e88b42a] Serialization [1a1011a3] SharedArrays [6462fe0b] Sockets [2f01184e] SparseArrays [10745b16] Statistics [4607b0f0] SuiteSparse [fa267f1f] TOML v1.0.0 [a4e569a6] Tar v1.10.1 [8dfed614] Test [cf7118a7] UUIDs [4ec0a83e] Unicode [e66e0078] CompilerSupportLibraries_jll v0.5.2+0 [deac9b47] LibCURL_jll v7.84.0+0 [29816b5a] LibSSH2_jll v1.10.2+0 [c8ffd9c3] MbedTLS_jll v2.28.0+0 [14a3606d] MozillaCACerts_jll v2022.2.1 [4536629a] OpenBLAS_jll v0.3.20+0 [05823500] OpenLibm_jll v0.8.1+0 [83775a58] Zlib_jll v1.2.12+3 [8e850b90] libblastrampoline_jll v5.1.1+0 [8e850ede] nghttp2_jll v1.48.0+0 [3f19e933] p7zip_jll v17.4.0+0 Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m` ```
`ls ~/.julia/packages` ``` AbstractAlgebra FilePathsBase LoopVectorization Setfield AbstractFFTs FillArrays LoweredCodeUtils ShaderAbstractions AbstractTrees FiniteDiff Lz4_jll ShiftedArrays Adapt FixedPointNumbers MIMEs Showoff Animations Fontconfig_jll MKL_jll SignedDistanceFields ArgCheck Formatting MacroTools SimpleBufferStream ArnoldiMethod ForwardDiff Makie SimpleNonlinearSolve Arpack FreeType MakieCore SimpleTraits Arpack_jll FreeType2_jll ManualMemory SimpleWeightedGraphs ArrayInterface FreeTypeAbstraction MappedArrays Sixel ArrayInterfaceCore FriBidi_jll Match SnoopPrecompile ArrayInterfaceGPUArrays FunctionWrappers MathOptInterface SoftGlobalScope ArrayInterfaceOffsetArrays FunctionWrappersWrappers MathTeXEngine SortingAlgorithms ArrayInterfaceStaticArrays FuzzyCompletions MbedTLS SparseDiffTools ArrayInterfaceStaticArraysCore GLFW Measurements Sparspak ArrayLayouts GLFW_jll Measures SpecialFunctions Arrow GLMakie Media SplittablesBase ArrowTypes GPUArraysCore MemPool StableHashTraits AutoHashEquals GR MeshIO StackViews Automa GR_jll Metatheory Static AxisAlgorithms Gadfly MicroCollections StaticArrayInterface AxisArrays GenericLinearAlgebra MiniQhull StaticArrays BandedMatrices GenericSchur Missings StaticArraysCore BangBang GeoInterface Mocking StatsAPI Baselet GeometryBasics ModelingToolkit StatsBase BenchmarkTools GeometryTypes ModernGL StatsFuns Bijections Gettext_jll MosaicViews StatsModels BinaryProvider Glib_jll MsgPack StatsPlots BitFlags Glob MuladdMacro SteadyStateDiffEq BitIntegers Graphics MultivariatePolynomials StochasticDiffEq BitTwiddlingConvenienceFunctions Graphite2_jll MultivariateStats StrideArraysCore BoundaryValueDiffEq Graphs Mustache StringEncodings Bzip2_jll GridLayoutBase MutableArithmetics StringManipulation CEnum Grisu NLSolversBase StructArrays CPUSummary Groebner NLsolve StructTypes CSTParser GroupsCore NaNMath Sundials CSV HTTP NearestNeighbors Sundials_jll Cairo HarfBuzz_jll Netpbm Suppressor CairoMakie HeartRateVariability NonlinearSolve SymbolicIndexingInterface Cairo_jll Hexagons Nullables SymbolicUtils Calculus Highlights Observables Symbolics CatIndices HostCPUFeatures OffsetArrays TableIOInterface Catalyst HypergeometricFunctions Ogg_jll TableOperations CategoricalArrays HypertextLiteral OnlineStats TableTraits Chain IJulia OnlineStatsBase TableTraitsUtils ChainRulesCore IdentityRanges OpenEXR Tables ChangesOfVariables IfElse OpenEXR_jll TensorCore CloseOpenIntervals ImageAxes OpenSSL TermInterface Clustering ImageBase OpenSSL_jll TextParse CodeTracking ImageContrastAdjustment OpenSpecFun_jll ThreadingUtilities CodecBzip2 ImageCore Optim ThreadsX CodecLz4 ImageDistances Opus_jll TiffImages CodecZlib ImageFiltering OrderedCollections TiledIteration CodecZstd ImageIO OrdinaryDiffEq TimeZones ColorBrewer ImageMetadata PCRE_jll TimerOutputs ColorSchemes ImageMorphology PDMats Tokenize ColorTypes ImageQualityIndexes PNGFiles TranscodingStreams ColorVectorSpace ImageShow Packing Transducers Colors ImageTransformations PaddedViews Trapz Combinatorics Images Pango_jll TreeViews CommonMark Imath_jll ParameterizedFunctions TriangularSolve CommonSolve IndexedTables Parameters Tricks CommonSubexpressions IndirectArrays Parsers TriplotBase Compat Inflate Pipe TupleTools Compose IniFile Pixman_jll URIs CompositeTypes InitialValues PkgVersion UnPack CompositionsBase InlineStrings PlotThemes UnicodeFun ComputationalResources IntegerMathUtils PlotUtils Unitful Conda IntelOpenMP_jll Plots Unityper Configurations Interpolations Pluto Unzip ConstructionBase IntervalSets PoissonRandom VectorizationBase Contour Intervals Polyester VersionParsing CoordinateTransformations InverseFunctions PolyesterWeave VertexSafeGraphs CoupledFields InvertedIndices PolygonOps Wayland_jll CpuId IrrationalConstants Polynomials Wayland_protocols_jll Crayons Isoband PooledArrays WeakRefStrings CustomUnitRanges IterTools PositiveFactorizations Weave DSP IterativeSolvers PreallocationTools Widgets Dagger IteratorInterfaceExtensions PrecompileSignatures WinReg DataAPI JLD2 Preferences WoodburyMatrices DataFrames JLFzf PrettyTables XML2_jll DataFramesMeta JLLWrappers Primes XSLT_jll DataStructures JSON ProgressMeter Xorg_libX11_jll DataValueInterfaces JpegTurbo QOI Xorg_libXau_jll DataValues JpegTurbo_jll QhullMiniWrapper_jll Xorg_libXcursor_jll DefineSingletons JuMP Qhull_jll Xorg_libXdmcp_jll DelayDiffEq JuliaDB Qt5Base_jll Xorg_libXext_jll DensityInterface JuliaFormatter QuadGK Xorg_libXfixes_jll DiffEqBase JuliaInterpreter Quadmath Xorg_libXi_jll DiffEqCallbacks JumpProcesses Quaternions Xorg_libXinerama_jll DiffEqDiffTools Juno RCall Xorg_libXrandr_jll DiffEqJump KLU Random123 Xorg_libXrender_jll DiffEqNoiseProcess KernelDensity RandomExtensions Xorg_libpthread_stubs_jll DiffResults Krylov RandomNumbers Xorg_libxcb_jll DiffRules KrylovKit RangeArrays Xorg_libxkbfile_jll DifferentialEquations LAME_jll Ratios Xorg_xcb_util_image_jll Distances LERC_jll RecipesBase Xorg_xcb_util_jll Distributions LZO_jll RecipesPipeline Xorg_xcb_util_keysyms_jll DocStringExtensions LaTeXStrings RecursiveArrayTools Xorg_xcb_util_renderutil_jll DomainSets LabelledArrays RecursiveFactorization Xorg_xcb_util_wm_jll DoubleFloats LambertW Reexport Xorg_xkbcomp_jll DrWatson Latexify Referenceables Xorg_xkeyboard_config_jll DualNumbers LayoutPointers RelocatableFolders Xorg_xtrans_jll DynamicPolynomials Lazy Requires YAML EarCut_jll LazyModules ResettableStacks ZMQ EnumX LevyArea Revise ZeroMQ_jll Expat_jll Libffi_jll Rmath Zstd_jll ExponentialUtilities Libgcrypt_jll Rmath_jll ZygoteRules ExprTools Libglvnd_jll Rotations fzf_jll ExproniconLite Libgpg_error_jll RuntimeGeneratedFunctions isoband_jll Extents Libiconv_jll SIMD libaom_jll FFMPEG Libmount_jll SIMDDualNumbers libass_jll FFMPEG_jll Libtiff_jll SIMDTypes libfdk_aac_jll FFTViews Libuuid_jll SLEEFPirates libpng_jll FFTW LineSearches ScanByte libsixel_jll FFTW_jll LinearSolve SciMLBase libsodium_jll FastBroadcast Loess SciMLNLSolve libvorbis_jll FastClosures LogExpFunctions SciMLOperators x264_jll FastLapackInterface LoggingExtras Scratch x265_jll FileIO LombScargle SentinelArrays xkbcommon_jll ```
isaacsas commented 1 year ago

Don't use DiffEqJump, it doesn't really exist any more and has been replaced by JumpProcesses. Just modify your first line to

using ModelingToolkit, JumpProcesses

(It does look like the doc string needs to be updated to include using JumpProcesses.)

I'd strongly suggest you delete DiffEqJump from your environment to avoid issues in the future.

arnold-c commented 1 year ago

Thanks. That fixed it!