diff --git a/Project.toml b/Project.toml index 859d712e..5d218138 100644 --- a/Project.toml +++ b/Project.toml @@ -17,13 +17,12 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [weakdeps] -Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179" -Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377" - [extensions] Render = ["Makie"] URDF = ["LightXML", "Graphs", "MetaGraphsNext", "JuliaFormatter"] @@ -47,12 +46,14 @@ StaticArrays = "1" julia = "1" [extras] -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179" -Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377" +OrdinaryDiffEqBDF = "6ad6398a-0878-4a85-9266-38940aa047c8" +OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce" +OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["OrdinaryDiffEq", "Test", "JuliaFormatter", "LightXML", "Graphs", "MetaGraphsNext"] +test = ["OrdinaryDiffEqBDF", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqTsit5", "Test", "JuliaFormatter", "LightXML", "Graphs", "MetaGraphsNext"] diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 02e84ab1..25bea55f 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.10.5" manifest_format = "2.0" -project_hash = "08003e42b5c1441ed313cb0f744985213930fbba" +project_hash = "08a78d2a0b8f7c13d94e84d1e87233ac1adf1ff0" [[deps.ADTypes]] git-tree-sha1 = "eea5d80188827b35333801ef97a40c2ed653b081" @@ -742,12 +742,6 @@ git-tree-sha1 = "1c6317308b9dc757616f0b5cb379db10494443a7" uuid = "2e619515-83b5-522b-bb60-26c02a35a201" version = "2.6.2+0" -[[deps.ExponentialUtilities]] -deps = ["Adapt", "ArrayInterface", "GPUArraysCore", "GenericSchur", "LinearAlgebra", "PrecompileTools", "Printf", "SparseArrays", "libblastrampoline_jll"] -git-tree-sha1 = "8e18940a5ba7f4ddb41fe2b79b6acaac50880a86" -uuid = "d4d017d3-3776-5f7e-afef-a10c40355c18" -version = "1.26.1" - [[deps.ExprTools]] git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec" uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" @@ -1923,18 +1917,6 @@ git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" version = "1.6.3" -[[deps.OrdinaryDiffEq]] -deps = ["ADTypes", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "EnumX", "ExponentialUtilities", "FastBroadcast", "FastClosures", "FillArrays", "FiniteDiff", "ForwardDiff", "FunctionWrappersWrappers", "InteractiveUtils", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "MacroTools", "MuladdMacro", "NonlinearSolve", "OrdinaryDiffEqAdamsBashforthMoulton", "OrdinaryDiffEqBDF", "OrdinaryDiffEqCore", "OrdinaryDiffEqDefault", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqExplicitRK", "OrdinaryDiffEqExponentialRK", "OrdinaryDiffEqExtrapolation", "OrdinaryDiffEqFIRK", "OrdinaryDiffEqFeagin", "OrdinaryDiffEqFunctionMap", "OrdinaryDiffEqHighOrderRK", "OrdinaryDiffEqIMEXMultistep", "OrdinaryDiffEqLinear", "OrdinaryDiffEqLowOrderRK", "OrdinaryDiffEqLowStorageRK", "OrdinaryDiffEqNonlinearSolve", "OrdinaryDiffEqNordsieck", "OrdinaryDiffEqPDIRK", "OrdinaryDiffEqPRK", "OrdinaryDiffEqQPRK", "OrdinaryDiffEqRKN", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqSDIRK", "OrdinaryDiffEqSSPRK", "OrdinaryDiffEqStabilizedIRK", "OrdinaryDiffEqStabilizedRK", "OrdinaryDiffEqSymplecticRK", "OrdinaryDiffEqTsit5", "OrdinaryDiffEqVerner", "Polyester", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleNonlinearSolve", "SimpleUnPack", "SparseArrays", "SparseDiffTools", "Static", "StaticArrayInterface", "StaticArrays", "TruncatedStacktraces"] -git-tree-sha1 = "cd892f12371c287dc50d6ad3af075b088b6f2d48" -uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" -version = "6.89.0" - -[[deps.OrdinaryDiffEqAdamsBashforthMoulton]] -deps = ["ADTypes", "DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqLowOrderRK", "Polyester", "RecursiveArrayTools", "Reexport", "Static"] -git-tree-sha1 = "8e3c5978d0531a961f70d2f2730d1d16ed3bbd12" -uuid = "89bda076-bce5-4f1c-845f-551c83cdda9a" -version = "1.1.0" - [[deps.OrdinaryDiffEqBDF]] deps = ["ArrayInterface", "DiffEqBase", "FastBroadcast", "LinearAlgebra", "MacroTools", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "OrdinaryDiffEqSDIRK", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "StaticArrays", "TruncatedStacktraces"] git-tree-sha1 = "b4498d40bf35da0b6d22652ff2e9d8820590b3c6" @@ -1963,108 +1945,12 @@ git-tree-sha1 = "e63ec633b1efa99e3caa2e26a01faaa88ba6cef9" uuid = "4302a76b-040a-498a-8c04-15b101fed76b" version = "1.1.0" -[[deps.OrdinaryDiffEqExplicitRK]] -deps = ["DiffEqBase", "FastBroadcast", "LinearAlgebra", "MuladdMacro", "OrdinaryDiffEqCore", "RecursiveArrayTools", "Reexport", "TruncatedStacktraces"] -git-tree-sha1 = "4dbce3f9e6974567082ce5176e21aab0224a69e9" -uuid = "9286f039-9fbf-40e8-bf65-aa933bdc4db0" -version = "1.1.0" - -[[deps.OrdinaryDiffEqExponentialRK]] -deps = ["DiffEqBase", "ExponentialUtilities", "FastBroadcast", "LinearAlgebra", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqSDIRK", "OrdinaryDiffEqVerner", "RecursiveArrayTools", "Reexport", "SciMLBase"] -git-tree-sha1 = "f63938b8e9e5d3a05815defb3ebdbdcf61ec0a74" -uuid = "e0540318-69ee-4070-8777-9e2de6de23de" -version = "1.1.0" - -[[deps.OrdinaryDiffEqExtrapolation]] -deps = ["DiffEqBase", "FastBroadcast", "LinearSolve", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "Polyester", "RecursiveArrayTools", "Reexport"] -git-tree-sha1 = "fea595528a160ed5cade9eee217a9691b1d97714" -uuid = "becaefa8-8ca2-5cf9-886d-c06f3d2bd2c4" -version = "1.1.0" - -[[deps.OrdinaryDiffEqFIRK]] -deps = ["DiffEqBase", "FastBroadcast", "LinearAlgebra", "LinearSolve", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "RecursiveArrayTools", "Reexport", "SciMLOperators"] -git-tree-sha1 = "795221c662698851328cb7787965ab4a180d9468" -uuid = "5960d6e9-dd7a-4743-88e7-cf307b64f125" -version = "1.1.1" - -[[deps.OrdinaryDiffEqFeagin]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "RecursiveArrayTools", "Reexport", "Static"] -git-tree-sha1 = "a7cc74d3433db98e59dc3d58bc28174c6c290adf" -uuid = "101fe9f7-ebb6-4678-b671-3a81e7194747" -version = "1.1.0" - -[[deps.OrdinaryDiffEqFunctionMap]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "RecursiveArrayTools", "Reexport", "SciMLBase", "Static"] -git-tree-sha1 = "925a91583d1ab84f1f0fea121be1abf1179c5926" -uuid = "d3585ca7-f5d3-4ba6-8057-292ed1abd90f" -version = "1.1.1" - -[[deps.OrdinaryDiffEqHighOrderRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "RecursiveArrayTools", "Reexport", "Static"] -git-tree-sha1 = "103e017ff186ac39d731904045781c9bacfca2b0" -uuid = "d28bc4f8-55e1-4f49-af69-84c1a99f0f58" -version = "1.1.0" - -[[deps.OrdinaryDiffEqIMEXMultistep]] -deps = ["DiffEqBase", "FastBroadcast", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "Reexport"] -git-tree-sha1 = "9f8f52aad2399d7714b400ff9d203254b0a89c4a" -uuid = "9f002381-b378-40b7-97a6-27a27c83f129" -version = "1.1.0" - -[[deps.OrdinaryDiffEqLinear]] -deps = ["DiffEqBase", "ExponentialUtilities", "LinearAlgebra", "OrdinaryDiffEqCore", "OrdinaryDiffEqTsit5", "OrdinaryDiffEqVerner", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators"] -git-tree-sha1 = "0f81a77ede3da0dc714ea61e81c76b25db4ab87a" -uuid = "521117fe-8c41-49f8-b3b6-30780b3f0fb5" -version = "1.1.0" - -[[deps.OrdinaryDiffEqLowOrderRK]] -deps = ["DiffEqBase", "FastBroadcast", "LinearAlgebra", "MuladdMacro", "OrdinaryDiffEqCore", "RecursiveArrayTools", "Reexport", "SciMLBase", "Static"] -git-tree-sha1 = "d4bb32e09d6b68ce2eb45fb81001eab46f60717a" -uuid = "1344f307-1e59-4825-a18e-ace9aa3fa4c6" -version = "1.2.0" - -[[deps.OrdinaryDiffEqLowStorageRK]] -deps = ["Adapt", "DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "Static", "StaticArrays"] -git-tree-sha1 = "590561f3af623d5485d070b4d7044f8854535f5a" -uuid = "b0944070-b475-4768-8dec-fb6eb410534d" -version = "1.2.1" - [[deps.OrdinaryDiffEqNonlinearSolve]] deps = ["ADTypes", "ArrayInterface", "DiffEqBase", "FastBroadcast", "FastClosures", "ForwardDiff", "LinearAlgebra", "LinearSolve", "MuladdMacro", "NonlinearSolve", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "PreallocationTools", "RecursiveArrayTools", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleNonlinearSolve", "StaticArrays"] git-tree-sha1 = "a2a4119f3e35f7982f78e17beea7b12485d179e9" uuid = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8" version = "1.2.1" -[[deps.OrdinaryDiffEqNordsieck]] -deps = ["DiffEqBase", "FastBroadcast", "LinearAlgebra", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqTsit5", "Polyester", "RecursiveArrayTools", "Reexport", "Static"] -git-tree-sha1 = "ef44754f10e0dfb9bb55ded382afed44cd94ab57" -uuid = "c9986a66-5c92-4813-8696-a7ec84c806c8" -version = "1.1.0" - -[[deps.OrdinaryDiffEqPDIRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "Polyester", "Reexport", "StaticArrays"] -git-tree-sha1 = "a8b7f8107c477e07c6a6c00d1d66cac68b801bbc" -uuid = "5dd0a6cf-3d4b-4314-aa06-06d4e299bc89" -version = "1.1.0" - -[[deps.OrdinaryDiffEqPRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "Reexport"] -git-tree-sha1 = "da525d277962a1b76102c79f30cb0c31e13fe5b9" -uuid = "5b33eab2-c0f1-4480-b2c3-94bc1e80bda1" -version = "1.1.0" - -[[deps.OrdinaryDiffEqQPRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "RecursiveArrayTools", "Reexport", "Static"] -git-tree-sha1 = "332f9d17d0229218f66a73492162267359ba85e9" -uuid = "04162be5-8125-4266-98ed-640baecc6514" -version = "1.1.0" - -[[deps.OrdinaryDiffEqRKN]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "RecursiveArrayTools", "Reexport"] -git-tree-sha1 = "41c09d9c20877546490f907d8dffdd52690dd65f" -uuid = "af6ede74-add8-4cfd-b1df-9a4dbb109d7a" -version = "1.1.0" - [[deps.OrdinaryDiffEqRosenbrock]] deps = ["ADTypes", "DiffEqBase", "FastBroadcast", "FiniteDiff", "ForwardDiff", "LinearAlgebra", "LinearSolve", "MacroTools", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "Static"] git-tree-sha1 = "96b47cdd12cb4ce8f70d701b49f855271a462bd4" @@ -2077,30 +1963,6 @@ git-tree-sha1 = "f6683803a58de600ab7a26d2f49411c9923e9721" uuid = "2d112036-d095-4a1e-ab9a-08536f3ecdbf" version = "1.1.0" -[[deps.OrdinaryDiffEqSSPRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "Static", "StaticArrays"] -git-tree-sha1 = "7dbe4ac56f930df5e9abd003cedb54e25cbbea86" -uuid = "669c94d9-1f4b-4b64-b377-1aa079aa2388" -version = "1.2.0" - -[[deps.OrdinaryDiffEqStabilizedIRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "RecursiveArrayTools", "Reexport", "StaticArrays"] -git-tree-sha1 = "348fd6def9a88518715425025eadd58517017325" -uuid = "e3e12d00-db14-5390-b879-ac3dd2ef6296" -version = "1.1.0" - -[[deps.OrdinaryDiffEqStabilizedRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "RecursiveArrayTools", "Reexport", "StaticArrays"] -git-tree-sha1 = "1b0d894c880e25f7d0b022d7257638cf8ce5b311" -uuid = "358294b1-0aab-51c3-aafe-ad5ab194a2ad" -version = "1.1.0" - -[[deps.OrdinaryDiffEqSymplecticRK]] -deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "RecursiveArrayTools", "Reexport"] -git-tree-sha1 = "4e8b8c8b81df3df17e2eb4603115db3b30a88235" -uuid = "fa646aed-7ef9-47eb-84c4-9443fc8cbfa8" -version = "1.1.0" - [[deps.OrdinaryDiffEqTsit5]] deps = ["DiffEqBase", "FastBroadcast", "LinearAlgebra", "MuladdMacro", "OrdinaryDiffEqCore", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "Static", "TruncatedStacktraces"] git-tree-sha1 = "96552f7d4619fabab4038a29ed37dd55e9eb513a" diff --git a/docs/Project.toml b/docs/Project.toml index d9bfc821..7097dabf 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -8,6 +8,8 @@ Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" ModelingToolkitStandardLibrary = "16a59e39-deab-5bd0-87e4-056b12336739" Multibody = "e1cad5d1-98ef-44f9-a79a-9ca4547f95b9" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" +OrdinaryDiffEqBDF = "6ad6398a-0878-4a85-9266-38940aa047c8" +OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce" +OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" RobustAndOptimalControl = "21fd56a4-db03-40ee-82ee-a87907bee541" diff --git a/docs/src/examples/free_motion.md b/docs/src/examples/free_motion.md index 3f2ecd6b..afa1b4a3 100644 --- a/docs/src/examples/free_motion.md +++ b/docs/src/examples/free_motion.md @@ -6,7 +6,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/gearbox.md b/docs/src/examples/gearbox.md index 3d1f0aeb..3b8eccf5 100644 --- a/docs/src/examples/gearbox.md +++ b/docs/src/examples/gearbox.md @@ -11,7 +11,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/gyroscopic_effects.md b/docs/src/examples/gyroscopic_effects.md index b3b93818..60f48200 100644 --- a/docs/src/examples/gyroscopic_effects.md +++ b/docs/src/examples/gyroscopic_effects.md @@ -12,7 +12,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqBDF t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/kinematic_loops.md b/docs/src/examples/kinematic_loops.md index 29f34abd..e4029229 100644 --- a/docs/src/examples/kinematic_loops.md +++ b/docs/src/examples/kinematic_loops.md @@ -27,7 +27,7 @@ using Multibody using ModelingToolkit import ModelingToolkitStandardLibrary.Mechanical.Rotational using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqBDF using LinearAlgebra using JuliaSimCompiler diff --git a/docs/src/examples/pendulum.md b/docs/src/examples/pendulum.md index 788608aa..f035d1ab 100644 --- a/docs/src/examples/pendulum.md +++ b/docs/src/examples/pendulum.md @@ -5,7 +5,7 @@ To start, we load the required packages ```@example pendulum using ModelingToolkit using Multibody, JuliaSimCompiler -using OrdinaryDiffEq # Contains the ODE solver we will use +using OrdinaryDiffEqRosenbrock # Contains the ODE solver we will use using Plots ``` We then access the world frame and time variable from the Multibody module @@ -57,7 +57,7 @@ This results in a simplified model with the minimum required variables and equat multibody ``` -We are now ready to create an `ODEProblem` and simulate it. We use the `Rodas4` solver from OrdinaryDiffEq.jl, and pass a dictionary for the initial conditions. We specify only initial condition for some variables, for those variables where no initial condition is specified, the default initial condition defined the model will be used. +We are now ready to create an `ODEProblem` and simulate it. We use the `Rodas4` solver from OrdinaryDiffEqRosenbrock.jl, and pass a dictionary for the initial conditions. We specify only initial condition for some variables, for those variables where no initial condition is specified, the default initial condition defined the model will be used. ```@example pendulum D = Differential(t) defs = Dict() # We may specify the initial condition here @@ -187,7 +187,7 @@ The systems we have modeled so far have all been _planar_ mechanisms. We now ext This pendulum, sometimes referred to as a _rotary pendulum_, has two joints, one in the "shoulder", which is typically configured to rotate around the gravitational axis, and one in the "elbow", which is typically configured to rotate around the axis of the upper arm. The upper arm is attached to the shoulder joint, and the lower arm is attached to the elbow joint. The tip of the pendulum is attached to the lower arm. ```@example pendulum -using ModelingToolkit, Multibody, JuliaSimCompiler, OrdinaryDiffEq, Plots +using ModelingToolkit, Multibody, JuliaSimCompiler, OrdinaryDiffEqRosenbrock, Plots import ModelingToolkitStandardLibrary.Mechanical.Rotational.Damper as RDamper import Multibody.Rotations @@ -326,6 +326,7 @@ We will continue the pendulum theme and design an inverted pendulum on cart. The We start by putting the model together and control it in open loop using a simple periodic input signal: ```@example pendulum +using OrdinaryDiffEqTsit5 import ModelingToolkitStandardLibrary.Mechanical.TranslationalModelica import ModelingToolkitStandardLibrary.Blocks using Plots diff --git a/docs/src/examples/prescribed_pose.md b/docs/src/examples/prescribed_pose.md index 2cd3f0c6..6c533644 100644 --- a/docs/src/examples/prescribed_pose.md +++ b/docs/src/examples/prescribed_pose.md @@ -23,7 +23,7 @@ using Multibody using Multibody.Rotations # To specify orientations using Euler angles using ModelingToolkit using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock using LinearAlgebra using JuliaSimCompiler using Test diff --git a/docs/src/examples/quad.md b/docs/src/examples/quad.md index ff1d60a6..3609f0c7 100644 --- a/docs/src/examples/quad.md +++ b/docs/src/examples/quad.md @@ -13,7 +13,7 @@ using ModelingToolkitStandardLibrary.Blocks using LinearAlgebra using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqBDF using Test t = Multibody.t D = Differential(t) @@ -336,3 +336,79 @@ nothing While gain and phase margins appear to be reasonable, we have a large high-frequency gain in the transfer functions from measurement noise to control signal, ``C(s)S(s)``. For a rotor craft where the control signal manipulates the current through motor windings, this may lead to excessive heat generation in the motors if the sensor measurements are noisy. The diskmargin at the plant output is small, luckily, the gain variation appears at the plant input where the diskmargin is significantly larger. The diskmargins are visualized in the figure titled "Stable region for combined gain and phase variation". See [Diskmargin example](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/#Diskmargin-example) to learn more about diskmargins. + +```@example QUAD +using LowLevelParticleFilters, SeeToDee, StaticArrays + +Ts = 0.02 +tv = range(0, 7, step=Ts) +Y = [SVector(i...) .+ 0.01 .* randn.() for i in sol(tv, idxs=outputs)] +Y0 = [SVector(i...) for i in sol(tv, idxs=outputs)] +U = [SVector(i...) .+ 0.2 .* randn.() for i in sol(tv, idxs=inputs)] +X = Matrix(sol(tv, idxs=x_sym)) +## + +state_parameters = [quad.body.m] + +function dyn_with_state_parameters(mmodel, inputs, state_parameters) + fdyn, x_sym, p_sym, io_sys = ModelingToolkit.generate_control_function(mmodel, inputs) + + p_inds = [findfirst(x -> string(x) == string(p), p_sym) for p in state_parameters] + # @info "found" p_sym[p_inds] + + nx_orig = length(x_sym) + nx_extended = nx_orig + length(state_parameters) + + p1 = copy(p) + dx = zeros(nx_orig) + out = zeros(nx_extended) + + f_ext = function (x, u, p, t) + for (i, p_ind) in enumerate(p_inds) + p1[p_ind] = max(x[nx_orig + i], 0.1) # NOTE: temp hack + end + dx .= 0 + fdyn(dx, x, u, p1, t) + @views out[1:nx_orig] .= dx + # [dx; x[nx_orig+1:end]] + @views out[nx_orig+1:end] .= x[nx_orig+1:end] + out + end + # f_ext, [x_sym; p_sym[p_inds]], p_sym[1:end-length(inputs)], io_sys + f_ext, [x_sym; p_sym[p_inds]], p_sym, io_sys +end + +fdyn, x_sym, p_sym, io_sys = dyn_with_state_parameters(multibody(quad), inputs, state_parameters) + +g = JuliaSimCompiler.build_explicit_observed_function(io_sys, outputs; inputs) +nx = length(x_sym) +nu = length(inputs) +ny = length(outputs) +x = randn(nx) +u = randn(nu) + +op = [ + quad.body.r_0[2] => 1e-32 + quad.v_alt => 1e-32 # To avoid singularity in linearization + quad.world.g => 9.81 + inputs .=> 13; + quad.body.m => 2 # We pretend that the body mass is close to cable+load+body mass for better altitude estimation +] |> Dict +## +x0, p = JuliaSimCompiler.initial_conditions(io_sys, op, op) +y0 = g(x0, u, p, 0) +R1 = collect(0.001I(nx)) +R1[end] = 0.01 +R2 = 0.01^2 * I(ny) + +d0 = LowLevelParticleFilters.MvNormal([x0; 2], R1) +discrete_dynamics = SeeToDee.Rk4(fdyn, 0.01) + +ukf = UnscentedKalmanFilter(discrete_dynamics, g, R1, R2, d0; p, nu, ny) + + +@time filtersol = forward_trajectory(ukf, U, Y) +plot(filtersol, size=(1200, 1000), ploty=false, plotu=false) +X[end,:] .= 5.3 +plot!(X', sp=(1:nx)', label=false, l=(:black, :dash)) +``` \ No newline at end of file diff --git a/docs/src/examples/robot.md b/docs/src/examples/robot.md index 608f229c..f07a68c7 100644 --- a/docs/src/examples/robot.md +++ b/docs/src/examples/robot.md @@ -7,7 +7,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock using Test t = Multibody.t diff --git a/docs/src/examples/ropes_and_cables.md b/docs/src/examples/ropes_and_cables.md index db5a8c77..a3c78889 100644 --- a/docs/src/examples/ropes_and_cables.md +++ b/docs/src/examples/ropes_and_cables.md @@ -16,7 +16,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock using Test t = Multibody.t diff --git a/docs/src/examples/sensors.md b/docs/src/examples/sensors.md index 2bcb730f..adb1174c 100644 --- a/docs/src/examples/sensors.md +++ b/docs/src/examples/sensors.md @@ -8,7 +8,7 @@ using Multibody using ModelingToolkit using JuliaSimCompiler using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock using LinearAlgebra t = Multibody.t @@ -37,7 +37,6 @@ ssys = structural_simplify(multibody(model)) D = Differential(t) prob = ODEProblem(ssys, [], (0, 3)) -using OrdinaryDiffEq sol = solve(prob, Rodas4()) @assert SciMLBase.successful_retcode(sol) diff --git a/docs/src/examples/space.md b/docs/src/examples/space.md index 71d822da..31a9a721 100644 --- a/docs/src/examples/space.md +++ b/docs/src/examples/space.md @@ -19,7 +19,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/spherical_pendulum.md b/docs/src/examples/spherical_pendulum.md index 4ae108e5..3e083b05 100644 --- a/docs/src/examples/spherical_pendulum.md +++ b/docs/src/examples/spherical_pendulum.md @@ -10,7 +10,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/spring_damper_system.md b/docs/src/examples/spring_damper_system.md index fa7375ce..aec3754f 100644 --- a/docs/src/examples/spring_damper_system.md +++ b/docs/src/examples/spring_damper_system.md @@ -13,7 +13,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/spring_mass_system.md b/docs/src/examples/spring_mass_system.md index b5ea518a..202f7f93 100644 --- a/docs/src/examples/spring_mass_system.md +++ b/docs/src/examples/spring_mass_system.md @@ -14,7 +14,7 @@ using ModelingToolkit using Plots using JuliaSimCompiler using ModelingToolkitStandardLibrary.Mechanical.TranslationalModelica -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/suspension.md b/docs/src/examples/suspension.md index 20ef81fa..e6f6a054 100644 --- a/docs/src/examples/suspension.md +++ b/docs/src/examples/suspension.md @@ -11,7 +11,7 @@ using Multibody using ModelingToolkit import ModelingToolkitStandardLibrary.Mechanical.TranslationalModelica as Translational using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqBDF, OrdinaryDiffEqRosenbrock using LinearAlgebra using JuliaSimCompiler using Test diff --git a/docs/src/examples/swing.md b/docs/src/examples/swing.md index 939672a2..674ccd4d 100644 --- a/docs/src/examples/swing.md +++ b/docs/src/examples/swing.md @@ -12,7 +12,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqBDF t = Multibody.t D = Differential(t) @@ -64,8 +64,9 @@ ssys = structural_simplify(multibody(model)) prob = ODEProblem(ssys, [ collect(model.body.v_0) .=> 0; collect(model.body.w_a) .=> 0; + collect(model.body.r_0) .=> [0.5, 2, 0.1]; # To make the animation interesting ], (0, 4)) -sol = solve(prob, ImplicitEuler(autodiff=false), reltol=5e-3) +sol = solve(prob, QNDF1(autodiff=false), reltol=5e-3) @assert SciMLBase.successful_retcode(sol) ``` @@ -149,7 +150,7 @@ prob = ODEProblem(ssys, [ ], (0.0, 6)) -@time sol = solve(prob, ImplicitEuler(autodiff=false), reltol=1e-2) +@time sol = solve(prob, QNDF1(autodiff=false), reltol=1e-2) @assert SciMLBase.successful_retcode(sol) Plots.plot(sol, idxs = [collect(model.body.r_0);]) @@ -162,5 +163,3 @@ nothing # hide ``` ![animation](swing.gif) - -There is an initial transient in the beginning where the springs in the ropes are vibrating substantially, but after about a second this transient is damped out (thanks in part to the, in this case desired, numerical damping contributed by the implicit Euler solver). \ No newline at end of file diff --git a/docs/src/examples/three_springs.md b/docs/src/examples/three_springs.md index 31909eff..e48cacc3 100644 --- a/docs/src/examples/three_springs.md +++ b/docs/src/examples/three_springs.md @@ -12,7 +12,7 @@ using Multibody using ModelingToolkit using Plots using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock t = Multibody.t D = Differential(t) diff --git a/docs/src/examples/wheel.md b/docs/src/examples/wheel.md index d43ef4ab..bc3e13af 100644 --- a/docs/src/examples/wheel.md +++ b/docs/src/examples/wheel.md @@ -24,7 +24,7 @@ using ModelingToolkit import ModelingToolkitStandardLibrary.Mechanical.Rotational import ModelingToolkitStandardLibrary.Blocks using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock, OrdinaryDiffEqTsit5 using LinearAlgebra using JuliaSimCompiler using Test @@ -307,7 +307,7 @@ import ModelingToolkitStandardLibrary.Mechanical.Rotational import ModelingToolkitStandardLibrary.Blocks import Multibody.PlanarMechanics as Pl using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqRosenbrock using LinearAlgebra using JuliaSimCompiler using Test diff --git a/docs/src/index.md b/docs/src/index.md index 616ca538..aac3f34a 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -9,7 +9,7 @@ Documentation for [Multibody](https://github.com/JuliaComputing/Multibody.jl). ```@setup logo using ModelingToolkit using Multibody, JuliaSimCompiler -using OrdinaryDiffEq # Contains the ODE solver we will use +using OrdinaryDiffEqRosenbrock # Contains the ODE solver we will use using Plots t = Multibody.t @@ -161,6 +161,18 @@ import Pkg Pkg.add("Multibody") ``` +In addition to Multibody.jl, we recommend installing the following **solver packages** to follow along with the examples in the documentation +```julia +Pkg.add([ + "OrdinaryDiffEqBDF", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqTsit5" +]) +``` +Alternatively, install all available DAE solvers at the same time using (incurs lengthy pre compilation) +```julia +Pkg.add("OrdinaryDiffEq") +``` + + ## Notable differences from Modelica diff --git a/test/runtests.jl b/test/runtests.jl index 846f072e..2066c3fe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,7 @@ using ModelingToolkit using Multibody using Test using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqBDF, OrdinaryDiffEqRosenbrock, OrdinaryDiffEqTsit5 using LinearAlgebra t = Multibody.t D = Differential(t) @@ -136,7 +136,6 @@ D = Differential(t) defs = Dict() prob = ODEProblem(ssys, defs, (0, 10)) -using OrdinaryDiffEq sol = solve(prob, Rodas4()) @test SciMLBase.successful_retcode(sol) @test minimum(sol[joint.phi])≈-π rtol=0.01 diff --git a/test/test_JointUSR_RRR.jl b/test/test_JointUSR_RRR.jl index fb6c3506..c96ad76e 100644 --- a/test/test_JointUSR_RRR.jl +++ b/test/test_JointUSR_RRR.jl @@ -3,7 +3,7 @@ using Multibody using ModelingToolkit import ModelingToolkitStandardLibrary.Mechanical.Rotational # using Plots -using OrdinaryDiffEq +using OrdinaryDiffEqBDF using LinearAlgebra using JuliaSimCompiler diff --git a/test/test_PlanarMechanics.jl b/test/test_PlanarMechanics.jl index 29942dea..86606f54 100644 --- a/test/test_PlanarMechanics.jl +++ b/test/test_PlanarMechanics.jl @@ -1,6 +1,6 @@ # using Revise # using Plots -using ModelingToolkit, OrdinaryDiffEq, Test +using ModelingToolkit, OrdinaryDiffEqRosenbrock, Test using ModelingToolkit: t_nounits as t, D_nounits as D import ModelingToolkitStandardLibrary.Blocks import Multibody.PlanarMechanics as Pl diff --git a/test/test_fourbar.jl b/test/test_fourbar.jl index 169e798d..574fa195 100644 --- a/test/test_fourbar.jl +++ b/test/test_fourbar.jl @@ -2,7 +2,7 @@ using Test using Multibody using ModelingToolkit import ModelingToolkitStandardLibrary.Mechanical.Rotational -using OrdinaryDiffEq +using OrdinaryDiffEqBDF using LinearAlgebra using JuliaSimCompiler diff --git a/test/test_quaternions.jl b/test/test_quaternions.jl index 28c87b64..a9bf0915 100644 --- a/test/test_quaternions.jl +++ b/test/test_quaternions.jl @@ -69,7 +69,7 @@ end ## Simple motion with quaternions=============================================== # ============================================================================== using LinearAlgebra, ModelingToolkit, Multibody, JuliaSimCompiler -using OrdinaryDiffEq, Test +using Test @testset "Simple motion with quaternions and state in Body" begin @@ -169,7 +169,6 @@ end collect(joint.Q̂) .=> q0; ], (0, 2pi)) - using OrdinaryDiffEq, Test sol = solve(prob, Rodas4(); u0 = prob.u0 .+ 1e-6 .* randn.()) @test SciMLBase.successful_retcode(sol) # doplot() && plot(sol, layout=21) @@ -230,7 +229,6 @@ end collect(body.Q̂d) .=> [0,0,0,0]; ], (0, 30)) - using OrdinaryDiffEq, Test sol = solve(prob, Rodas5Pr(); u0 = prob.u0 .+ 0 .* randn.()) @test SciMLBase.successful_retcode(sol) # doplot() && plot(sol, layout=21) @@ -263,7 +261,6 @@ using Multibody using ModelingToolkit # using Plots using JuliaSimCompiler -using OrdinaryDiffEq using Multibody.Rotations: params @testset "FreeBody" begin diff --git a/test/test_robot.jl b/test/test_robot.jl index 4175f27c..1c22cd62 100644 --- a/test/test_robot.jl +++ b/test/test_robot.jl @@ -4,8 +4,8 @@ using Test using JuliaSimCompiler t = Multibody.t D = Differential(t) -using OrdinaryDiffEq -using OrdinaryDiffEq.SciMLBase: successful_retcode +using OrdinaryDiffEqRosenbrock +using OrdinaryDiffEqRosenbrock.SciMLBase: successful_retcode using Multibody: AccSensor,AxisType2,AxisType1,Controller,GearType2,BearingFriction,GearType1,Motor,MechanicalStructure,RobotAxis,Robot6DOF,PathPlanning1,PathPlanning6 diff --git a/test/test_urdf.jl b/test/test_urdf.jl index 71d920fd..997b70b3 100644 --- a/test/test_urdf.jl +++ b/test/test_urdf.jl @@ -9,7 +9,7 @@ include("doublependulum.jl") -using ModelingToolkit, Multibody, JuliaSimCompiler, OrdinaryDiffEq#, Plots +using ModelingToolkit, Multibody, JuliaSimCompiler, OrdinaryDiffEqTsit5#, Plots import ModelingToolkit: t_nounits as t, D_nounits as D @named model = DoublePendulum() diff --git a/test/test_worldforces.jl b/test/test_worldforces.jl index d1178fb9..889ad5e6 100644 --- a/test/test_worldforces.jl +++ b/test/test_worldforces.jl @@ -2,7 +2,7 @@ using ModelingToolkit using Multibody using Test using JuliaSimCompiler -using OrdinaryDiffEq +using OrdinaryDiffEqTsit5, OrdinaryDiffEqRosenbrock doplot() = false world = Multibody.world