diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 75de923a70c..b33a5c86f72 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-19T22:23:44","documenter_version":"1.1.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-20T04:27:53","documenter_version":"1.1.1"}} \ No newline at end of file diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index 606e61c51b8..8f252480806 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -1271,9 +1271,9 @@ version = "2.1.91+0" [[deps.JuliaFormatter]] deps = ["CSTParser", "CommonMark", "DataStructures", "Glob", "Pkg", "PrecompileTools", "Tokenize"] -git-tree-sha1 = "80031f6e58b09b0de4553bf63d9a36ec5db57967" +git-tree-sha1 = "0bac3374ff3aa798148669ecb5559ba20c8b0e73" uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899" -version = "1.0.39" +version = "1.0.40" [[deps.JuliaVariables]] deps = ["MLStyle", "NameResolution"] diff --git a/dev/comparisons/cppfortran/index.html b/dev/comparisons/cppfortran/index.html index 01dc18cac84..1115781211f 100644 --- a/dev/comparisons/cppfortran/index.html +++ b/dev/comparisons/cppfortran/index.html @@ -1,2 +1,2 @@ -Getting Started with Julia's SciML for the C++/Fortran User · Overview of Julia's SciML

Getting Started with Julia's SciML for the C++/Fortran User

You don't need help if you're a Fortran guru. I'm just kidding, you're not a Lisp developer. If you're coming from C++ or Fortran, you may be familiar with high-performance computing environments similar to SciML, such as PETSc, Trilinos, or Sundials. The following are some points to help the transition.

Why SciML? High-Level Workflow Reasons

If you're coming from “hardcore” C++/Fortran computing environments, some things to check out with Julia's SciML are:

  • Interactivity - use the interactive REPL to easily investigate numerical details.
  • Metaprogramming performance tools - tools like LoopVectorization.jl can be used to generate faster code than even some of the most hand-optimized C++/Fortran code. Current benchmarks show this SIMD-optimized Julia code outperforming OpenBLAS and MKL BLAS implementations in many performance regimes.
  • Symbolic modeling languages - writing models by hand can leave a lot of performance on the table. Using high-level modeling tools like ModelingToolkit can automate symbolic simplifications, which improve the stability and performance of numerical solvers. On complex models, even the best handwritten C++/Fortran code is orders of magnitude behind the code that symbolic tearing algorithms can achieve!
  • Composable Library Components - In C++/Fortran environments, every package feels like a silo. Arrays made for PETSc cannot easily be used in Trilinos, and converting Sundials NVector outputs to DataFrames for post-simulation data processing is a process itself. The Julia SciML environment embraces interoperability. Don't wait for SciML to do it: by using generic coding with JIT compilation, these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • Wrappers to the Libraries You Know and Trust - Moving to SciML does not have to be a quick transition. SciML has extensive wrappers to many widely-used classical solver environments such as SUNDIALS and Hairer's classic Fortran ODE solvers (dopri5, dop853, etc.). Using these wrapped solvers is painless and can be swapped in for the Julia versions with one line of code. This gives you a way to incrementally adopt new features/methods while retaining the older pieces you know and trust.
  • Don't Start from Scratch - SciML builds on the extensive Base library of Julia, and thus grows and improves with every update to the language. With hundreds of monthly contributors to SciML and hundreds of monthly contributors to Julia, SciML is one of the most actively developed open-source scientific computing ecosystems out there!
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, Sundials/Hairer in purple/red represent C++/Fortrans most commonly used solvers:

Why SciML? Some Technical Details

Let's face the facts, in the open benchmarks the pure-Julia solvers tend to outperform the classic “best” C++ and Fortran solvers in almost every example (with a few notable exceptions). But why?

The answer is two-fold: Julia is as fast as C++/Fortran, and the algorithms are what matter.

Julia is as Fast as C++/Fortran

While Julia code looks high level like Python or MATLAB, its performance is on par with C++ and Fortran. At a technical level, when Julia code is type-stable, i.e. that the types that are returned from a function are deducible at compile-time from the types that go into a function, then Julia can optimize it as much as C++ or Fortran by automatically devirtualizing all dynamic behavior and compile-time optimizing the quasi-static code. This is not an empirical statement, it's a provable type-theoretic result. The resulting compiler used on the resulting quasi-static representation is LLVM, the same optimizing compiler used by clang and LFortran.

For more details on how Julia code is optimized and how to optimize your own Julia code, check out this chapter from the SciML Book.

SciML's Julia Algorithms Have Performance Advantages in Many Common Regimes

There are many ways which Julia's algorithms achieve performance advantages. Some facts to highlight include:

Let's Dig Deep Into One Case: Adjoints of ODEs for Solving Inverse Problems

To really highlight how JIT compilation and automatic differentiation integration can change algorithms, let's look at the problem of differentiating an ODE solver. As is derived and discussed in detail at a seminar with the American Statistical Association, there are many ways to implement well-known “adjoint” methods which are required for performance. Each has different stability and performance trade-offs, and Julia's SciML is the only system to systemically offer all of the trade-off options. In many cases, using analytical adjoints of a solver is not advised due to performance reasons, with the trade-off described in detail here. Likewise, even when analytical adjoints are used, it turns out that for general nonlinear equations there is a trick which uses automatic differentiation in the construction of the analytical adjoint to improve its performance. As demonstrated in this publication, this can lead to about 2-3 orders of magnitude performance improvements. These AD-enhanced adjoints are showcased as the seeding methods in this plot:

Unless one directly defines special “vjp” functions, this is how the Julia SciML methods achieve orders of magnitude performance advantages over CVODES's adjoints and PETSC's TS-adjoint.

Moral of the story, even there are many reasons to use automatic differentiation of a solver, and even if an analytical adjoint rule is used for some specific performance reason, that analytical expression can often times be accelerated by orders of magnitude itself by embedding some form of automatic differentiation into it. This is just one algorithm of many which are optimized in this fashion.

+Getting Started with Julia's SciML for the C++/Fortran User · Overview of Julia's SciML

Getting Started with Julia's SciML for the C++/Fortran User

You don't need help if you're a Fortran guru. I'm just kidding, you're not a Lisp developer. If you're coming from C++ or Fortran, you may be familiar with high-performance computing environments similar to SciML, such as PETSc, Trilinos, or Sundials. The following are some points to help the transition.

Why SciML? High-Level Workflow Reasons

If you're coming from “hardcore” C++/Fortran computing environments, some things to check out with Julia's SciML are:

  • Interactivity - use the interactive REPL to easily investigate numerical details.
  • Metaprogramming performance tools - tools like LoopVectorization.jl can be used to generate faster code than even some of the most hand-optimized C++/Fortran code. Current benchmarks show this SIMD-optimized Julia code outperforming OpenBLAS and MKL BLAS implementations in many performance regimes.
  • Symbolic modeling languages - writing models by hand can leave a lot of performance on the table. Using high-level modeling tools like ModelingToolkit can automate symbolic simplifications, which improve the stability and performance of numerical solvers. On complex models, even the best handwritten C++/Fortran code is orders of magnitude behind the code that symbolic tearing algorithms can achieve!
  • Composable Library Components - In C++/Fortran environments, every package feels like a silo. Arrays made for PETSc cannot easily be used in Trilinos, and converting Sundials NVector outputs to DataFrames for post-simulation data processing is a process itself. The Julia SciML environment embraces interoperability. Don't wait for SciML to do it: by using generic coding with JIT compilation, these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • Wrappers to the Libraries You Know and Trust - Moving to SciML does not have to be a quick transition. SciML has extensive wrappers to many widely-used classical solver environments such as SUNDIALS and Hairer's classic Fortran ODE solvers (dopri5, dop853, etc.). Using these wrapped solvers is painless and can be swapped in for the Julia versions with one line of code. This gives you a way to incrementally adopt new features/methods while retaining the older pieces you know and trust.
  • Don't Start from Scratch - SciML builds on the extensive Base library of Julia, and thus grows and improves with every update to the language. With hundreds of monthly contributors to SciML and hundreds of monthly contributors to Julia, SciML is one of the most actively developed open-source scientific computing ecosystems out there!
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, Sundials/Hairer in purple/red represent C++/Fortrans most commonly used solvers:

Why SciML? Some Technical Details

Let's face the facts, in the open benchmarks the pure-Julia solvers tend to outperform the classic “best” C++ and Fortran solvers in almost every example (with a few notable exceptions). But why?

The answer is two-fold: Julia is as fast as C++/Fortran, and the algorithms are what matter.

Julia is as Fast as C++/Fortran

While Julia code looks high level like Python or MATLAB, its performance is on par with C++ and Fortran. At a technical level, when Julia code is type-stable, i.e. that the types that are returned from a function are deducible at compile-time from the types that go into a function, then Julia can optimize it as much as C++ or Fortran by automatically devirtualizing all dynamic behavior and compile-time optimizing the quasi-static code. This is not an empirical statement, it's a provable type-theoretic result. The resulting compiler used on the resulting quasi-static representation is LLVM, the same optimizing compiler used by clang and LFortran.

For more details on how Julia code is optimized and how to optimize your own Julia code, check out this chapter from the SciML Book.

SciML's Julia Algorithms Have Performance Advantages in Many Common Regimes

There are many ways which Julia's algorithms achieve performance advantages. Some facts to highlight include:

Let's Dig Deep Into One Case: Adjoints of ODEs for Solving Inverse Problems

To really highlight how JIT compilation and automatic differentiation integration can change algorithms, let's look at the problem of differentiating an ODE solver. As is derived and discussed in detail at a seminar with the American Statistical Association, there are many ways to implement well-known “adjoint” methods which are required for performance. Each has different stability and performance trade-offs, and Julia's SciML is the only system to systemically offer all of the trade-off options. In many cases, using analytical adjoints of a solver is not advised due to performance reasons, with the trade-off described in detail here. Likewise, even when analytical adjoints are used, it turns out that for general nonlinear equations there is a trick which uses automatic differentiation in the construction of the analytical adjoint to improve its performance. As demonstrated in this publication, this can lead to about 2-3 orders of magnitude performance improvements. These AD-enhanced adjoints are showcased as the seeding methods in this plot:

Unless one directly defines special “vjp” functions, this is how the Julia SciML methods achieve orders of magnitude performance advantages over CVODES's adjoints and PETSC's TS-adjoint.

Moral of the story, even there are many reasons to use automatic differentiation of a solver, and even if an analytical adjoint rule is used for some specific performance reason, that analytical expression can often times be accelerated by orders of magnitude itself by embedding some form of automatic differentiation into it. This is just one algorithm of many which are optimized in this fashion.

diff --git a/dev/comparisons/matlab/index.html b/dev/comparisons/matlab/index.html index ec931696504..7eee4168624 100644 --- a/dev/comparisons/matlab/index.html +++ b/dev/comparisons/matlab/index.html @@ -1,2 +1,2 @@ -Getting Started with Julia's SciML for the MATLAB User · Overview of Julia's SciML

Getting Started with Julia's SciML for the MATLAB User

If you're a MATLAB user who has looked into Julia for some performance improvements, you may have noticed that the standard library does not have all of the “batteries” included with a base MATLAB installation. Where's the ODE solver? Where's fmincon and fsolve? Those scientific computing functionalities are the pieces provided by the Julia SciML ecosystem!

Why SciML? High-Level Workflow Reasons

  • Performance - The key reason people are moving from MATLAB to Julia's SciML in droves is performance. Even simple ODE solvers are much faster!, demonstrating orders of magnitude performance improvements for differential equations, nonlinear solving, optimization, and more. And the performance advantages continue to grow as more complex algorithms are required.
  • Julia is quick to learn from MATLAB - Most ODE codes can be translated in a few minutes. If you need help, check out the QuantEcon MATLAB-Python-Julia Cheat Sheet.
  • Package Management and Versioning - Julia's package manager takes care of dependency management, testing, and continuous delivery in order to make the installation and maintenance process smoother. For package users, this means it's easier to get packages with complex functionality in your hands.
  • Free and Open Source - If you want to know how things are being computed, just look at our GitHub organization. Lots of individuals use Julia's SciML to research how the algorithms actually work because of how accessible and tweakable the ecosystem is!
  • Composable Library Components - In MATLAB environments, every package feels like a silo. Functions made for one file exchange library cannot easily compose with another. SciML's generic coding with JIT compilation these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, MATLAB in orange represents MATLAB's most commonly used solvers:

Need a case study?

Check out this talk from NASA Scientists getting a 15,000x acceleration by switching from Simulink to Julia's ModelingToolkit!

Need Help Translating from MATLAB to Julia?

The following resources can be particularly helpful when adopting Julia for SciML for the first time:

MATLAB to Julia SciML Functionality Translations

The following chart will help you get quickly acquainted with Julia's SciML Tools:

MATLAB FunctionSciML-Supported Julia packages
plotPlots, Makie
sparseSparseArrays
interp1DataInterpolations
\, gmres, cgLinearSolve
fsolveNonlinearSolve
quadIntegrals
fminconOptimization
odeXXDifferentialEquations
ode45Tsit5
ode113VCABM
ode23sRosenbrock23
ode15sQNDF or FBDF
ode15iIDA
bvp4c and bvp5cDifferentialEquations
Simulink, SimscapeModelingToolkit
fftFFTW
chebfunApproxFun
+Getting Started with Julia's SciML for the MATLAB User · Overview of Julia's SciML

Getting Started with Julia's SciML for the MATLAB User

If you're a MATLAB user who has looked into Julia for some performance improvements, you may have noticed that the standard library does not have all of the “batteries” included with a base MATLAB installation. Where's the ODE solver? Where's fmincon and fsolve? Those scientific computing functionalities are the pieces provided by the Julia SciML ecosystem!

Why SciML? High-Level Workflow Reasons

  • Performance - The key reason people are moving from MATLAB to Julia's SciML in droves is performance. Even simple ODE solvers are much faster!, demonstrating orders of magnitude performance improvements for differential equations, nonlinear solving, optimization, and more. And the performance advantages continue to grow as more complex algorithms are required.
  • Julia is quick to learn from MATLAB - Most ODE codes can be translated in a few minutes. If you need help, check out the QuantEcon MATLAB-Python-Julia Cheat Sheet.
  • Package Management and Versioning - Julia's package manager takes care of dependency management, testing, and continuous delivery in order to make the installation and maintenance process smoother. For package users, this means it's easier to get packages with complex functionality in your hands.
  • Free and Open Source - If you want to know how things are being computed, just look at our GitHub organization. Lots of individuals use Julia's SciML to research how the algorithms actually work because of how accessible and tweakable the ecosystem is!
  • Composable Library Components - In MATLAB environments, every package feels like a silo. Functions made for one file exchange library cannot easily compose with another. SciML's generic coding with JIT compilation these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, MATLAB in orange represents MATLAB's most commonly used solvers:

Need a case study?

Check out this talk from NASA Scientists getting a 15,000x acceleration by switching from Simulink to Julia's ModelingToolkit!

Need Help Translating from MATLAB to Julia?

The following resources can be particularly helpful when adopting Julia for SciML for the first time:

MATLAB to Julia SciML Functionality Translations

The following chart will help you get quickly acquainted with Julia's SciML Tools:

MATLAB FunctionSciML-Supported Julia packages
plotPlots, Makie
sparseSparseArrays
interp1DataInterpolations
\, gmres, cgLinearSolve
fsolveNonlinearSolve
quadIntegrals
fminconOptimization
odeXXDifferentialEquations
ode45Tsit5
ode113VCABM
ode23sRosenbrock23
ode15sQNDF or FBDF
ode15iIDA
bvp4c and bvp5cDifferentialEquations
Simulink, SimscapeModelingToolkit
fftFFTW
chebfunApproxFun
diff --git a/dev/comparisons/python/index.html b/dev/comparisons/python/index.html index a517efe5bdc..05b0f5daa28 100644 --- a/dev/comparisons/python/index.html +++ b/dev/comparisons/python/index.html @@ -1,2 +1,2 @@ -Getting Started with Julia's SciML for the Python User · Overview of Julia's SciML

Getting Started with Julia's SciML for the Python User

If you're a Python user who has looked into Julia, you're probably wondering what is the equivalent to SciPy is. And you found it: it's the SciML ecosystem! To a Python developer, SciML is SciPy, but with the high-performance GPU, capabilities of PyTorch, and neural network capabilities, all baked right in. With SciML, there is no “separate world” of machine learning sublanguages: there is just one cohesive package ecosystem.

Why SciML? High-Level Workflow Reasons

  • Performance - The key reason people are moving from SciPy to Julia's SciML in droves is performance. Even simple ODE solvers are much faster!, demonstrating orders of magnitude performance improvements for differential equations, nonlinear solving, optimization, and more. And the performance advantages continue to grow as more complex algorithms are required.
  • Package Management and Versioning - Julia's package manager takes care of dependency management, testing, and continuous delivery in order to make the installation and maintenance process smoother. For package users, this means it's easier to get packages with complex functionality in your hands.
  • Composable Library Components - In Python environments, every package feels like a silo. Functions made for one file exchange library cannot easily compose with another. SciML's generic coding with JIT compilation these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, SciPy in yellow represents Python's most commonly used solvers:

Need Help Translating from Python to Julia?

The following resources can be particularly helpful when adopting Julia for SciML for the first time:

Python to Julia SciML Functionality Translations

The following chart will help you get quickly acquainted with Julia's SciML Tools:

Workflow ElementSciML-Supported Julia packages
MatplotlibPlots, Makie
scipy.specialSpecialFunctions
scipy.linalg.solveLinearSolve
scipy.integrateIntegrals
scipy.optimizeOptimization
scipy.optimize.fsolveNonlinearSolve
scipy.interpolateDataInterpolations
scipy.fftFFTW
scipy.linalgJulia's Built-In Linear Algebra
scipy.sparseSparseArrays, ARPACK
odeint/solve_ivpDifferentialEquations
scipy.integrate.solve_bvpBoundary-value problem
PyTorchFlux, Lux
gillespy2Catalyst, JumpProcesses
scipy.optimize.approx_fprimeFiniteDiff
autogradForwardDiff*, Enzyme*, DiffEqSensitivity
StanTuring
sympySymbolics

Why is Differentiable Programming Important for Scientific Computing?

Check out this blog post that goes into detail on how training neural networks in tandem with simulation improves performance by orders of magnitude. But can't you use analytical adjoint definitions? You can, but there are tricks to mix automatic differentiation into the adjoint definitions for a few orders of magnitude improvement too, as explained in this blog post.

These facts, along with many others, compose to algorithmic improvements with the implementation improvements, which leads to orders of magnitude improvements!

+Getting Started with Julia's SciML for the Python User · Overview of Julia's SciML

Getting Started with Julia's SciML for the Python User

If you're a Python user who has looked into Julia, you're probably wondering what is the equivalent to SciPy is. And you found it: it's the SciML ecosystem! To a Python developer, SciML is SciPy, but with the high-performance GPU, capabilities of PyTorch, and neural network capabilities, all baked right in. With SciML, there is no “separate world” of machine learning sublanguages: there is just one cohesive package ecosystem.

Why SciML? High-Level Workflow Reasons

  • Performance - The key reason people are moving from SciPy to Julia's SciML in droves is performance. Even simple ODE solvers are much faster!, demonstrating orders of magnitude performance improvements for differential equations, nonlinear solving, optimization, and more. And the performance advantages continue to grow as more complex algorithms are required.
  • Package Management and Versioning - Julia's package manager takes care of dependency management, testing, and continuous delivery in order to make the installation and maintenance process smoother. For package users, this means it's easier to get packages with complex functionality in your hands.
  • Composable Library Components - In Python environments, every package feels like a silo. Functions made for one file exchange library cannot easily compose with another. SciML's generic coding with JIT compilation these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, SciPy in yellow represents Python's most commonly used solvers:

Need Help Translating from Python to Julia?

The following resources can be particularly helpful when adopting Julia for SciML for the first time:

Python to Julia SciML Functionality Translations

The following chart will help you get quickly acquainted with Julia's SciML Tools:

Workflow ElementSciML-Supported Julia packages
MatplotlibPlots, Makie
scipy.specialSpecialFunctions
scipy.linalg.solveLinearSolve
scipy.integrateIntegrals
scipy.optimizeOptimization
scipy.optimize.fsolveNonlinearSolve
scipy.interpolateDataInterpolations
scipy.fftFFTW
scipy.linalgJulia's Built-In Linear Algebra
scipy.sparseSparseArrays, ARPACK
odeint/solve_ivpDifferentialEquations
scipy.integrate.solve_bvpBoundary-value problem
PyTorchFlux, Lux
gillespy2Catalyst, JumpProcesses
scipy.optimize.approx_fprimeFiniteDiff
autogradForwardDiff*, Enzyme*, DiffEqSensitivity
StanTuring
sympySymbolics

Why is Differentiable Programming Important for Scientific Computing?

Check out this blog post that goes into detail on how training neural networks in tandem with simulation improves performance by orders of magnitude. But can't you use analytical adjoint definitions? You can, but there are tricks to mix automatic differentiation into the adjoint definitions for a few orders of magnitude improvement too, as explained in this blog post.

These facts, along with many others, compose to algorithmic improvements with the implementation improvements, which leads to orders of magnitude improvements!

diff --git a/dev/comparisons/r/index.html b/dev/comparisons/r/index.html index 74daca3ef1d..d38aa68e13b 100644 --- a/dev/comparisons/r/index.html +++ b/dev/comparisons/r/index.html @@ -1,2 +1,2 @@ -Getting Started with Julia's SciML for the R User · Overview of Julia's SciML

Getting Started with Julia's SciML for the R User

If you're an R user who has looked into Julia, you're probably wondering where all of the scientific computing packages are. How do I solve ODEs? Solve f(x)=0 for x? Etc. SciML is the ecosystem for doing this with Julia.

Why SciML? High-Level Workflow Reasons

  • Performance - The key reason people are moving from R to Julia's SciML in droves is performance. Even simple ODE solvers are much faster!, demonstrating orders of magnitude performance improvements for differential equations, nonlinear solving, optimization, and more. And the performance advantages continue to grow as more complex algorithms are required.
  • Composable Library Components - In R environments, every package feels like a silo. Functions made for one file exchange library cannot easily compose with another. SciML's generic coding with JIT compilation these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • A Global Harmonious Documentation for Scientific Computing - R's documentation for scientific computing is scattered in a bunch of individual packages where the developers do not talk to each other! This not only leads to documentation differences, but also “style” differences: one package uses tol while the other uses atol. With Julia's SciML, the whole ecosystem is considered together, and inconsistencies are handled at the global level. The goal is to be working in one environment with one language.
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, deSolve in blue represents R's most commonly used solver:

Need Help Translating from R to Julia?

The following resources can be particularly helpful when adopting Julia for SciML for the first time:

R to Julia SciML Functionality Translations

The following chart will help you get quickly acquainted with Julia's SciML Tools:

R Function/PackageSciML-Supported Julia packages
data.frameDataFrames
plotPlots, Makie
ggplot2AlgebraOfGraphics
deSolveDifferentialEquations
StanTuring

Want to See the Power of Julia?

Check out this R-Bloggers blog post on diffeqr, a package which uses ModelingToolkit to translate R code to Julia, and achieves 350x acceleration over R's popular deSolve ODE solver package. But when the solve is done purely in Julia, it achieves 2777x acceleration over deSolve!

+Getting Started with Julia's SciML for the R User · Overview of Julia's SciML

Getting Started with Julia's SciML for the R User

If you're an R user who has looked into Julia, you're probably wondering where all of the scientific computing packages are. How do I solve ODEs? Solve f(x)=0 for x? Etc. SciML is the ecosystem for doing this with Julia.

Why SciML? High-Level Workflow Reasons

  • Performance - The key reason people are moving from R to Julia's SciML in droves is performance. Even simple ODE solvers are much faster!, demonstrating orders of magnitude performance improvements for differential equations, nonlinear solving, optimization, and more. And the performance advantages continue to grow as more complex algorithms are required.
  • Composable Library Components - In R environments, every package feels like a silo. Functions made for one file exchange library cannot easily compose with another. SciML's generic coding with JIT compilation these connections create new optimized code on the fly and allow for a more expansive feature set than can ever be documented. Take new high-precision number types from a package and stick them into a nonlinear solver. Take a package for Intel GPU arrays and stick it into the differential equation solver to use specialized hardware acceleration.
  • A Global Harmonious Documentation for Scientific Computing - R's documentation for scientific computing is scattered in a bunch of individual packages where the developers do not talk to each other! This not only leads to documentation differences, but also “style” differences: one package uses tol while the other uses atol. With Julia's SciML, the whole ecosystem is considered together, and inconsistencies are handled at the global level. The goal is to be working in one environment with one language.
  • Easier High-Performance and Parallel Computing - With Julia's ecosystem, CUDA will automatically install of the required binaries and cu(A)*cu(B) is then all that's required to GPU-accelerate large-scale linear algebra. MPI is easy to install and use. Distributed computing through password-less SSH. Multithreading is automatic and baked into many libraries, with a specialized algorithm to ensure hierarchical usage does not oversubscribe threads. Basically, libraries give you a lot of parallelism for free, and doing the rest is a piece of cake.
  • Mix Scientific Computing with Machine Learning - Want to automate the discovery of missing physical laws using neural networks embedded in differentiable simulations? Julia's SciML is the ecosystem with the tooling to integrate machine learning into the traditional high-performance scientific computing domains, from multiphysics simulations to partial differential equations.

In this plot, deSolve in blue represents R's most commonly used solver:

Need Help Translating from R to Julia?

The following resources can be particularly helpful when adopting Julia for SciML for the first time:

R to Julia SciML Functionality Translations

The following chart will help you get quickly acquainted with Julia's SciML Tools:

R Function/PackageSciML-Supported Julia packages
data.frameDataFrames
plotPlots, Makie
ggplot2AlgebraOfGraphics
deSolveDifferentialEquations
StanTuring

Want to See the Power of Julia?

Check out this R-Bloggers blog post on diffeqr, a package which uses ModelingToolkit to translate R code to Julia, and achieves 350x acceleration over R's popular deSolve ODE solver package. But when the solve is done purely in Julia, it achieves 2777x acceleration over deSolve!

diff --git a/dev/getting_started/find_root/index.html b/dev/getting_started/find_root/index.html index 95e843506fd..1a1efdad99e 100644 --- a/dev/getting_started/find_root/index.html +++ b/dev/getting_started/find_root/index.html @@ -69,4 +69,4 @@ 0.0 0.0 0.0

Step 5: Analyze the Solution

Now let's check out the solution. First of all, what kind of thing is the sol? We can see that by asking for its type:

typeof(sol)
SciMLBase.NonlinearSolution{Float64, 1, Vector{Float64}, Vector{Float64}, SciMLBase.NonlinearProblem{Vector{Float64}, true, Vector{Float64}, SciMLBase.NonlinearFunction{true, SciMLBase.FullSpecialize, ModelingToolkit.var"#f#733"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x892348f8, 0xa22abdbe, 0xa285f9d8, 0x95831967, 0xeaff7cf7), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x2a5931a9, 0x19d9b662, 0x2773c77d, 0x8f1eafb9, 0xd485c91b), Nothing}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Vector{Symbol}, ModelingToolkit.var"#generated_observed#736"{ModelingToolkit.NonlinearSystem, Dict{Any, Any}}, Nothing, ModelingToolkit.NonlinearSystem, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardNonlinearProblem}, NonlinearSolve.NewtonRaphson{0, true, Val{:forward}, Nothing, typeof(NonlinearSolve.DEFAULT_PRECS), true, nothing}, Nothing, Nothing, SciMLBase.NLStats}

From this, we can see that it is an NonlinearSolution. We can see the documentation for how to use the NonlinearSolution by checking the NonlinearSolve.jl solution type page. For example, the solution is stored as .u. What is the solution to our nonlinear system, and what is the final residual value? We can check it as follows:

# Analyze the solution
-@show sol.u, sol.resid
([0.0, 0.0, 0.0], [0.0, 0.0, 0.0])
+@show sol.u, sol.resid
([0.0, 0.0, 0.0], [0.0, 0.0, 0.0])
diff --git a/dev/getting_started/first_optimization/index.html b/dev/getting_started/first_optimization/index.html index 5a26ee92460..7c54af74ffb 100644 --- a/dev/getting_started/first_optimization/index.html +++ b/dev/getting_started/first_optimization/index.html @@ -28,4 +28,4 @@ sol = solve(prob, NLopt.LD_LBFGS())
u: 2-element Vector{Float64}:
  1.0
  1.0

Step 4: Analyze the Solution

Now let's check out the solution. First of all, what kind of thing is the sol? We can see that by asking for its type:

typeof(sol)
SciMLBase.OptimizationSolution{Float64, 1, Vector{Float64}, Optimization.OptimizationCache{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), OptimizationForwardDiffExt.var"#38#56"{ForwardDiff.GradientConfig{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Float64}, Float64, 2}}}, OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}}, OptimizationForwardDiffExt.var"#41#59"{ForwardDiff.HessianConfig{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Float64}, ForwardDiff.Dual{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Float64}, Float64, 2}, 2}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Float64}, Float64, 2}}}, OptimizationForwardDiffExt.var"#37#55"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}}, OptimizationForwardDiffExt.var"#44#62", Nothing, OptimizationForwardDiffExt.var"#48#66"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, OptimizationForwardDiffExt.var"#53#71"{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Optimization.ReInitCache{Vector{Float64}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, NLopt.Algorithm, Base.Iterators.Cycle{Tuple{Optimization.NullData}}, Bool, Optimization.var"#41#43"}, NLopt.Algorithm, Float64, NLopt.Opt, Float64, Nothing}

From this, we can see that it is an OptimizationSolution. We can see the documentation for how to use the OptimizationSolution by checking the Optimization.jl solution type page. For example, the solution is stored as .u. What is the solution to our optimization, and what is the final loss value? We can check it as follows:

# Analyze the solution
-@show sol.u, L(sol.u, p)
([1.0, 1.0], 0.0)
+@show sol.u, L(sol.u, p)
([1.0, 1.0], 0.0)
diff --git a/dev/getting_started/first_simulation/e83eeaaf.svg b/dev/getting_started/first_simulation/513502f0.svg similarity index 90% rename from dev/getting_started/first_simulation/e83eeaaf.svg rename to dev/getting_started/first_simulation/513502f0.svg index 8039ca287f1..3fc92adf0da 100644 --- a/dev/getting_started/first_simulation/e83eeaaf.svg +++ b/dev/getting_started/first_simulation/513502f0.svg @@ -1,46 +1,46 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/getting_started/first_simulation/732601a1.svg b/dev/getting_started/first_simulation/8b77f2d4.svg similarity index 91% rename from dev/getting_started/first_simulation/732601a1.svg rename to dev/getting_started/first_simulation/8b77f2d4.svg index 7c4ab038a8f..2f8add04aee 100644 --- a/dev/getting_started/first_simulation/732601a1.svg +++ b/dev/getting_started/first_simulation/8b77f2d4.svg @@ -1,86 +1,86 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/getting_started/first_simulation/97d5904a.svg b/dev/getting_started/first_simulation/9edf9fde.svg similarity index 91% rename from dev/getting_started/first_simulation/97d5904a.svg rename to dev/getting_started/first_simulation/9edf9fde.svg index a8a02583b0e..b747f337de1 100644 --- a/dev/getting_started/first_simulation/97d5904a.svg +++ b/dev/getting_started/first_simulation/9edf9fde.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/getting_started/first_simulation/dbefc72e.svg b/dev/getting_started/first_simulation/ea8ce5cc.svg similarity index 91% rename from dev/getting_started/first_simulation/dbefc72e.svg rename to dev/getting_started/first_simulation/ea8ce5cc.svg index 1b8ee554bbf..df13da97294 100644 --- a/dev/getting_started/first_simulation/dbefc72e.svg +++ b/dev/getting_started/first_simulation/ea8ce5cc.svg @@ -1,86 +1,86 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/getting_started/first_simulation/index.html b/dev/getting_started/first_simulation/index.html index 0106543ab9e..44659d4fc30 100644 --- a/dev/getting_started/first_simulation/index.html +++ b/dev/getting_started/first_simulation/index.html @@ -35,7 +35,7 @@ p1 = plot(sol, title = "Rabbits vs Wolves") p2 = plot(sol, idxs = z, title = "Total Animals") -plot(p1, p2, layout = (2, 1))Example block output

Step-by-Step Solution

Step 1: Install and Import the Required Packages

To do this tutorial, we will need a few components:

To start, let's add these packages as demonstrated in the installation tutorial:

using Pkg
+plot(p1, p2, layout = (2, 1))
Example block output

Step-by-Step Solution

Step 1: Install and Import the Required Packages

To do this tutorial, we will need a few components:

To start, let's add these packages as demonstrated in the installation tutorial:

using Pkg
 Pkg.add(["ModelingToolkit", "DifferentialEquations", "Plots"])

Now we're ready. Let's load in these packages:

using ModelingToolkit, DifferentialEquations, Plots

Step 2: Define our ODE Equations

Now let's define our ODEs. We use the ModelingToolkit.@variabes statement to declare our variables. We have the independent variable time t, and then define our 3 state variables:

# Define our state variables: state(t) = initial condition
 @variables t x(t)=1 y(t)=1 z(t)=2

\[ \begin{equation} \left[ @@ -152,7 +152,7 @@ 3.9376728023907703 2.57936090872541 1.940128509890674

returns the time series of the observable z at time points corresponding to sol.t. We can use this with the automated plotting functionality. First let's create a plot of x and y over time using plot(sol) which will plot all of the states. Then next, we will explicitly tell it to make a plot with the index being z, i.e. idxs=z.

Note

Note that one can pass an array of indices as well, so idxs=[x,y,z] would make a plot with all three lines together!

# Plot the solution
-p1 = plot(sol, title = "Rabbits vs Wolves")
Example block output
p2 = plot(sol, idxs = z, title = "Total Animals")
Example block output

Finally, let's make a plot where we merge these two plot elements. To do so, we can take our two plot objects, p1 and p2, and make a plot with both of them. Then we tell Plots to do a layout of (2,1), or 2 rows and 1 columns. Let's see what happens when we bring these together:

plot(p1, p2, layout = (2, 1))
Example block output

And tada, we have a full analysis of our ecosystem!

Bonus Step: Emoji Variables

If you made it this far, then congrats, you get to learn a fun fact! Since Julia code can use Unicode, emojis work for variable names. Here's the simulation using emojis of rabbits and wolves to define the system:

using ModelingToolkit, DifferentialEquations
+p1 = plot(sol, title = "Rabbits vs Wolves")
Example block output
p2 = plot(sol, idxs = z, title = "Total Animals")
Example block output

Finally, let's make a plot where we merge these two plot elements. To do so, we can take our two plot objects, p1 and p2, and make a plot with both of them. Then we tell Plots to do a layout of (2,1), or 2 rows and 1 columns. Let's see what happens when we bring these together:

plot(p1, p2, layout = (2, 1))
Example block output

And tada, we have a full analysis of our ecosystem!

Bonus Step: Emoji Variables

If you made it this far, then congrats, you get to learn a fun fact! Since Julia code can use Unicode, emojis work for variable names. Here's the simulation using emojis of rabbits and wolves to define the system:

using ModelingToolkit, DifferentialEquations
 @parameters α=1.5 β=1.0 γ=3.0 δ=1.0
 @variables t 🐰(t)=1.0 🐺(t)=1.0
 D = Differential(t)
@@ -205,4 +205,4 @@
  [1.816420140681761, 4.064056625315978]
  [1.1465021407690728, 2.7911706616216976]
  [0.9557986135403302, 1.6235622951850799]
- [1.0337581256020607, 0.9063703842886133]

Now go make your professor mad that they have to grade a fully emojified code. I'll vouch for you: the documentation told you to do this.

+ [1.0337581256020607, 0.9063703842886133]

Now go make your professor mad that they have to grade a fully emojified code. I'll vouch for you: the documentation told you to do this.

diff --git a/dev/getting_started/fit_simulation/index.html b/dev/getting_started/fit_simulation/index.html index f333be5b4bf..56590cee589 100644 --- a/dev/getting_started/fit_simulation/index.html +++ b/dev/getting_started/fit_simulation/index.html @@ -136,4 +136,4 @@ 1.5002841181763384 1.0009286254415546 3.0002381483082114 - 1.0004604305929508

and the answer from the optimization is our desired parameters.

+ 1.0004604305929508

and the answer from the optimization is our desired parameters.

diff --git a/dev/getting_started/getting_started/index.html b/dev/getting_started/getting_started/index.html index 241bbbe4163..4a28bd372bb 100644 --- a/dev/getting_started/getting_started/index.html +++ b/dev/getting_started/getting_started/index.html @@ -1,2 +1,2 @@ -Getting Started with Julia's SciML · Overview of Julia's SciML

Getting Started with Julia's SciML

Quickly: What is Julia's SciML Ecosystem?

Julia's SciML is:

  • SciPy or MATLAB's standard library but in Julia, but
  • Runs orders of magnitude faster, even outperforms C and Fortran libraries, and
  • Is fully compatible with machine learning and automatic differentiation,
  • All while having an easy-to-use high level interactive development environment.

Interested?

Introductory Tutorials

Note

Each of the SciML packages starts with its own introductory tutorial as well! Once you have started to get the hang of a few things, start checking out the introductory tutorials of the different packages. For example, the DifferentialEquations.jl getting started tutorial is a fun one!

Coming from...

Are you familiar with other scientific computing tools? Take a look at the guided introductions below.

+Getting Started with Julia's SciML · Overview of Julia's SciML

Getting Started with Julia's SciML

Quickly: What is Julia's SciML Ecosystem?

Julia's SciML is:

  • SciPy or MATLAB's standard library but in Julia, but
  • Runs orders of magnitude faster, even outperforms C and Fortran libraries, and
  • Is fully compatible with machine learning and automatic differentiation,
  • All while having an easy-to-use high level interactive development environment.

Interested?

Introductory Tutorials

Note

Each of the SciML packages starts with its own introductory tutorial as well! Once you have started to get the hang of a few things, start checking out the introductory tutorials of the different packages. For example, the DifferentialEquations.jl getting started tutorial is a fun one!

Coming from...

Are you familiar with other scientific computing tools? Take a look at the guided introductions below.

diff --git a/dev/getting_started/installation/index.html b/dev/getting_started/installation/index.html index f654a06cc0f..d2133be0cc2 100644 --- a/dev/getting_started/installation/index.html +++ b/dev/getting_started/installation/index.html @@ -1,3 +1,3 @@ Installing SciML Software · Overview of Julia's SciML

Installing SciML Software

Step 1: Install Julia

Download Julia using this website.

Note

Some Linux distributions do weird and incorrect things with Julia installations! Please install Julia using the binaries provided by the official JuliaLang website!

To ensure that you have installed Julia correctly, open it up and type versioninfo() in the REPL. It should look like the following:

(with the CPU/OS/etc. details matching your computer!)

If you got stuck in this installation process, ask for help on the Julia Discourse or in the Julia Zulip chatrooms

Optional Step 1.5: Get VS Code Setup with the Julia Extension

You can run SciML with Julia in any development environment you please, but our recommended environment is VS Code. For more information on using Julia with VS Code, check out the Julia VS Code Extension website. Let's install it!

First download VS Code from the official website.

Next, open Visual Studio Code and click Extensions.

Then, search for “Julia” in the search bar on the top of the extension tab, click on the “Julia” extension, and click the install button on the tab that opens up.

To make sure your installation is correct, try running some code. Open a new file by either going to the top left navigation bar File |> New Text File, or hitting Ctrl+n. Name your new file test.jl (important: the Julia VS Code functionality only turns on when using a .jl file!). Next, type 1+1 and hit Ctrl+Enter. A Julia REPL should pop up and the result 2 should be displayed. Your environment should look something like this:

For more help on using the VS Code editor with Julia, check out the VS Code in Julia documentation. Useful keyboard commands can be found here.

Once again, if you got stuck in this installation process, ask for help on the Julia Discourse or in the Julia Zulip chatrooms

Step 2: Install a SciML Package

SciML is over 130 Julia packages. That's too much stuff to give someone in a single download! Thus instead, the SciML organization divides its functionality into composable modules that can be mixed and matched as required. Installing SciML ecosystem functionality is equivalent to installation of such packages.

For example, do you need the differential equation solver? Then install DifferentialEquations via the command:

using Pkg;
-Pkg.add("DifferentialEquations");

in the Julia REPL. Or, for a more robust REPL experience, hit the ] command to make the blue pkg> REPL environment start, and type in add DifferentialEquations. The package REPL environment will have nice extras like auto-complete that will be useful in the future. This command should run an installation sequence and precompile all of the packages (precompile = "run a bunch of performance optimizations!"). Don't be surprised if this installation process takes ~10 minutes on older computers. During the installation, it should look like this:

And that's it!

How do I test that my installed correctly?

The best way is to build and run your first simulation!

+Pkg.add("DifferentialEquations");

in the Julia REPL. Or, for a more robust REPL experience, hit the ] command to make the blue pkg> REPL environment start, and type in add DifferentialEquations. The package REPL environment will have nice extras like auto-complete that will be useful in the future. This command should run an installation sequence and precompile all of the packages (precompile = "run a bunch of performance optimizations!"). Don't be surprised if this installation process takes ~10 minutes on older computers. During the installation, it should look like this:

And that's it!

How do I test that my installed correctly?

The best way is to build and run your first simulation!

diff --git a/dev/highlevels/array_libraries/index.html b/dev/highlevels/array_libraries/index.html index 86af6904915..52369f4acfc 100644 --- a/dev/highlevels/array_libraries/index.html +++ b/dev/highlevels/array_libraries/index.html @@ -22,4 +22,4 @@ lorenz_p = (σ = 10.0, ρ = 28.0, β = 8 / 3) lorenz_ic = ComponentArray(x = 0.0, y = 0.0, z = 0.0) -lorenz_prob = ODEProblem(lorenz!, lorenz_ic, tspan, lorenz_p)

Is that beautiful? Yes, it is.

StaticArrays.jl: Statically-Defined Arrays

StaticArrays.jl is a library for statically-defined arrays. Because these arrays have type-level information for size, they recompile the solvers for every new size. They can be dramatically faster for small sizes (up to approximately size 10), but for larger equations they increase compile time with little to no benefit.

CUDA.jl: NVIDIA CUDA-Based GPU Array Computations

CUDA.jl is the library for defining arrays which live on NVIDIA GPUs (CuArray). SciML's libraries will respect the GPU-ness of the inputs, i.e., if the input arrays live on the GPU then the operations will all take place on the GPU or else the libraries will error if it's unable to do so. Thus, using CUDA.jl's CuArray is how one GPU-accelerates any computation with the SciML organization's libraries. Simply use a CuArray as the initial condition to an ODE solve or as the initial guess for a nonlinear solve, and the whole solve will recompile to take place on the GPU.

AMDGPU.jl: AMD-Based GPU Array Computations

AMDGPU.jl is the library for defining arrays which live on AMD GPUs (ROCArray). SciML's libraries will respect the GPU-ness of the inputs, i.e., if the input arrays live on the GPU then the operations will all take place on the GPU or else the libraries will error if it's unable to do so. Thus using AMDGPU.jl's ROCArray is how one GPU-accelerates any computation with the SciML organization's libraries. Simply use a ROCArray as the initial condition to an ODE solve or as the initial guess for a nonlinear solve, and the whole solve will recompile to take place on the GPU.

FillArrays.jl: Lazy Arrays

FillArrays.jl is a library for defining arrays with lazy values. For example, an O(1) representation of the identity matrix is given by Eye{Int}(5). FillArrays.jl is used extensively throughout the ecosystem to improve runtime and memory performance.

BandedMatrices.jl: Fast Banded Matrices

Banded matrices show up in many equation solver contexts, such as the Jacobians of many partial differential equations. While the base SparseMatrixCSC sparse matrix type can represent such matrices, BandedMatrices.jl is a specialized format specifically for BandedMatrices which can be used to greatly improve performance of operations on a banded matrix.

BlockBandedMatrices.jl: Fast Block-Banded Matrices

Block banded matrices show up in many equation solver contexts, such as the Jacobians of many systems of partial differential equations. While the base SparseMatrixCSC sparse matrix type can represent such matrices, BlockBandedMatrices.jl is a specialized format specifically for BlockBandedMatrices which can be used to greatly improve performance of operations on a block-banded matrix.

+lorenz_prob = ODEProblem(lorenz!, lorenz_ic, tspan, lorenz_p)

Is that beautiful? Yes, it is.

StaticArrays.jl: Statically-Defined Arrays

StaticArrays.jl is a library for statically-defined arrays. Because these arrays have type-level information for size, they recompile the solvers for every new size. They can be dramatically faster for small sizes (up to approximately size 10), but for larger equations they increase compile time with little to no benefit.

CUDA.jl: NVIDIA CUDA-Based GPU Array Computations

CUDA.jl is the library for defining arrays which live on NVIDIA GPUs (CuArray). SciML's libraries will respect the GPU-ness of the inputs, i.e., if the input arrays live on the GPU then the operations will all take place on the GPU or else the libraries will error if it's unable to do so. Thus, using CUDA.jl's CuArray is how one GPU-accelerates any computation with the SciML organization's libraries. Simply use a CuArray as the initial condition to an ODE solve or as the initial guess for a nonlinear solve, and the whole solve will recompile to take place on the GPU.

AMDGPU.jl: AMD-Based GPU Array Computations

AMDGPU.jl is the library for defining arrays which live on AMD GPUs (ROCArray). SciML's libraries will respect the GPU-ness of the inputs, i.e., if the input arrays live on the GPU then the operations will all take place on the GPU or else the libraries will error if it's unable to do so. Thus using AMDGPU.jl's ROCArray is how one GPU-accelerates any computation with the SciML organization's libraries. Simply use a ROCArray as the initial condition to an ODE solve or as the initial guess for a nonlinear solve, and the whole solve will recompile to take place on the GPU.

FillArrays.jl: Lazy Arrays

FillArrays.jl is a library for defining arrays with lazy values. For example, an O(1) representation of the identity matrix is given by Eye{Int}(5). FillArrays.jl is used extensively throughout the ecosystem to improve runtime and memory performance.

BandedMatrices.jl: Fast Banded Matrices

Banded matrices show up in many equation solver contexts, such as the Jacobians of many partial differential equations. While the base SparseMatrixCSC sparse matrix type can represent such matrices, BandedMatrices.jl is a specialized format specifically for BandedMatrices which can be used to greatly improve performance of operations on a banded matrix.

BlockBandedMatrices.jl: Fast Block-Banded Matrices

Block banded matrices show up in many equation solver contexts, such as the Jacobians of many systems of partial differential equations. While the base SparseMatrixCSC sparse matrix type can represent such matrices, BlockBandedMatrices.jl is a specialized format specifically for BlockBandedMatrices which can be used to greatly improve performance of operations on a block-banded matrix.

diff --git a/dev/highlevels/developer_documentation/index.html b/dev/highlevels/developer_documentation/index.html index efe9698fd55..7a8012248e2 100644 --- a/dev/highlevels/developer_documentation/index.html +++ b/dev/highlevels/developer_documentation/index.html @@ -1,3 +1,3 @@ Developer Documentation · Overview of Julia's SciML

Developer Documentation

For uniformity and clarity, the SciML Open-Source Software Organization has many well-defined rules and practices for its development. However, we stress one important principle:

Do not be deterred from contributing if you think you do not know everything. No one knows everything. These rules and styles are designed for iterative contributions. Open pull requests and contribute what you can with what you know, and the maintainers will help you learn and do the rest!

If you need any help contributing, please feel welcome joining our community channels.

We welcome everybody.

Getting Started With Contributing to SciML

To get started contributing to SciML, check out the following resources:

SciMLStyle: The SciML Style Guide for Julia

SciML Code Style

This is a style guide for how to program in Julia for SciML contributions. It describes everything one needs to know, from preferred naming schemes of functions to fundamental dogmas for designing traits. We stress that this style guide is meant to be comprehensive for the sake of designing automatic formatters and teaching desired rules, but complete knowledge and adherence to the style guide is not required for contributions!

COLPRAC: Contributor's Guide on Collaborative Practices for Community Packages

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages

What are the rules for when PRs should be merged? What are the rules for whether to tag a major, minor, or patch release? All of these development rules are defined in COLPRAC.

DiffEq Developer Documentation

There are many solver libraries which share similar internals, such as OrdinaryDiffEq.jl, StochasticDiffEq.jl, and DelayDiffEq.jl. This section of the documentation describes the internal systems of these packages and how they are used to quickly write efficient solvers.

Third-Party Libraries to Note

Documenter.jl

Documenter.jl is the documentation generation library that the SciML organization uses, and thus its documentation is the documentation of the documentation.

JuliaFormatter.jl

JuliaFormatter.jl is the formatter used by the SciML organization to enforce the SciML Style. Setting style = "sciml" in a .JuliaFormatter.toml file of a repo and using the standard FormatCheck.yml as part of continuous integration makes JuliaFormatter check for SciML Style compliance on pull requests.

To run JuliaFormatter in a SciML repository, do:

using JuliaFomatter, DevedPackage
-JuliaFormatter.format(pkgdir(DevedPackage))

which will reformat the code according to the SciML Style.

GitHub Actions Continuous Integrations

The SciML Organization uses continuous integration testing to always ensure tests are passing when merging pull requests. The organization uses the GitHub Actions supplied by Julia Actions to accomplish this. Common continuous integration scripts are:

  • CI.yml, the standard CI script
  • Downstream.yml, used to specify packages for downstream testing. This will make packages which depend on the current package also be tested to ensure that “non-breaking changes” do not actually break other packages.
  • Documentation.yml, used to run the documentation automatic generation with Documenter.jl
  • FormatCheck.yml, used to check JuliaFormatter SciML Style compliance

CompatHelper

CompatHelper is used to automatically create pull requests whenever a dependent package is upper bounded. The results of CompatHelper PRs should be checked to ensure that the latest version of the dependencies are grabbed for the test process. After successful CompatHelper PRs, i.e. if the increase of the upper bound did not cause a break to the tests, a new version tag should follow. It is set up by adding the CompatHelper.yml GitHub action.

TagBot

TagBot automatically creates tags in the GitHub repository whenever a package is registered to the Julia General repository. It is set up by adding the TagBot.yml GitHub action.

+JuliaFormatter.format(pkgdir(DevedPackage))

which will reformat the code according to the SciML Style.

GitHub Actions Continuous Integrations

The SciML Organization uses continuous integration testing to always ensure tests are passing when merging pull requests. The organization uses the GitHub Actions supplied by Julia Actions to accomplish this. Common continuous integration scripts are:

  • CI.yml, the standard CI script
  • Downstream.yml, used to specify packages for downstream testing. This will make packages which depend on the current package also be tested to ensure that “non-breaking changes” do not actually break other packages.
  • Documentation.yml, used to run the documentation automatic generation with Documenter.jl
  • FormatCheck.yml, used to check JuliaFormatter SciML Style compliance

CompatHelper

CompatHelper is used to automatically create pull requests whenever a dependent package is upper bounded. The results of CompatHelper PRs should be checked to ensure that the latest version of the dependencies are grabbed for the test process. After successful CompatHelper PRs, i.e. if the increase of the upper bound did not cause a break to the tests, a new version tag should follow. It is set up by adding the CompatHelper.yml GitHub action.

TagBot

TagBot automatically creates tags in the GitHub repository whenever a package is registered to the Julia General repository. It is set up by adding the TagBot.yml GitHub action.

diff --git a/dev/highlevels/equation_solvers/index.html b/dev/highlevels/equation_solvers/index.html index 9bb167a9647..bb2a5d34ee6 100644 --- a/dev/highlevels/equation_solvers/index.html +++ b/dev/highlevels/equation_solvers/index.html @@ -1,2 +1,2 @@ -Equation Solvers · Overview of Julia's SciML

Equation Solvers

The SciML Equation Solvers cover a large set of SciMLProblems with SciMLAlgorithms that are efficient, numerically stable, and flexible. These methods tie into libraries like SciMLSensitivity.jl to be fully differentiable and compatible with machine learning pipelines, and are designed for integration with applications like parameter estimation, global sensitivity analysis, and more.

LinearSolve.jl: Unified Interface for Linear Solvers

LinearSolve.jl is the canonical library for solving LinearProblems. It includes:

  • Fast pure Julia LU factorizations which outperform standard BLAS
  • KLU for faster sparse LU factorization on unstructured matrices
  • UMFPACK for faster sparse LU factorization on matrices with some repeated structure
  • MKLPardiso wrappers for handling many sparse matrices faster than SuiteSparse (KLU, UMFPACK) methods
  • GPU-offloading for large dense matrices
  • Wrappers to all of the Krylov implementations (Krylov.jl, IterativeSolvers.jl, KrylovKit.jl) for easy testing of all of them. LinearSolve.jl handles the API differences, especially with the preconditioner definitions
  • A polyalgorithm that smartly chooses between these methods
  • A caching interface which automates caching of symbolic factorizations and numerical factorizations as optimally as possible
  • Compatible with arbitrary AbstractArray and Number types, such as GPU-based arrays, uncertainty quantification number types, and more.

NonlinearSolve.jl: Unified Interface for Nonlinear Solvers

NonlinearSolve.jl is the canonical library for solving NonlinearProblems. It includes:

  • Fast non-allocating implementations on static arrays of common methods (Newton-Rhapson)
  • Bracketing methods (Bisection, Falsi) for methods with known upper and lower bounds (IntervalNonlinearProblem)
  • Wrappers to common other solvers (NLsolve.jl, MINPACK, KINSOL from Sundials) for trust region methods, line search-based approaches, etc.
  • Built over the LinearSolve.jl API for maximum flexibility and performance in the solving approach
  • Compatible with arbitrary AbstractArray and Number types, such as GPU-based arrays, uncertainty quantification number types, and more.

DifferentialEquations.jl: Unified Interface for Differential Equation Solvers

DifferentialEquations.jl is the canonical library for solving DEProblems. This includes:

  • Discrete equations (function maps, discrete stochastic (Gillespie/Markov) simulations) (DiscreteProblem)
  • Ordinary differential equations (ODEs) (ODEProblem)
  • Split and Partitioned ODEs (Symplectic integrators, IMEX Methods) (SplitODEProblem)
  • Stochastic ordinary differential equations (SODEs or SDEs) (SDEProblem)
  • Stochastic differential-algebraic equations (SDAEs) (SDEProblem with mass matrices)
  • Random differential equations (RODEs or RDEs) (RODEProblem)
  • Differential algebraic equations (DAEs) (DAEProblem and ODEProblem with mass matrices)
  • Delay differential equations (DDEs) (DDEProblem)
  • Neutral, retarded, and algebraic delay differential equations (NDDEs, RDDEs, and DDAEs)
  • Stochastic delay differential equations (SDDEs) (SDDEProblem)
  • Experimental support for stochastic neutral, retarded, and algebraic delay differential equations (SNDDEs, SRDDEs, and SDDAEs)
  • Mixed discrete and continuous equations (Hybrid Equations, Jump Diffusions) (DEProblems with callbacks and JumpProblem)

The well-optimized DifferentialEquations solvers benchmark as some of the fastest implementations of classic algorithms. It also includes algorithms from recent research which routinely outperform the “standard” C/Fortran methods, and algorithms optimized for high-precision and HPC applications. Simultaneously, it wraps the classic C/Fortran methods, making it easy to switch over to them whenever necessary. Solving differential equations with different methods from different languages and packages can be done by changing one line of code, allowing for easy benchmarking to ensure you are using the fastest method possible.

DifferentialEquations.jl integrates with the Julia package sphere. Examples are:

  • GPU acceleration through CUDAnative.jl and CuArrays.jl
  • Automated sparsity detection with Symbolics.jl
  • Automatic Jacobian coloring with SparseDiffTools.jl, allowing for fast solutions to problems with sparse or structured (Tridiagonal, Banded, BlockBanded, etc.) Jacobians
  • Allowing the specification of linear solvers for maximal efficiency
  • Progress meter integration with the Juno IDE for estimated time to solution
  • Automatic plotting of time series and phase plots
  • Built-in interpolations
  • Wraps for common C/Fortran methods, like Sundials and Hairer's radau
  • Arbitrary precision with BigFloats and Arbfloats
  • Arbitrary array types, allowing the definition of differential equations on matrices and distributed arrays
  • Unit-checked arithmetic with Unitful

Optimization.jl: Unified Interface for Optimization

Optimization.jl is the canonical library for solving OptimizationProblems. It includes wrappers of most of the Julia nonlinear optimization ecosystem, allowing one syntax to use all packages in a uniform manner. This covers:

Integrals.jl: Unified Interface for Numerical Integration

Integrals.jl is the canonical library for solving IntegralsProblems. It includes wrappers of most of the Julia quadrature ecosystem, allowing one syntax to use all packages in a uniform manner. This covers:

  • Gauss-Kronrod quadrature
  • Cubature methods (both h and p cubature)
  • Adaptive Monte Carlo methods

JumpProcesses.jl: Stochastic Simulation Algorithms for Jump Processes, Jump-ODEs, and Jump-Diffusions

JumpProcesses.jl is the library for Poisson jump processes, also known as chemical master equations or Gillespie simulations, for simulating chemical reaction networks and other applications. It allows for solving with many methods, including:

  • Direct: the Gillespie Direct method SSA.
  • RDirect: A variant of Gillespie's Direct method that uses rejection to sample the next reaction.
  • DirectCR: The Composition-Rejection Direct method of Slepoy et al. For large networks and linear chain-type networks, it will often give better performance than Direct. (Requires dependency graph, see below.)
  • DirectFW: the Gillespie Direct method SSA with FunctionWrappers. This aggregator uses a different internal storage format for collections of ConstantRateJumps.
  • FRM: the Gillespie first reaction method SSA. Direct should generally offer better performance and be preferred to FRM.
  • FRMFW: the Gillespie first reaction method SSA with FunctionWrappers.
  • NRM: The Gibson-Bruck Next Reaction Method. For some reaction network structures, this may offer better performance than Direct (for example, large, linear chains of reactions). (Requires dependency graph, see below.)
  • RSSA: The Rejection SSA (RSSA) method of Thanh et al. With RSSACR, for very large reaction networks, it often offers the best performance of all methods. (Requires dependency graph, see below.)
  • RSSACR: The Rejection SSA (RSSA) with Composition-Rejection method of Thanh et al. With RSSA, for very large reaction networks, it often offers the best performance of all methods. (Requires dependency graph, see below.)
  • SortingDirect: The Sorting Direct Method of McCollum et al. It will usually offer performance as good as Direct, and for some systems can offer substantially better performance. (Requires dependency graph, see below.)

The design of JumpProcesses.jl composes with DifferentialEquations.jl, allowing for discrete stochastic chemical reactions to be easily mixed with differential equation models, allowing for simulation of hybrid systems, jump diffusions, and differential equations driven by Levy processes.

In addition, JumpProcesses's interfaces allow for solving with regular jump methods, such as adaptive Tau-Leaping.

Third-Party Libraries to Note

JuMP.jl: Julia for Mathematical Programming

While Optimization.jl is the preferred library for nonlinear optimization, for all other forms of optimization Julia for Mathematical Programming (JuMP) is the star. JuMP is the leading choice in Julia for doing:

  • Linear Programming
  • Quadratic Programming
  • Convex Programming
  • Conic Programming
  • Semidefinite Programming
  • Mixed-Complementarity Programming
  • Integer Programming
  • Mixed Integer (nonlinear/linear) Programming
  • (Mixed Integer) Second Order Conic Programming

JuMP can also be used for some nonlinear programming, though the Optimization.jl bindings to the JuMP solvers (via MathOptInterface.jl) is generally preferred.

FractionalDiffEq.jl: Fractional Differential Equation Solvers

FractionalDiffEq.jl is a set of high-performance solvers for fractional differential equations.

ManifoldDiffEq.jl: Solvers for Differential Equations on Manifolds

ManifoldDiffEq.jl is a set of high-performance solvers for differential equations on manifolds using methods such as Lie Group actions and frozen coefficients (Crouch-Grossman methods). These solvers can in many cases out-perform the OrdinaryDiffEq.jl nonautonomous operator ODE solvers by using methods specialized on manifold definitions of ManifoldsBase.

Manopt.jl: Optimization on Manifolds

ManOpt.jl allows for easy and efficient solving of nonlinear optimization problems on manifolds.

+Equation Solvers · Overview of Julia's SciML

Equation Solvers

The SciML Equation Solvers cover a large set of SciMLProblems with SciMLAlgorithms that are efficient, numerically stable, and flexible. These methods tie into libraries like SciMLSensitivity.jl to be fully differentiable and compatible with machine learning pipelines, and are designed for integration with applications like parameter estimation, global sensitivity analysis, and more.

LinearSolve.jl: Unified Interface for Linear Solvers

LinearSolve.jl is the canonical library for solving LinearProblems. It includes:

  • Fast pure Julia LU factorizations which outperform standard BLAS
  • KLU for faster sparse LU factorization on unstructured matrices
  • UMFPACK for faster sparse LU factorization on matrices with some repeated structure
  • MKLPardiso wrappers for handling many sparse matrices faster than SuiteSparse (KLU, UMFPACK) methods
  • GPU-offloading for large dense matrices
  • Wrappers to all of the Krylov implementations (Krylov.jl, IterativeSolvers.jl, KrylovKit.jl) for easy testing of all of them. LinearSolve.jl handles the API differences, especially with the preconditioner definitions
  • A polyalgorithm that smartly chooses between these methods
  • A caching interface which automates caching of symbolic factorizations and numerical factorizations as optimally as possible
  • Compatible with arbitrary AbstractArray and Number types, such as GPU-based arrays, uncertainty quantification number types, and more.

NonlinearSolve.jl: Unified Interface for Nonlinear Solvers

NonlinearSolve.jl is the canonical library for solving NonlinearProblems. It includes:

  • Fast non-allocating implementations on static arrays of common methods (Newton-Rhapson)
  • Bracketing methods (Bisection, Falsi) for methods with known upper and lower bounds (IntervalNonlinearProblem)
  • Wrappers to common other solvers (NLsolve.jl, MINPACK, KINSOL from Sundials) for trust region methods, line search-based approaches, etc.
  • Built over the LinearSolve.jl API for maximum flexibility and performance in the solving approach
  • Compatible with arbitrary AbstractArray and Number types, such as GPU-based arrays, uncertainty quantification number types, and more.

DifferentialEquations.jl: Unified Interface for Differential Equation Solvers

DifferentialEquations.jl is the canonical library for solving DEProblems. This includes:

  • Discrete equations (function maps, discrete stochastic (Gillespie/Markov) simulations) (DiscreteProblem)
  • Ordinary differential equations (ODEs) (ODEProblem)
  • Split and Partitioned ODEs (Symplectic integrators, IMEX Methods) (SplitODEProblem)
  • Stochastic ordinary differential equations (SODEs or SDEs) (SDEProblem)
  • Stochastic differential-algebraic equations (SDAEs) (SDEProblem with mass matrices)
  • Random differential equations (RODEs or RDEs) (RODEProblem)
  • Differential algebraic equations (DAEs) (DAEProblem and ODEProblem with mass matrices)
  • Delay differential equations (DDEs) (DDEProblem)
  • Neutral, retarded, and algebraic delay differential equations (NDDEs, RDDEs, and DDAEs)
  • Stochastic delay differential equations (SDDEs) (SDDEProblem)
  • Experimental support for stochastic neutral, retarded, and algebraic delay differential equations (SNDDEs, SRDDEs, and SDDAEs)
  • Mixed discrete and continuous equations (Hybrid Equations, Jump Diffusions) (DEProblems with callbacks and JumpProblem)

The well-optimized DifferentialEquations solvers benchmark as some of the fastest implementations of classic algorithms. It also includes algorithms from recent research which routinely outperform the “standard” C/Fortran methods, and algorithms optimized for high-precision and HPC applications. Simultaneously, it wraps the classic C/Fortran methods, making it easy to switch over to them whenever necessary. Solving differential equations with different methods from different languages and packages can be done by changing one line of code, allowing for easy benchmarking to ensure you are using the fastest method possible.

DifferentialEquations.jl integrates with the Julia package sphere. Examples are:

  • GPU acceleration through CUDAnative.jl and CuArrays.jl
  • Automated sparsity detection with Symbolics.jl
  • Automatic Jacobian coloring with SparseDiffTools.jl, allowing for fast solutions to problems with sparse or structured (Tridiagonal, Banded, BlockBanded, etc.) Jacobians
  • Allowing the specification of linear solvers for maximal efficiency
  • Progress meter integration with the Juno IDE for estimated time to solution
  • Automatic plotting of time series and phase plots
  • Built-in interpolations
  • Wraps for common C/Fortran methods, like Sundials and Hairer's radau
  • Arbitrary precision with BigFloats and Arbfloats
  • Arbitrary array types, allowing the definition of differential equations on matrices and distributed arrays
  • Unit-checked arithmetic with Unitful

Optimization.jl: Unified Interface for Optimization

Optimization.jl is the canonical library for solving OptimizationProblems. It includes wrappers of most of the Julia nonlinear optimization ecosystem, allowing one syntax to use all packages in a uniform manner. This covers:

Integrals.jl: Unified Interface for Numerical Integration

Integrals.jl is the canonical library for solving IntegralsProblems. It includes wrappers of most of the Julia quadrature ecosystem, allowing one syntax to use all packages in a uniform manner. This covers:

  • Gauss-Kronrod quadrature
  • Cubature methods (both h and p cubature)
  • Adaptive Monte Carlo methods

JumpProcesses.jl: Stochastic Simulation Algorithms for Jump Processes, Jump-ODEs, and Jump-Diffusions

JumpProcesses.jl is the library for Poisson jump processes, also known as chemical master equations or Gillespie simulations, for simulating chemical reaction networks and other applications. It allows for solving with many methods, including:

  • Direct: the Gillespie Direct method SSA.
  • RDirect: A variant of Gillespie's Direct method that uses rejection to sample the next reaction.
  • DirectCR: The Composition-Rejection Direct method of Slepoy et al. For large networks and linear chain-type networks, it will often give better performance than Direct. (Requires dependency graph, see below.)
  • DirectFW: the Gillespie Direct method SSA with FunctionWrappers. This aggregator uses a different internal storage format for collections of ConstantRateJumps.
  • FRM: the Gillespie first reaction method SSA. Direct should generally offer better performance and be preferred to FRM.
  • FRMFW: the Gillespie first reaction method SSA with FunctionWrappers.
  • NRM: The Gibson-Bruck Next Reaction Method. For some reaction network structures, this may offer better performance than Direct (for example, large, linear chains of reactions). (Requires dependency graph, see below.)
  • RSSA: The Rejection SSA (RSSA) method of Thanh et al. With RSSACR, for very large reaction networks, it often offers the best performance of all methods. (Requires dependency graph, see below.)
  • RSSACR: The Rejection SSA (RSSA) with Composition-Rejection method of Thanh et al. With RSSA, for very large reaction networks, it often offers the best performance of all methods. (Requires dependency graph, see below.)
  • SortingDirect: The Sorting Direct Method of McCollum et al. It will usually offer performance as good as Direct, and for some systems can offer substantially better performance. (Requires dependency graph, see below.)

The design of JumpProcesses.jl composes with DifferentialEquations.jl, allowing for discrete stochastic chemical reactions to be easily mixed with differential equation models, allowing for simulation of hybrid systems, jump diffusions, and differential equations driven by Levy processes.

In addition, JumpProcesses's interfaces allow for solving with regular jump methods, such as adaptive Tau-Leaping.

Third-Party Libraries to Note

JuMP.jl: Julia for Mathematical Programming

While Optimization.jl is the preferred library for nonlinear optimization, for all other forms of optimization Julia for Mathematical Programming (JuMP) is the star. JuMP is the leading choice in Julia for doing:

  • Linear Programming
  • Quadratic Programming
  • Convex Programming
  • Conic Programming
  • Semidefinite Programming
  • Mixed-Complementarity Programming
  • Integer Programming
  • Mixed Integer (nonlinear/linear) Programming
  • (Mixed Integer) Second Order Conic Programming

JuMP can also be used for some nonlinear programming, though the Optimization.jl bindings to the JuMP solvers (via MathOptInterface.jl) is generally preferred.

FractionalDiffEq.jl: Fractional Differential Equation Solvers

FractionalDiffEq.jl is a set of high-performance solvers for fractional differential equations.

ManifoldDiffEq.jl: Solvers for Differential Equations on Manifolds

ManifoldDiffEq.jl is a set of high-performance solvers for differential equations on manifolds using methods such as Lie Group actions and frozen coefficients (Crouch-Grossman methods). These solvers can in many cases out-perform the OrdinaryDiffEq.jl nonautonomous operator ODE solvers by using methods specialized on manifold definitions of ManifoldsBase.

Manopt.jl: Optimization on Manifolds

ManOpt.jl allows for easy and efficient solving of nonlinear optimization problems on manifolds.

diff --git a/dev/highlevels/function_approximation/index.html b/dev/highlevels/function_approximation/index.html index b34af569b20..38f5e2064bc 100644 --- a/dev/highlevels/function_approximation/index.html +++ b/dev/highlevels/function_approximation/index.html @@ -1,2 +1,2 @@ -Function Approximation · Overview of Julia's SciML

Function Approximation

While SciML is not an ecosystem for machine learning, SciML has many libraries for doing machine learning with its equation solver libraries and machine learning libraries which are integrated into the equation solvers.

Surrogates.jl: Easy Generation of Differentiable Surrogate Models

Surrogates.jl is a library for generating surrogate approximations to computationally expensive simulations. It has the following high-dimensional function approximators:

  • Kriging
  • Kriging using Stheno
  • Radial Basis
  • Wendland
  • Linear
  • Second Order Polynomial
  • Support Vector Machines (Wait for LIBSVM resolution)
  • Neural Networks
  • Random Forests
  • Lobachevsky splines
  • Inverse-distance
  • Polynomial expansions
  • Variable fidelity
  • Mixture of experts (Waiting GaussianMixtures package to work on v1.5)
  • Earth
  • Gradient Enhanced Kriging

ReservoirComputing.jl: Fast and Flexible Reservoir Computing Methods

ReservoirComputing.jl is a library for doing machine learning using reservoir computing techniques, such as with methods like Echo State Networks (ESNs). Its reservoir computing methods make it stabilized for usage with difficult equations like stiff dynamics, chaotic equations, and more.

Third-Party Libraries to Note

Flux.jl: the ML library that doesn't make you tensor

Flux.jl is the most popular machine learning library in the Julia programming language. SciML's libraries are heavily tested with it and its automatic differentiation engine Zygote.jl for composability and compatibility.

Lux.jl: Explicitly Parameterized Neural Networks in Julia

Lux.jl is a library for fully explicitly parameterized neural networks. Thus, while alternative interfaces are required to use Flux with many equation solvers (i.e. Flux.destructure), Lux.jl's explicit design marries effortlessly with the SciML equation solver libraries. For this reason, SciML's library are also heavily tested with Lux to ensure compatibility with neural network definitions from here.

SimpleChains.jl: Fast Small-Scale Machine Learning

SimpleChains.jl is a library specialized for small-scale machine learning. It uses non-allocating mutating forms to be highly efficient for the cases where matrix multiplication kernels cannot overcome the common overheads of machine learning libraries. Thus for SciML cases with small neural networks (<100 node layers) and non-batched usage (many/most use cases), SimpleChains.jl can be the fastest choice for the neural network definitions.

NNLib.jl: Neural Network Primitives with Multiple Backends

NNLib.jl is the core library which defines the handling of common functions, like conv and how they map to device accelerators such as the NVIDIA cudnn. This library can thus be used to directly grab many of the core functions used in machine learning, such as common activation functions and gather/scatter operations, without depending on the given style of any machine learning library.

GeometricFlux.jl: Geometric Deep Learning and Graph Neural Networks

GeometricFlux.jl is a library for graph neural networks and geometric deep learning. It is the one that is used and tested by the SciML developers for mixing with equation solver applications.

AbstractGPs.jl: Fast and Flexible Gaussian Processes

AbstractGPs.jl is the fast and flexible Gaussian Process library that is used by the SciML packages and recommended for downstream usage.

MLDatasets.jl: Common Machine Learning Datasets

MLDatasets.jl is a common interface for accessing common machine learning datasets. For example, if you want to run a test on MNIST data, MLDatasets is the quickest way to obtain it.

MLUtils.jl: Utility Functions for Machine Learning Pipelines

MLUtils.jl is a library of utility functions for making writing common machine learning pipelines easier. This includes functionality for:

  • An extensible dataset interface (numobs and getobs).
  • Data iteration and data loaders (eachobs and DataLoader).
  • Lazy data views (obsview).
  • Resampling procedures (undersample and oversample).
  • Train/test splits (splitobs)
  • Data partitioning and aggregation tools (batch, unbatch, chunk, group_counts, group_indices).
  • Folds for cross-validation (kfolds, leavepout).
  • Datasets lazy transformations (mapobs, filterobs, groupobs, joinobs, shuffleobs).
  • Toy datasets for demonstration purpose.
  • Other data handling utilities (flatten, normalise, unsqueeze, stack, unstack).
+Function Approximation · Overview of Julia's SciML

Function Approximation

While SciML is not an ecosystem for machine learning, SciML has many libraries for doing machine learning with its equation solver libraries and machine learning libraries which are integrated into the equation solvers.

Surrogates.jl: Easy Generation of Differentiable Surrogate Models

Surrogates.jl is a library for generating surrogate approximations to computationally expensive simulations. It has the following high-dimensional function approximators:

  • Kriging
  • Kriging using Stheno
  • Radial Basis
  • Wendland
  • Linear
  • Second Order Polynomial
  • Support Vector Machines (Wait for LIBSVM resolution)
  • Neural Networks
  • Random Forests
  • Lobachevsky splines
  • Inverse-distance
  • Polynomial expansions
  • Variable fidelity
  • Mixture of experts (Waiting GaussianMixtures package to work on v1.5)
  • Earth
  • Gradient Enhanced Kriging

ReservoirComputing.jl: Fast and Flexible Reservoir Computing Methods

ReservoirComputing.jl is a library for doing machine learning using reservoir computing techniques, such as with methods like Echo State Networks (ESNs). Its reservoir computing methods make it stabilized for usage with difficult equations like stiff dynamics, chaotic equations, and more.

Third-Party Libraries to Note

Flux.jl: the ML library that doesn't make you tensor

Flux.jl is the most popular machine learning library in the Julia programming language. SciML's libraries are heavily tested with it and its automatic differentiation engine Zygote.jl for composability and compatibility.

Lux.jl: Explicitly Parameterized Neural Networks in Julia

Lux.jl is a library for fully explicitly parameterized neural networks. Thus, while alternative interfaces are required to use Flux with many equation solvers (i.e. Flux.destructure), Lux.jl's explicit design marries effortlessly with the SciML equation solver libraries. For this reason, SciML's library are also heavily tested with Lux to ensure compatibility with neural network definitions from here.

SimpleChains.jl: Fast Small-Scale Machine Learning

SimpleChains.jl is a library specialized for small-scale machine learning. It uses non-allocating mutating forms to be highly efficient for the cases where matrix multiplication kernels cannot overcome the common overheads of machine learning libraries. Thus for SciML cases with small neural networks (<100 node layers) and non-batched usage (many/most use cases), SimpleChains.jl can be the fastest choice for the neural network definitions.

NNLib.jl: Neural Network Primitives with Multiple Backends

NNLib.jl is the core library which defines the handling of common functions, like conv and how they map to device accelerators such as the NVIDIA cudnn. This library can thus be used to directly grab many of the core functions used in machine learning, such as common activation functions and gather/scatter operations, without depending on the given style of any machine learning library.

GeometricFlux.jl: Geometric Deep Learning and Graph Neural Networks

GeometricFlux.jl is a library for graph neural networks and geometric deep learning. It is the one that is used and tested by the SciML developers for mixing with equation solver applications.

AbstractGPs.jl: Fast and Flexible Gaussian Processes

AbstractGPs.jl is the fast and flexible Gaussian Process library that is used by the SciML packages and recommended for downstream usage.

MLDatasets.jl: Common Machine Learning Datasets

MLDatasets.jl is a common interface for accessing common machine learning datasets. For example, if you want to run a test on MNIST data, MLDatasets is the quickest way to obtain it.

MLUtils.jl: Utility Functions for Machine Learning Pipelines

MLUtils.jl is a library of utility functions for making writing common machine learning pipelines easier. This includes functionality for:

  • An extensible dataset interface (numobs and getobs).
  • Data iteration and data loaders (eachobs and DataLoader).
  • Lazy data views (obsview).
  • Resampling procedures (undersample and oversample).
  • Train/test splits (splitobs)
  • Data partitioning and aggregation tools (batch, unbatch, chunk, group_counts, group_indices).
  • Folds for cross-validation (kfolds, leavepout).
  • Datasets lazy transformations (mapobs, filterobs, groupobs, joinobs, shuffleobs).
  • Toy datasets for demonstration purpose.
  • Other data handling utilities (flatten, normalise, unsqueeze, stack, unstack).
diff --git a/dev/highlevels/implicit_layers/index.html b/dev/highlevels/implicit_layers/index.html index 112113aa73a..50204fbe201 100644 --- a/dev/highlevels/implicit_layers/index.html +++ b/dev/highlevels/implicit_layers/index.html @@ -1,2 +1,2 @@ -Implicit Layer Deep Learning · Overview of Julia's SciML

Implicit Layer Deep Learning

Implicit layer deep learning is a field which uses implicit rules, such as differential equations and nonlinear solvers, to define the layers of neural networks. This field has brought the potential to automatically optimize network depth and improve training performance. SciML's differentiable solver ecosystem is specifically designed to accommodate implicit layer methodologies, and provides libraries with pre-built layers for common methods.

DiffEqFlux.jl: High Level Pre-Built Architectures for Implicit Deep Learning

DiffEqFlux.jl is a library of pre-built architectures for implicit deep learning, including layer definitions for methods like:

DeepEquilibriumNetworks.jl: Deep Equilibrium Models Made Fast

DeepEquilibriumNetworks.jl is a library of optimized layer implementations for Deep Equilibrium Models (DEQs). It uses special training techniques such as implicit-explicit regularization in order to accelerate the convergence over traditional implementations, all while using the optimized and flexible SciML libraries under the hood.

+Implicit Layer Deep Learning · Overview of Julia's SciML

Implicit Layer Deep Learning

Implicit layer deep learning is a field which uses implicit rules, such as differential equations and nonlinear solvers, to define the layers of neural networks. This field has brought the potential to automatically optimize network depth and improve training performance. SciML's differentiable solver ecosystem is specifically designed to accommodate implicit layer methodologies, and provides libraries with pre-built layers for common methods.

DiffEqFlux.jl: High Level Pre-Built Architectures for Implicit Deep Learning

DiffEqFlux.jl is a library of pre-built architectures for implicit deep learning, including layer definitions for methods like:

DeepEquilibriumNetworks.jl: Deep Equilibrium Models Made Fast

DeepEquilibriumNetworks.jl is a library of optimized layer implementations for Deep Equilibrium Models (DEQs). It uses special training techniques such as implicit-explicit regularization in order to accelerate the convergence over traditional implementations, all while using the optimized and flexible SciML libraries under the hood.

diff --git a/dev/highlevels/interfaces/index.html b/dev/highlevels/interfaces/index.html index bd6566c0e37..b684fa9c11d 100644 --- a/dev/highlevels/interfaces/index.html +++ b/dev/highlevels/interfaces/index.html @@ -1,2 +1,2 @@ -The SciML Interface Libraries · Overview of Julia's SciML

The SciML Interface Libraries

SciMLBase.jl: The SciML Common Interface

SciMLBase.jl defines the core interfaces of the SciML libraries, such as the definitions of abstract types like SciMLProblem, along with their instantiations like ODEProblem. While SciMLBase.jl is insufficient to solve any equations, it holds all the equation definitions, and thus downstream libraries which wish to allow for using SciML solvers without depending on any solvers can directly depend on SciMLBase.jl.

SciMLOperators.jl: The AbstractSciMLOperator Interface

SciMLOperators.jl defines the interface for how matrix-free linear and affine operators are defined and used throughout the SciML ecosystem.

DiffEqNoiseProcess.jl: The SciML Common Noise Interface

DiffEqNoiseProcess.jl defines the common interface for stochastic noise processes used by the equation solvers of the SciML ecosystem.

CommonSolve.jl: The Common Definition of Solve

CommonSolve.jl is the library that defines the solve, solve!, and init interfaces which are used throughout all the SciML equation solvers. It's defined as an extremely lightweight library so that other ecosystems can build on the same solve definition without clashing with SciML when both export.

Static.jl: A Shared Interface for Static Compile-Time Computation

Static.jl is a set of statically parameterized types for performing operations in a statically-defined (compiler-optimized) way with respect to values.

DiffEqBase.jl: A Library of Shared Components for Differential Equation Solvers

DiffEqBase.jl is the core shared component of the DifferentialEquations.jl ecosystem. It's not intended for non-developer users to interface directly with, instead it's used for the common functionality for uniformity of implementation between the solver libraries.

Third-Party Libraries to Note

ArrayInterface.jl: Extensions to the Julia AbstractArray Interface

ArrayInterface.jl are traits and functions which extend the Julia Base AbstractArray interface, giving a much larger set of queries to allow for writing high-performance generic code over all array types. For example, functions include can_change_size to know if an AbstractArray type is compatible with resize!, fast_scalar_indexing to know whether direct scalar indexing A[i] is optimized, and functions like findstructralnz to get the structural non-zeros of arbitrary sparse and structured matrices.

Adapt.jl: Conversion to Allow Chip-Generic Programs

Adapt.jl makes it possible to write code that is generic to the compute devices, i.e. code that works on both CPUs and GPUs. It defines the adapt function which acts like convert(T, x), but without the restriction of returning a T. This allows you to “convert” wrapper types, like Adjoint to be GPU compatible (for example) without throwing away the wrapper.

Example usage:

adapt(CuArray, ::Adjoint{Array})::Adjoint{CuArray}

AbstractFFTs.jl: High Level Shared Interface for Fast Fourier Transformation Libraries

AbstractFFTs.jl defines the common interface for Fast Fourier Transformations (FFTs) in Julia. Similar to SciMLBase.jl, AbstractFFTs.jl is not a solver library but instead a shared API which is extended by solver libraries such as FFTW.jl. Code written using AbstractFFTs.jl can be made compatible with FFT libraries without having an explicit dependency on a solver.

GPUArrays.jl: Common Interface for GPU-Based Array Types

GPUArrays.jl defines the shared higher-level operations for GPU-based array types, like CUDA.jl's CuArray and AMDGPU.jl's ROCmArray. Packages in SciML use the designation x isa AbstractGPUArray in order to find out if a user's operation is on the GPU and specialize computations.

RecipesBase.jl: Standard Plotting Recipe Interface

RecipesBase.jl defines the common interface for plotting recipes, composable transformations of Julia data types into simpler data types for visualization with libraries such as Plots.jl and Makie.jl. SciML libraries attempt to always include plot recipes wherever possible for ease of visualization.

Tables.jl: Common Interface for Tabular Data Types

Tables.jl is a common interface for defining tabular data structures, such as DataFrames.jl. SciML's libraries extend the Tables.jl interface to allow for automated conversions into data frame libraries without explicit dependence on any singular implementation.

+The SciML Interface Libraries · Overview of Julia's SciML

The SciML Interface Libraries

SciMLBase.jl: The SciML Common Interface

SciMLBase.jl defines the core interfaces of the SciML libraries, such as the definitions of abstract types like SciMLProblem, along with their instantiations like ODEProblem. While SciMLBase.jl is insufficient to solve any equations, it holds all the equation definitions, and thus downstream libraries which wish to allow for using SciML solvers without depending on any solvers can directly depend on SciMLBase.jl.

SciMLOperators.jl: The AbstractSciMLOperator Interface

SciMLOperators.jl defines the interface for how matrix-free linear and affine operators are defined and used throughout the SciML ecosystem.

DiffEqNoiseProcess.jl: The SciML Common Noise Interface

DiffEqNoiseProcess.jl defines the common interface for stochastic noise processes used by the equation solvers of the SciML ecosystem.

CommonSolve.jl: The Common Definition of Solve

CommonSolve.jl is the library that defines the solve, solve!, and init interfaces which are used throughout all the SciML equation solvers. It's defined as an extremely lightweight library so that other ecosystems can build on the same solve definition without clashing with SciML when both export.

Static.jl: A Shared Interface for Static Compile-Time Computation

Static.jl is a set of statically parameterized types for performing operations in a statically-defined (compiler-optimized) way with respect to values.

DiffEqBase.jl: A Library of Shared Components for Differential Equation Solvers

DiffEqBase.jl is the core shared component of the DifferentialEquations.jl ecosystem. It's not intended for non-developer users to interface directly with, instead it's used for the common functionality for uniformity of implementation between the solver libraries.

Third-Party Libraries to Note

ArrayInterface.jl: Extensions to the Julia AbstractArray Interface

ArrayInterface.jl are traits and functions which extend the Julia Base AbstractArray interface, giving a much larger set of queries to allow for writing high-performance generic code over all array types. For example, functions include can_change_size to know if an AbstractArray type is compatible with resize!, fast_scalar_indexing to know whether direct scalar indexing A[i] is optimized, and functions like findstructralnz to get the structural non-zeros of arbitrary sparse and structured matrices.

Adapt.jl: Conversion to Allow Chip-Generic Programs

Adapt.jl makes it possible to write code that is generic to the compute devices, i.e. code that works on both CPUs and GPUs. It defines the adapt function which acts like convert(T, x), but without the restriction of returning a T. This allows you to “convert” wrapper types, like Adjoint to be GPU compatible (for example) without throwing away the wrapper.

Example usage:

adapt(CuArray, ::Adjoint{Array})::Adjoint{CuArray}

AbstractFFTs.jl: High Level Shared Interface for Fast Fourier Transformation Libraries

AbstractFFTs.jl defines the common interface for Fast Fourier Transformations (FFTs) in Julia. Similar to SciMLBase.jl, AbstractFFTs.jl is not a solver library but instead a shared API which is extended by solver libraries such as FFTW.jl. Code written using AbstractFFTs.jl can be made compatible with FFT libraries without having an explicit dependency on a solver.

GPUArrays.jl: Common Interface for GPU-Based Array Types

GPUArrays.jl defines the shared higher-level operations for GPU-based array types, like CUDA.jl's CuArray and AMDGPU.jl's ROCmArray. Packages in SciML use the designation x isa AbstractGPUArray in order to find out if a user's operation is on the GPU and specialize computations.

RecipesBase.jl: Standard Plotting Recipe Interface

RecipesBase.jl defines the common interface for plotting recipes, composable transformations of Julia data types into simpler data types for visualization with libraries such as Plots.jl and Makie.jl. SciML libraries attempt to always include plot recipes wherever possible for ease of visualization.

Tables.jl: Common Interface for Tabular Data Types

Tables.jl is a common interface for defining tabular data structures, such as DataFrames.jl. SciML's libraries extend the Tables.jl interface to allow for automated conversions into data frame libraries without explicit dependence on any singular implementation.

diff --git a/dev/highlevels/inverse_problems/index.html b/dev/highlevels/inverse_problems/index.html index 22d0292c4d0..aea98f650d9 100644 --- a/dev/highlevels/inverse_problems/index.html +++ b/dev/highlevels/inverse_problems/index.html @@ -1,2 +1,2 @@ -Parameter Estimation, Bayesian Analysis, and Inverse Problems · Overview of Julia's SciML

Parameter Estimation, Bayesian Analysis, and Inverse Problems

Parameter estimation for models and equations, also known as dynamic data analysis, solving the inverse problem, or Bayesian posterior estimation (when done probabilistically), is provided by the SciML tools for the equations in its set. In this introduction, we briefly present the relevant packages that facilitate parameter estimation, namely:

We also provide information regarding the respective strengths of these packages so that you can easily decide which one suits your needs best.

SciMLSensitivity.jl: Local Sensitivity Analysis and Automatic Differentiation Support for Solvers

SciMLSensitivity.jl is the system for local sensitivity, which all other inverse problem methods rely on. This package defines the interactions between the equation solvers and automatic differentiation, defining fast overloads for forward and adjoint (reverse) sensitivity analysis for fast gradient and Jacobian calculations with respect to model inputs. Its documentation covers how to use direct differentiation of equation solvers in conjunction with tools like Optimization.jl to perform model calibration of ODEs against data, PDE-constrained optimization, nonlinear optimal controls analysis, and much more. As a lower level tool, this library is very versatile, feature-rich, and high-performance, giving all the tools required but not directly providing a higher level interface.

Note

Sensitivity analysis is kept in a separate library from the solvers (SciMLSensitivity.jl), in order to not require all equation solvers to have a dependency on all automatic differentiation libraries. If automatic differentiation is applied to a solver library without importing SciMLSensitivity.jl, an error is thrown letting the user know to import SciMLSensitivity.jl for the functionality to exist.

DataDrivenDiffEq.jl: Data-Driven Modeling and Equation Discovery

The distinguishing feature of this package is that its ultimate goal is to identify the differential equation model that generated the input data. Depending on the user's needs, the package can provide structural identification of a given differential equation (output in a symbolic form) or structural estimation (output as a function for prediction purposes).

DiffEqParamEstim.jl: Simplified Parameter Estimation Interface

This package is for simplified parameter estimation. While not as flexible of a system like DiffEqFlux.jl, it provides ready-made functions for doing standard optimization procedures like L2 fitting and MAP estimates. Among other features, it allows for the optimization of parameters in ODEs, stochastic problems, and delay differential equations.

DiffEqBayes.jl: Simplified Bayesian Estimation Interface

As the name suggests, this package has been designed to provide the estimation of differential equations parameters by Bayesian methods. It works in conjunction with Turing.jl, CmdStan.jl, DynamicHMC.jl, and ApproxBayes.jl. While not as flexible as direct usage of DiffEqFlux.jl or Turing.jl, DiffEqBayes.jl can be an approachable interface for those not familiar with Bayesian estimation, and provides a nice way to use Stan from pure Julia.

Third-Party Tools of Note

Turing.jl: A Flexible Probabilistic Programming Language for Bayesian Analysis

In the context of differential equations and parameter estimation, Turing.jl allows for a Bayesian estimation of differential equations (used in conjunction with the high-level package DiffEqBayes.jl). For more examples on combining Turing.jl with DiffEqBayes.jl, see the documentation below. It is important to note that Turing.jl can also perform Bayesian estimation without relying on DiffEqBayes.jl (for an example, consult this tutorial).

Topopt.jl: Topology Optimization in Julia

Topopt.jl solves topology optimization problems which are inverse problems on partial differential equations, solving for an optimal domain.

Recommended Automatic Differentiation Libraries

Solving inverse problems commonly requires using automatic differentiation (AD). SciML includes extensive support for automatic differentiation throughout its solvers, though some AD libraries are more tested than others. The following libraries are the current recommendations of the SciML developers.

ForwardDiff.jl: Operator-Overloading Forward Mode Automatic Differentiation

ForwardDiff.jl is a library for operator-overloading based forward-mode automatic differentiation. It's commonly used as the default method for generating Jacobians throughout the SciML solver libraries.

Note

Because ForwardDiff.jl uses an operator overloading approach, uses of ForwardDiff.jl require that any caches for non-allocating mutating code allows for Dual numbers. To allow such code to be ForwardDiff.jl-compatible, see PreallocationTools.jl.

Enzyme.jl: LLVM-Level Forward and Reverse Mode Automatic Differentiation

Enzyme.jl is an LLVM-level AD library for forward and reverse automatic differentiation. It supports many features required for high performance, such as being able to differentiate mutating and interleave compiler optimization with the AD passes. However, it does not support all of the Julia runtime, and thus some code with many dynamic behaviors and garbage collection (GC) invocations can be incompatible with Enzyme. Enzyme.jl is quickly becoming the new standard AD for SciML.

Zygote.jl: Julia-Level Source-to-Source Reverse Mode Automatic Differentiation

Zygote.jl is the current standard user-level reverse-mode automatic differentiation library for the SciML solvers. User-level means that many library tutorials, like in SciMLSensitivity.jl and DiffEqFlux.jl, showcase user code using Zygote.jl. This is because Zygote.jl is the AD engine associated with the Flux machine learning library. However, Zygote.jl has many limitations which limits its performance in equation solver contexts, such as an inability to handle mutation and introducing many small allocations and type-instabilities. For this reason, the SciML equation solvers define differentiation overloads using ChainRules.jl, meaning that the equation solvers tend not to use Zygote.jl internally even if the user code uses Zygote.gradient. In this manner, the speed and performance of more advanced techniques can be preserved while using the Julia standard.

FiniteDiff.jl: Fast Finite Difference Approximations

FiniteDiff.jl is the preferred fallback library for numerical differentiation and is commonly used by SciML solver libraries when automatic differentiation is disabled.

SparseDiffTools.jl: Tools for Fast Automatic Differentiation with Sparse Operators

SparseDiffTools.jl is a library for sparse automatic differentiation. It's used internally by many of the SciML equation solver libraries, which explicitly expose interfaces for colorvec color vectors generated by SparseDiffTools.jl's methods. SparseDiffTools.jl also includes many features useful to users, such as operators for matrix-free Jacobian-vector and Hessian-vector products.

+Parameter Estimation, Bayesian Analysis, and Inverse Problems · Overview of Julia's SciML

Parameter Estimation, Bayesian Analysis, and Inverse Problems

Parameter estimation for models and equations, also known as dynamic data analysis, solving the inverse problem, or Bayesian posterior estimation (when done probabilistically), is provided by the SciML tools for the equations in its set. In this introduction, we briefly present the relevant packages that facilitate parameter estimation, namely:

We also provide information regarding the respective strengths of these packages so that you can easily decide which one suits your needs best.

SciMLSensitivity.jl: Local Sensitivity Analysis and Automatic Differentiation Support for Solvers

SciMLSensitivity.jl is the system for local sensitivity, which all other inverse problem methods rely on. This package defines the interactions between the equation solvers and automatic differentiation, defining fast overloads for forward and adjoint (reverse) sensitivity analysis for fast gradient and Jacobian calculations with respect to model inputs. Its documentation covers how to use direct differentiation of equation solvers in conjunction with tools like Optimization.jl to perform model calibration of ODEs against data, PDE-constrained optimization, nonlinear optimal controls analysis, and much more. As a lower level tool, this library is very versatile, feature-rich, and high-performance, giving all the tools required but not directly providing a higher level interface.

Note

Sensitivity analysis is kept in a separate library from the solvers (SciMLSensitivity.jl), in order to not require all equation solvers to have a dependency on all automatic differentiation libraries. If automatic differentiation is applied to a solver library without importing SciMLSensitivity.jl, an error is thrown letting the user know to import SciMLSensitivity.jl for the functionality to exist.

DataDrivenDiffEq.jl: Data-Driven Modeling and Equation Discovery

The distinguishing feature of this package is that its ultimate goal is to identify the differential equation model that generated the input data. Depending on the user's needs, the package can provide structural identification of a given differential equation (output in a symbolic form) or structural estimation (output as a function for prediction purposes).

DiffEqParamEstim.jl: Simplified Parameter Estimation Interface

This package is for simplified parameter estimation. While not as flexible of a system like DiffEqFlux.jl, it provides ready-made functions for doing standard optimization procedures like L2 fitting and MAP estimates. Among other features, it allows for the optimization of parameters in ODEs, stochastic problems, and delay differential equations.

DiffEqBayes.jl: Simplified Bayesian Estimation Interface

As the name suggests, this package has been designed to provide the estimation of differential equations parameters by Bayesian methods. It works in conjunction with Turing.jl, CmdStan.jl, DynamicHMC.jl, and ApproxBayes.jl. While not as flexible as direct usage of DiffEqFlux.jl or Turing.jl, DiffEqBayes.jl can be an approachable interface for those not familiar with Bayesian estimation, and provides a nice way to use Stan from pure Julia.

Third-Party Tools of Note

Turing.jl: A Flexible Probabilistic Programming Language for Bayesian Analysis

In the context of differential equations and parameter estimation, Turing.jl allows for a Bayesian estimation of differential equations (used in conjunction with the high-level package DiffEqBayes.jl). For more examples on combining Turing.jl with DiffEqBayes.jl, see the documentation below. It is important to note that Turing.jl can also perform Bayesian estimation without relying on DiffEqBayes.jl (for an example, consult this tutorial).

Topopt.jl: Topology Optimization in Julia

Topopt.jl solves topology optimization problems which are inverse problems on partial differential equations, solving for an optimal domain.

Recommended Automatic Differentiation Libraries

Solving inverse problems commonly requires using automatic differentiation (AD). SciML includes extensive support for automatic differentiation throughout its solvers, though some AD libraries are more tested than others. The following libraries are the current recommendations of the SciML developers.

ForwardDiff.jl: Operator-Overloading Forward Mode Automatic Differentiation

ForwardDiff.jl is a library for operator-overloading based forward-mode automatic differentiation. It's commonly used as the default method for generating Jacobians throughout the SciML solver libraries.

Note

Because ForwardDiff.jl uses an operator overloading approach, uses of ForwardDiff.jl require that any caches for non-allocating mutating code allows for Dual numbers. To allow such code to be ForwardDiff.jl-compatible, see PreallocationTools.jl.

Enzyme.jl: LLVM-Level Forward and Reverse Mode Automatic Differentiation

Enzyme.jl is an LLVM-level AD library for forward and reverse automatic differentiation. It supports many features required for high performance, such as being able to differentiate mutating and interleave compiler optimization with the AD passes. However, it does not support all of the Julia runtime, and thus some code with many dynamic behaviors and garbage collection (GC) invocations can be incompatible with Enzyme. Enzyme.jl is quickly becoming the new standard AD for SciML.

Zygote.jl: Julia-Level Source-to-Source Reverse Mode Automatic Differentiation

Zygote.jl is the current standard user-level reverse-mode automatic differentiation library for the SciML solvers. User-level means that many library tutorials, like in SciMLSensitivity.jl and DiffEqFlux.jl, showcase user code using Zygote.jl. This is because Zygote.jl is the AD engine associated with the Flux machine learning library. However, Zygote.jl has many limitations which limits its performance in equation solver contexts, such as an inability to handle mutation and introducing many small allocations and type-instabilities. For this reason, the SciML equation solvers define differentiation overloads using ChainRules.jl, meaning that the equation solvers tend not to use Zygote.jl internally even if the user code uses Zygote.gradient. In this manner, the speed and performance of more advanced techniques can be preserved while using the Julia standard.

FiniteDiff.jl: Fast Finite Difference Approximations

FiniteDiff.jl is the preferred fallback library for numerical differentiation and is commonly used by SciML solver libraries when automatic differentiation is disabled.

SparseDiffTools.jl: Tools for Fast Automatic Differentiation with Sparse Operators

SparseDiffTools.jl is a library for sparse automatic differentiation. It's used internally by many of the SciML equation solver libraries, which explicitly expose interfaces for colorvec color vectors generated by SparseDiffTools.jl's methods. SparseDiffTools.jl also includes many features useful to users, such as operators for matrix-free Jacobian-vector and Hessian-vector products.

diff --git a/dev/highlevels/learning_resources/index.html b/dev/highlevels/learning_resources/index.html index 3323ea7d79f..051042429d1 100644 --- a/dev/highlevels/learning_resources/index.html +++ b/dev/highlevels/learning_resources/index.html @@ -1,2 +1,2 @@ -Curated Learning, Teaching, and Training Resources · Overview of Julia's SciML

Curated Learning, Teaching, and Training Resources

While the SciML documentation is made to be comprehensive, there will always be good alternative resources. The purpose of this section of the documentation is to highlight the alternative resources which can be helpful for learning how to use the SciML Open-Source Software libraries.

JuliaCon and SciMLCon Videos

Many tutorials and introductions to packages have been taught through previous JuliaCon/SciMLCon workshops and talks. The following is a curated list of such training videos:

SciML Book: Parallel Computing and Scientific Machine Learning (SciML): Methods and Applications

The book Parallel Computing and Scientific Machine Learning (SciML): Methods and Applications is a compilation of the lecture notes from the MIT Course 18.337J/6.338J: Parallel Computing and Scientific Machine Learning. It contains a walkthrough of many of the methods implemented in the SciML libraries, as well as how to understand much of the functionality at a deeper level. This course was intended for MIT graduate students in engineering, computer science, and mathematics and thus may have a high prerequisite requirement than many other resources.

sir-julia: Various implementations of the classical SIR model in Julia

For those who like to learn by example, the repository sir-julia is a great resource! It showcases how to use the SciML libraries in many different ways to simulate different variations of the classic SIR epidemic model.

Other Books Featuring SciML

+Curated Learning, Teaching, and Training Resources · Overview of Julia's SciML

Curated Learning, Teaching, and Training Resources

While the SciML documentation is made to be comprehensive, there will always be good alternative resources. The purpose of this section of the documentation is to highlight the alternative resources which can be helpful for learning how to use the SciML Open-Source Software libraries.

JuliaCon and SciMLCon Videos

Many tutorials and introductions to packages have been taught through previous JuliaCon/SciMLCon workshops and talks. The following is a curated list of such training videos:

SciML Book: Parallel Computing and Scientific Machine Learning (SciML): Methods and Applications

The book Parallel Computing and Scientific Machine Learning (SciML): Methods and Applications is a compilation of the lecture notes from the MIT Course 18.337J/6.338J: Parallel Computing and Scientific Machine Learning. It contains a walkthrough of many of the methods implemented in the SciML libraries, as well as how to understand much of the functionality at a deeper level. This course was intended for MIT graduate students in engineering, computer science, and mathematics and thus may have a high prerequisite requirement than many other resources.

sir-julia: Various implementations of the classical SIR model in Julia

For those who like to learn by example, the repository sir-julia is a great resource! It showcases how to use the SciML libraries in many different ways to simulate different variations of the classic SIR epidemic model.

Other Books Featuring SciML

diff --git a/dev/highlevels/model_libraries_and_importers/index.html b/dev/highlevels/model_libraries_and_importers/index.html index 210ae3dac12..7ad6afab2e6 100644 --- a/dev/highlevels/model_libraries_and_importers/index.html +++ b/dev/highlevels/model_libraries_and_importers/index.html @@ -1,2 +1,2 @@ -Model Libraries and Importers · Overview of Julia's SciML

Model Libraries and Importers

Models are passed on from generation to generation. Many models are not built from scratch but have a legacy of the known physics, biology, and chemistry embedded into them. Julia's SciML offers a range of pre-built modeling tools, from reusable acausal components to direct imports from common file formats.

ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit

Given the composable nature of acausal modeling systems, it's helpful to not have to define every component from scratch and instead build off a common base of standard components. ModelingToolkitStandardLibrary.jl is that library. It provides components for standard models to start building everything from circuits and engines to robots.

DiffEqCallbacks.jl: Pre-Made Callbacks for DifferentialEquations.jl

DiffEqCallbacks.jl has many event handling and callback definitions which allow for quickly building up complex differential equation models. It includes:

  • Callbacks for specialized output and saving procedures
  • Callbacks for enforcing domain constraints, positivity, and manifolds
  • Timed callbacks for periodic dosing, presetting of tstops, and more
  • Callbacks for determining and terminating at steady state
  • Callbacks for controlling stepsizes and enforcing CFL conditions
  • Callbacks for quantifying uncertainty with respect to numerical errors

SBMLToolkit.jl: SBML Import

SBMLToolkit.jl is a library for reading SBML files into the standard formats for Catalyst.jl and ModelingToolkit.jl. There are well over one thousand biological models available in the BioModels Repository.

CellMLToolkit.jl: CellML Import

CellMLToolkit.jl is a library for reading CellML files into the standard formats for ModelingToolkit.jl. There are several hundred biological models available in the CellML Model Repository.

ReactionNetworkImporters.jl: BioNetGen Import

ReactionNetworkImporters.jl is a library for reading BioNetGen .net files and various stoichiometry matrix representations into the standard formats for Catalyst.jl and ModelingToolkit.jl.

+Model Libraries and Importers · Overview of Julia's SciML

Model Libraries and Importers

Models are passed on from generation to generation. Many models are not built from scratch but have a legacy of the known physics, biology, and chemistry embedded into them. Julia's SciML offers a range of pre-built modeling tools, from reusable acausal components to direct imports from common file formats.

ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit

Given the composable nature of acausal modeling systems, it's helpful to not have to define every component from scratch and instead build off a common base of standard components. ModelingToolkitStandardLibrary.jl is that library. It provides components for standard models to start building everything from circuits and engines to robots.

DiffEqCallbacks.jl: Pre-Made Callbacks for DifferentialEquations.jl

DiffEqCallbacks.jl has many event handling and callback definitions which allow for quickly building up complex differential equation models. It includes:

  • Callbacks for specialized output and saving procedures
  • Callbacks for enforcing domain constraints, positivity, and manifolds
  • Timed callbacks for periodic dosing, presetting of tstops, and more
  • Callbacks for determining and terminating at steady state
  • Callbacks for controlling stepsizes and enforcing CFL conditions
  • Callbacks for quantifying uncertainty with respect to numerical errors

SBMLToolkit.jl: SBML Import

SBMLToolkit.jl is a library for reading SBML files into the standard formats for Catalyst.jl and ModelingToolkit.jl. There are well over one thousand biological models available in the BioModels Repository.

CellMLToolkit.jl: CellML Import

CellMLToolkit.jl is a library for reading CellML files into the standard formats for ModelingToolkit.jl. There are several hundred biological models available in the CellML Model Repository.

ReactionNetworkImporters.jl: BioNetGen Import

ReactionNetworkImporters.jl is a library for reading BioNetGen .net files and various stoichiometry matrix representations into the standard formats for Catalyst.jl and ModelingToolkit.jl.

diff --git a/dev/highlevels/modeling_languages/index.html b/dev/highlevels/modeling_languages/index.html index f7b445f7c43..cc42622ab4d 100644 --- a/dev/highlevels/modeling_languages/index.html +++ b/dev/highlevels/modeling_languages/index.html @@ -1,2 +1,2 @@ -Modeling Languages · Overview of Julia's SciML

Modeling Languages

While in theory one can build perfect code for all models from scratch, in practice many scientists and engineers need or want some help! The SciML modeling tools provide a higher level interface over the equation solver, which helps the translation from good models to good simulations in a way that abstracts away the mathematical and computational details without giving up performance.

ModelingToolkit.jl: Acausal Symbolic Modeling

Acausal modeling is an extension of causal modeling that is more composable and allows for more code reuse. Build a model of an electric engine, then build a model of a battery, and now declare connections by stating "the voltage at the engine equals the voltage at the connector of the battery", and generate the composed model. The tool for this is ModelingToolkit.jl. ModelingToolkit.jl is a sophisticated symbolic modeling library which allows for specifying these types of large-scale differential equation models in a simple way, abstracting away the computational details. However, its symbolic analysis allows for generating much more performant code for differential-algebraic equations than most users could ever write by hand, with its structural_simplify automatically correcting the model to improve parallelism, numerical stability, and automatically remove variables which it can show are redundant.

ModelingToolkit.jl is the base of the SciML symbolic modeling ecosystem, defining the AbstractSystem types, such as ODESystem, SDESystem, OptimizationSystem, PDESystem, and more, which are then used by all the other modeling tools. As such, when using other modeling tools like Catalyst.jl, the reference for all the things that can be done with the symbolic representation is simply ModelingToolkit.jl.

Catalyst.jl: Chemical Reaction Networks (CRN), Systems Biology, and Quantitative Systems Pharmacology (QSP) Modeling

Catalyst.jl is a modeling interface for efficient simulation of mass action ODE, chemical Langevin SDE, and stochastic chemical kinetics jump process (i.e. chemical master equation) models for chemical reaction networks and population processes. It uses a highly intuitive chemical reaction syntax interface, which generates all the extra functionality necessary for the fastest use with JumpProcesses.jl, DifferentialEquations.jl, and higher level SciML libraries. Its ReactionSystem type is a programmable extension of the ModelingToolkit AbstractSystem interface, meaning that complex reaction systems are represented symbolically, and then compiled to optimized representations automatically when converting ReactionSystems to concrete ODE/SDE/jump process representations. Catalyst also provides functionality to support chemical reaction network and steady-state analysis.

For an overview of the library, see Modeling Biochemical Systems with Catalyst.jl - Samuel Isaacson

NBodySimulator.jl: A differentiable simulator for N-body problems, including astrophysical and molecular dynamics

NBodySimulator.jl is a differentiable simulator for N-body problems, including astrophysical and molecular dynamics. It uses the DifferentialEquations.jl solvers, allowing for one to choose between a large variety of symplectic integration schemes. It implements many of the thermostats required for doing standard molecular dynamics approximations.

DiffEqFinancial.jl: Financial models for use in the DifferentialEquations ecosystem

The goal of DiffEqFinancial.jl is to be a feature-complete set of solvers for the types of problems found in libraries like QuantLib, such as the Heston process or the Black-Scholes model.

ParameterizedFunctions.jl: Simple Differential Equation Definitions Made Easy

This image that went viral is actually runnable code from ParameterizedFunctions.jl. Define equations and models using a very simple high-level syntax and let the code generation tools build symbolic fast Jacobian, gradient, etc. functions for you.

Third-Party Tools of Note

MomentClosure.jl: Automated Generation of Moment Closure Equations

MomentClosure.jl is a library for generating the moment closure equations for a given chemical master equation or stochastic differential equation. Thus instead of solving a stochastic model thousands of times to find the mean and variance, this library can generate the deterministic equations for how the mean and variance evolve in order to be solved in a single run. MomentClosure.jl uses Catalyst ReactionSystem and ModelingToolkit SDESystem types as the input for its symbolic generation processes.

Agents.jl: Agent-Based Modeling Framework in Julia

If one wants to do agent-based modeling in Julia, Agents.jl is the go-to library. It's fast and flexible, making it a solid foundation for any agent-based model.

Unitful.jl: A Julia package for physical units

Supports not only SI units, but also any other unit system. Unitful.jl has minimal run-time penalty of units. Includes facilities for dimensional analysis, and integrates easily with the usual mathematical operations and collections that are defined in Julia.

ReactionMechanismSimulator.jl: Simulation and Analysis of Large Chemical Reaction Systems

ReactionMechanismSimulator.jl is a tool for simulating and analyzing large chemical reaction mechanisms. It interfaces with the ReactionMechanismGenerator suite for automatically constructing reaction pathways from chemical components to quickly build realistic models of chemical systems.

FiniteStateProjection.jl: Direct Solution of Chemical Master Equations

FiniteStateProjection.jl is a library for finite state projection direct solving of the chemical master equation. It automatically converts the Catalyst ReactionSystem definitions into ModelingToolkit ODESystem representations for the evolution of probability distributions to allow for directly solving the weak form of the stochastic model.

AlgebraicPetri.jl: Applied Category Theory of Modeling

AlgebraicPetri.jl is a library for automating the intuitive generation of dynamical models using a Category theory-based approach.

QuantumOptics.jl: Simulating quantum systems.

QuantumOptics.jl makes it easy to simulate various kinds of quantum systems. It is inspired by the Quantum Optics Toolbox for MATLAB and the Python framework QuTiP.

+Modeling Languages · Overview of Julia's SciML

Modeling Languages

While in theory one can build perfect code for all models from scratch, in practice many scientists and engineers need or want some help! The SciML modeling tools provide a higher level interface over the equation solver, which helps the translation from good models to good simulations in a way that abstracts away the mathematical and computational details without giving up performance.

ModelingToolkit.jl: Acausal Symbolic Modeling

Acausal modeling is an extension of causal modeling that is more composable and allows for more code reuse. Build a model of an electric engine, then build a model of a battery, and now declare connections by stating "the voltage at the engine equals the voltage at the connector of the battery", and generate the composed model. The tool for this is ModelingToolkit.jl. ModelingToolkit.jl is a sophisticated symbolic modeling library which allows for specifying these types of large-scale differential equation models in a simple way, abstracting away the computational details. However, its symbolic analysis allows for generating much more performant code for differential-algebraic equations than most users could ever write by hand, with its structural_simplify automatically correcting the model to improve parallelism, numerical stability, and automatically remove variables which it can show are redundant.

ModelingToolkit.jl is the base of the SciML symbolic modeling ecosystem, defining the AbstractSystem types, such as ODESystem, SDESystem, OptimizationSystem, PDESystem, and more, which are then used by all the other modeling tools. As such, when using other modeling tools like Catalyst.jl, the reference for all the things that can be done with the symbolic representation is simply ModelingToolkit.jl.

Catalyst.jl: Chemical Reaction Networks (CRN), Systems Biology, and Quantitative Systems Pharmacology (QSP) Modeling

Catalyst.jl is a modeling interface for efficient simulation of mass action ODE, chemical Langevin SDE, and stochastic chemical kinetics jump process (i.e. chemical master equation) models for chemical reaction networks and population processes. It uses a highly intuitive chemical reaction syntax interface, which generates all the extra functionality necessary for the fastest use with JumpProcesses.jl, DifferentialEquations.jl, and higher level SciML libraries. Its ReactionSystem type is a programmable extension of the ModelingToolkit AbstractSystem interface, meaning that complex reaction systems are represented symbolically, and then compiled to optimized representations automatically when converting ReactionSystems to concrete ODE/SDE/jump process representations. Catalyst also provides functionality to support chemical reaction network and steady-state analysis.

For an overview of the library, see Modeling Biochemical Systems with Catalyst.jl - Samuel Isaacson

NBodySimulator.jl: A differentiable simulator for N-body problems, including astrophysical and molecular dynamics

NBodySimulator.jl is a differentiable simulator for N-body problems, including astrophysical and molecular dynamics. It uses the DifferentialEquations.jl solvers, allowing for one to choose between a large variety of symplectic integration schemes. It implements many of the thermostats required for doing standard molecular dynamics approximations.

DiffEqFinancial.jl: Financial models for use in the DifferentialEquations ecosystem

The goal of DiffEqFinancial.jl is to be a feature-complete set of solvers for the types of problems found in libraries like QuantLib, such as the Heston process or the Black-Scholes model.

ParameterizedFunctions.jl: Simple Differential Equation Definitions Made Easy

This image that went viral is actually runnable code from ParameterizedFunctions.jl. Define equations and models using a very simple high-level syntax and let the code generation tools build symbolic fast Jacobian, gradient, etc. functions for you.

Third-Party Tools of Note

MomentClosure.jl: Automated Generation of Moment Closure Equations

MomentClosure.jl is a library for generating the moment closure equations for a given chemical master equation or stochastic differential equation. Thus instead of solving a stochastic model thousands of times to find the mean and variance, this library can generate the deterministic equations for how the mean and variance evolve in order to be solved in a single run. MomentClosure.jl uses Catalyst ReactionSystem and ModelingToolkit SDESystem types as the input for its symbolic generation processes.

Agents.jl: Agent-Based Modeling Framework in Julia

If one wants to do agent-based modeling in Julia, Agents.jl is the go-to library. It's fast and flexible, making it a solid foundation for any agent-based model.

Unitful.jl: A Julia package for physical units

Supports not only SI units, but also any other unit system. Unitful.jl has minimal run-time penalty of units. Includes facilities for dimensional analysis, and integrates easily with the usual mathematical operations and collections that are defined in Julia.

ReactionMechanismSimulator.jl: Simulation and Analysis of Large Chemical Reaction Systems

ReactionMechanismSimulator.jl is a tool for simulating and analyzing large chemical reaction mechanisms. It interfaces with the ReactionMechanismGenerator suite for automatically constructing reaction pathways from chemical components to quickly build realistic models of chemical systems.

FiniteStateProjection.jl: Direct Solution of Chemical Master Equations

FiniteStateProjection.jl is a library for finite state projection direct solving of the chemical master equation. It automatically converts the Catalyst ReactionSystem definitions into ModelingToolkit ODESystem representations for the evolution of probability distributions to allow for directly solving the weak form of the stochastic model.

AlgebraicPetri.jl: Applied Category Theory of Modeling

AlgebraicPetri.jl is a library for automating the intuitive generation of dynamical models using a Category theory-based approach.

QuantumOptics.jl: Simulating quantum systems.

QuantumOptics.jl makes it easy to simulate various kinds of quantum systems. It is inspired by the Quantum Optics Toolbox for MATLAB and the Python framework QuTiP.

diff --git a/dev/highlevels/numerical_utilities/index.html b/dev/highlevels/numerical_utilities/index.html index 93495b90d62..f43f7510081 100644 --- a/dev/highlevels/numerical_utilities/index.html +++ b/dev/highlevels/numerical_utilities/index.html @@ -1,2 +1,2 @@ -SciML Numerical Utility Libraries · Overview of Julia's SciML

SciML Numerical Utility Libraries

ExponentialUtilities.jl: Faster Matrix Exponentials

ExponentialUtilities.jl is a library for efficient computation of matrix exponentials. While Julia has a built-in exp(A) method, ExponentialUtilities.jl offers many features around this to improve performance in scientific contexts, including:

  • Faster methods for (non-allocating) matrix exponentials via exponential!
  • Methods for computing matrix exponential that are generic to number types and arrays (i.e. GPUs)
  • Methods for computing Arnoldi iterations on Krylov subspaces
  • Direct computation of exp(t*A)*v, i.e. exponentiation of a matrix times a vector, without computing the matrix exponential
  • Direct computation of ϕ_m(t*A)*v operations, where ϕ_0(z) = exp(z) and ϕ_(k+1)(z) = (ϕ_k(z) - 1) / z

ExponentialUtilities.jl includes complex adaptive time stepping techniques such as KIOPS in order to perform these calculations in a fast and numerically-stable way.

QuasiMonteCarlo.jl: Fast Quasi-Random Number Generation

QuasiMonteCarlo.jl is a library for fast generation of low discrepancy Quasi-Monte Carlo samples, using methods like:

  • GridSample(dx) where the grid is given by lb:dx[i]:ub in the ith direction.
  • UniformSample for uniformly distributed random numbers.
  • SobolSample for the Sobol sequence.
  • LatinHypercubeSample for a Latin Hypercube.
  • LatticeRuleSample for a randomly-shifted rank-1 lattice rule.
  • LowDiscrepancySample(base) where base[i] is the base in the ith direction.
  • GoldenSample for a Golden Ratio sequence.
  • KroneckerSample(alpha, s0) for a Kronecker sequence, where alpha is a length-d vector of irrational numbers (often sqrt(d)) and s0 is a length-d seed vector (often 0).
  • SectionSample(x0, sampler) where sampler is any sampler above and x0 is a vector of either NaN for a free dimension or some scalar for a constrained dimension.

DataInterpolations.jl: One-Dimensional Interpolations

DataInterpolations.jl is a library of one-dimensional interpolation schemes which are composable with automatic differentiation and the SciML ecosystem. It includes direct interpolation methods and regression techniques for handling noisy data. Its methods include:

  • ConstantInterpolation(u,t) - A piecewise constant interpolation.

  • LinearInterpolation(u,t) - A linear interpolation.

  • QuadraticInterpolation(u,t) - A quadratic interpolation.

  • LagrangeInterpolation(u,t,n) - A Lagrange interpolation of order n.

  • QuadraticSpline(u,t) - A quadratic spline interpolation.

  • CubicSpline(u,t) - A cubic spline interpolation.

  • BSplineInterpolation(u,t,d,pVec,knotVec) - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:

    • d - degree of B-spline
    • pVec - Symbol to Parameters Vector, pVec = :Uniform for uniform spaced parameters and pVec = :ArcLen for parameters generated by chord length method.
    • knotVec - Symbol to Knot Vector, knotVec = :Uniform for uniform knot vector, knotVec = :Average for average spaced knot vector.
  • BSplineApprox(u,t,d,h,pVec,knotVec) - A regression B-spline which smooths the fitting curve. The argument choices are the same as the BSplineInterpolation, with the additional parameter h<length(t) which is the number of control points to use, with smaller h indicating more smoothing.

  • Curvefit(u,t,m,p,alg) - An interpolation which is done by fitting a user-given functional form m(t,p) where p is the vector of parameters. The user's input p is an initial value for a least-square fitting, alg is the algorithm choice used to optimize the cost function (sum of squared deviations) via Optim.jl and optimal ps are used in the interpolation.

These interpolations match the SciML interfaces and have direct support for packages like ModelingToolkit.jl.

PoissonRandom.jl: Fast Poisson Random Number Generation

PoissonRandom.jl is just fast Poisson random number generation for Poisson processes, like chemical master equations.

PreallocationTools.jl: Write Non-Allocating Code Easier

PreallocationTools.jl is a library of tools for writing non-allocating code that interacts well with advanced features like automatic differentiation and symbolics.

RuntimeGeneratedFunctions.jl: Efficient Staged Programming in Julia

RuntimeGeneratedFunctions.jl allows for staged programming in Julia, compiling functions at runtime with full optimizations. This is used by many libraries such as ModelingToolkit.jl to allow for runtime code generation for improved performance.

EllipsisNotation.jl: Implementation of Ellipsis Array Slicing

EllipsisNotation.jl defines the ellipsis array slicing notation for Julia. It uses .. as a catch-all for “all dimensions”, allowing for indexing like [..,1] to mean [:,:,:,1] on four dimensional arrays, in a way that is generic to the number of dimensions in the underlying array.

Third-Party Libraries to Note

Distributions.jl: Representations of Probability Distributions

Distributions.jl is a library for defining distributions in Julia. It's used all throughout the SciML libraries for specifications of probability distributions.

Note

For full compatibility with automatic differentiation, see DistributionsAD.jl

FFTW.jl: Fastest Fourier Transformation in the West

FFTW.jl is the preferred library for fast Fourier Transformations on the CPU.

SpecialFunctions.jl: Implementations of Mathematical Special Functions

SpecialFunctions.jl is a library of implementations of special functions, like Bessel functions and error functions (erf). This library is compatible with automatic differentiation.

LoopVectorization.jl: Automated Loop Accelerator

LoopVectorization.jl is a library which provides the @turbo and @tturbo macros for accelerating the computation of loops. This can be used to accelerating the model functions sent to the equation solvers, for example, accelerating handwritten PDE discretizations.

Polyester.jl: Cheap Threads

Polyester.jl is a cheaper version of threads for Julia, which use a set pool of threads for lower overhead. Note that Polyester does not compose with the standard Julia composable threading infrastructure, and thus one must take care not to compose two levels of Polyester, as this will oversubscribe the computation and lead to performance degradation. Many SciML solvers have options to use Polyester for threading to achieve the top performance.

Tullio.jl: Fast Tensor Calculations and Einstein Notation

Tullio.jl is a library for fast tensor calculations with Einstein notation. It allows for defining operations which are compatible with automatic differentiation, GPUs, and more.

ParallelStencil.jl: High-Level Code for Parallelized Stencil Computations

ParallelStencil.jl is a library for writing high-level code for parallelized stencil computations. It is compatible with SciML equation solvers and is thus a good way to generate GPU and distributed parallel model code.

Julia Utilities

StaticCompiler.jl

StaticCompiler.jl is a package for generating static binaries from Julia code. It only supports a subset of Julia, so not all equation solver algorithms are compatible with StaticCompiler.jl.

PackageCompiler.jl

PackageCompiler.jl is a package for generating shared libraries from Julia code. It builds the entirety of Julia by bundling a system image with the Julia runtime. It thus builds complete binaries that can hold all the functionality of SciML. Furthermore, it can also be used to generate new system images to decrease startup times and remove JIT-compilation from SciML usage.

+SciML Numerical Utility Libraries · Overview of Julia's SciML

SciML Numerical Utility Libraries

ExponentialUtilities.jl: Faster Matrix Exponentials

ExponentialUtilities.jl is a library for efficient computation of matrix exponentials. While Julia has a built-in exp(A) method, ExponentialUtilities.jl offers many features around this to improve performance in scientific contexts, including:

  • Faster methods for (non-allocating) matrix exponentials via exponential!
  • Methods for computing matrix exponential that are generic to number types and arrays (i.e. GPUs)
  • Methods for computing Arnoldi iterations on Krylov subspaces
  • Direct computation of exp(t*A)*v, i.e. exponentiation of a matrix times a vector, without computing the matrix exponential
  • Direct computation of ϕ_m(t*A)*v operations, where ϕ_0(z) = exp(z) and ϕ_(k+1)(z) = (ϕ_k(z) - 1) / z

ExponentialUtilities.jl includes complex adaptive time stepping techniques such as KIOPS in order to perform these calculations in a fast and numerically-stable way.

QuasiMonteCarlo.jl: Fast Quasi-Random Number Generation

QuasiMonteCarlo.jl is a library for fast generation of low discrepancy Quasi-Monte Carlo samples, using methods like:

  • GridSample(dx) where the grid is given by lb:dx[i]:ub in the ith direction.
  • UniformSample for uniformly distributed random numbers.
  • SobolSample for the Sobol sequence.
  • LatinHypercubeSample for a Latin Hypercube.
  • LatticeRuleSample for a randomly-shifted rank-1 lattice rule.
  • LowDiscrepancySample(base) where base[i] is the base in the ith direction.
  • GoldenSample for a Golden Ratio sequence.
  • KroneckerSample(alpha, s0) for a Kronecker sequence, where alpha is a length-d vector of irrational numbers (often sqrt(d)) and s0 is a length-d seed vector (often 0).
  • SectionSample(x0, sampler) where sampler is any sampler above and x0 is a vector of either NaN for a free dimension or some scalar for a constrained dimension.

DataInterpolations.jl: One-Dimensional Interpolations

DataInterpolations.jl is a library of one-dimensional interpolation schemes which are composable with automatic differentiation and the SciML ecosystem. It includes direct interpolation methods and regression techniques for handling noisy data. Its methods include:

  • ConstantInterpolation(u,t) - A piecewise constant interpolation.

  • LinearInterpolation(u,t) - A linear interpolation.

  • QuadraticInterpolation(u,t) - A quadratic interpolation.

  • LagrangeInterpolation(u,t,n) - A Lagrange interpolation of order n.

  • QuadraticSpline(u,t) - A quadratic spline interpolation.

  • CubicSpline(u,t) - A cubic spline interpolation.

  • BSplineInterpolation(u,t,d,pVec,knotVec) - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:

    • d - degree of B-spline
    • pVec - Symbol to Parameters Vector, pVec = :Uniform for uniform spaced parameters and pVec = :ArcLen for parameters generated by chord length method.
    • knotVec - Symbol to Knot Vector, knotVec = :Uniform for uniform knot vector, knotVec = :Average for average spaced knot vector.
  • BSplineApprox(u,t,d,h,pVec,knotVec) - A regression B-spline which smooths the fitting curve. The argument choices are the same as the BSplineInterpolation, with the additional parameter h<length(t) which is the number of control points to use, with smaller h indicating more smoothing.

  • Curvefit(u,t,m,p,alg) - An interpolation which is done by fitting a user-given functional form m(t,p) where p is the vector of parameters. The user's input p is an initial value for a least-square fitting, alg is the algorithm choice used to optimize the cost function (sum of squared deviations) via Optim.jl and optimal ps are used in the interpolation.

These interpolations match the SciML interfaces and have direct support for packages like ModelingToolkit.jl.

PoissonRandom.jl: Fast Poisson Random Number Generation

PoissonRandom.jl is just fast Poisson random number generation for Poisson processes, like chemical master equations.

PreallocationTools.jl: Write Non-Allocating Code Easier

PreallocationTools.jl is a library of tools for writing non-allocating code that interacts well with advanced features like automatic differentiation and symbolics.

RuntimeGeneratedFunctions.jl: Efficient Staged Programming in Julia

RuntimeGeneratedFunctions.jl allows for staged programming in Julia, compiling functions at runtime with full optimizations. This is used by many libraries such as ModelingToolkit.jl to allow for runtime code generation for improved performance.

EllipsisNotation.jl: Implementation of Ellipsis Array Slicing

EllipsisNotation.jl defines the ellipsis array slicing notation for Julia. It uses .. as a catch-all for “all dimensions”, allowing for indexing like [..,1] to mean [:,:,:,1] on four dimensional arrays, in a way that is generic to the number of dimensions in the underlying array.

Third-Party Libraries to Note

Distributions.jl: Representations of Probability Distributions

Distributions.jl is a library for defining distributions in Julia. It's used all throughout the SciML libraries for specifications of probability distributions.

Note

For full compatibility with automatic differentiation, see DistributionsAD.jl

FFTW.jl: Fastest Fourier Transformation in the West

FFTW.jl is the preferred library for fast Fourier Transformations on the CPU.

SpecialFunctions.jl: Implementations of Mathematical Special Functions

SpecialFunctions.jl is a library of implementations of special functions, like Bessel functions and error functions (erf). This library is compatible with automatic differentiation.

LoopVectorization.jl: Automated Loop Accelerator

LoopVectorization.jl is a library which provides the @turbo and @tturbo macros for accelerating the computation of loops. This can be used to accelerating the model functions sent to the equation solvers, for example, accelerating handwritten PDE discretizations.

Polyester.jl: Cheap Threads

Polyester.jl is a cheaper version of threads for Julia, which use a set pool of threads for lower overhead. Note that Polyester does not compose with the standard Julia composable threading infrastructure, and thus one must take care not to compose two levels of Polyester, as this will oversubscribe the computation and lead to performance degradation. Many SciML solvers have options to use Polyester for threading to achieve the top performance.

Tullio.jl: Fast Tensor Calculations and Einstein Notation

Tullio.jl is a library for fast tensor calculations with Einstein notation. It allows for defining operations which are compatible with automatic differentiation, GPUs, and more.

ParallelStencil.jl: High-Level Code for Parallelized Stencil Computations

ParallelStencil.jl is a library for writing high-level code for parallelized stencil computations. It is compatible with SciML equation solvers and is thus a good way to generate GPU and distributed parallel model code.

Julia Utilities

StaticCompiler.jl

StaticCompiler.jl is a package for generating static binaries from Julia code. It only supports a subset of Julia, so not all equation solver algorithms are compatible with StaticCompiler.jl.

PackageCompiler.jl

PackageCompiler.jl is a package for generating shared libraries from Julia code. It builds the entirety of Julia by bundling a system image with the Julia runtime. It thus builds complete binaries that can hold all the functionality of SciML. Furthermore, it can also be used to generate new system images to decrease startup times and remove JIT-compilation from SciML usage.

diff --git a/dev/highlevels/parameter_analysis/index.html b/dev/highlevels/parameter_analysis/index.html index 2a5aa96fa63..5516e797ec2 100644 --- a/dev/highlevels/parameter_analysis/index.html +++ b/dev/highlevels/parameter_analysis/index.html @@ -1,2 +1,2 @@ -Parameter Analysis Utilities · Overview of Julia's SciML

Parameter Analysis Utilities

GlobalSensitivity.jl: Global Sensitivity Analysis

Derivatives calculate the local sensitivity of a model, i.e. the change in the simulation's outcome if one were to change the parameter with respect to some chosen part of the parameter space. But how does a simulation's output change “in general” with respect to a given parameter? That is what global sensitivity analysis (GSA) computes, and thus GlobalSensitivity.jl is the way to answer that question. GlobalSensitivity.jl includes a wide array of methods, including:

  • Morris's method
  • Sobol's method
  • Regression methods (PCC, SRC, Pearson)
  • eFAST
  • Delta Moment-Independent method
  • Derivative-based Global Sensitivity Measures (DGSM)
  • EASI
  • Fractional Factorial method
  • Random Balance Design FAST method

StructuralIdentifiability.jl: Identifiability Analysis Made Simple

Performing parameter estimation from a data set means attempting to recover parameters like reaction rates by fitting some model to the data. But how do you know whether you have enough data to even consider getting the “correct” parameters back? StructuralIdentifiability.jl allows for running a structural identifiability analysis on a given model to determine whether it's theoretically possible to recover the correct parameters. It can state whether a given type of output data can be used to globally recover the parameters (i.e. only a unique parameter set for the model produces a given output), whether the parameters are only locally identifiable (i.e. there are finitely many parameter sets which could generate the seen data), or whether it's unidentifiable (there are infinitely many parameters which generate the same output data).

For more information on what StructuralIdentifiability.jl is all about, see the SciMLCon 2022 tutorial video.

MinimallyDisruptiveCurves.jl

MinimallyDisruptiveCurves.jl is a library for finding relationships between parameters of models, finding the curves on which the solution is constant.

Third-Party Libraries to Note

SIAN.jl: Structural Identifiability Analyzer

SIAN.jl is a structural identifiability analysis package which uses an entirely different algorithm from StructuralIdentifiability.jl. For information on the differences between the two approaches, see the Structural Identifiability Tools in Julia tutorial.

DynamicalSystems.jl: A Suite of Dynamical Systems Analysis

DynamicalSystems.jl is an entire ecosystem of dynamical systems analysis methods, for computing measures of chaos (dimension estimation, Lyapunov coefficients), generating delay embeddings, and much more. It uses the SciML tools for its internal equation solving and thus shares much of its API, adding a layer of new tools for extended analyses.

For more information, watch the tutorial Introduction to DynamicalSystems.jl.

BifurcationKit.jl

BifurcationKit.jl is a tool for performing bifurcation analysis. It uses and composes with many SciML equation solvers.

ReachabilityAnalysis.jl

ReachabilityAnalysis.jl is a library for performing reachability analysis of dynamical systems, determining for a given uncertainty interval the full set of possible outcomes from a dynamical system.

ControlSystems.jl

ControlSystems.jl is a library for building and analyzing control systems.

+Parameter Analysis Utilities · Overview of Julia's SciML

Parameter Analysis Utilities

GlobalSensitivity.jl: Global Sensitivity Analysis

Derivatives calculate the local sensitivity of a model, i.e. the change in the simulation's outcome if one were to change the parameter with respect to some chosen part of the parameter space. But how does a simulation's output change “in general” with respect to a given parameter? That is what global sensitivity analysis (GSA) computes, and thus GlobalSensitivity.jl is the way to answer that question. GlobalSensitivity.jl includes a wide array of methods, including:

  • Morris's method
  • Sobol's method
  • Regression methods (PCC, SRC, Pearson)
  • eFAST
  • Delta Moment-Independent method
  • Derivative-based Global Sensitivity Measures (DGSM)
  • EASI
  • Fractional Factorial method
  • Random Balance Design FAST method

StructuralIdentifiability.jl: Identifiability Analysis Made Simple

Performing parameter estimation from a data set means attempting to recover parameters like reaction rates by fitting some model to the data. But how do you know whether you have enough data to even consider getting the “correct” parameters back? StructuralIdentifiability.jl allows for running a structural identifiability analysis on a given model to determine whether it's theoretically possible to recover the correct parameters. It can state whether a given type of output data can be used to globally recover the parameters (i.e. only a unique parameter set for the model produces a given output), whether the parameters are only locally identifiable (i.e. there are finitely many parameter sets which could generate the seen data), or whether it's unidentifiable (there are infinitely many parameters which generate the same output data).

For more information on what StructuralIdentifiability.jl is all about, see the SciMLCon 2022 tutorial video.

MinimallyDisruptiveCurves.jl

MinimallyDisruptiveCurves.jl is a library for finding relationships between parameters of models, finding the curves on which the solution is constant.

Third-Party Libraries to Note

SIAN.jl: Structural Identifiability Analyzer

SIAN.jl is a structural identifiability analysis package which uses an entirely different algorithm from StructuralIdentifiability.jl. For information on the differences between the two approaches, see the Structural Identifiability Tools in Julia tutorial.

DynamicalSystems.jl: A Suite of Dynamical Systems Analysis

DynamicalSystems.jl is an entire ecosystem of dynamical systems analysis methods, for computing measures of chaos (dimension estimation, Lyapunov coefficients), generating delay embeddings, and much more. It uses the SciML tools for its internal equation solving and thus shares much of its API, adding a layer of new tools for extended analyses.

For more information, watch the tutorial Introduction to DynamicalSystems.jl.

BifurcationKit.jl

BifurcationKit.jl is a tool for performing bifurcation analysis. It uses and composes with many SciML equation solvers.

ReachabilityAnalysis.jl

ReachabilityAnalysis.jl is a library for performing reachability analysis of dynamical systems, determining for a given uncertainty interval the full set of possible outcomes from a dynamical system.

ControlSystems.jl

ControlSystems.jl is a library for building and analyzing control systems.

diff --git a/dev/highlevels/partial_differential_equation_solvers/index.html b/dev/highlevels/partial_differential_equation_solvers/index.html index 14fa36f101e..d72931e19b8 100644 --- a/dev/highlevels/partial_differential_equation_solvers/index.html +++ b/dev/highlevels/partial_differential_equation_solvers/index.html @@ -1,2 +1,2 @@ -Partial Differential Equations (PDE) · Overview of Julia's SciML

Partial Differential Equations (PDE)

NeuralPDE.jl: Physics-Informed Neural Network (PINN) PDE Solvers

NeuralPDE.jl is a partial differential equation solver library which uses physics-informed neural networks (PINNs) to solve the equations. It uses the ModelingToolkit.jl symbolic PDESystem as its input and can handle a wide variety of equation types, including systems of partial differential equations, partial differential-algebraic equations, and integro-differential equations. Its benefit is its flexibility, and it can be used to easily generate surrogate solutions over entire parameter ranges. However, its downside is solver speed: PINN solvers tend to be a lot slower than other methods for solving PDEs.

MethodOflines.jl: Automated Finite Difference Method (FDM)

MethodOflines.jl is a partial differential equation solver library which automates the discretization of PDEs via the finite difference method. It uses the ModelingToolkit.jl symbolic PDESystem as its input, and generates AbstractSystems and SciMLProblems whose numerical solution gives the solution to the PDE.

FEniCS.jl: Wrappers for the Finite Element Method (FEM)

FEniCS.jl is a wrapper for the popular FEniCS finite element method library.

HighDimPDE.jl: High-dimensional PDE Solvers

HighDimPDE.jl is a partial differential equation solver library which implements algorithms that break down the curse of dimensionality to solve the equations. It implements deep-learning based and Picard-iteration based methods to approximately solve high-dimensional, nonlinear, non-local PDEs in up to 10,000 dimensions. Its cons are accuracy: high-dimensional solvers are stochastic, and might result in wrong solutions if the solver meta-parameters are not appropriate.

NeuralOperators.jl: (Fourier) Neural Operators and DeepONets for PDE Solving

NeuralOperators.jl is a library for operator learning based PDE solvers. This includes techniques like:

  • Fourier Neural Operators (FNO)
  • Deep Operator Networks (DeepONets)
  • Markov Neural Operators (MNO)

Currently, its connection to PDE solving must be specified manually, though an interface for ModelingToolkit PDESystems is in progress.

DiffEqOperators.jl: Operators for Finite Difference Method (FDM) Discretizations

DiffEqOperators.jl is a library for defining finite difference operators to easily perform manual FDM semi-discretizations of partial differential equations. This library is fairly incomplete and most cases should receive better performance using MethodOflines.jl.

Third-Party Libraries to Note

ApproxFun.jl: Automated Spectral Discretizations

ApproxFun.jl is a package for approximating functions in basis sets. One particular use case is with spectral basis sets, such as Chebyshev functions and Fourier decompositions, making it easy to represent spectral and pseudospectral discretizations of partial differential equations as ordinary differential equations for the SciML equation solvers.

Gridap.jl: Julia-Based Tools for Finite Element Discretizations

Gridap.jl is a package for grid-based approximation of partial differential equations, particularly notable for its use of conforming and nonconforming finite element (FEM) discretizations.

Trixi.jl: Adaptive High-Order Numerical Simulations of Hyperbolic Equations

Trixi.jl is a package for numerical simulation of hyperbolic conservation laws, i.e. a large set of hyperbolic partial differential equations, which interfaces and uses the SciML ordinary differential equation solvers.

VoronoiFVM.jl: Tools for the Voronoi Finite Volume Discretizations

VoronoiFVM.jl is a library for generating FVM discretizations of systems of PDEs. It interfaces with many of the SciML equation solver libraries to allow for ease of discretization and flexibility in the solver choice.

+Partial Differential Equations (PDE) · Overview of Julia's SciML

Partial Differential Equations (PDE)

NeuralPDE.jl: Physics-Informed Neural Network (PINN) PDE Solvers

NeuralPDE.jl is a partial differential equation solver library which uses physics-informed neural networks (PINNs) to solve the equations. It uses the ModelingToolkit.jl symbolic PDESystem as its input and can handle a wide variety of equation types, including systems of partial differential equations, partial differential-algebraic equations, and integro-differential equations. Its benefit is its flexibility, and it can be used to easily generate surrogate solutions over entire parameter ranges. However, its downside is solver speed: PINN solvers tend to be a lot slower than other methods for solving PDEs.

MethodOflines.jl: Automated Finite Difference Method (FDM)

MethodOflines.jl is a partial differential equation solver library which automates the discretization of PDEs via the finite difference method. It uses the ModelingToolkit.jl symbolic PDESystem as its input, and generates AbstractSystems and SciMLProblems whose numerical solution gives the solution to the PDE.

FEniCS.jl: Wrappers for the Finite Element Method (FEM)

FEniCS.jl is a wrapper for the popular FEniCS finite element method library.

HighDimPDE.jl: High-dimensional PDE Solvers

HighDimPDE.jl is a partial differential equation solver library which implements algorithms that break down the curse of dimensionality to solve the equations. It implements deep-learning based and Picard-iteration based methods to approximately solve high-dimensional, nonlinear, non-local PDEs in up to 10,000 dimensions. Its cons are accuracy: high-dimensional solvers are stochastic, and might result in wrong solutions if the solver meta-parameters are not appropriate.

NeuralOperators.jl: (Fourier) Neural Operators and DeepONets for PDE Solving

NeuralOperators.jl is a library for operator learning based PDE solvers. This includes techniques like:

  • Fourier Neural Operators (FNO)
  • Deep Operator Networks (DeepONets)
  • Markov Neural Operators (MNO)

Currently, its connection to PDE solving must be specified manually, though an interface for ModelingToolkit PDESystems is in progress.

DiffEqOperators.jl: Operators for Finite Difference Method (FDM) Discretizations

DiffEqOperators.jl is a library for defining finite difference operators to easily perform manual FDM semi-discretizations of partial differential equations. This library is fairly incomplete and most cases should receive better performance using MethodOflines.jl.

Third-Party Libraries to Note

ApproxFun.jl: Automated Spectral Discretizations

ApproxFun.jl is a package for approximating functions in basis sets. One particular use case is with spectral basis sets, such as Chebyshev functions and Fourier decompositions, making it easy to represent spectral and pseudospectral discretizations of partial differential equations as ordinary differential equations for the SciML equation solvers.

Gridap.jl: Julia-Based Tools for Finite Element Discretizations

Gridap.jl is a package for grid-based approximation of partial differential equations, particularly notable for its use of conforming and nonconforming finite element (FEM) discretizations.

Trixi.jl: Adaptive High-Order Numerical Simulations of Hyperbolic Equations

Trixi.jl is a package for numerical simulation of hyperbolic conservation laws, i.e. a large set of hyperbolic partial differential equations, which interfaces and uses the SciML ordinary differential equation solvers.

VoronoiFVM.jl: Tools for the Voronoi Finite Volume Discretizations

VoronoiFVM.jl is a library for generating FVM discretizations of systems of PDEs. It interfaces with many of the SciML equation solver libraries to allow for ease of discretization and flexibility in the solver choice.

diff --git a/dev/highlevels/plots_visualization/index.html b/dev/highlevels/plots_visualization/index.html index 15f99c34c7e..28b5c0691b3 100644 --- a/dev/highlevels/plots_visualization/index.html +++ b/dev/highlevels/plots_visualization/index.html @@ -1,2 +1,2 @@ -SciML-Supported Plotting and Visualization Libraries · Overview of Julia's SciML

SciML-Supported Plotting and Visualization Libraries

The following libraries are the plotting and visualization libraries which are supported and co-developed by the SciML developers. Other libraries may be used, though these are the libraries used in the tutorials and which have special hooks to ensure ergonomic usage with SciML tooling.

Plots.jl

Plots.jl is the current standard plotting system for the SciML ecosystem. SciML types attempt to include plot recipes for as many types as possible, allowing for automatic visualization with the Plots.jl system. All current tutorials and documentation default to using Plots.jl.

Makie.jl

Makie.jl is a high-performance interactive plotting system for the Julia programming language. It's planned to be the default plotting system used by the SciML organization in the near future.

+SciML-Supported Plotting and Visualization Libraries · Overview of Julia's SciML

SciML-Supported Plotting and Visualization Libraries

The following libraries are the plotting and visualization libraries which are supported and co-developed by the SciML developers. Other libraries may be used, though these are the libraries used in the tutorials and which have special hooks to ensure ergonomic usage with SciML tooling.

Plots.jl

Plots.jl is the current standard plotting system for the SciML ecosystem. SciML types attempt to include plot recipes for as many types as possible, allowing for automatic visualization with the Plots.jl system. All current tutorials and documentation default to using Plots.jl.

Makie.jl

Makie.jl is a high-performance interactive plotting system for the Julia programming language. It's planned to be the default plotting system used by the SciML organization in the near future.

diff --git a/dev/highlevels/symbolic_learning/index.html b/dev/highlevels/symbolic_learning/index.html index 4231957adda..e55e9f6b8b8 100644 --- a/dev/highlevels/symbolic_learning/index.html +++ b/dev/highlevels/symbolic_learning/index.html @@ -1,2 +1,2 @@ -Symbolic Learning and Artificial Intelligence · Overview of Julia's SciML

Symbolic Learning and Artificial Intelligence

Symbolic learning, the classical artificial intelligence, is a set of methods for learning symbolic equations from data and numerical functions. SciML offers an array of symbolic learning utilities which connect with the other machine learning and equation solver functionalities to make it easy to embed prior knowledge and discover missing physics. For more information, see Universal Differential Equations for Scientific Machine Learning.

DataDrivenDiffEq.jl: Data-Driven Modeling and Automated Discovery of Dynamical Systems

DataDrivenDiffEq.jl is a general interface for data-driven modeling, containing a large array of techniques such as:

  • Koopman operator methods (Dynamic-Mode Decomposition (DMD) and variations)
  • Sparse Identification of Dynamical Systems (SINDy and variations like iSINDy)
  • Sparse regression methods (STSLQ, SR3, etc.)
  • PDEFind
  • Wrappers for SymbolicRegression.jl
  • AI Feynman
  • OccamNet

SymbolicNumericIntegration.jl: Symbolic Integration via Numerical Methods

SymbolicNumericIntegration.jl is a package computing the solution to symbolic integration problem using numerical methods (numerical integration mixed with sparse regression).

Third-Party Libraries to Note

SymbolicRegression.jl

SymbolicRegression.jl is a symbolic regression library which uses genetic algorithms with parallelization to achieve fast and robust symbolic learning.

+Symbolic Learning and Artificial Intelligence · Overview of Julia's SciML

Symbolic Learning and Artificial Intelligence

Symbolic learning, the classical artificial intelligence, is a set of methods for learning symbolic equations from data and numerical functions. SciML offers an array of symbolic learning utilities which connect with the other machine learning and equation solver functionalities to make it easy to embed prior knowledge and discover missing physics. For more information, see Universal Differential Equations for Scientific Machine Learning.

DataDrivenDiffEq.jl: Data-Driven Modeling and Automated Discovery of Dynamical Systems

DataDrivenDiffEq.jl is a general interface for data-driven modeling, containing a large array of techniques such as:

  • Koopman operator methods (Dynamic-Mode Decomposition (DMD) and variations)
  • Sparse Identification of Dynamical Systems (SINDy and variations like iSINDy)
  • Sparse regression methods (STSLQ, SR3, etc.)
  • PDEFind
  • Wrappers for SymbolicRegression.jl
  • AI Feynman
  • OccamNet

SymbolicNumericIntegration.jl: Symbolic Integration via Numerical Methods

SymbolicNumericIntegration.jl is a package computing the solution to symbolic integration problem using numerical methods (numerical integration mixed with sparse regression).

Third-Party Libraries to Note

SymbolicRegression.jl

SymbolicRegression.jl is a symbolic regression library which uses genetic algorithms with parallelization to achieve fast and robust symbolic learning.

diff --git a/dev/highlevels/symbolic_tools/index.html b/dev/highlevels/symbolic_tools/index.html index 1406c21b8b7..bb8924d5866 100644 --- a/dev/highlevels/symbolic_tools/index.html +++ b/dev/highlevels/symbolic_tools/index.html @@ -1,2 +1,2 @@ -Symbolic Model Tooling and JuliaSymbolics · Overview of Julia's SciML

Symbolic Model Tooling and JuliaSymbolics

JuliaSymbolics is a sister organization of SciML. It spawned out of the symbolic modeling tools being developed within SciML (ModelingToolkit.jl) to become its own organization dedicated to building a fully-featured Julia-based Computer Algebra System (CAS). As such, the two organizations are closely aligned in terms of its developer community, and many of the SciML libraries use Symbolics.jl extensively.

ModelOrderReduction.jl: Automated Model Reduction for Fast Approximations of Solutions

ModelOrderReduction.jl is a package for automating the reduction of models. These methods function a submodel with a projection, where solving the smaller model provides approximation information about the full model. MOR.jl uses ModelingToolkit.jl as a system description and automatically transforms equations to the subform, defining the observables to automatically lazily reconstruct the full model on-demand in a fast and stable form.

Symbolics.jl: The Computer Algebra System (CAS) of the Julia Programming Language

Symbolics.jl is the CAS of the Julia programming language. If something needs to be done symbolically, most likely Symbolics.jl is the answer.

MetaTheory.jl: E-Graphs to Automate Symbolic Transformations

Metatheory.jl is a library for defining e-graph rewriters for use on the common symbolic interface. This can be used to do all sorts of analysis and code transformations, such as improving code performance, numerical stability, and more. See Automated Code Optimization with E-Graphs for more details.

SymbolicUtils.jl: Define Your Own Computer Algebra System

SymbolicUtils.jl is the underlying utility library and rule-based rewriting language on which Symbolics.jl is developed. Symbolics.jl is standardized type and rule definitions built using SymbolicUtils.jl. However, if non-standard types are required, such as symbolic computing over Fock algebras, then SymbolicUtils.jl is the library from which the new symbolic types can be implemented.

+Symbolic Model Tooling and JuliaSymbolics · Overview of Julia's SciML

Symbolic Model Tooling and JuliaSymbolics

JuliaSymbolics is a sister organization of SciML. It spawned out of the symbolic modeling tools being developed within SciML (ModelingToolkit.jl) to become its own organization dedicated to building a fully-featured Julia-based Computer Algebra System (CAS). As such, the two organizations are closely aligned in terms of its developer community, and many of the SciML libraries use Symbolics.jl extensively.

ModelOrderReduction.jl: Automated Model Reduction for Fast Approximations of Solutions

ModelOrderReduction.jl is a package for automating the reduction of models. These methods function a submodel with a projection, where solving the smaller model provides approximation information about the full model. MOR.jl uses ModelingToolkit.jl as a system description and automatically transforms equations to the subform, defining the observables to automatically lazily reconstruct the full model on-demand in a fast and stable form.

Symbolics.jl: The Computer Algebra System (CAS) of the Julia Programming Language

Symbolics.jl is the CAS of the Julia programming language. If something needs to be done symbolically, most likely Symbolics.jl is the answer.

MetaTheory.jl: E-Graphs to Automate Symbolic Transformations

Metatheory.jl is a library for defining e-graph rewriters for use on the common symbolic interface. This can be used to do all sorts of analysis and code transformations, such as improving code performance, numerical stability, and more. See Automated Code Optimization with E-Graphs for more details.

SymbolicUtils.jl: Define Your Own Computer Algebra System

SymbolicUtils.jl is the underlying utility library and rule-based rewriting language on which Symbolics.jl is developed. Symbolics.jl is standardized type and rule definitions built using SymbolicUtils.jl. However, if non-standard types are required, such as symbolic computing over Fock algebras, then SymbolicUtils.jl is the library from which the new symbolic types can be implemented.

diff --git a/dev/highlevels/uncertainty_quantification/index.html b/dev/highlevels/uncertainty_quantification/index.html index 00dd191c0a6..e08afce400b 100644 --- a/dev/highlevels/uncertainty_quantification/index.html +++ b/dev/highlevels/uncertainty_quantification/index.html @@ -1,2 +1,2 @@ -Uncertainty Quantification · Overview of Julia's SciML

Uncertainty Quantification

There's always uncertainty in our models. Whether it's in the form of the model's equations or in the model's parameters, the uncertainty in our simulation's output often needs to be quantified. The following tools automate this process.

For Measurements.jl vs MonteCarloMeasurements.jl vs Intervals.jl, and the relation to other methods, see the Uncertainty Programming chapter of the SciML Book.

PolyChaos.jl: Intrusive Polynomial Chaos Expansions Made Unintrusive

PolyChaos.jl is a library for calculating intrusive polynomial chaos expansions (PCE) on arbitrary Julia functions. This allows for inputting representations of probability distributions into functions to compute the output distribution in an expansion representation. While normally this would require deriving the PCE-expanded equations by hand, PolyChaos.jl does this at the compiler level using Julia's multiple dispatch, giving a high-performance implementation to a normally complex and tedious mathematical transformation.

SciMLExpectations.jl: Fast Calculations of Expectations of Equation Solutions

SciMLExpectations.jl is a library for accelerating the calculation of expectations of equation solutions with respect to input probability distributions, allowing for applications like robust optimization with respect to uncertainty. It uses Koopman operator techniques to calculate these expectations without requiring the propagation of uncertainties through a solver, effectively performing the adjoint of uncertainty quantification and being much more efficient in the process.

Third-Party Libraries to Note

Measurements.jl: Automated Linear Error Propagation

Measurements.jl is a library for automating linear error propagation. Uncertain numbers are defined as x = 3.8 ± 0.4 and are pushed through calculations using a normal distribution approximation in order to compute an approximate uncertain output. Measurements.jl uses a dictionary-based approach to keep track of correlations to improve the accuracy over naive implementations, though note that linear error propagation theory still has some major issues handling some types of equations, as described in detail in the MonteCarloMeasurements.jl documentation.

MonteCarloMeasurements.jl: Automated Monte Carlo Error Propagation

MonteCarloMeasurements.jl is a library for automating the uncertainty quantification of equation solution using Monte Carlo methods. It defines number types which sample from an input distribution to receive a representative set of parameters that propagate through the solver to calculate a representative set of possible solutions. Note that Monte Carlo techniques can be expensive but are exact, in the sense that as the number of sample points increases to infinity it will compute a correct approximation of the output uncertainty.

ProbNumDiffEq.jl: Probabilistic Numerics Based Differential Equation Solvers

ProbNumDiffEq.jl is a set of probabilistic numerical ODE solvers which compute the solution of a differential equation along with a posterior distribution to estimate its numerical approximation error. Thus these specialized integrators compute an uncertainty output similar to the ProbInts technique of DiffEqUncertainty, but use specialized integration techniques in order to do it much faster for specific kinds of equations.

TaylorIntegration.jl: Taylor Series Integration for Rigorous Numerical Bounds

TaylorIntegration.jl is a library for Taylor series integrators, which has special functionality for computing the interval bound of possible solutions with respect to numerical approximation error.

IntervalArithmetic.jl: Rigorous Numerical Intervals

IntervalArithmetic.jl is a library for performing interval arithmetic calculations on arbitrary Julia code. Interval arithmetic computes rigorous computations with respect to finite-precision floating-point arithmetic, i.e. its intervals are guaranteed to include the true solution. However, interval arithmetic intervals can grow at exponential rates in many problems, thus being unsuitable for analyses in many equation solver contexts.

+Uncertainty Quantification · Overview of Julia's SciML

Uncertainty Quantification

There's always uncertainty in our models. Whether it's in the form of the model's equations or in the model's parameters, the uncertainty in our simulation's output often needs to be quantified. The following tools automate this process.

For Measurements.jl vs MonteCarloMeasurements.jl vs Intervals.jl, and the relation to other methods, see the Uncertainty Programming chapter of the SciML Book.

PolyChaos.jl: Intrusive Polynomial Chaos Expansions Made Unintrusive

PolyChaos.jl is a library for calculating intrusive polynomial chaos expansions (PCE) on arbitrary Julia functions. This allows for inputting representations of probability distributions into functions to compute the output distribution in an expansion representation. While normally this would require deriving the PCE-expanded equations by hand, PolyChaos.jl does this at the compiler level using Julia's multiple dispatch, giving a high-performance implementation to a normally complex and tedious mathematical transformation.

SciMLExpectations.jl: Fast Calculations of Expectations of Equation Solutions

SciMLExpectations.jl is a library for accelerating the calculation of expectations of equation solutions with respect to input probability distributions, allowing for applications like robust optimization with respect to uncertainty. It uses Koopman operator techniques to calculate these expectations without requiring the propagation of uncertainties through a solver, effectively performing the adjoint of uncertainty quantification and being much more efficient in the process.

Third-Party Libraries to Note

Measurements.jl: Automated Linear Error Propagation

Measurements.jl is a library for automating linear error propagation. Uncertain numbers are defined as x = 3.8 ± 0.4 and are pushed through calculations using a normal distribution approximation in order to compute an approximate uncertain output. Measurements.jl uses a dictionary-based approach to keep track of correlations to improve the accuracy over naive implementations, though note that linear error propagation theory still has some major issues handling some types of equations, as described in detail in the MonteCarloMeasurements.jl documentation.

MonteCarloMeasurements.jl: Automated Monte Carlo Error Propagation

MonteCarloMeasurements.jl is a library for automating the uncertainty quantification of equation solution using Monte Carlo methods. It defines number types which sample from an input distribution to receive a representative set of parameters that propagate through the solver to calculate a representative set of possible solutions. Note that Monte Carlo techniques can be expensive but are exact, in the sense that as the number of sample points increases to infinity it will compute a correct approximation of the output uncertainty.

ProbNumDiffEq.jl: Probabilistic Numerics Based Differential Equation Solvers

ProbNumDiffEq.jl is a set of probabilistic numerical ODE solvers which compute the solution of a differential equation along with a posterior distribution to estimate its numerical approximation error. Thus these specialized integrators compute an uncertainty output similar to the ProbInts technique of DiffEqUncertainty, but use specialized integration techniques in order to do it much faster for specific kinds of equations.

TaylorIntegration.jl: Taylor Series Integration for Rigorous Numerical Bounds

TaylorIntegration.jl is a library for Taylor series integrators, which has special functionality for computing the interval bound of possible solutions with respect to numerical approximation error.

IntervalArithmetic.jl: Rigorous Numerical Intervals

IntervalArithmetic.jl is a library for performing interval arithmetic calculations on arbitrary Julia code. Interval arithmetic computes rigorous computations with respect to finite-precision floating-point arithmetic, i.e. its intervals are guaranteed to include the true solution. However, interval arithmetic intervals can grow at exponential rates in many problems, thus being unsuitable for analyses in many equation solver contexts.

diff --git a/dev/index.html b/dev/index.html index 51b67dbefbf..25c23a68a19 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,5 +1,5 @@ -SciML: Open Source Software for Scientific Machine Learning with Julia · Overview of Julia's SciML

SciML: Differentiable Modeling and Simulation Combined with Machine Learning

The SciML organization is a collection of tools for solving equations and modeling systems developed in the Julia programming language with bindings to other languages such as R and Python. The organization provides well-maintained tools which compose together as a coherent ecosystem. It has a coherent development principle, unified APIs over large collections of equation solvers, pervasive differentiability and sensitivity analysis, and features many of the highest performance and parallel implementations one can find.

Scientific Machine Learning (SciML) = Scientific Computing + Machine Learning

Where to Start?

And for diving into the details, use the bar on the top to navigate to the submodule of interest!

Reproducibility

The documentation of the [SciML Showcase](@ref showcase) was built using these direct dependencies,
Status `/var/lib/buildkite-agent/builds/gpuci-5/julialang/scimldocs/docs/Project.toml`
+SciML: Open Source Software for Scientific Machine Learning with Julia · Overview of Julia's SciML

SciML: Differentiable Modeling and Simulation Combined with Machine Learning

The SciML organization is a collection of tools for solving equations and modeling systems developed in the Julia programming language with bindings to other languages such as R and Python. The organization provides well-maintained tools which compose together as a coherent ecosystem. It has a coherent development principle, unified APIs over large collections of equation solvers, pervasive differentiability and sensitivity analysis, and features many of the highest performance and parallel implementations one can find.

Scientific Machine Learning (SciML) = Scientific Computing + Machine Learning

Where to Start?

And for diving into the details, use the bar on the top to navigate to the submodule of interest!

Reproducibility

The documentation of the [SciML Showcase](@ref showcase) was built using these direct dependencies,
Status `/var/lib/buildkite-agent/builds/gpuci-9/julialang/scimldocs/docs/Project.toml`
   [0bf59076] AdvancedHMC v0.5.5
   [6e4b80f9] BenchmarkTools v1.3.2
   [336ed68f] CSV v0.10.11
@@ -9,7 +9,7 @@
   [5b588203] DataDrivenSparse v0.1.2
   [a93c6f00] DataFrames v1.6.1
   [aae7a2af] DiffEqFlux v2.4.0
-  [071ae1c0] DiffEqGPU v2.5.1
+ [071ae1c0] DiffEqGPU v2.5.1
  [0c46a032] DifferentialEquations v7.10.0
   [31c24e10] Distributions v0.25.102
   [e30172f5] Documenter v1.1.1
@@ -66,7 +66,7 @@
   JULIA_DEPOT_PATH = /root/.cache/julia-buildkite-plugin/depots/0183cc98-c3b4-4959-aaaa-6c0d5f351407
   LD_LIBRARY_PATH = /usr/local/nvidia/lib:/usr/local/nvidia/lib64
   JULIA_PKG_SERVER =
-  JULIA_IMAGE_THREADS = 1
A more complete overview of all dependencies and their versions is also provided.
Status `/var/lib/buildkite-agent/builds/gpuci-5/julialang/scimldocs/docs/Manifest.toml`
+  JULIA_IMAGE_THREADS = 1
A more complete overview of all dependencies and their versions is also provided.
Status `/var/lib/buildkite-agent/builds/gpuci-9/julialang/scimldocs/docs/Manifest.toml`
   [47edcb42] ADTypes v0.2.4
   [a4c015fc] ANSIColoredPrinters v0.0.1
  [c3fe647b] AbstractAlgebra v0.32.5
@@ -141,7 +141,7 @@
  [2b5f629d] DiffEqBase v6.130.0
   [459566f4] DiffEqCallbacks v2.33.1
   [aae7a2af] DiffEqFlux v2.4.0
-  [071ae1c0] DiffEqGPU v2.5.1
+ [071ae1c0] DiffEqGPU v2.5.1
   [77a26b50] DiffEqNoiseProcess v5.19.0
   [163ba53b] DiffResults v1.1.0
   [b552c78f] DiffRules v1.15.1
@@ -216,7 +216,7 @@
   [1019f520] JLFzf v0.1.6
   [692b3bcd] JLLWrappers v1.5.0
   [682c06a0] JSON v0.21.4
-  [98e50ef6] JuliaFormatter v1.0.39
+  [98e50ef6] JuliaFormatter v1.0.40
   [b14d175d] JuliaVariables v0.2.4
   [ccbc3e58] JumpProcesses v9.8.0
   [ef3ab10e] KLU v0.4.1
@@ -565,4 +565,4 @@
   [8e850b90] libblastrampoline_jll v5.8.0+0
   [8e850ede] nghttp2_jll v1.48.0+0
   [3f19e933] p7zip_jll v17.4.0+0
-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 -m`

You can also download the manifest file and the project file.

+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 -m`

You can also download the manifest file and the project file.

diff --git a/dev/overview/index.html b/dev/overview/index.html index a3191fa930e..86f35d79aa0 100644 --- a/dev/overview/index.html +++ b/dev/overview/index.html @@ -1,2 +1,2 @@ -Detailed Overview of the SciML Software Ecosystem · Overview of Julia's SciML

Detailed Overview of the SciML Software Ecosystem

SciML: Combining High-Performance Scientific Computing and Machine Learning

SciML is not standard machine learning, SciML is the combination of scientific computing techniques with machine learning. Thus the SciML organization is not an organization for machine learning libraries (see FluxML for machine learning in Julia), rather SciML is an organization dedicated to the development of scientific computing tools which work seamlessly in conjunction with next-generation machine learning workflows. This includes:

  • High-performance and accurate tools for standard scientific computing modeling and simulation
  • Compatibility with differentiable programming and automatic differentiation
  • Tools for building complex multiscale models
  • Methods for handling inverse problems, model calibration, controls, and Bayesian analysis
  • Symbolic modeling tools for generating efficient code for numerical equation solvers
  • Methods for automatic discovery of (bio)physical equations

and much more. For an overview of the broad goals of the SciML organization, watch:

Overview of Computational Science in Julia with SciML

Below is a simplification of the user-facing packages for use in scientific computing and SciML workflows.

Workflow ElementSciML-Supported Julia packages
Plotting and VisualizationPlots*, Makie*
Sparse matrixSparseArrays*
Interpolation/approximationDataInterpolations*, ApproxFun*
Linear system / least squaresLinearSolve
Nonlinear system / rootfindingNonlinearSolve
Polynomial rootsPolynomials*
IntegrationIntegrals
Nonlinear OptimizationOptimization
Other Optimization (linear, quadratic, convex, etc.)JuMP*
Initial-value problemDifferentialEquations
Boundary-value problemDifferentialEquations
Continuous-Time Markov Chains (Poisson Jumps), Jump DiffusionsJumpProcesses
Finite differencesFiniteDifferences*, FiniteDiff*
Automatic DifferentiationForwardDiff*, Enzyme*, DiffEqSensitivity
Bayesian ModelingTuring*
Deep LearningFlux*
Acausal Modeling / DAEsModelingToolkit
Chemical Reaction NetworksCatalyst
Symbolic ComputingSymbolics
Fast Fourier TransformFFTW*
Partial Differential Equation DiscretizationsAssociated Julia packages
–-–-
Finite DifferencesMethodOfLines
Discontinuous GalerkinTrixi*
Finite ElementGridap*
Physics-Informed Neural NetworksNeuralPDE
Neural OperatorsNeuralOperators
High Dimensional Deep LearningHighDimPDE

* Denotes a non-SciML package that is heavily tested against as part of SciML workflows and has frequent collaboration with the SciML developers.

SciML Mind Map

Domains of SciML

The SciML common interface covers the following domains:

  • Linear systems (LinearProblem)

    • Direct methods for dense and sparse
    • Iterative solvers with preconditioning
  • Nonlinear Systems (NonlinearProblem)

    • Systems of nonlinear equations
    • Scalar bracketing systems
  • Integrals (quadrature) (IntegralProblem)

  • Differential Equations

    • Discrete equations (function maps, discrete stochastic (Gillespie/Markov) simulations) (DiscreteProblem and JumpProblem)
    • Ordinary differential equations (ODEs) (ODEProblem)
    • Split and Partitioned ODEs (Symplectic integrators, IMEX Methods) (SplitODEProblem)
    • Stochastic ordinary differential equations (SODEs or SDEs) (SDEProblem)
    • Stochastic differential-algebraic equations (SDAEs) (SDEProblem with mass matrices)
    • Random differential equations (RODEs or RDEs) (RODEProblem)
    • Differential algebraic equations (DAEs) (DAEProblem and ODEProblem with mass matrices)
    • Delay differential equations (DDEs) (DDEProblem)
    • Neutral, retarded, and algebraic delay differential equations (NDDEs, RDDEs, and DDAEs)
    • Stochastic delay differential equations (SDDEs) (SDDEProblem)
    • Experimental support for stochastic neutral, retarded, and algebraic delay differential equations (SNDDEs, SRDDEs, and SDDAEs)
    • Mixed discrete and continuous equations (Hybrid Equations, Jump Diffusions) (DEProblems with callbacks and JumpProblem)
  • Optimization (OptimizationProblem)

    • Nonlinear (constrained) optimization
  • (Stochastic/Delay/Differential-Algebraic) Partial Differential Equations (PDESystem)

    • Finite difference and finite volume methods
    • Interfaces to finite element methods
    • Physics-Informed Neural Networks (PINNs)
    • Integro-Differential Equations
    • Fractional Differential Equations
  • Specialized Forms

    • Partial Integro-Differential Equations (PIPDEProblem)
  • Data-driven modeling

    • Discrete-time data-driven dynamical systems (DiscreteDataDrivenProblem)
    • Continuous-time data-driven dynamical systems (ContinuousDataDrivenProblem)
    • Symbolic regression (DirectDataDrivenProblem)
  • Uncertainty quantification and expected values (ExpectationProblem)

The SciML common interface also includes ModelingToolkit.jl for defining such systems symbolically, allowing for optimizations like automated generation of parallel code, symbolic simplification, and generation of sparsity patterns.

Inverse Problems, Parameter Estimation, and Structural Identification

Parameter estimation and inverse problems are solved directly on their constituent problem types using tools like SciMLSensitivity.jl. Thus for example, there is no ODEInverseProblem, and instead ODEProblem is used to find the parameters p that solve the inverse problem. Check out the SciMLSensitivity documentation for a discussion on connections to automatic differentiation, optimization, and adjoints.

Common Interface High-Level Overview

The SciML interface is common as the usage of arguments is standardized across all of the problem domains. Underlying high-level ideas include:

  • All domains use the same interface of defining a AbstractSciMLProblem which is then solved via solve(prob,alg;kwargs), where alg is a AbstractSciMLAlgorithm. The keyword argument namings are standardized across the organization.
  • AbstractSciMLProblems are generally defined by a AbstractSciMLFunction which can define extra details about a model function, such as its analytical Jacobian, its sparsity patterns and so on.
  • There is an organization-wide method for defining linear and nonlinear solvers used within other solvers, giving maximum control of performance to the user.
  • Types used within the packages are defined by the input types. For example, packages attempt to internally use the type of the initial condition as the type for the state within differential equation solvers.
  • solve calls should be thread-safe and parallel-safe.
  • init(prob,alg;kwargs) returns an iterator which allows for directly iterating over the solution process
  • High performance is key. Any performance that is not at the top level is considered a bug and should be reported as such.
  • All functions have an in-place and out-of-place form, where the in-place form is made to utilize mutation for high performance on large-scale problems and the out-of-place form is for compatibility with tooling like static arrays and some reverse-mode automatic differentiation systems.

Flowchart Example for PDE-Constrained Optimal Control

The following example showcases how the pieces of the common interface connect to solve a problem that mixes inference, symbolics, and numerics.

External Binding Libraries

  • diffeqr

    • Solving differential equations in R using DifferentialEquations.jl with ModelingToolkit for JIT compilation and GPU-acceleration
  • diffeqpy

    • Solving differential equations in Python using DifferentialEquations.jl

Note About Third-Party Libraries

The SciML documentation references and recommends many third-party libraries for improving ones modeling, simulation, and analysis workflow in Julia. Take these as a positive affirmation of the quality of these libraries, as these libraries are commonly tested by SciML developers who are in contact with the development teams of these groups. It also documents the libraries which are commonly chosen by SciML as dependencies. Do not take omissions as negative affirmations against a given library, i.e. a library left off of the list by SciML is not a negative endorsement. Rather, it means that compatibility with SciML is untested, SciML developers may have a personal preference for another choice, or SciML developers may be simply unaware of the library's existence. If one would like to add a third-party library to the SciML documentation, open a pull request with the requested text.

Note that the libraries in this documentation are only those that are meant to be used in the SciML extended universe of modeling, simulation, and analysis and thus there are many high-quality libraries in other domains (machine learning, data science, etc.) which are purposefully not included. For an overview of the Julia package ecosystem, see the JuliaHub Search Engine.

+Detailed Overview of the SciML Software Ecosystem · Overview of Julia's SciML

Detailed Overview of the SciML Software Ecosystem

SciML: Combining High-Performance Scientific Computing and Machine Learning

SciML is not standard machine learning, SciML is the combination of scientific computing techniques with machine learning. Thus the SciML organization is not an organization for machine learning libraries (see FluxML for machine learning in Julia), rather SciML is an organization dedicated to the development of scientific computing tools which work seamlessly in conjunction with next-generation machine learning workflows. This includes:

  • High-performance and accurate tools for standard scientific computing modeling and simulation
  • Compatibility with differentiable programming and automatic differentiation
  • Tools for building complex multiscale models
  • Methods for handling inverse problems, model calibration, controls, and Bayesian analysis
  • Symbolic modeling tools for generating efficient code for numerical equation solvers
  • Methods for automatic discovery of (bio)physical equations

and much more. For an overview of the broad goals of the SciML organization, watch:

Overview of Computational Science in Julia with SciML

Below is a simplification of the user-facing packages for use in scientific computing and SciML workflows.

Workflow ElementSciML-Supported Julia packages
Plotting and VisualizationPlots*, Makie*
Sparse matrixSparseArrays*
Interpolation/approximationDataInterpolations*, ApproxFun*
Linear system / least squaresLinearSolve
Nonlinear system / rootfindingNonlinearSolve
Polynomial rootsPolynomials*
IntegrationIntegrals
Nonlinear OptimizationOptimization
Other Optimization (linear, quadratic, convex, etc.)JuMP*
Initial-value problemDifferentialEquations
Boundary-value problemDifferentialEquations
Continuous-Time Markov Chains (Poisson Jumps), Jump DiffusionsJumpProcesses
Finite differencesFiniteDifferences*, FiniteDiff*
Automatic DifferentiationForwardDiff*, Enzyme*, DiffEqSensitivity
Bayesian ModelingTuring*
Deep LearningFlux*
Acausal Modeling / DAEsModelingToolkit
Chemical Reaction NetworksCatalyst
Symbolic ComputingSymbolics
Fast Fourier TransformFFTW*
Partial Differential Equation DiscretizationsAssociated Julia packages
–-–-
Finite DifferencesMethodOfLines
Discontinuous GalerkinTrixi*
Finite ElementGridap*
Physics-Informed Neural NetworksNeuralPDE
Neural OperatorsNeuralOperators
High Dimensional Deep LearningHighDimPDE

* Denotes a non-SciML package that is heavily tested against as part of SciML workflows and has frequent collaboration with the SciML developers.

SciML Mind Map

Domains of SciML

The SciML common interface covers the following domains:

  • Linear systems (LinearProblem)

    • Direct methods for dense and sparse
    • Iterative solvers with preconditioning
  • Nonlinear Systems (NonlinearProblem)

    • Systems of nonlinear equations
    • Scalar bracketing systems
  • Integrals (quadrature) (IntegralProblem)

  • Differential Equations

    • Discrete equations (function maps, discrete stochastic (Gillespie/Markov) simulations) (DiscreteProblem and JumpProblem)
    • Ordinary differential equations (ODEs) (ODEProblem)
    • Split and Partitioned ODEs (Symplectic integrators, IMEX Methods) (SplitODEProblem)
    • Stochastic ordinary differential equations (SODEs or SDEs) (SDEProblem)
    • Stochastic differential-algebraic equations (SDAEs) (SDEProblem with mass matrices)
    • Random differential equations (RODEs or RDEs) (RODEProblem)
    • Differential algebraic equations (DAEs) (DAEProblem and ODEProblem with mass matrices)
    • Delay differential equations (DDEs) (DDEProblem)
    • Neutral, retarded, and algebraic delay differential equations (NDDEs, RDDEs, and DDAEs)
    • Stochastic delay differential equations (SDDEs) (SDDEProblem)
    • Experimental support for stochastic neutral, retarded, and algebraic delay differential equations (SNDDEs, SRDDEs, and SDDAEs)
    • Mixed discrete and continuous equations (Hybrid Equations, Jump Diffusions) (DEProblems with callbacks and JumpProblem)
  • Optimization (OptimizationProblem)

    • Nonlinear (constrained) optimization
  • (Stochastic/Delay/Differential-Algebraic) Partial Differential Equations (PDESystem)

    • Finite difference and finite volume methods
    • Interfaces to finite element methods
    • Physics-Informed Neural Networks (PINNs)
    • Integro-Differential Equations
    • Fractional Differential Equations
  • Specialized Forms

    • Partial Integro-Differential Equations (PIPDEProblem)
  • Data-driven modeling

    • Discrete-time data-driven dynamical systems (DiscreteDataDrivenProblem)
    • Continuous-time data-driven dynamical systems (ContinuousDataDrivenProblem)
    • Symbolic regression (DirectDataDrivenProblem)
  • Uncertainty quantification and expected values (ExpectationProblem)

The SciML common interface also includes ModelingToolkit.jl for defining such systems symbolically, allowing for optimizations like automated generation of parallel code, symbolic simplification, and generation of sparsity patterns.

Inverse Problems, Parameter Estimation, and Structural Identification

Parameter estimation and inverse problems are solved directly on their constituent problem types using tools like SciMLSensitivity.jl. Thus for example, there is no ODEInverseProblem, and instead ODEProblem is used to find the parameters p that solve the inverse problem. Check out the SciMLSensitivity documentation for a discussion on connections to automatic differentiation, optimization, and adjoints.

Common Interface High-Level Overview

The SciML interface is common as the usage of arguments is standardized across all of the problem domains. Underlying high-level ideas include:

  • All domains use the same interface of defining a AbstractSciMLProblem which is then solved via solve(prob,alg;kwargs), where alg is a AbstractSciMLAlgorithm. The keyword argument namings are standardized across the organization.
  • AbstractSciMLProblems are generally defined by a AbstractSciMLFunction which can define extra details about a model function, such as its analytical Jacobian, its sparsity patterns and so on.
  • There is an organization-wide method for defining linear and nonlinear solvers used within other solvers, giving maximum control of performance to the user.
  • Types used within the packages are defined by the input types. For example, packages attempt to internally use the type of the initial condition as the type for the state within differential equation solvers.
  • solve calls should be thread-safe and parallel-safe.
  • init(prob,alg;kwargs) returns an iterator which allows for directly iterating over the solution process
  • High performance is key. Any performance that is not at the top level is considered a bug and should be reported as such.
  • All functions have an in-place and out-of-place form, where the in-place form is made to utilize mutation for high performance on large-scale problems and the out-of-place form is for compatibility with tooling like static arrays and some reverse-mode automatic differentiation systems.

Flowchart Example for PDE-Constrained Optimal Control

The following example showcases how the pieces of the common interface connect to solve a problem that mixes inference, symbolics, and numerics.

External Binding Libraries

  • diffeqr

    • Solving differential equations in R using DifferentialEquations.jl with ModelingToolkit for JIT compilation and GPU-acceleration
  • diffeqpy

    • Solving differential equations in Python using DifferentialEquations.jl

Note About Third-Party Libraries

The SciML documentation references and recommends many third-party libraries for improving ones modeling, simulation, and analysis workflow in Julia. Take these as a positive affirmation of the quality of these libraries, as these libraries are commonly tested by SciML developers who are in contact with the development teams of these groups. It also documents the libraries which are commonly chosen by SciML as dependencies. Do not take omissions as negative affirmations against a given library, i.e. a library left off of the list by SciML is not a negative endorsement. Rather, it means that compatibility with SciML is untested, SciML developers may have a personal preference for another choice, or SciML developers may be simply unaware of the library's existence. If one would like to add a third-party library to the SciML documentation, open a pull request with the requested text.

Note that the libraries in this documentation are only those that are meant to be used in the SciML extended universe of modeling, simulation, and analysis and thus there are many high-quality libraries in other domains (machine learning, data science, etc.) which are purposefully not included. For an overview of the Julia package ecosystem, see the JuliaHub Search Engine.

diff --git a/dev/showcase/bayesian_neural_ode/2e718531.svg b/dev/showcase/bayesian_neural_ode/2e718531.svg new file mode 100644 index 00000000000..837ab8a0565 --- /dev/null +++ b/dev/showcase/bayesian_neural_ode/2e718531.svg @@ -0,0 +1,324 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/bayesian_neural_ode/38f246ef.svg b/dev/showcase/bayesian_neural_ode/38f246ef.svg deleted file mode 100644 index fbfe2e320e7..00000000000 --- a/dev/showcase/bayesian_neural_ode/38f246ef.svg +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/bayesian_neural_ode/416d13b1.svg b/dev/showcase/bayesian_neural_ode/416d13b1.svg deleted file mode 100644 index 7294c8e2a6d..00000000000 --- a/dev/showcase/bayesian_neural_ode/416d13b1.svg +++ /dev/null @@ -1,731 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/bayesian_neural_ode/439e1e50.svg b/dev/showcase/bayesian_neural_ode/439e1e50.svg new file mode 100644 index 00000000000..00c307561f6 --- /dev/null +++ b/dev/showcase/bayesian_neural_ode/439e1e50.svg @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/bayesian_neural_ode/48c01851.svg b/dev/showcase/bayesian_neural_ode/48c01851.svg new file mode 100644 index 00000000000..d65eb947211 --- /dev/null +++ b/dev/showcase/bayesian_neural_ode/48c01851.svg @@ -0,0 +1,731 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/bayesian_neural_ode/98058eff.svg b/dev/showcase/bayesian_neural_ode/98058eff.svg deleted file mode 100644 index 79e0d97b457..00000000000 --- a/dev/showcase/bayesian_neural_ode/98058eff.svg +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/bayesian_neural_ode/a59e4d28.svg b/dev/showcase/bayesian_neural_ode/a59e4d28.svg deleted file mode 100644 index 86384981463..00000000000 --- a/dev/showcase/bayesian_neural_ode/a59e4d28.svg +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/bayesian_neural_ode/aa68f3cc.svg b/dev/showcase/bayesian_neural_ode/aa68f3cc.svg new file mode 100644 index 00000000000..58da75e7b60 --- /dev/null +++ b/dev/showcase/bayesian_neural_ode/aa68f3cc.svg @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/bayesian_neural_ode/index.html b/dev/showcase/bayesian_neural_ode/index.html index 7b1f68a7ede..7bb814b8c09 100644 --- a/dev/showcase/bayesian_neural_ode/index.html +++ b/dev/showcase/bayesian_neural_ode/index.html @@ -20,24 +20,24 @@ prob_neuralode = NeuralODE(dudt2, tspan, Tsit5(), saveat = tsteps) rng = Random.default_rng() p = Float64.(prob_neuralode.p)
252-element Vector{Float64}:
- -0.2669006288051605
-  0.08850638568401337
- -0.031148523092269897
-  0.07270926982164383
-  0.14983640611171722
-  0.11053717881441116
- -0.12777431309223175
-  0.0007596963550895452
- -0.1058516874909401
-  0.154923677444458
+  0.12581832706928253
+  0.17287731170654297
+  0.2685897648334503
+  0.04122938960790634
+  0.315757691860199
+  0.0950828343629837
+ -0.18138937652111053
+ -0.029932385310530663
+ -0.2854670584201813
+  0.21617558598518372
   ⋮
-  0.016394030302762985
- -0.04459467530250549
-  0.056144844740629196
-  0.02901565469801426
-  0.023344233632087708
-  0.0069085354916751385
- -0.030019687488675117
+ -0.3285813331604004
+ -0.2345162183046341
+ -0.24677307903766632
+ -0.316188246011734
+ -0.1604321449995041
+ -0.03692129999399185
+ -0.24775637686252594
   0.0
   0.0

Note that the f64 is required to put the Flux neural network into Float64 precision.

Step 3: Define the loss function for the Neural ODE.

function predict_neuralode(p)
     Array(prob_neuralode(u0, p))
@@ -57,11 +57,11 @@
 h = Hamiltonian(metric, l, dldθ)
Hamiltonian(metric=DiagEuclideanMetric([1.0, 1.0, 1.0, 1.0, 1.0, 1 ...]), kinetic=AdvancedHMC.GaussianKinetic())

We use the NUTS sampler with an acceptance ratio of δ= 0.45 in this example. In addition, we use Nesterov Dual Averaging for the Step Size adaptation.

We sample using 500 warmup samples and 500 posterior samples.

integrator = Leapfrog(find_good_stepsize(h, p))
 kernel = HMCKernel(Trajectory{MultinomialTS}(integrator, GeneralisedNoUTurn()))
 adaptor = StanHMCAdaptor(MassMatrixAdaptor(metric), StepSizeAdaptor(0.45, integrator))
-samples, stats = sample(h, kernel, p, 500, adaptor, 500; progress = true)
([[-0.25405652479745916, 0.10704302670772749, -0.09104472961698586, 0.0382560512646758, 0.16123650887689633, 0.1257208185047157, -0.16815653914769108, 0.04254120811176496, -0.03475164382085551, 0.10376443128130047  …  -0.25903884262052546, 0.016260720285381176, 0.007135596523769473, 0.055668889142862346, -0.008158141024032194, 0.01694018622778835, -0.021197257976876733, -0.020135469114311, -0.019342544417836068, -0.028083241993550195], [-0.25405652479745916, 0.10704302670772749, -0.09104472961698586, 0.0382560512646758, 0.16123650887689633, 0.1257208185047157, -0.16815653914769108, 0.04254120811176496, -0.03475164382085551, 0.10376443128130047  …  -0.25903884262052546, 0.016260720285381176, 0.007135596523769473, 0.055668889142862346, -0.008158141024032194, 0.01694018622778835, -0.021197257976876733, -0.020135469114311, -0.019342544417836068, -0.028083241993550195], [-0.25405652479745916, 0.10704302670772749, -0.09104472961698586, 0.0382560512646758, 0.16123650887689633, 0.1257208185047157, -0.16815653914769108, 0.04254120811176496, -0.03475164382085551, 0.10376443128130047  …  -0.25903884262052546, 0.016260720285381176, 0.007135596523769473, 0.055668889142862346, -0.008158141024032194, 0.01694018622778835, -0.021197257976876733, -0.020135469114311, -0.019342544417836068, -0.028083241993550195], [-0.25405652479745916, 0.10704302670772749, -0.09104472961698586, 0.0382560512646758, 0.16123650887689633, 0.1257208185047157, -0.16815653914769108, 0.04254120811176496, -0.03475164382085551, 0.10376443128130047  …  -0.25903884262052546, 0.016260720285381176, 0.007135596523769473, 0.055668889142862346, -0.008158141024032194, 0.01694018622778835, -0.021197257976876733, -0.020135469114311, -0.019342544417836068, -0.028083241993550195], [-0.10931193572912096, 0.4340447261976026, -0.2171087305245229, 0.18744628833201404, 0.29475590053421713, 0.33794422327826634, -0.03207355551692192, 0.10565580002482618, 0.21561635691853215, 0.26397933592079104  …  -0.40257268804343016, -0.24481502006837064, 0.1460328926673699, 0.09623637479085774, -0.0568972329339228, 0.09163600800978272, -0.06824322912424577, -0.203046422389258, -0.07893397212362854, -0.11651250211843596], [0.24400173202965525, 0.18979896316144296, -0.25439140990557085, 0.2383722912265167, 0.40148353080901467, 0.4003452087974493, -0.1160208535689683, 0.22501191470675308, -0.042440853542981424, 0.3639344564277807  …  -0.394259825310868, 0.0717133682942474, -0.08977350042361935, 0.032188376501797816, 0.08993461907651254, -0.19005668722737826, -0.429598916619931, 0.09965107797995171, -0.4689937889871395, -0.10642764919495908], [0.8406801329441804, -0.21782614468961736, -0.10915473478109866, 0.5079609962704486, 0.42173472953127944, 0.43686216759726615, -0.1771895989851754, 0.2884767416154781, 0.23614585092587864, 0.09206430996140094  …  -0.3194728326518092, 0.5960207706493439, 0.18582591469613557, 0.1267410637561872, -0.24823352156562023, 0.03317522452850512, -0.6090625871095422, -0.10903793493551969, -0.5394269372329775, -0.3878182810823925], [0.8406801329441804, -0.21782614468961736, -0.10915473478109866, 0.5079609962704486, 0.42173472953127944, 0.43686216759726615, -0.1771895989851754, 0.2884767416154781, 0.23614585092587864, 0.09206430996140094  …  -0.3194728326518092, 0.5960207706493439, 0.18582591469613557, 0.1267410637561872, -0.24823352156562023, 0.03317522452850512, -0.6090625871095422, -0.10903793493551969, -0.5394269372329775, -0.3878182810823925], [0.9609527982722651, -0.27644296465802315, -0.08534835171694433, 0.4616540463354513, 0.4052516170327955, 0.29743387271967836, -0.022161740166503185, 0.3429960238718739, 0.42432297046047807, 0.007431762000549624  …  -0.34301446233967436, 0.6287160100075599, 0.19251534189745503, 0.032632921327726085, -0.28530213946659067, 0.26054305605094025, -0.5601517638987488, -0.03837607197033388, -0.5735710439989958, -0.4212855034859492], [0.38757645165196103, 0.1609385955625805, 0.30633332628329335, 0.37636397024321255, 0.33738658996946147, 0.2786427332116632, 1.2257137382834495, 0.31837101627178077, 0.04946943842674298, -0.8254415586294473  …  -0.6953729726193391, 0.5447139883488458, 0.8121564295046002, -0.9779909584192352, -0.5188918656716444, 0.19973176603166373, 0.2792830988229672, 0.5662477512316307, -0.19959001246801036, 0.08334712422003769]  …  [0.8239248480960855, -0.6787216418926075, 0.1296593209681067, 1.2119559674207037, 0.597205807825741, 1.1233816135059413, 0.31201996668981186, -0.22775080835728723, 0.19300289339088317, -0.5456448377426001  …  -0.14730588850949689, 0.56989665983421, -0.353393097363258, 0.3623328217525518, 0.6662523385984053, -1.3692680920967708, -0.109235638201607, -0.9650387443624784, -0.6838118845308367, 0.08000427644698731], [0.5432089446856658, -0.1710075902463364, 0.5964095998351946, -1.0725579549731878, -0.055438194558246875, -1.0381683362715441, -1.1647550620778278, 0.28137380115092403, -0.6249924128201825, -0.0037916802349654485  …  0.9009756377008195, -0.008019334786889858, 0.13529255605408183, 0.08908535101726951, -0.20713069031462805, -0.6956743529009316, -0.10999710183251372, 0.7076911813367721, 0.10256269353970067, 0.24861123006307417], [-0.036410462830283326, -0.9307565281685726, 0.9214549400629239, -0.6491575115618106, -0.61302826222192, -0.13959822100528407, 0.5476176699556908, 0.005748099600051591, 0.45231685298516455, 0.34391116775127567  …  0.40402584749323683, 0.171612819487869, -0.08996511750078101, -0.050005679243730713, 0.40801626406968344, 1.0220676778516313, -0.0677963026423638, 0.14535342491585346, -0.30076643157579125, -0.1512246047925164], [-0.4728594009218927, -0.6041186748035964, 0.8492945629538484, -0.02114333258220543, -0.17662982902465582, -0.47745777690781954, 0.6335415144646395, 0.38138694847834415, 0.4029192230051877, 1.5615082154865287  …  0.05314675336296954, 0.05677832376366776, 0.540186509690709, -1.313644274445501, 0.07958557195603114, -0.011333602605913144, -0.39937323696468524, 0.9932554054788031, -0.6331971914540009, -0.05474798357076523], [-0.39221813673863287, -0.49096336255799866, 0.9728984811505321, 0.39131090370002647, -0.0014365435953202933, -0.27507892140953655, 1.3792470974026845, 0.3186972992263456, 0.12443671592123766, 1.6765648726827802  …  -0.15545929053958252, -0.09675597943617296, 0.4299540870446711, -1.246796431660938, -0.18591116718406397, 0.5801991028475726, -0.5281109948263278, 0.789761194429605, -0.8790194387857974, -0.024103035660155075], [-0.5464918942995151, -0.8408755066642398, -0.5047534944678339, -0.638939697316952, 0.4591984756073934, 0.556227720917438, 0.49622504100000686, 0.0946965753285581, -0.8339220564592045, -0.26633261087606186  …  -0.36630421747255343, -0.27647949666609084, 0.8365265917795949, 0.0982309138641444, -0.12048574772118255, 0.0699839095758674, -1.548729901677542, 0.2528921361474324, -0.07120660445599883, 1.5682744553785966], [-0.2221587866699062, 1.1166670665780474, -0.18259806592302114, 1.0625218872352697, 0.1654293502838849, 0.5051202798513502, 0.5155387381474705, 0.3614108325940649, -0.2333678578586955, -0.3160416592274408  …  1.2497645664508275, -0.043794985037914035, 0.20877126429168882, -0.053333602933484776, -0.21555723642807412, -0.708992562389592, -0.6732330786572763, -0.42945999552378306, -0.5200143099434262, 0.9856610514810186], [-0.2221587866699062, 1.1166670665780474, -0.18259806592302114, 1.0625218872352697, 0.1654293502838849, 0.5051202798513502, 0.5155387381474705, 0.3614108325940649, -0.2333678578586955, -0.3160416592274408  …  1.2497645664508275, -0.043794985037914035, 0.20877126429168882, -0.053333602933484776, -0.21555723642807412, -0.708992562389592, -0.6732330786572763, -0.42945999552378306, -0.5200143099434262, 0.9856610514810186], [-0.7690512140213087, -0.9210502084870662, -0.004330756430160678, -0.0023852882085771254, -0.38929635129639, -0.4047120090112789, 0.15107884575481548, 0.1327567243005217, -0.4175921955204186, -0.9503473490786886  …  -0.8739688815569335, 0.23283423662530217, 0.36314742761088353, -0.9374366183429271, 0.6405535034057517, 0.4024450267758557, 0.2153207960680765, -0.444832759909152, 0.44220963119238854, -0.26025451512953035], [-0.8762093053001682, -0.8476273919090043, -0.1539160694295381, -0.10892293612702661, -0.6078014345337247, -0.23687370907834088, 0.4197351451065159, -0.10545876370178553, -0.3014536492720188, -0.9382968779243277  …  -0.9372181164520117, 0.4337866750738824, 0.7165670076724744, -1.123118526839141, 0.5743844479589275, 0.36783206393343437, 0.20811967536718942, -0.4494736037825649, 0.328326054007871, -0.4636997746791362]], NamedTuple[(n_steps = 31, is_accept = true, acceptance_rate = 1.0, log_density = -243.74726589696357, hamiltonian_energy = 504.86300253604713, hamiltonian_energy_error = -56.355497589009246, max_hamiltonian_energy_error = -56.355497589009246, tree_depth = 5, numerical_error = false, step_size = 0.025, nom_step_size = 0.025, is_adapt = true), (n_steps = 1, is_accept = true, acceptance_rate = 0.0, log_density = -243.74726589696357, hamiltonian_energy = 383.5432697789277, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 2.2645216693055257e6, tree_depth = 0, numerical_error = true, step_size = 0.6795704571147614, nom_step_size = 0.6795704571147614, is_adapt = true), (n_steps = 1, is_accept = true, acceptance_rate = 0.0, log_density = -243.74726589696357, hamiltonian_energy = 377.9187939978612, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 1521.5439386449882, tree_depth = 0, numerical_error = true, step_size = 0.3164493440113639, nom_step_size = 0.3164493440113639, is_adapt = true), (n_steps = 5, is_accept = true, acceptance_rate = 3.171575507618303e-5, log_density = -243.74726589696357, hamiltonian_energy = 371.9133676435174, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 1263.220642784226, tree_depth = 2, numerical_error = true, step_size = 0.09837809577101383, nom_step_size = 0.09837809577101383, is_adapt = true), (n_steps = 30, is_accept = true, acceptance_rate = 0.908675423726952, log_density = -155.1224506449488, hamiltonian_energy = 372.6019934627836, hamiltonian_energy_error = -1.1088217505567286, max_hamiltonian_energy_error = 1150.436107368096, tree_depth = 4, numerical_error = true, step_size = 0.025427652135054553, nom_step_size = 0.025427652135054553, is_adapt = true), (n_steps = 5, is_accept = true, acceptance_rate = 0.6042170944885391, log_density = -115.99900143967501, hamiltonian_energy = 276.5524940966033, hamiltonian_energy_error = -1.6173411562626825, max_hamiltonian_energy_error = 24506.769287992825, tree_depth = 2, numerical_error = true, step_size = 0.09037089004137243, nom_step_size = 0.09037089004137243, is_adapt = true), (n_steps = 4, is_accept = true, acceptance_rate = 0.5000047995967523, log_density = -73.96576779274261, hamiltonian_energy = 237.51334481122, hamiltonian_energy_error = -3.2808224819894747, max_hamiltonian_energy_error = 8304.101213762713, tree_depth = 2, numerical_error = true, step_size = 0.14098601560410218, nom_step_size = 0.14098601560410218, is_adapt = true), (n_steps = 1, is_accept = true, acceptance_rate = 0.0, log_density = -73.96576779274261, hamiltonian_energy = 198.64100149254836, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 5342.2597114649225, tree_depth = 0, numerical_error = true, step_size = 0.16317237639585677, nom_step_size = 0.16317237639585677, is_adapt = true), (n_steps = 111, is_accept = true, acceptance_rate = 0.05110674621874226, log_density = -67.12016567490352, hamiltonian_energy = 191.28974604906597, hamiltonian_energy_error = -0.4284281216270074, max_hamiltonian_energy_error = 2417.2242754579693, tree_depth = 6, numerical_error = true, step_size = 0.03950688131282286, nom_step_size = 0.03950688131282286, is_adapt = true), (n_steps = 255, is_accept = true, acceptance_rate = 0.97796208869193, log_density = -147.94452813545368, hamiltonian_energy = 203.83830179000438, hamiltonian_energy_error = -0.294929353333373, max_hamiltonian_energy_error = -0.8028932063563445, tree_depth = 8, numerical_error = false, step_size = 0.011110489878280262, nom_step_size = 0.011110489878280262, is_adapt = true)  …  (n_steps = 255, is_accept = true, acceptance_rate = 0.5349706116653804, log_density = -125.96601753527476, hamiltonian_energy = 253.6068633737704, hamiltonian_energy_error = 0.5143797194798196, max_hamiltonian_energy_error = 5.252717559455874, tree_depth = 8, numerical_error = false, step_size = 0.015802685486437217, nom_step_size = 0.015802685486437217, is_adapt = true), (n_steps = 255, is_accept = true, acceptance_rate = 0.7343766911353963, log_density = -116.32361910543361, hamiltonian_energy = 235.2305111784467, hamiltonian_energy_error = 0.6631506028223271, max_hamiltonian_energy_error = 1.855972272388982, tree_depth = 8, numerical_error = false, step_size = 0.02003204591152491, nom_step_size = 0.02003204591152491, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.39204603974227664, log_density = -123.41049317041768, hamiltonian_energy = 233.8282071885734, hamiltonian_energy_error = 0.016928417004152152, max_hamiltonian_energy_error = 315.7539333675469, tree_depth = 7, numerical_error = false, step_size = 0.04159335448293264, nom_step_size = 0.04159335448293264, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.280973436790089, log_density = -151.755097195011, hamiltonian_energy = 263.36975236671566, hamiltonian_energy_error = -2.243518914864694, max_hamiltonian_energy_error = 130.63713571716056, tree_depth = 7, numerical_error = false, step_size = 0.036625658920291626, nom_step_size = 0.036625658920291626, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.3550600996240301, log_density = -150.35986416697, hamiltonian_energy = 283.499351350628, hamiltonian_energy_error = 0.4531713684143597, max_hamiltonian_energy_error = 4.721435430663803, tree_depth = 7, numerical_error = false, step_size = 0.024592212827381096, nom_step_size = 0.024592212827381096, is_adapt = true), (n_steps = 255, is_accept = true, acceptance_rate = 0.7949536459230067, log_density = -139.65315734712811, hamiltonian_energy = 279.2869548051598, hamiltonian_energy_error = 0.511271200583792, max_hamiltonian_energy_error = 1.439389950762461, tree_depth = 8, numerical_error = false, step_size = 0.019893665421233987, nom_step_size = 0.019893665421233987, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.511512160278778, log_density = -137.7611647298945, hamiltonian_energy = 264.76764109894975, hamiltonian_energy_error = -2.847948656286235, max_hamiltonian_energy_error = 37.291628550533915, tree_depth = 7, numerical_error = false, step_size = 0.04684235142679917, nom_step_size = 0.04684235142679917, is_adapt = true), (n_steps = 63, is_accept = true, acceptance_rate = 1.1655213826388342e-5, log_density = -137.7611647298945, hamiltonian_energy = 280.2032100610669, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 555.9588006229125, tree_depth = 6, numerical_error = false, step_size = 0.05511387683557302, nom_step_size = 0.05511387683557302, is_adapt = true), (n_steps = 255, is_accept = true, acceptance_rate = 0.85184329469272, log_density = -142.3829964279738, hamiltonian_energy = 272.8058075005123, hamiltonian_energy_error = -0.12659853645027397, max_hamiltonian_energy_error = 1.6559910107795304, tree_depth = 8, numerical_error = false, step_size = 0.01906256461198719, nom_step_size = 0.01906256461198719, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.20063355971398664, log_density = -145.3364805067361, hamiltonian_energy = 270.5794121187859, hamiltonian_energy_error = 0.3330359706131958, max_hamiltonian_energy_error = 611.6197715996047, tree_depth = 6, numerical_error = false, step_size = 0.05048312765032871, nom_step_size = 0.05048312765032871, is_adapt = true)])

Step 5: Plot diagnostics

Now let's make sure the fit is good. This can be done by looking at the chain mixing plot and the autocorrelation plot. First, let's create the chain mixing plot using the plot recipes from ????

samples = hcat(samples...)
+samples, stats = sample(h, kernel, p, 500, adaptor, 500; progress = true)
([[0.1459048720690972, 0.1506211858875353, 0.28190318766022177, 0.08779236306335092, 0.34662452616949474, 0.12198125442294652, -0.19426849264787538, -0.11133505582390985, -0.3498093610418175, 0.22467052029747636  …  0.21844873513145757, -0.32367932328957866, -0.2195114967054609, -0.2683328692271144, -0.32715986103723, -0.16368773282902513, 0.03726275292741481, -0.24726425239826455, -0.05343780588455094, 0.03214720889064082], [0.1459048720690972, 0.1506211858875353, 0.28190318766022177, 0.08779236306335092, 0.34662452616949474, 0.12198125442294652, -0.19426849264787538, -0.11133505582390985, -0.3498093610418175, 0.22467052029747636  …  0.21844873513145757, -0.32367932328957866, -0.2195114967054609, -0.2683328692271144, -0.32715986103723, -0.16368773282902513, 0.03726275292741481, -0.24726425239826455, -0.05343780588455094, 0.03214720889064082], [0.1459048720690972, 0.1506211858875353, 0.28190318766022177, 0.08779236306335092, 0.34662452616949474, 0.12198125442294652, -0.19426849264787538, -0.11133505582390985, -0.3498093610418175, 0.22467052029747636  …  0.21844873513145757, -0.32367932328957866, -0.2195114967054609, -0.2683328692271144, -0.32715986103723, -0.16368773282902513, 0.03726275292741481, -0.24726425239826455, -0.05343780588455094, 0.03214720889064082], [0.1459048720690972, 0.1506211858875353, 0.28190318766022177, 0.08779236306335092, 0.34662452616949474, 0.12198125442294652, -0.19426849264787538, -0.11133505582390985, -0.3498093610418175, 0.22467052029747636  …  0.21844873513145757, -0.32367932328957866, -0.2195114967054609, -0.2683328692271144, -0.32715986103723, -0.16368773282902513, 0.03726275292741481, -0.24726425239826455, -0.05343780588455094, 0.03214720889064082], [0.8530681834584484, -0.030994097605505463, 0.5821338757890956, 0.38938405850206786, -0.13423402653082805, 0.4826168407521888, -0.21300719441366336, -0.25436572387436307, -0.12513143940220878, 0.35790950924701137  …  -0.16522262882887037, -0.17149125251434277, 0.019756682409391883, -0.5306206421639734, -0.5217685874827881, -0.3998977315626046, 0.42371488673574403, -0.744584950875927, -0.8255942769242299, -0.05878555100881333], [0.5815102359221804, 0.11280249243262681, 0.6669194065775066, 0.38339639839735273, -0.6264752690623949, 0.6327963912501391, 0.13602650531825533, -0.6520009057938728, -0.5495813190442432, 0.19597213966583976  …  0.1386043983585747, -0.08309942065196689, -0.49611018485807484, -1.2237442009039639, -0.10848696553423365, 0.19036387023066115, 0.17497440506667328, -1.2377246773120638, -0.9006759907199938, -0.42560548909429735], [0.5815102359221804, 0.11280249243262681, 0.6669194065775066, 0.38339639839735273, -0.6264752690623949, 0.6327963912501391, 0.13602650531825533, -0.6520009057938728, -0.5495813190442432, 0.19597213966583976  …  0.1386043983585747, -0.08309942065196689, -0.49611018485807484, -1.2237442009039639, -0.10848696553423365, 0.19036387023066115, 0.17497440506667328, -1.2377246773120638, -0.9006759907199938, -0.42560548909429735], [0.5657064615106189, 0.5340536819340527, 0.36216040038101605, 0.4050165253726768, -0.665142698648101, 0.5342878555663314, 0.15270419152583756, -0.5268731364856518, -0.43093165859302685, 0.1137712723430091  …  0.07553805598483826, -0.333841864677052, -0.2647280398125431, -1.2326330905608942, -0.2814867835226784, 0.11822546244949933, 0.24518815605185362, -1.1838687347572148, -0.802734884141623, -0.44641910736910156], [-0.09278910355912913, 0.8851412900071919, -0.18665481279051063, 0.3369895393768272, -0.281344245633109, 0.04760930098121985, 0.18583643911802125, -0.45522883119740765, -0.028180937407683827, -0.5566935138679964  …  0.3219437701425924, -0.4651357389284164, -0.05589063488068184, -0.27806949357048544, -0.5924795740156197, -0.6072984819024341, -0.28785921579684287, -0.7212052815696735, -0.5150626332272928, -0.6481881784279656], [0.6993181417542708, -0.6046853586879584, 0.5137396117261726, 1.3157382594918507, 0.34889044237878497, -0.2987051744424675, 1.0306305539379212, -0.06492148207819985, -0.09558871659829506, -0.3772012259536287  …  0.3983927879383764, 0.40581792010965945, -0.05939417671648814, -0.3998354608425687, -1.093667873343151, -0.4296583682827532, 0.3176678269350154, -0.11303129328286506, 0.19616112333328237, -0.22876499397398847]  …  [-1.3498518529771921, -0.491965256704345, -1.0664977246961933, -0.4577703012206109, 1.6371954569090554, -0.4852613791739936, -0.39983920260300676, -1.2056082070729275, 0.2833699243822977, -0.4975217733528757  …  0.1508922737071086, -0.34096094677393757, -0.6207479613271373, 0.12459488131678997, 0.07298080787531758, -0.19405522736925715, -0.34871028198482507, 1.0958255794513734, -1.509732384313668, 0.1663152841024108], [-0.04166524890048186, -0.3396119602308359, -1.1431096050119538, 0.37875020246323277, 0.06997723631949129, -0.9783189547861972, -0.4003668354324022, -0.4187937874053661, 0.28109500933243503, -1.7346919223190078  …  0.1734237790105103, 0.42018495681172213, 0.5319076843172134, 0.34064047866241076, 0.442359623285001, 0.15553502836175975, -0.8284456773641059, -0.07386306557234601, -0.30098521209492224, 0.0883437872126141], [-1.1687995119134713, -0.10252216260249825, -0.8049696939291622, 0.503237380843913, 0.33615507982587073, -1.4806287776407348, -0.34875386482126847, -0.8965737760117288, -0.3051033047308918, -1.3308765146685608  …  -0.44972448359673517, 0.33424759376600094, -0.35817586113701066, 1.6229287224721143, 0.8487603175778311, 0.03796802971421065, -0.6936440907974153, 0.47494961096983723, -0.477889490039392, 0.021520878045850508], [-0.5917544177178929, -0.49811162100898915, -1.0480729885039426, 0.7103041863204159, 0.8286908631455566, -0.2220637520374696, -0.3062734112723119, -0.8008601324354803, -0.6777794875927893, -0.5902169306397016  …  -0.5246564625752814, 0.973959873926373, 0.31484973119357884, -0.04287096206984678, 0.8330005570974229, 1.0462388319297673, -0.6759317403324617, 0.9669253693405007, 0.1589359987123535, -0.08372939745827172], [-1.1146788144146431, -0.30768091656501084, -1.0509739198424082, 0.0005566799373861106, 1.4355488731539192, -0.42043801958431676, -0.5354062066266109, 0.6514713785236244, -0.574895846685267, -0.13748771354288222  …  0.058953686578439565, 0.5654866034894099, 0.336963368186654, 0.5933103098672399, -0.31308049221413375, 1.1023532596980656, -0.42850833349560613, 0.9853922394982383, -0.41456401348592775, -0.07197846892513021], [-0.09759380943651179, 0.04177114282812288, -1.0648347709825599, -0.1796549592451296, 0.7842148264638192, -0.3892976962267767, -0.9654846014088578, -0.28209501174769414, -0.7592186120337743, 0.3177591624980775  …  -0.29853206434017276, -0.12497151611945032, 0.05280164904560842, 0.36207928188151, -0.3482070246922768, 0.5966325110566075, -0.48504556006178123, 0.018108210416462323, -0.13225876238036782, -0.25337165129127914], [-0.23433119534167812, 0.03478793992953902, -1.0501387987232857, -0.15723117300150408, 0.6930375475491365, -0.49644065379657965, -0.8965504315311572, -0.25958951242613376, -0.6585055101892224, 0.24727815481712523  …  -0.2752925728731057, 0.08177316720366595, 0.25184782513874504, 0.27245540444423416, -0.3701484291062427, 0.5434968707285631, -0.548824812771198, 0.018026499065779068, -0.01844918224664712, -0.3022759737239605], [0.3776825206457904, 0.34104373691939666, 0.757480185406535, 0.1313366194015156, 0.7250296032500759, 0.31134958450546407, 0.2798373307628873, 0.3917339711569044, 1.0691686628601635, -0.3693539634117767  …  -0.7114542716328232, -1.6998564215725815, -0.2852443454796097, -0.47115080484128136, 0.20175592774292134, -0.933963408691461, 0.024725725135626, -0.3103112866771341, -0.8355198242157531, 0.7211216389966529], [0.38606798050321783, 0.3240917193628806, 0.8221153892986891, -0.013867037449644806, 0.7083717306077439, 0.3711126115459523, 0.1650856313175213, 0.6842394874759923, 0.8899711979757117, -0.1926812588678174  …  -0.6262258372565357, -1.5843466127236683, -0.3688107987432845, -0.4893106230283592, 0.1676329559387152, -0.984476137506497, 0.0029535524459748334, -0.19900586908794873, -0.6204181988544546, 0.6628599213463037], [0.3797660868639946, 1.0274995605869093, 0.09888007324194296, 0.14989577131154874, -1.2612498378831347, 0.9424444372168922, 1.0928028066556636, -0.6209385802114284, 0.8219146473865833, 0.6467039089602499  …  0.8312822075366828, -0.0007278716142137959, -0.2749413235595906, -0.042211310676877604, -0.25346734565330903, 0.29855899227096516, -0.2278531279532622, -0.4988724534220622, -0.036490173966151764, 0.7556629822781674]], NamedTuple[(n_steps = 15, is_accept = true, acceptance_rate = 1.0, log_density = -266.67019332142763, hamiltonian_energy = 500.4454403428263, hamiltonian_energy_error = -44.30262543333646, max_hamiltonian_energy_error = -44.30262543333646, tree_depth = 4, numerical_error = false, step_size = 0.025, nom_step_size = 0.025, is_adapt = true), (n_steps = 1, is_accept = true, acceptance_rate = 0.0, log_density = -266.67019332142763, hamiltonian_energy = 384.4537830977451, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 7708.133984258763, tree_depth = 0, numerical_error = true, step_size = 0.6795704571147614, nom_step_size = 0.6795704571147614, is_adapt = true), (n_steps = 1, is_accept = true, acceptance_rate = 0.0, log_density = -266.67019332142763, hamiltonian_energy = 372.9473661664874, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 1236.2392229359498, tree_depth = 0, numerical_error = true, step_size = 0.3164493440113639, nom_step_size = 0.3164493440113639, is_adapt = true), (n_steps = 13, is_accept = true, acceptance_rate = 6.166513562314749e-15, log_density = -266.67019332142763, hamiltonian_energy = 397.1688036175286, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 7907.641860647865, tree_depth = 3, numerical_error = true, step_size = 0.09837809577101383, nom_step_size = 0.09837809577101383, is_adapt = true), (n_steps = 31, is_accept = true, acceptance_rate = 0.9354838709677419, log_density = -123.1803945589349, hamiltonian_energy = 378.00136938608847, hamiltonian_energy_error = -3.096383351409429, max_hamiltonian_energy_error = 1793.321943643797, tree_depth = 4, numerical_error = true, step_size = 0.025425348076057157, nom_step_size = 0.025425348076057157, is_adapt = true), (n_steps = 10, is_accept = true, acceptance_rate = 0.6129642596237849, log_density = -83.12260906957017, hamiltonian_energy = 239.24477315832485, hamiltonian_energy_error = -5.233352109711177, max_hamiltonian_energy_error = 1086.716403943174, tree_depth = 3, numerical_error = true, step_size = 0.09788124829504163, nom_step_size = 0.09788124829504163, is_adapt = true), (n_steps = 3, is_accept = true, acceptance_rate = 0.03377697349919567, log_density = -83.12260906957017, hamiltonian_energy = 197.87032954137743, hamiltonian_energy_error = 0.0, max_hamiltonian_energy_error = 52807.22959959065, tree_depth = 1, numerical_error = true, step_size = 0.15718602567440013, nom_step_size = 0.15718602567440013, is_adapt = true), (n_steps = 57, is_accept = true, acceptance_rate = 0.2873033342067722, log_density = -81.510044436524, hamiltonian_energy = 201.1270146684385, hamiltonian_energy_error = -0.5878636283796368, max_hamiltonian_energy_error = 43506.571497103774, tree_depth = 5, numerical_error = true, step_size = 0.042699071799598566, nom_step_size = 0.042699071799598566, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.44454804009292315, log_density = -117.2487601437049, hamiltonian_energy = 198.4044002577529, hamiltonian_energy_error = 0.002611711162927577, max_hamiltonian_energy_error = 3.9277502522595853, tree_depth = 7, numerical_error = false, step_size = 0.02517396371642053, nom_step_size = 0.02517396371642053, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.4757913078827028, log_density = -133.5630535118202, hamiltonian_energy = 247.3917163907308, hamiltonian_energy_error = 0.12569597656440124, max_hamiltonian_energy_error = 40.02473706177972, tree_depth = 7, numerical_error = false, step_size = 0.02447107731053278, nom_step_size = 0.02447107731053278, is_adapt = true)  …  (n_steps = 63, is_accept = true, acceptance_rate = 0.09351406576401793, log_density = -119.20413155431244, hamiltonian_energy = 255.71403818901194, hamiltonian_energy_error = -0.6512376573627989, max_hamiltonian_energy_error = 271.43994013497354, tree_depth = 6, numerical_error = false, step_size = 0.06679009047008448, nom_step_size = 0.06679009047008448, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.6458445679801108, log_density = -121.5273269030964, hamiltonian_energy = 248.79801323451585, hamiltonian_energy_error = 2.3447695502860597, max_hamiltonian_energy_error = 47.39430342701138, tree_depth = 7, numerical_error = false, step_size = 0.027721643758803403, nom_step_size = 0.027721643758803403, is_adapt = true), (n_steps = 127, is_accept = true, acceptance_rate = 0.4664028997186645, log_density = -119.78144581821434, hamiltonian_energy = 231.95748573281713, hamiltonian_energy_error = -2.0604483948166035, max_hamiltonian_energy_error = 61.80090055320568, tree_depth = 7, numerical_error = false, step_size = 0.04617562467375827, nom_step_size = 0.04617562467375827, is_adapt = true), (n_steps = 63, is_accept = true, acceptance_rate = 0.4275028838174605, log_density = -131.01560553748848, hamiltonian_energy = 239.36550131091138, hamiltonian_energy_error = 0.6854157814535711, max_hamiltonian_energy_error = 35.98912205403144, tree_depth = 6, numerical_error = false, step_size = 0.048967589536515164, nom_step_size = 0.048967589536515164, is_adapt = true), (n_steps = 106, is_accept = true, acceptance_rate = 0.5024002530641722, log_density = -118.93735699081097, hamiltonian_energy = 247.8384306502584, hamiltonian_energy_error = -0.14346440229147106, max_hamiltonian_energy_error = 2502.734488141457, tree_depth = 6, numerical_error = true, step_size = 0.04715184069743176, nom_step_size = 0.04715184069743176, is_adapt = true), (n_steps = 63, is_accept = true, acceptance_rate = 0.43723806079015576, log_density = -132.60286481241263, hamiltonian_energy = 261.8700095617286, hamiltonian_energy_error = 0.5534305632183987, max_hamiltonian_energy_error = 51.79885334887149, tree_depth = 6, numerical_error = false, step_size = 0.054529547338671186, nom_step_size = 0.054529547338671186, is_adapt = true), (n_steps = 49, is_accept = true, acceptance_rate = 0.11003797601268323, log_density = -130.10612625967642, hamiltonian_energy = 249.32136357157262, hamiltonian_energy_error = -0.9689147104769802, max_hamiltonian_energy_error = 10702.075844098295, tree_depth = 5, numerical_error = true, step_size = 0.053739770800516735, nom_step_size = 0.053739770800516735, is_adapt = true), (n_steps = 255, is_accept = true, acceptance_rate = 0.7152430297941968, log_density = -119.06974540852107, hamiltonian_energy = 260.3262746230375, hamiltonian_energy_error = 0.24041020117959988, max_hamiltonian_energy_error = 5.9693845632918965, tree_depth = 8, numerical_error = false, step_size = 0.024109606914176948, nom_step_size = 0.024109606914176948, is_adapt = true), (n_steps = 114, is_accept = true, acceptance_rate = 0.05830876108203624, log_density = -117.80077055712982, hamiltonian_energy = 245.35248137669208, hamiltonian_energy_error = -0.8213242260031279, max_hamiltonian_energy_error = 2611.3795723079606, tree_depth = 6, numerical_error = true, step_size = 0.04642382581985111, nom_step_size = 0.04642382581985111, is_adapt = true), (n_steps = 255, is_accept = true, acceptance_rate = 0.8700690572587414, log_density = -138.85709113611395, hamiltonian_energy = 246.05076909630338, hamiltonian_energy_error = -0.5899628985420975, max_hamiltonian_energy_error = -1.1995389956403244, tree_depth = 8, numerical_error = false, step_size = 0.018638367209544465, nom_step_size = 0.018638367209544465, is_adapt = true)])

Step 5: Plot diagnostics

Now let's make sure the fit is good. This can be done by looking at the chain mixing plot and the autocorrelation plot. First, let's create the chain mixing plot using the plot recipes from ????

samples = hcat(samples...)
 samples_reduced = samples[1:5, :]
 samples_reshape = reshape(samples_reduced, (500, 5, 1))
 Chain_Spiral = Chains(samples_reshape)
-plot(Chain_Spiral)
Example block output

Now we check the autocorrelation plot:

autocorplot(Chain_Spiral)
Example block output

As another diagnostic, let's check the result on retrodicted data. To do this, we generate solutions of the Neural ODE on samples of the neural network parameters, and check the results of the predictions against the data. Let's start by looking at the time series:

pl = scatter(tsteps, ode_data[1, :], color = :red, label = "Data: Var1", xlabel = "t",
+plot(Chain_Spiral)
Example block output

Now we check the autocorrelation plot:

autocorplot(Chain_Spiral)
Example block output

As another diagnostic, let's check the result on retrodicted data. To do this, we generate solutions of the Neural ODE on samples of the neural network parameters, and check the results of the predictions against the data. Let's start by looking at the time series:

pl = scatter(tsteps, ode_data[1, :], color = :red, label = "Data: Var1", xlabel = "t",
              title = "Spiral Neural ODE")
 scatter!(tsteps, ode_data[2, :], color = :blue, label = "Data: Var2")
 for k in 1:300
@@ -75,11 +75,11 @@
 prediction = predict_neuralode(samples[:, idx])
 plot!(tsteps, prediction[1, :], color = :black, w = 2, label = "")
 plot!(tsteps, prediction[2, :], color = :black, w = 2, label = "Best fit prediction",
-      ylims = (-2.5, 3.5))
Example block output

That showed the time series form. We can similarly do a phase-space plot:

pl = scatter(ode_data[1, :], ode_data[2, :], color = :red, label = "Data", xlabel = "Var1",
+      ylims = (-2.5, 3.5))
Example block output

That showed the time series form. We can similarly do a phase-space plot:

pl = scatter(ode_data[1, :], ode_data[2, :], color = :red, label = "Data", xlabel = "Var1",
              ylabel = "Var2", title = "Spiral Neural ODE")
 for k in 1:300
     resol = predict_neuralode(samples[:, 100:end][:, rand(1:400)])
     plot!(resol[1, :], resol[2, :], alpha = 0.04, color = :red, label = "")
 end
 plot!(prediction[1, :], prediction[2, :], color = :black, w = 2,
-      label = "Best fit prediction", ylims = (-2.5, 3))
Example block output + label = "Best fit prediction", ylims = (-2.5, 3))Example block output diff --git a/dev/showcase/blackhole/dae2dc1e.svg b/dev/showcase/blackhole/26fe77f6.svg similarity index 94% rename from dev/showcase/blackhole/dae2dc1e.svg rename to dev/showcase/blackhole/26fe77f6.svg index e76ca165b2f..db9c66e4eb5 100644 --- a/dev/showcase/blackhole/dae2dc1e.svg +++ b/dev/showcase/blackhole/26fe77f6.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/blackhole/cd134a8d.svg b/dev/showcase/blackhole/38fee935.svg similarity index 93% rename from dev/showcase/blackhole/cd134a8d.svg rename to dev/showcase/blackhole/38fee935.svg index bd091d275ca..25eb1e0e7da 100644 --- a/dev/showcase/blackhole/cd134a8d.svg +++ b/dev/showcase/blackhole/38fee935.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/blackhole/be18b50e.svg b/dev/showcase/blackhole/85d99d32.svg similarity index 76% rename from dev/showcase/blackhole/be18b50e.svg rename to dev/showcase/blackhole/85d99d32.svg index aaf976035eb..c64345e0fa1 100644 --- a/dev/showcase/blackhole/be18b50e.svg +++ b/dev/showcase/blackhole/85d99d32.svg @@ -1,301 +1,301 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/blackhole/991a7a22.svg b/dev/showcase/blackhole/91cf40db.svg similarity index 86% rename from dev/showcase/blackhole/991a7a22.svg rename to dev/showcase/blackhole/91cf40db.svg index 68f60c40f44..9f491dff050 100644 --- a/dev/showcase/blackhole/991a7a22.svg +++ b/dev/showcase/blackhole/91cf40db.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/blackhole/f6eae0f3.svg b/dev/showcase/blackhole/fe64b50e.svg similarity index 88% rename from dev/showcase/blackhole/f6eae0f3.svg rename to dev/showcase/blackhole/fe64b50e.svg index d984574934d..b1ccc8a35a1 100644 --- a/dev/showcase/blackhole/f6eae0f3.svg +++ b/dev/showcase/blackhole/fe64b50e.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/blackhole/index.html b/dev/showcase/blackhole/index.html index 260dcf29bf7..fa6241af921 100644 --- a/dev/showcase/blackhole/index.html +++ b/dev/showcase/blackhole/index.html @@ -364,7 +364,7 @@ plt = plot(tsteps, waveform, markershape=:circle, markeralpha = 0.25, linewidth = 2, alpha = 0.5, - label="waveform data", xlabel="Time", ylabel="Waveform")Example block output

Looks great!

Automating the Discovery of Relativistic Equations from Newtonian Physics

Now let's learn the relativistic corrections directly from the data. To define the UDE, we will define a Lux neural network and pass it into our Newtonian Physics + Nerual Network ODE definition from above:

NN = Lux.Chain((x) -> cos.(x),
+           label="waveform data", xlabel="Time", ylabel="Waveform")
Example block output

Looks great!

Automating the Discovery of Relativistic Equations from Newtonian Physics

Now let's learn the relativistic corrections directly from the data. To define the UDE, we will define a Lux neural network and pass it into our Newtonian Physics + Nerual Network ODE definition from above:

NN = Lux.Chain((x) -> cos.(x),
     Lux.Dense(1, 32, cos),
     Lux.Dense(32, 32, cos),
     Lux.Dense(32, 2))
@@ -443,9 +443,9 @@
 Newt_orbit = soln2orbit(Newtonian_solution, model_params)
 plt = plot(true_orbit[1,:], true_orbit[2,:], linewidth = 2, label = "truth")
 plot!(plt, pred_orbit[1,:], pred_orbit[2,:], linestyle = :dash, linewidth = 2, label = "prediction")
-plot!(plt, Newt_orbit[1,:], Newt_orbit[2,:], linewidth = 2, label = "Newtonian")
Example block output
plt = plot(tsteps,true_waveform, linewidth = 2, label = "truth", xlabel="Time", ylabel="Waveform")
+plot!(plt, Newt_orbit[1,:], Newt_orbit[2,:], linewidth = 2, label = "Newtonian")
Example block output
plt = plot(tsteps,true_waveform, linewidth = 2, label = "truth", xlabel="Time", ylabel="Waveform")
 plot!(plt,tsteps,pred_waveform, linestyle = :dash, linewidth = 2, label = "prediction")
-plot!(plt,tsteps,Newt_waveform, linewidth = 2, label = "Newtonian")
Example block output

Now we'll do the same, but extrapolating the model out in time.

factor=5
+plot!(plt,tsteps,Newt_waveform, linewidth = 2, label = "Newtonian")
Example block output

Now we'll do the same, but extrapolating the model out in time.

factor=5
 
 extended_tspan = (tspan[1], factor*tspan[2])
 extended_tsteps = range(tspan[1], factor*tspan[2], length = factor*datasize)
@@ -461,9 +461,9 @@
 Newt_orbit = soln2orbit(Newtonian_solution, model_params)
 plt = plot(true_orbit[1,:], true_orbit[2,:], linewidth = 2, label = "truth")
 plot!(plt, pred_orbit[1,:], pred_orbit[2,:], linestyle = :dash, linewidth = 2, label = "prediction")
-plot!(plt, Newt_orbit[1,:], Newt_orbit[2,:], linewidth = 2, label = "Newtonian")
Example block output
true_waveform = compute_waveform(dt_data, reference_solution, mass_ratio, model_params)[1]
+plot!(plt, Newt_orbit[1,:], Newt_orbit[2,:], linewidth = 2, label = "Newtonian")
Example block output
true_waveform = compute_waveform(dt_data, reference_solution, mass_ratio, model_params)[1]
 pred_waveform = compute_waveform(dt_data, optimized_solution, mass_ratio, model_params)[1]
 Newt_waveform = compute_waveform(dt_data, Newtonian_solution, mass_ratio, model_params)[1]
 plt = plot(extended_tsteps,true_waveform, linewidth = 2, label = "truth", xlabel="Time", ylabel="Waveform")
 plot!(plt,extended_tsteps,pred_waveform, linestyle = :dash, linewidth = 2, label = "prediction")
-plot!(plt,extended_tsteps,Newt_waveform, linewidth = 2, label = "Newtonian")
Example block output +plot!(plt,extended_tsteps,Newt_waveform, linewidth = 2, label = "Newtonian")Example block output diff --git a/dev/showcase/brusselator/index.html b/dev/showcase/brusselator/index.html index 327ddda9f15..415b532fdce 100644 --- a/dev/showcase/brusselator/index.html +++ b/dev/showcase/brusselator/index.html @@ -378,4 +378,4 @@ ydomain:([0.0, 11.5], 0.0:0.03125:1.0, 0.0:0.03125:1.0) u: Dict{Symbolics.Num, Array{Float64, 3}} with 2 entries: u(x, y, t) => [0.0 0.115882 … 0.115882 0.0; 0.0 0.115882 … 0.115882 0.0; … ; … - v(x, y, t) => [0.0 0.0 … 0.0 0.0; 0.142219 0.142219 … 0.142219 0.142219; … ; …

And now we're zooming! For more information on these performance improvements, check out the deeper dive in the DifferentialEquations.jl tutorials.

If you're interested in figuring out what's the fastest current solver for this kind of PDE, check out the Brusselator benchmark in SciMLBenchmarks.jl

+ v(x, y, t) => [0.0 0.0 … 0.0 0.0; 0.142219 0.142219 … 0.142219 0.142219; … ; …

And now we're zooming! For more information on these performance improvements, check out the deeper dive in the DifferentialEquations.jl tutorials.

If you're interested in figuring out what's the fastest current solver for this kind of PDE, check out the Brusselator benchmark in SciMLBenchmarks.jl

diff --git a/dev/showcase/gpu_spde/cdc85131.svg b/dev/showcase/gpu_spde/48693347.svg similarity index 88% rename from dev/showcase/gpu_spde/cdc85131.svg rename to dev/showcase/gpu_spde/48693347.svg index 8f3cd0b329c..9dc30df00d7 100644 --- a/dev/showcase/gpu_spde/cdc85131.svg +++ b/dev/showcase/gpu_spde/48693347.svg @@ -1,56 +1,56 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + diff --git a/dev/showcase/gpu_spde/d9f11163.svg b/dev/showcase/gpu_spde/54605985.svg similarity index 87% rename from dev/showcase/gpu_spde/d9f11163.svg rename to dev/showcase/gpu_spde/54605985.svg index d6cb85167e7..8cd6ae2a3ec 100644 --- a/dev/showcase/gpu_spde/d9f11163.svg +++ b/dev/showcase/gpu_spde/54605985.svg @@ -1,58 +1,58 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + diff --git a/dev/showcase/gpu_spde/59119d64.svg b/dev/showcase/gpu_spde/59119d64.svg new file mode 100644 index 00000000000..c5243b3721e --- /dev/null +++ b/dev/showcase/gpu_spde/59119d64.svg @@ -0,0 +1,1560 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/gpu_spde/a7c4283b.svg b/dev/showcase/gpu_spde/a7c4283b.svg deleted file mode 100644 index c99b623fb73..00000000000 --- a/dev/showcase/gpu_spde/a7c4283b.svg +++ /dev/null @@ -1,1572 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/gpu_spde/index.html b/dev/showcase/gpu_spde/index.html index fc4f7c5b50f..ca5c47604a5 100644 --- a/dev/showcase/gpu_spde/index.html +++ b/dev/showcase/gpu_spde/index.html @@ -206,7 +206,7 @@ p1 = surface(X, Y, sol[end][:, :, 1], title = "[A]") p2 = surface(X, Y, sol[end][:, :, 2], title = "[B]") p3 = surface(X, Y, sol[end][:, :, 3], title = "[C]") -plot(p1, p2, p3, layout = grid(3, 1))Example block output

and see the pretty gradients. Using this 2nd order ROCK method we solve this equation in about 2 seconds. That's okay.

Some Optimizations

There are some optimizations that can still be done. When we do A*B as matrix multiplication, we create another temporary matrix. These allocations can bog down the system. Instead, we can pre-allocate the outputs and use the inplace functions mul! to make better use of memory. The easiest way to store these cache arrays are constant globals, but you can use closures (anonymous functions which capture data, i.e. (x)->f(x,y)) or call-overloaded types to do it without globals. The globals way (the easy way) is simply:

const MyA = zeros(N, N)
+plot(p1, p2, p3, layout = grid(3, 1))
Example block output

and see the pretty gradients. Using this 2nd order ROCK method we solve this equation in about 2 seconds. That's okay.

Some Optimizations

There are some optimizations that can still be done. When we do A*B as matrix multiplication, we create another temporary matrix. These allocations can bog down the system. Instead, we can pre-allocate the outputs and use the inplace functions mul! to make better use of memory. The easiest way to store these cache arrays are constant globals, but you can use closures (anonymous functions which capture data, i.e. (x)->f(x,y)) or call-overloaded types to do it without globals. The globals way (the easy way) is simply:

const MyA = zeros(N, N)
 const AMx = zeros(N, N)
 const DA = zeros(N, N)
 function f(du, u, p, t)
@@ -329,7 +329,7 @@
 p1 = surface(X, Y, sol[end][:, :, 1], title = "[A]")
 p2 = surface(X, Y, sol[end][:, :, 2], title = "[B]")
 p3 = surface(X, Y, sol[end][:, :, 3], title = "[C]")
-plot(p1, p2, p3, layout = grid(3, 1))
Example block output

Making Use of GPU Parallelism

That was all using the CPU. How do we turn on GPU parallelism with DifferentialEquations.jl? Well, you don't. DifferentialEquations.jl "doesn't have GPU bits". So, wait... can we not do GPU parallelism? No, this is the glory of type-genericness, especially in broadcasted operations. To make things use the GPU, we simply use a CuArray from CUDA.jl. If instead of zeros(N,M) we used CuArray(zeros(N,M)), then the array lives on the GPU. CuArray naturally overrides broadcast such that dotted operations are performed on the GPU. DifferentialEquations.jl uses broadcast internally, and thus just by putting the array as a CuArray, the array-type will take over how all internal updates are performed and turn this algorithm into a fully GPU-parallelized algorithm that doesn't require copying to the CPU. Wasn't that simple?

From that you can probably also see how to multithread everything, or how to set everything up with distributed parallelism. You can make the ODE solvers do whatever you want by defining an array type where the broadcast does whatever special behavior you want.

So to recap, the entire difference from above is changing to:

using CUDA
+plot(p1, p2, p3, layout = grid(3, 1))
Example block output

Making Use of GPU Parallelism

That was all using the CPU. How do we turn on GPU parallelism with DifferentialEquations.jl? Well, you don't. DifferentialEquations.jl "doesn't have GPU bits". So, wait... can we not do GPU parallelism? No, this is the glory of type-genericness, especially in broadcasted operations. To make things use the GPU, we simply use a CuArray from CUDA.jl. If instead of zeros(N,M) we used CuArray(zeros(N,M)), then the array lives on the GPU. CuArray naturally overrides broadcast such that dotted operations are performed on the GPU. DifferentialEquations.jl uses broadcast internally, and thus just by putting the array as a CuArray, the array-type will take over how all internal updates are performed and turn this algorithm into a fully GPU-parallelized algorithm that doesn't require copying to the CPU. Wasn't that simple?

From that you can probably also see how to multithread everything, or how to set everything up with distributed parallelism. You can make the ODE solvers do whatever you want by defining an array type where the broadcast does whatever special behavior you want.

So to recap, the entire difference from above is changing to:

using CUDA
 const gMx = CuArray(Float32.(Mx))
 const gMy = CuArray(Float32.(My))
 const gα₁ = CuArray(Float32.(α₁))
@@ -380,7 +380,7 @@
 end
g (generic function with 1 method)

Now we just define and solve the system of SDEs:

prob = SDEProblem(f, g, u0, (0.0, 100.0))
 @time sol = solve(prob, SRIW1());
retcode: Success
 Interpolation: 1st order linear
-t: 81593-element Vector{Float64}:
+t: 81851-element Vector{Float64}:
    0.0
    9.999999999999999e-5
    0.0002125
@@ -392,40 +392,40 @@
    0.0012526276111602785
    0.0015092060625553133
    ⋮
-  99.99620988870055
-  99.99653857846032
-  99.99690835444007
-  99.99732435241728
-  99.99779235014165
-  99.99831884758157
-  99.99891115720148
-  99.99957750552387
+  99.98307699869058
+  99.98462545537967
+  99.9863674691549
+  99.98832723465203
+  99.99053197083632
+  99.99301229904363
+  99.99580266827685
+  99.99894183366423
  100.0
-u: 81593-element Vector{Array{Float64, 3}}:
+u: 81851-element Vector{Array{Float64, 3}}:
  [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0;;; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0;;; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0]
- [4.999999999999999e-9 4.999999999999999e-9 … 0.00010001970767065549 9.906876860539888e-5; 4.999999999999999e-9 4.999999999999999e-9 … 0.00010094483042374298 9.995455676794776e-5; … ; 4.999999999999999e-9 4.999999999999999e-9 … 0.00010095120165963166 9.99033444971664e-5; 4.999999999999999e-9 4.999999999999999e-9 … 0.00010006084628574199 9.900675000822356e-5;;; 9.999999999999999e-5 9.999999999999999e-5 … 0.00010000768053241945 0.00010000016071395579; 9.999999999999999e-5 9.999999999999999e-5 … 9.992200058660799e-5 9.988777314525816e-5; … ; 9.999999999999999e-5 9.999999999999999e-5 … 0.00010006784195946359 9.990173578595471e-5; 9.999999999999999e-5 9.999999999999999e-5 … 0.00010002097489805361 0.00010004438038439646;;; 9.999e-5 9.999e-5 … 9.995738914278281e-5 9.996262651760115e-5; 9.999e-5 9.999e-5 … 9.994911384326805e-5 9.997212596714771e-5; … ; 9.999e-5 9.999e-5 … 0.00010000241144332559 9.997073191143076e-5; 9.999e-5 9.999e-5 … 9.989183460718062e-5 0.0001000116735029045]
- [2.2346464423296463e-8 2.2595066610912047e-8 … 0.00021263503615837602 0.00020801579155965501; 2.2576997238362738e-8 2.280506362270817e-8 … 0.00021696809701506333 0.00021234044396063788; … ; 2.2588752633513042e-8 2.2829885084790387e-8 … 0.0002169788978312685 0.00021239237852782486; 2.2329989378978438e-8 2.2565514859998152e-8 … 0.0002125391798814717 0.0002078825718143447;;; 0.0002124999879694636 0.0002124999832997978 … 0.0002122869129883827 0.00021270483851630574; 0.00021249999679982337 0.00021249999866670416 … 0.0002124726066626981 0.00021258070675416846; … ; 0.0002124999951484381 0.00021249998970966427 … 0.00021288157272483953 0.00021235681414219257; 0.00021250000232042563 0.00021250000371965565 … 0.00021229157799386623 0.00021260320503027025;;; 0.00021245484091384027 0.00021245484363806243 … 0.00021240306654160155 0.00021254006051688143; 0.00021245486134184344 0.00021245483616832788 … 0.00021243454842988756 0.00021249838028926672; … ; 0.00021245485844074302 0.0002124548313821705 … 0.00021270113388113047 0.00021211376175614579; 0.00021245483916834592 0.00021245484505732343 … 0.00021208948220933797 0.00021255805990238522]
- [5.6358081691903135e-8 5.7485390560291675e-8 … 0.0003393025943449419 0.0003278326157803665; 5.7458046866395345e-8 5.862474124898845e-8 … 0.00035054002305189675 0.00033852276591156053; … ; 5.745736963436767e-8 5.866314569989519e-8 … 0.00035082443559110893 0.0003384543840340276; 5.6318559784201835e-8 5.737693223754426e-8 … 0.0003392189233487561 0.0003279321918173408;;; 0.00033906250394659566 0.0003390624326522281 … 0.0003388625132097978 0.00033957822510766433; 0.0003390624960145901 0.00033906250919121865 … 0.00033884893480608935 0.000339842170427497; … ; 0.00033906246914851626 0.00033906240471342646 … 0.0003391119943623317 0.0003389646129797056; 0.0003390625194548116 0.00033906246771321294 … 0.000338840226847917 0.00033949374712959925;;; 0.000338947595983019 0.00033894759792386686 … 0.00033843665877317865 0.00033904900802877487; 0.00033894757296611166 0.000338947582279004 … 0.0003393679565329802 0.0003392555051228542; … ; 0.00033894754247435 0.00033894758550452787 … 0.0003391510504777318 0.0003388922787523327; 0.00033894751807164736 0.00033894746572448017 … 0.00033863564687617475 0.00033901360897463595]
- [1.1249835901578941e-7 1.1580806388385886e-7 … 0.00048083962460799764 0.0004591967030280774; 1.1570289467002759e-7 1.1927376423777626e-7 … 0.0005035074775354921 0.0004801239015916846; … ; 1.1584479968304372e-7 1.1930088193294338e-7 … 0.0005036474620141303 0.00048018334640753164; 1.123076786402811e-7 1.1573017576775738e-7 … 0.0004823989240482499 0.0004588082283591088;;; 0.0004814450289129674 0.00048144514982996695 … 0.0004813126253015462 0.00048204209602172303; 0.00048144521995985263 0.00048144535409927155 … 0.0004812165171870667 0.0004817378545382583; … ; 0.000481445251107656 0.0004814450806912959 … 0.00048054723281645427 0.0004819396152929195; 0.0004814452716046804 0.0004814451678878154 … 0.0004805656971942971 0.00048177227604316694;;; 0.00048121364528914425 0.00048121355688796226 … 0.00048063800394704926 0.0004811086929553834; 0.00048121361061728246 0.0004812136297101779 … 0.0004819682019928739 0.00048176819517218835; … ; 0.00048121377298559624 0.00048121380664418263 … 0.0004812955051429065 0.0004803284050125154; 0.00048121352927787085 0.00048121348041550276 … 0.00048065400268425306 0.0004810929393547578]
- [1.9803867130682272e-7 2.053789387474887e-7 … 0.0006409866334498258 0.0006034002497481925; 2.055340751324474e-7 2.1380059992778875e-7 … 0.0006798880973883988 0.0006399375965519305; … ; 2.05198439840563e-7 2.1416426590896794e-7 … 0.0006807110065479611 0.0006396675504930293; 1.9748868519382652e-7 2.0545868197707434e-7 … 0.0006406807707626909 0.0006022625127537943;;; 0.0006416256778769289 0.0006416260179698708 … 0.0006410872145277632 0.0006422232503954915; 0.0006416255464491603 0.0006416257551783166 … 0.0006412041440299745 0.0006425491695069505; … ; 0.0006416258363832101 0.0006416255168704118 … 0.0006413344809129552 0.0006419785008183267; 0.0006416257657520689 0.0006416258159459848 … 0.0006412963934965748 0.0006421685852141439;;; 0.0006412145511551574 0.0006412139667821343 … 0.0006411251001506567 0.0006419276917341542; 0.0006412141871529584 0.0006412147614643492 … 0.0006420582348437994 0.0006415356682963308; … ; 0.0006412147919753178 0.000641214818241239 … 0.0006422967140854499 0.0006412863599591814; 0.0006412140926395027 0.0006412143055091038 … 0.0006404196743197119 0.0006407799194975337]
- [3.209112963813805e-7 3.3642552880636073e-7 … 0.0008196347425960763 0.0007614021406604412; 3.3769727675995487e-7 3.544582685790344e-7 … 0.0008839303009034053 0.000818219327934778; … ; 3.3690791758358376e-7 3.540001887346012e-7 … 0.0008830880227047163 0.0008177154172131095; 3.20145546592648e-7 3.3675314478697526e-7 … 0.0008195853727142488 0.0007591261625901722;;; 0.0008218289916223441 0.000821828993543309 … 0.000821783774665703 0.0008210165446167801; 0.0008218287952838991 0.0008218291092774156 … 0.0008214646819677541 0.0008209807752288545; … ; 0.000821829106626497 0.0008218281377556884 … 0.0008223167762898783 0.000823179822347046; 0.0008218293210056947 0.0008218290495560425 … 0.0008221481964520626 0.000823431406868087;;; 0.0008211544105411905 0.0008211540881074765 … 0.0008195553837586505 0.0008218423664476975; 0.0008211541865673741 0.000821154343769497 … 0.0008238328049241268 0.0008239714699253705; … ; 0.0008211547030370101 0.0008211543649634755 … 0.0008218590901732206 0.0008207038871044885; 0.0008211537111056706 0.0008211549515838894 … 0.0008215800838732225 0.0008205022199334508]
- [4.922428231807351e-7 5.223894119425717e-7 … 0.0010223003315838629 0.0009348473186441489; 5.236264917823158e-7 5.561334317183104e-7 … 0.0011232262116823769 0.0010199691451562186; … ; 5.231921943494689e-7 5.564866442764865e-7 … 0.0011185431837545715 0.0010202244611930077; 4.913752693485182e-7 5.220395024052565e-7 … 0.0010198808183339433 0.0009302949422307533;;; 0.0010245584254228131 0.001024556479548961 … 0.0010261686109066174 0.0010226479716855745; 0.0010245585404466634 0.0010245578255377405 … 0.0010232850508374745 0.0010243400650830118; … ; 0.0010245586724859626 0.0010245570460068949 … 0.0010237196169160907 0.0010271424476182038; 0.0010245579234980187 0.0010245575346072703 … 0.0010264089309883404 0.0010245550229665628;;; 0.0010235080767920098 0.0010235076261478745 … 0.0010193964014632122 0.001024959371574326; 0.001023508581774958 0.001023509389824388 … 0.0010257501114307448 0.0010270406312153269; … ; 0.0010235096803544342 0.0010235093454945094 … 0.0010235385598076482 0.00102219776990147; 0.001023509323994688 0.0010235096563831105 … 0.0010259703374137594 0.0010234004945160208]
- [7.265589995127429e-7 7.810075792418593e-7 … 0.0012438603287101377 0.0011208397258045597; 7.824758719321343e-7 8.399800995587391e-7 … 0.0013940036597537271 0.001244593080082291; … ; 7.81409830682552e-7 8.421879211776739e-7 … 0.0013888850623409714 0.0012463866794796912; 7.253777743833804e-7 7.806083069341224e-7 … 0.0012451451363502816 0.0011160084396409798;;; 0.0012526273887852337 0.0012526245778637453 … 0.0012568649579672185 0.0012507314324936086; 0.0012526267538987708 0.0012526269684174486 … 0.0012488773589997189 0.001253433591622979; … ; 0.0012526293016737842 0.001252626826004381 … 0.0012527108968594738 0.001256058172577956; 0.001252627467748648 0.0012526274541759682 … 0.0012560610857106234 0.0012523619895103053;;; 0.001251057456366983 0.0012510584503640809 … 0.0012453058573252513 0.0012530245733645606; 0.0012510598489855165 0.0012510609996790214 … 0.0012519561029831678 0.0012539643367344882; … ; 0.0012510606147593166 0.0012510608997939295 … 0.0012504879239672551 0.0012531001645298102; 0.0012510610970693906 0.0012510594113369132 … 0.0012554253018518655 0.0012526037982904413]
- [1.038133683135691e-6 1.1320434810547245e-6 … 0.0014980807265665068 0.0013202559478856144; 1.1339690106068312e-6 1.2372797275643986e-6 … 0.0017036209432557893 0.0014992342634481683; … ; 1.133112951831089e-6 1.2411995373725183e-6 … 0.0017052424394910634 0.0014950927147683825; 1.0371105079763023e-6 1.1315437405362387e-6 … 0.0014942824191875026 0.0013175273740004345;;; 0.001509203916802127 0.0015092030551353683 … 0.0015133560307347086 0.0015085345765541507; 0.0015092047340310693 0.0015092048362939307 … 0.0015075897133291602 0.0015113490932440019; … ; 0.0015092100148057178 0.0015092048436306108 … 0.0015114837826148923 0.001510081427505487; 0.001509203461117591 0.0015092059378629074 … 0.0015151469989919026 0.0015090871020773898;;; 0.0015069289658465959 0.0015069278578299329 … 0.0015049653793432294 0.0015106472427263353; 0.001506930404042986 0.0015069315700079486 … 0.001508397635416757 0.0015060603622299089; … ; 0.0015069327224251274 0.0015069320086960472 … 0.0015037737775841602 0.0015121675088471665; 0.001506930049883609 0.0015069304528092873 … 0.0015129358589216393 0.0015098583020174813]
+ [4.999999999999999e-9 4.999999999999999e-9 … 9.993482997173668e-5 9.900487042171737e-5; 4.999999999999999e-9 4.999999999999999e-9 … 0.00010094390968857081 0.00010003224313318503; … ; 4.999999999999999e-9 4.999999999999999e-9 … 0.00010106589451762011 9.989686861356209e-5; 4.999999999999999e-9 4.999999999999999e-9 … 9.997727745017184e-5 9.904493238985357e-5;;; 9.999999999999999e-5 9.999999999999999e-5 … 0.00010004850535409554 0.00010003346181605166; 9.999999999999999e-5 9.999999999999999e-5 … 9.998564115509986e-5 9.996230057878485e-5; … ; 9.999999999999999e-5 9.999999999999999e-5 … 0.00010000011855158883 9.9959030892365e-5; 9.999999999999999e-5 9.999999999999999e-5 … 9.997226442086079e-5 9.996585717624541e-5;;; 9.999e-5 9.999e-5 … 9.999917784563441e-5 9.995385048470912e-5; 9.999e-5 9.999e-5 … 9.99382087929476e-5 9.982705981247323e-5; … ; 9.999e-5 9.999e-5 … 0.00010003739112992583 0.00010006224606076174; 9.999e-5 9.999e-5 … 0.00010000560834742116 0.00010003978738700352]
+ [2.2326710785006467e-8 2.2583467484425618e-8 … 0.00021246525729578614 0.00020781958058738493; 2.2574769677254435e-8 2.2822830563181193e-8 … 0.00021687788091669265 0.00021245768743191048; … ; 2.2584292575080323e-8 2.2821502303019185e-8 … 0.00021698243209768495 0.00021225792558059257; 2.23234644773307e-8 2.2566550449860973e-8 … 0.00021244827149276665 0.00020837158133095484;;; 0.00021250001297913303 0.00021249999223830072 … 0.00021250391515114693 0.00021262931484842157; 0.00021249999544934966 0.00021249998978275814 … 0.00021261196024668802 0.00021206947773818634; … ; 0.00021249998326022926 0.00021249999037911278 … 0.00021287276907652804 0.00021285801719704879; 0.00021249999203406847 0.00021250001074085643 … 0.000212243834224247 0.0002121898239202435;;; 0.00021245482935102684 0.00021245482496214303 … 0.00021214222410951994 0.00021258541926784247; 0.00021245487205121273 0.00021245487222680806 … 0.00021254249665122955 0.00021243776099942005; … ; 0.0002124548494343788 0.0002124548405653332 … 0.00021213047168803029 0.0002119922635699346; 0.00021245486435612955 0.00021245483919429898 … 0.00021235197466118905 0.00021251007679329027]
+ [5.6301723785101417e-8 5.743485509457809e-8 … 0.00033913314533426115 0.0003279259761059492; 5.744296515407329e-8 5.861903805786269e-8 … 0.0003495605670921685 0.00033921896646162554; … ; 5.7503367163808916e-8 5.856676289732302e-8 … 0.0003497034356372778 0.00033912047587356857; 5.6361055940515486e-8 5.746500813878776e-8 … 0.0003387661442131136 0.00032838082223454046;;; 0.0003390624994666035 0.000339062489621299 … 0.00033902616114664776 0.00033891938884308693; 0.0003390624820776164 0.0003390624490120134 … 0.0003387220253063564 0.0003387593635065912; … ; 0.00033906242719240114 0.00033906250747146773 … 0.0003389150216823202 0.00033902639752474655; 0.0003390624662348594 0.00033906248020586856 … 0.00033876495828904867 0.0003389633816939708;;; 0.0003389475438127628 0.0003389475506571631 … 0.00033797412288092684 0.0003389792531151472; 0.00033894753276841004 0.00033894766806203807 … 0.00033921995966293964 0.00033889504446218987; … ; 0.00033894759736630766 0.00033894753327850857 … 0.0003386792475869783 0.0003384332143576715; 0.0003389476152066408 0.0003389475016937164 … 0.0003388308996166602 0.0003394260765108697]
+ [1.1249151197364304e-7 1.1570028366319455e-7 … 0.00048149511647024287 0.0004596111176373396; 1.1584899645721509e-7 1.191767177065361e-7 … 0.0005024634498765601 0.0004817853748368437; … ; 1.1579389637461036e-7 1.19292656383289e-7 … 0.0005033517836942873 0.000481561726286618; 1.1239206161302367e-7 1.1592278375808834e-7 … 0.0004807852859302022 0.0004596224349121259;;; 0.0004814454603633468 0.0004814453260154663 … 0.00048153799599544566 0.00048166313855356127; 0.00048144524097612745 0.0004814452383906987 … 0.00048165050911117875 0.000481267672972083; … ; 0.0004814453836545358 0.0004814454244308031 … 0.0004815682923527196 0.0004814489449007494; 0.00048144510275197554 0.00048144519331426867 … 0.00048102242871192805 0.00048101094285828275;;; 0.000481213376260875 0.00048121343125378185 … 0.00048011942348322406 0.0004807139203207704; 0.00048121346870720437 0.00048121363659502314 … 0.00048089049761668715 0.00048087440758828507; … ; 0.0004812135333746655 0.000481213529173877 … 0.0004811108685708453 0.0004810614108869324; 0.00048121367339319437 0.00048121347168236567 … 0.00048213158318584815 0.0004821823219971631]
+ [1.975093428236869e-7 2.0575572832451516e-7 … 0.0006401948735711482 0.0006035282908215258; 2.0581760406879296e-7 2.134805570131856e-7 … 0.0006794038008470538 0.0006422149841866456; … ; 2.0562667186687495e-7 2.1406573492349932e-7 … 0.0006804086767341577 0.000639843614168962; 1.9786897739825396e-7 2.057422353296099e-7 … 0.0006398845454836144 0.000602756078338088;;; 0.0006416260265762668 0.0006416257980834957 … 0.000642931685360552 0.0006421678026101263; 0.00064162596134036 0.000641625964071053 … 0.0006427717134778887 0.0006420095120314318; … ; 0.000641626311843703 0.0006416258277892389 … 0.0006422639281502504 0.0006409175221149363; 0.0006416257042638392 0.0006416254904419881 … 0.0006415697753617628 0.0006413591904908072;;; 0.0006412143841172732 0.0006412141641589775 … 0.0006409226640981083 0.0006405252719584299; 0.0006412144591230012 0.0006412144852937436 … 0.0006406767023756652 0.0006404533008637835; … ; 0.0006412145476487695 0.0006412142691480922 … 0.0006408483308671941 0.0006406275553476786; 0.0006412146645789516 0.000641214494683531 … 0.0006425697522239791 0.0006433030684577026]
+ [3.1999042279840414e-7 3.363460068415554e-7 … 0.0008185387397241 0.0007609348136059539; 3.373270435912628e-7 3.5395294602880945e-7 … 0.000883263629622095 0.0008213089477845422; … ; 3.372601883297447e-7 3.5464338655003345e-7 … 0.000885129297576866 0.0008180452478427565; 3.2090083366609234e-7 3.3728568316516807e-7 … 0.0008193208388201894 0.0007601403972325383;;; 0.0008218288317003707 0.0008218287796554249 … 0.0008219209103772356 0.0008228278432088284; 0.0008218289958428593 0.0008218295227351196 … 0.0008233061848593406 0.0008215364083575217; … ; 0.0008218293030230421 0.0008218288534569612 … 0.0008231239150971814 0.0008209742945548609; 0.000821828640876371 0.0008218286158040532 … 0.0008224108588256692 0.0008212416755986696;;; 0.0008211540549994679 0.0008211537670603966 … 0.000821987781681834 0.0008205846027954223; 0.0008211538349355904 0.0008211539140841028 … 0.0008200798854213432 0.0008207196202312392; … ; 0.0008211534109901224 0.0008211544023561771 … 0.0008218440102089487 0.0008201577761942484; 0.0008211545044600645 0.0008211539890016892 … 0.0008227152471602784 0.0008227819735369449]
+ [4.907713716940884e-7 5.221642128060513e-7 … 0.0010187489676946873 0.0009318011887682378; 5.238094835583502e-7 5.564330267328791e-7 … 0.001118435234499259 0.0010199952279858146; … ; 5.228513102928267e-7 5.568621558771255e-7 … 0.0011212083346585097 0.0010185995546730991; 4.934660801655733e-7 5.24079490106371e-7 … 0.0010197489995969538 0.0009332024708218448;;; 0.0010245575494506162 0.0010245567574541728 … 0.0010254563895509892 0.0010248741623113554; 0.0010245579916634095 0.0010245584982358918 … 0.0010247238482044962 0.0010243911450297043; … ; 0.0010245580631109731 0.0010245578125372596 … 0.0010248793169337193 0.00102352217769876; 0.0010245572031491283 0.0010245574280891494 … 0.0010250867755070116 0.0010248790313948522;;; 0.0010235091616142826 0.0010235076181714104 … 0.0010241586371512509 0.0010225172388249062; 0.0010235085775165986 0.0010235095525331116 … 0.0010194469161365347 0.0010244735576061407; … ; 0.0010235074520831798 0.00102351015852586 … 0.0010244479251585884 0.001025379651203299; 0.0010235088499798953 0.001023509073545887 … 0.0010244963158200925 0.0010262748190976048]
+ [7.253755550602136e-7 7.820917533761418e-7 … 0.0012384085725009209 0.0011191978329374997; 7.817994282734097e-7 8.422867713572952e-7 … 0.0013908555557909461 0.0012459251014497615; … ; 7.819684480028853e-7 8.429706124455838e-7 … 0.0013930468336713618 0.0012459954157369628; 7.268503449440037e-7 7.818147008203122e-7 … 0.001246277447725048 0.0011180995374090476;;; 0.0012526275153284545 0.0012526254222504452 … 0.0012507788327465752 0.001253013414298233; 0.0012526262652129084 0.0012526293781015526 … 0.001251480867999027 0.0012523907798072584; … ; 0.0012526266129306385 0.001252626338011414 … 0.0012549020347529447 0.0012524082713834708; 0.0012526250984725117 0.0012526254425678871 … 0.0012516018917836276 0.001252948738604559;;; 0.0012510596182717343 0.0012510577410964332 … 0.0012512719251434176 0.0012473809329479352; 0.0012510585206301262 0.0012510600388306982 … 0.0012455249594229513 0.0012551356123168295; … ; 0.001251060137762441 0.001251059900695235 … 0.001252547654696482 0.0012549043031263283; 0.0012510609831865196 0.0012510594808059332 … 0.0012494883550250035 0.0012509054038105216]
+ [1.0377708634850847e-6 1.134946945909756e-6 … 0.0014950073825572537 0.00131874100220838; 1.1330220884043552e-6 1.2370030305143592e-6 … 0.0017025758211852192 0.0014940942846527103; … ; 1.1323950783722245e-6 1.2388515822064408e-6 … 0.001704404911353382 0.0014990125358166993; 1.0380324009981977e-6 1.1297317735939426e-6 … 0.0014979444017170541 0.0013172769633982907;;; 0.0015092042328721988 0.0015092039500643353 … 0.00150742008136297 0.0015082614293633562; 0.0015092023106101744 0.0015092034951662006 … 0.0015090249392287114 0.0015062627717848669; … ; 0.0015092070914611364 0.0015092061347130635 … 0.0015116499485715773 0.0015108161928638032; 0.001509202373897689 0.0015092036868968462 … 0.0015108529344829852 0.0015076116348968125;;; 0.0015069302077044117 0.0015069310864765449 … 0.0015078226934020671 0.0015019680625633057; 0.0015069278829037832 0.00150692839000952 … 0.001501253688017662 0.0015130268269100292; … ; 0.0015069297598934424 0.0015069324221253769 … 0.0015061754953388006 0.0015075305821242845; 0.0015069307494357913 0.0015069301341697613 … 0.0015052272098627613 0.0015080226702619752]
  ⋮
- [0.10417490706136438 0.1349842566305138 … 0.44020707305294143 0.35309785267516175; 0.1379885128218307 0.4288659247228196 … 1.2568689129938984 0.40988759176067135; … ; 0.14814277631225573 0.40065155074482656 … 1.572464957089656 0.46054580619735735; 0.10085043034817465 0.13757878193143444 … 0.49996238738291315 0.3169704254124807;;; 1.4348167766103592 1.4562321132985365 … 0.9114278347227486 1.308030582384092; 1.3961032932251447 1.530972685137958 … 0.5115513905339442 1.640576544388415; … ; 1.5242845281942223 1.4836431219211297 … 0.9883829341299495 1.1587644901698084; 1.4655366085174713 1.478426570849894 … 1.1729029717101838 1.3106379817838412;;; 0.5662885260850231 0.6481229504125448 … 0.7099932596876536 0.674923258077451; 0.6641310436256151 0.8968710221520679 … 0.921604041239738 0.9050970242237741; … ; 0.6057402936179989 0.6715923550064439 … 0.6304233957847951 0.8490669221965376; 0.6007610952540832 0.7531399051497127 … 1.0221741194860574 0.8742726683707548]
- [0.100269527895235 0.1456195630558512 … 0.4623115838451201 0.336783554089402; 0.14587709846378277 0.4115234920483781 … 1.212941985914313 0.43766818068673224; … ; 0.15451310839555274 0.385964924131796 … 1.4959283203001834 0.48971687011284776; 0.09753726229929968 0.14466395858104805 … 0.5249868634615135 0.3088300576223496;;; 1.4347227681408965 1.4558437171896115 … 0.9122698453082828 1.3079399015897446; 1.39602674173749 1.529591760286079 … 0.5133952082127327 1.6392579361787043; … ; 1.524129849020581 1.4821855598428326 … 0.9882542291959137 1.1587233230923073; 1.465761226091089 1.4783394379393089 … 1.1738153865123562 1.3100586609885672;;; 0.5666754850106093 0.6479762370817933 … 0.7108388106982212 0.6747281126483098; 0.6641297011245187 0.8963406898677087 … 0.923676171413268 0.9049887589243196; … ; 0.6060786816735872 0.6716391968886907 … 0.6323684934790639 0.8486186447994543; 0.6010276902855237 0.7529138817786496 … 1.0207469254834984 0.8752735851548405]
- [0.09680949013296997 0.15448587586630558 … 0.4806813030183751 0.323435227665222; 0.15305690421149895 0.3959912173016125 … 1.177801789738328 0.46107910855778667; … ; 0.16018449096285817 0.3742924417136572 … 1.432238337615063 0.5126354001923576; 0.09497443207249485 0.15124329395299688 … 0.5466018752934471 0.3022653112585101;;; 1.4346570785435273 1.455775796504047 … 0.9124461854957341 1.307575646210005; 1.396653883632371 1.5288481111942407 … 0.5142948704170911 1.6392143937449624; … ; 1.5243420602004356 1.4812917288586123 … 0.9885644094141988 1.1561734788457523; 1.4655990227057984 1.4783801872920443 … 1.1738149190072797 1.3098160824807223;;; 0.566566392482125 0.6483030240179619 … 0.7088522347893109 0.675473475954846; 0.6637982251220431 0.8961284954454736 … 0.9242324549772488 0.9058814200682056; … ; 0.606458853617659 0.6724258150709688 … 0.6353100350960309 0.8492648628506478; 0.6006411367066427 0.7528614755434605 … 1.0225608352181714 0.8748984592187571]
- [0.09417197872759428 0.1622619940407751 … 0.49810670417017083 0.3115103613006201; 0.15919901617071933 0.3841428250725756 … 1.1445680664919378 0.4808848932033856; … ; 0.1649084092699568 0.36401851825748194 … 1.376993767036888 0.5331738745082044; 0.09296462124716111 0.15594637400057107 … 0.5646474611648571 0.2986367004906084;;; 1.4347352502819954 1.4560292954364062 … 0.9131917791896998 1.3081100130084289; 1.396765721084098 1.5289571102068056 … 0.5159920860538397 1.6389893631634846; … ; 1.5245594751257077 1.4819345179142098 … 0.9928274033572084 1.156959628992747; 1.4656468831338607 1.4785630530354097 … 1.1739718699698052 1.310059525422481;;; 0.5665218676394441 0.6483336727282798 … 0.7084708567152697 0.6759494009763352; 0.6634366615504942 0.8965483848025891 … 0.9227628231962951 0.9051955638397301; … ; 0.6062707656759316 0.6726860878076055 … 0.6371654306264345 0.8496449439627037; 0.6006595917512343 0.7524454032618024 … 1.019975175972632 0.8749310258020815]
- [0.09211655027585279 0.16821610561016773 … 0.5108519750941776 0.3022344779048013; 0.16398053637003132 0.37666712815806913 … 1.1185719620715113 0.49849546058562055; … ; 0.16860120335588658 0.35617807233001814 … 1.3339451142952994 0.5504915970258937; 0.09132034683996818 0.15994272718832886 … 0.5775615222723633 0.29669330665197874;;; 1.4345857989337474 1.4556323791376702 … 0.9142972529809585 1.3089964537182321; 1.3960561917480343 1.529578517046588 … 0.5188308183861108 1.6409183468887845; … ; 1.5247215065886486 1.4812182493400659 … 0.9941137087519409 1.154774033642107; 1.4659394265080061 1.4784211346541505 … 1.1737089734996122 1.3104295043680372;;; 0.5666892279356328 0.648876860686673 … 0.706827409719208 0.6759844545518386; 0.663534756383029 0.8963938585411136 … 0.9191778394175616 0.9059749302421621; … ; 0.6063751626490617 0.6733057813370532 … 0.6355998229165845 0.8497006003932137; 0.6007302343949427 0.7524296207559809 … 1.0187863864412185 0.8748316025655788]
- [0.0907795967335189 0.1725388616150105 … 0.5200062733487043 0.2943852755031473; 0.16740045251902116 0.3705458962229378 … 1.1027648842583233 0.5102688082894624; … ; 0.1713288179749906 0.35012576255249667 … 1.2868136961155248 0.5640747314840944; 0.08999245652788032 0.16310989185698752 … 0.5868678724111249 0.2942971270405798;;; 1.4343846515587657 1.4555091280345154 … 0.9154996432394329 1.3088090422749739; 1.3962821854180294 1.5283224051171809 … 0.5169621833428506 1.6408119425313459; … ; 1.524648522595547 1.4804256863079381 … 0.9931169472500729 1.1571211604968101; 1.4657717171347486 1.4782307546467781 … 1.1741709707160142 1.31019683081311;;; 0.5668774418403256 0.6488135553821011 … 0.709404516196359 0.6765673080493874; 0.6631459594445542 0.8971617927365432 … 0.9172348069350637 0.9076045119870745; … ; 0.6060953543185135 0.6741231392372599 … 0.6359718865113476 0.8487786121564915; 0.6004492083875503 0.7521103313232382 … 1.018668961415488 0.8745475144976684]
- [0.0898960751085624 0.1758678748016408 … 0.525351572332539 0.2878447472086006; 0.17058607274532944 0.365740940157952 … 1.0853470903535585 0.5194298398488096; … ; 0.17248481950708577 0.34600743343323426 … 1.2585635017447445 0.5732943562954262; 0.08918776298879129 0.16537186659684006 … 0.592182564227493 0.29314856753427265;;; 1.4344401058215652 1.4555340225474838 … 0.914420276548537 1.3093266782294117; 1.3968875058405301 1.527695421095644 … 0.5179350010025969 1.6396472076845123; … ; 1.5241291897749933 1.4798443116645208 … 0.9857209232296439 1.1566341630547643; 1.465759996819333 1.4787020371239232 … 1.1764375988207236 1.31029248193463;;; 0.5670387699719232 0.6491370295828893 … 0.7082984599661518 0.6756384960467703; 0.663026840270622 0.8959401117368359 … 0.9164895915616322 0.9084687155106239; … ; 0.6065873306782508 0.6743891403282403 … 0.6381530465830959 0.8501004588367811; 0.6004252538015082 0.7522143987256744 … 1.015153776921568 0.8751732834998701]
- [0.08968060487936201 0.17899460404183026 … 0.5285358361262851 0.28191750401696025; 0.17283748068264673 0.36186589572830286 … 1.074325012636326 0.5252793301221316; … ; 0.17322948271494878 0.34307689813433756 … 1.232210345477391 0.5796720714354121; 0.08831007399346748 0.16722433407392845 … 0.5967809219077058 0.29345627455410966;;; 1.4346956404416473 1.4556122987711895 … 0.9165725447591375 1.3095132796134357; 1.3958434775953852 1.5270361930025094 … 0.5181973711893659 1.6391308122058037; … ; 1.5241306990141303 1.4787049552864338 … 0.9899801492226361 1.1548691652219683; 1.4657222374726742 1.4790427843226206 … 1.1762659104263529 1.3097237198094545;;; 0.5667620537506495 0.6490315870545575 … 0.7081014275457156 0.675891509000831; 0.6626676537730959 0.8972662665518184 … 0.9170241124046852 0.9090392748480454; … ; 0.6075017272031544 0.6734018978500793 … 0.6415884717869162 0.8521423871018239; 0.6006234378962195 0.7521776073335323 … 1.014376257386246 0.8755446573102058]
- [0.08938258874666091 0.1795071771009007 … 0.5329504451035828 0.28033050725735476; 0.17371432996490824 0.36055163688877867 … 1.0735442669386723 0.5265592421680801; … ; 0.17342405076597325 0.3410569173737527 … 1.2197019906080766 0.5817253527384598; 0.08819723911802922 0.16823118010774718 … 0.5967762948223 0.29443812484412124;;; 1.4347264503021038 1.4558837058733527 … 0.9156117004561741 1.3101431073284846; 1.3961375869903705 1.5271712520546104 … 0.5184678781572044 1.6378724457239224; … ; 1.5241829595425174 1.4780305141425434 … 0.9911546016191056 1.154015692283262; 1.4656297080815475 1.4793656973715954 … 1.1762693075438095 1.3094289192903579;;; 0.5666929080542672 0.6496254655512244 … 0.7089141965887338 0.6755899299472694; 0.6624306855775595 0.8971884788727181 … 0.9143215059744637 0.9099470480358658; … ; 0.6078186304781418 0.6735220909345387 … 0.6366636610339461 0.8520978811019274; 0.6006731693103119 0.7518754831630631 … 1.0154915089568923 0.8758256801458707]
using Plots;
+ [0.07911151495021684 0.16058285566078465 … 0.528909565865549 0.2666580644540028; 0.16038378781839388 0.32423475077708247 … 1.0439480330017488 0.5261214849320338; … ; 0.18469723705102736 0.3680251218750628 … 0.9177037792352939 0.47585705739242434; 0.09138268792733859 0.18145110577726337 … 0.45476226074069726 0.23466463604270477;;; 1.4303735918634457 1.5394686644784181 … 0.9330937081780705 1.3632295278174986; 1.3772615590580202 1.488828215991522 … 1.1395747889810797 1.0261301948273087; … ; 1.37313357916199 1.25721943321184 … 1.1290675657351592 1.6965705793035386; 1.3967860568945174 1.495715294371464 … 0.9466162363371355 1.384174446960481;;; 0.5421173837159731 0.47985679712115276 … 1.0717957691263906 0.6257599329888547; 0.7597910180947431 0.8080595486198711 … 1.1274164383181475 0.9809329566309268; … ; 0.706291000104916 0.9492590786784335 … 1.423225624034273 0.7533805224546087; 0.5403488008757062 0.6248985627051644 … 1.050538684631819 0.6328008798036644]
+ [0.0801329756127645 0.16217181048247056 … 0.52903751634206 0.2666953895643063; 0.16240324221665045 0.32666280526198893 … 1.0472411159467945 0.5256702641706062; … ; 0.1858976243534527 0.36978556447651706 … 0.9240643239709442 0.47368258125038487; 0.09201338274704511 0.18238217826543263 … 0.45854830397630736 0.23533584478754202;;; 1.4303513915674857 1.5395738615654786 … 0.9331038118133679 1.3642408455482125; 1.3776041152028382 1.4892431309134198 … 1.138089007343553 1.0283798102994886; … ; 1.373338845709781 1.2594010632686967 … 1.1264550472084396 1.6984560173314986; 1.3968797162679876 1.4968401207708146 … 0.9455110137077853 1.383306421694609;;; 0.5426561045000377 0.47993954333061867 … 1.0724880337172986 0.6268043823733144; 0.7594818730433509 0.8085077847638509 … 1.1226688671824576 0.9789605049033742; … ; 0.7047524295215087 0.9491918925839703 … 1.4195503815534203 0.7516290120894344; 0.5408286177065267 0.6261006307904741 … 1.0502921309153264 0.6336000739621348]
+ [0.08137025511725891 0.16356336966422663 … 0.5296315717705593 0.2670808989091754; 0.16402787588327003 0.32905677054167454 … 1.0494249166322454 0.5274252052998503; … ; 0.18590784233491078 0.36974328842809845 … 0.9264053026815139 0.47605730586637074; 0.09207668718085044 0.18273784700324783 … 0.4605019231221662 0.23549192258471324;;; 1.430434731001963 1.5393497155554996 … 0.933724576450301 1.36404558223163; 1.3768655230292377 1.4894490519872916 … 1.144324475144405 1.0277062073543268; … ; 1.373310155258226 1.2619732529789525 … 1.1305103838719752 1.699716269604133; 1.3972809635675134 1.4961925910352014 … 0.9497065009813135 1.3829009631018834;;; 0.5428839482710149 0.48115283293164784 … 1.0733829099008407 0.6268452943429378; 0.7587487574122176 0.8100525605114225 … 1.1091844062808425 0.9770835437354783; … ; 0.7025126125251854 0.9474078308322865 … 1.4171395634307289 0.7492017101047531; 0.5411904012532396 0.6257295300815592 … 1.0490879839485092 0.6345276263631991]
+ [0.0824317864723768 0.16567453752132813 … 0.5321041950830705 0.267755755441817; 0.16697063574493665 0.33343244121319215 … 1.050226939250429 0.5300119110974147; … ; 0.18658798167187213 0.3696549620286247 … 0.9299720736991425 0.4762431209042206; 0.09244011772182846 0.18376628473085851 … 0.465027108861358 0.2364763851050922;;; 1.4304928925871128 1.5377422080867107 … 0.9369138305550392 1.365734983292227; 1.3774322614559946 1.4891906172978795 … 1.1407944196779853 1.027619710722421; … ; 1.3738185177264446 1.2637568227967075 … 1.1295764966485333 1.6992130414626279; 1.3973477513447692 1.4960540880075424 … 0.9506830850839194 1.3829088557214921;;; 0.5428273084410784 0.4809400431327263 … 1.0754919552030313 0.6276741644359256; 0.7590615920036596 0.8100029214042757 … 1.102609539644006 0.9755312660969936; … ; 0.7025529057400358 0.9478085946774686 … 1.4086644346986792 0.7515899606556948; 0.5414215358517894 0.6257766046829916 … 1.0489253794471984 0.6348445887081252]
+ [0.08333942437147154 0.1671669798536646 … 0.5308601841906808 0.2675890061810634; 0.1685139530515695 0.33560115141709534 … 1.0529142509489384 0.5306221786221311; … ; 0.18708635827862485 0.37057863241501676 … 0.9327459590452994 0.47502929306706493; 0.09242075052513499 0.18528454881035197 … 0.4690375657630225 0.23750812508508073;;; 1.4298159684748322 1.5369758908272735 … 0.9372653026472357 1.366707955828996; 1.3770277113879974 1.4904146432651968 … 1.1406331533129515 1.0252746513000028; … ; 1.3737606436147225 1.2654372372790441 … 1.1242367886818987 1.6961828733365423; 1.3974695871125986 1.4960958188031552 … 0.9533797019561939 1.3819362665812058;;; 0.5433932229461129 0.4819360743280641 … 1.0723045595190597 0.6271434334354308; 0.7569964194146978 0.8092984989103778 … 1.104060853206808 0.9761367203507558; … ; 0.7030033573095137 0.946951868077254 … 1.4009258029748992 0.7482494090274899; 0.5409407933146029 0.624790488114771 … 1.0490310035271642 0.6364185688868038]
+ [0.08419513304613585 0.16836045850639675 … 0.5336312904524814 0.2675610137249839; 0.16941881369544023 0.33887772955809997 … 1.0540084167393167 0.5305243025764708; … ; 0.1870126501492851 0.3694794200573973 … 0.9435525897880787 0.477810432433132; 0.09280455375453006 0.18458363157365523 … 0.47342025635309226 0.23903326241797326;;; 1.429794079572177 1.5381243867929706 … 0.9385270360223866 1.3678488247102158; 1.3767730046385447 1.4918270030212801 … 1.1293716931914886 1.0316424594412918; … ; 1.3752149173950727 1.2655908900735409 … 1.1218775024472578 1.6932337240476372; 1.3967414476107713 1.4967052587461052 … 0.9553473231961513 1.3809679733881925;;; 0.5432890847356654 0.48266090955292545 … 1.0701247715116717 0.6282745723193319; 0.7564188712181 0.8074523330411955 … 1.1060807858057313 0.9720594561769931; … ; 0.7022481959121231 0.9441153159828432 … 1.3975266141681086 0.7461112292492218; 0.5409536718566202 0.6252979554186152 … 1.0471274864766837 0.6361329829545023]
+ [0.08515272342765577 0.16960194065823614 … 0.5341286426293743 0.2672536828017802; 0.16941339525008 0.34013377896135966 … 1.053909376454039 0.5281700351060055; … ; 0.18688599405857384 0.37172911189256186 … 0.9439323298320338 0.4820176044387431; 0.09297319832058838 0.1861163917802027 … 0.4760589873549488 0.2383725259548895;;; 1.429329974615866 1.5371891869516974 … 0.9391889119590827 1.3696407953960816; 1.377446646966161 1.492061897748269 … 1.1345537827791377 1.0321638725656246; … ; 1.3735601590792668 1.2677947970435213 … 1.1199979165650065 1.6918840592571562; 1.3965277948518633 1.4946182824906016 … 0.9560780386953148 1.3833975977431856;;; 0.5427087634522111 0.48473062188758953 … 1.0679982275635929 0.6292334304718562; 0.7561850586243066 0.8064367908066971 … 1.0964804908838335 0.9663472284845032; … ; 0.7018190092634092 0.9446129435690618 … 1.3968010864838574 0.7490637406485682; 0.5416012841256583 0.6253353293246281 … 1.042137339094905 0.6342769196260805]
+ [0.08555517029377173 0.17141010159599884 … 0.5315379964649755 0.2664823692432431; 0.17059563568255834 0.3438426803579506 … 1.0549601891590419 0.5311033841591458; … ; 0.18698846954167836 0.37353332257633587 … 0.9489435210768803 0.48892309630669467; 0.09338353603691339 0.1866126705965896 … 0.48259184508504493 0.23917568510880013;;; 1.4297033949879145 1.5363189118911142 … 0.9406832163651125 1.3698461042164125; 1.3768231580280286 1.489316268383831 … 1.1396094818433187 1.032490714002841; … ; 1.3727175558302378 1.2713114249357527 … 1.113181982253538 1.6916478700192328; 1.3961662110970452 1.4922952232981388 … 0.9576070594588519 1.382777122876297;;; 0.5431999434409267 0.484334872434462 … 1.0677342157950411 0.6301414417023334; 0.755886033708813 0.8070651901301826 … 1.0880900010709853 0.9703391130937432; … ; 0.7007561215265348 0.9455470233669361 … 1.3942910642081876 0.7486088073215688; 0.5420544501474033 0.626624648160425 … 1.0399313263856877 0.6345168174140203]
+ [0.0859187631494718 0.17169101730113812 … 0.532180419166209 0.26585371260106183; 0.17138718331821792 0.34377922180854587 … 1.0571690888979464 0.5302149231610978; … ; 0.1868497734990262 0.3713629245731267 … 0.9577230202046016 0.4864145174728968; 0.09428361743725532 0.18726996936651588 … 0.48099353631166825 0.24087645002925323;;; 1.429696229005601 1.5344909695785534 … 0.9399208990256616 1.3702505211624203; 1.3766730911121694 1.488539380642222 … 1.1394307785336555 1.0321751623248474; … ; 1.3730224095104302 1.2722370774471132 … 1.1091407476217838 1.6868229159039891; 1.3962088952349858 1.4925670842103878 … 0.9587735783965101 1.3816784410281004;;; 0.543781833461471 0.48509532837997316 … 1.0661507695006518 0.6302068250923721; 0.7555274391312143 0.8044039465246351 … 1.0893682979160306 0.9709361071281329; … ; 0.7009167992607154 0.9449993684365715 … 1.394119132030891 0.7501601379740841; 0.5422009662745422 0.6264787474387514 … 1.0390957038641664 0.6343418892467331]
using Plots;
 gr();
 
 # Use `Array` to transform the result back into a CPU-based `Array` for plotting
 p1 = surface(X, Y, Array(sol[end][:, :, 1]), title = "[A]")
 p2 = surface(X, Y, Array(sol[end][:, :, 2]), title = "[B]")
 p3 = surface(X, Y, Array(sol[end][:, :, 3]), title = "[C]")
-plot(p1, p2, p3, layout = grid(3, 1))
Example block output

We can see the cool effect that diffusion dampens the noise in [A] but is unable to dampen the noise in [B] which results in a very noisy [C]. The stiff SPDE takes much longer to solve even using high order plus adaptivity because stochastic problems are just that much more difficult (current research topic is to make new algorithms for this!). It gets GPU'd just by using CuArray like before. But there we go: solving systems of stochastic PDEs using high order adaptive algorithms with within-method GPU parallelism. That's gotta be a first? The cool thing is that nobody ever had to implement the GPU-parallelism either, it just exists by virtue of the Julia type system.

(Note: We can also use one of the SROCK methods for better performance here, but they will require a choice of dt. This is left to the reader to try.)

Note

This can take a while to solve! An explicit Runge-Kutta algorithm isn't necessarily great here, though to use a stiff solver on a problem of this size requires once again smartly choosing sparse linear solvers. The high order adaptive method is pretty much necessary though, since something like Euler-Maruyama is simply not stable enough to solve this at a reasonable dt. Also, the current algorithms are not so great at handling this problem. Good thing there's a publication coming along with some new stuff...

+plot(p1, p2, p3, layout = grid(3, 1))Example block output

We can see the cool effect that diffusion dampens the noise in [A] but is unable to dampen the noise in [B] which results in a very noisy [C]. The stiff SPDE takes much longer to solve even using high order plus adaptivity because stochastic problems are just that much more difficult (current research topic is to make new algorithms for this!). It gets GPU'd just by using CuArray like before. But there we go: solving systems of stochastic PDEs using high order adaptive algorithms with within-method GPU parallelism. That's gotta be a first? The cool thing is that nobody ever had to implement the GPU-parallelism either, it just exists by virtue of the Julia type system.

(Note: We can also use one of the SROCK methods for better performance here, but they will require a choice of dt. This is left to the reader to try.)

Note

This can take a while to solve! An explicit Runge-Kutta algorithm isn't necessarily great here, though to use a stiff solver on a problem of this size requires once again smartly choosing sparse linear solvers. The high order adaptive method is pretty much necessary though, since something like Euler-Maruyama is simply not stable enough to solve this at a reasonable dt. Also, the current algorithms are not so great at handling this problem. Good thing there's a publication coming along with some new stuff...

diff --git a/dev/showcase/massively_parallel_gpu/index.html b/dev/showcase/massively_parallel_gpu/index.html index 2daf868b291..93064f0e7e7 100644 --- a/dev/showcase/massively_parallel_gpu/index.html +++ b/dev/showcase/massively_parallel_gpu/index.html @@ -23,4 +23,4 @@ sol = solve(monteprob, Tsit5(), EnsembleThreads(), trajectories = 10_000, saveat = 1.0f0)
EnsembleSolution Solution of length 10000 with uType:
 SciMLBase.ODESolution{Float32, 2, Vector{StaticArraysCore.SVector{3, Float32}}, Nothing, Nothing, Vector{Float32}, Vector{Vector{StaticArraysCore.SVector{3, Float32}}}, SciMLBase.ODEProblem{StaticArraysCore.SVector{3, Float32}, Tuple{Float32, Float32}, false, StaticArraysCore.SVector{3, Float32}, SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, typeof(Main.lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, typeof(Main.lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{StaticArraysCore.SVector{3, Float32}}, Vector{Float32}, Vector{Vector{StaticArraysCore.SVector{3, Float32}}}, OrdinaryDiffEq.Tsit5ConstantCache}, DiffEqBase.Stats, Nothing}

Taking the Ensemble to the GPU

Now uhh, we just change EnsembleThreads() to EnsembleGPUArray()

sol = solve(monteprob, Tsit5(), EnsembleGPUArray(CUDA.CUDABackend()), trajectories = 10_000, saveat = 1.0f0)
EnsembleSolution Solution of length 10000 with uType:
 SciMLBase.ODESolution{Float32, 2, uType, Nothing, Nothing, Vector{Float32}, rateType, SciMLBase.ODEProblem{StaticArraysCore.SVector{3, Float32}, Tuple{Float32, Float32}, false, StaticArraysCore.SVector{3, Float32}, SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, typeof(Main.lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, IType, DiffEqBase.Stats, Nothing} where {uType, rateType, IType}

Or for a more efficient version, EnsembleGPUKernel(). But that requires special solvers, so we also change to GPUTsit5().

sol = solve(monteprob, GPUTsit5(), EnsembleGPUKernel(CUDA.CUDABackend()), trajectories = 10_000)
EnsembleSolution Solution of length 10000 with uType:
-SciMLBase.ODESolution{Float32, 2, uType, Nothing, Nothing, tType, Nothing, P, A, IType, Nothing, Nothing} where {uType, tType, P, A, IType}

Okay, so that was anticlimactic, but that's the point: if it were harder than that, it wouldn't be automatic! Now go check out DiffEqGPU.jl's documentation for more details, that's the end of our show.

+SciMLBase.ODESolution{Float32, 2, uType, Nothing, Nothing, tType, Nothing, P, A, IType, Nothing, Nothing} where {uType, tType, P, A, IType}

Okay, so that was anticlimactic, but that's the point: if it were harder than that, it wouldn't be automatic! Now go check out DiffEqGPU.jl's documentation for more details, that's the end of our show.

diff --git a/dev/showcase/missing_physics/a9c7a08d.svg b/dev/showcase/missing_physics/0b8367f0.svg similarity index 80% rename from dev/showcase/missing_physics/a9c7a08d.svg rename to dev/showcase/missing_physics/0b8367f0.svg index e96161d9376..52777c06a05 100644 --- a/dev/showcase/missing_physics/a9c7a08d.svg +++ b/dev/showcase/missing_physics/0b8367f0.svg @@ -1,92 +1,92 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/aa482ffd.svg b/dev/showcase/missing_physics/1743b6a1.svg similarity index 88% rename from dev/showcase/missing_physics/aa482ffd.svg rename to dev/showcase/missing_physics/1743b6a1.svg index 3f223c5f844..289b7c9cf80 100644 --- a/dev/showcase/missing_physics/aa482ffd.svg +++ b/dev/showcase/missing_physics/1743b6a1.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/3a1d082d.svg b/dev/showcase/missing_physics/231eb313.svg similarity index 83% rename from dev/showcase/missing_physics/3a1d082d.svg rename to dev/showcase/missing_physics/231eb313.svg index 2f17ebbfd97..ae9605f6f41 100644 --- a/dev/showcase/missing_physics/3a1d082d.svg +++ b/dev/showcase/missing_physics/231eb313.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/62958a41.svg b/dev/showcase/missing_physics/4572963c.svg similarity index 90% rename from dev/showcase/missing_physics/62958a41.svg rename to dev/showcase/missing_physics/4572963c.svg index eb96a8acfa3..fe508ffc1d2 100644 --- a/dev/showcase/missing_physics/62958a41.svg +++ b/dev/showcase/missing_physics/4572963c.svg @@ -1,52 +1,52 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/2ac59fbf.svg b/dev/showcase/missing_physics/536a838b.svg similarity index 85% rename from dev/showcase/missing_physics/2ac59fbf.svg rename to dev/showcase/missing_physics/536a838b.svg index 041692ffcb6..eb30ca0648e 100644 --- a/dev/showcase/missing_physics/2ac59fbf.svg +++ b/dev/showcase/missing_physics/536a838b.svg @@ -1,213 +1,213 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + Timeseries of UODE Error - - - - - - + + + + + + x(t) - - + + y(t) - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Neural Network Fit of U2(t) - - - - - - + + + + + + Neural Network - - + + True Missing Term - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Extrapolated Fit From Short Training Data - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + x data - - + + y data - - + + True x(t) - - + + True y(t) - - + + Estimated x(t) - - + + Estimated y(t) - + Training - + Data diff --git a/dev/showcase/missing_physics/31abc02c.svg b/dev/showcase/missing_physics/722e97dd.svg similarity index 79% rename from dev/showcase/missing_physics/31abc02c.svg rename to dev/showcase/missing_physics/722e97dd.svg index 750b618ee1a..b2629312a85 100644 --- a/dev/showcase/missing_physics/31abc02c.svg +++ b/dev/showcase/missing_physics/722e97dd.svg @@ -1,92 +1,92 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/6f8a9429.svg b/dev/showcase/missing_physics/7ee58e75.svg similarity index 97% rename from dev/showcase/missing_physics/6f8a9429.svg rename to dev/showcase/missing_physics/7ee58e75.svg index 4b815b8301a..ee47b62321f 100644 --- a/dev/showcase/missing_physics/6f8a9429.svg +++ b/dev/showcase/missing_physics/7ee58e75.svg @@ -1,36 +1,36 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/e6f05dae.svg b/dev/showcase/missing_physics/b40e3884.svg similarity index 82% rename from dev/showcase/missing_physics/e6f05dae.svg rename to dev/showcase/missing_physics/b40e3884.svg index dbe5c820af9..2cca52d9c28 100644 --- a/dev/showcase/missing_physics/e6f05dae.svg +++ b/dev/showcase/missing_physics/b40e3884.svg @@ -1,155 +1,155 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/d09fe212.svg b/dev/showcase/missing_physics/b4a0d097.svg similarity index 84% rename from dev/showcase/missing_physics/d09fe212.svg rename to dev/showcase/missing_physics/b4a0d097.svg index 385a872d060..9e1ac140829 100644 --- a/dev/showcase/missing_physics/d09fe212.svg +++ b/dev/showcase/missing_physics/b4a0d097.svg @@ -1,52 +1,52 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/missing_physics/index.html b/dev/showcase/missing_physics/index.html index b3ce38301cb..3814a181b8e 100644 --- a/dev/showcase/missing_physics/index.html +++ b/dev/showcase/missing_physics/index.html @@ -36,7 +36,7 @@ Xₙ = X .+ (noise_magnitude * x̄) .* randn(rng, eltype(X), size(X)) plot(solution, alpha = 0.75, color = :black, label = ["True Data" nothing]) -scatter!(t, transpose(Xₙ), color = :red, label = ["Noisy Data" nothing])Example block output

Definition of the Universal Differential Equation

Now let's define our UDE. We will use Lux.jl to define the neural network as follows:

rbf(x) = exp.(-(x .^ 2))
+scatter!(t, transpose(Xₙ), color = :red, label = ["Noisy Data" nothing])
Example block output

Definition of the Universal Differential Equation

Now let's define our UDE. We will use Lux.jl to define the neural network as follows:

rbf(x) = exp.(-(x .^ 2))
 
 # Multilayer FeedForward
 const U = Lux.Chain(Lux.Dense(2, 5, rbf), Lux.Dense(5, 5, rbf), Lux.Dense(5, 5, rbf),
@@ -186,26 +186,26 @@
 pl_losses = plot(1:5000, losses[1:5000], yaxis = :log10, xaxis = :log10,
                  xlabel = "Iterations", ylabel = "Loss", label = "ADAM", color = :blue)
 plot!(5001:length(losses), losses[5001:end], yaxis = :log10, xaxis = :log10,
-      xlabel = "Iterations", ylabel = "Loss", label = "BFGS", color = :red)
Example block output

Next, we compare the original data to the output of the UDE predictor. Note that we can even create more samples from the underlying model by simply adjusting the time steps!

## Analysis of the trained network
+      xlabel = "Iterations", ylabel = "Loss", label = "BFGS", color = :red)
Example block output

Next, we compare the original data to the output of the UDE predictor. Note that we can even create more samples from the underlying model by simply adjusting the time steps!

## Analysis of the trained network
 # Plot the data and the approximation
 ts = first(solution.t):(mean(diff(solution.t)) / 2):last(solution.t)
 X̂ = predict(p_trained, Xₙ[:, 1], ts)
 # Trained on noisy data vs real solution
 pl_trajectory = plot(ts, transpose(X̂), xlabel = "t", ylabel = "x(t), y(t)", color = :red,
                      label = ["UDE Approximation" nothing])
-scatter!(solution.t, transpose(Xₙ), color = :black, label = ["Measurements" nothing])
Example block output

Let's see how well the unknown term has been approximated:

# Ideal unknown interactions of the predictor
+scatter!(solution.t, transpose(Xₙ), color = :black, label = ["Measurements" nothing])
Example block output

Let's see how well the unknown term has been approximated:

# Ideal unknown interactions of the predictor
 Ȳ = [-p_[2] * (X̂[1, :] .* X̂[2, :])'; p_[3] * (X̂[1, :] .* X̂[2, :])']
 # Neural network guess
 Ŷ = U(X̂, p_trained, st)[1]
 
 pl_reconstruction = plot(ts, transpose(Ŷ), xlabel = "t", ylabel = "U(x,y)", color = :red,
                          label = ["UDE Approximation" nothing])
-plot!(ts, transpose(Ȳ), color = :black, label = ["True Interaction" nothing])
Example block output

And have a nice look at all the information:

# Plot the error
+plot!(ts, transpose(Ȳ), color = :black, label = ["True Interaction" nothing])
Example block output

And have a nice look at all the information:

# Plot the error
 pl_reconstruction_error = plot(ts, norm.(eachcol(Ȳ - Ŷ)), yaxis = :log, xlabel = "t",
                                ylabel = "L2-Error", label = nothing, color = :red)
 pl_missing = plot(pl_reconstruction, pl_reconstruction_error, layout = (2, 1))
 
-pl_overall = plot(pl_trajectory, pl_missing)
Example block output

That looks pretty good. And if we are happy with deep learning, we can leave it at that: we have trained a neural network to capture our missing dynamics.

But...

Can we also make it print out the LaTeX for what the missing equations were? Find out more after the break!

Symbolic regression via sparse regression (SINDy based)

This part of the showcase is still a work in progress... shame on us. But be back in a jiffy and we'll have it done.

Okay, that was a quick break, and that's good because this next part is pretty cool. Let's use DataDrivenDiffEq.jl to transform our trained neural network from machine learning mumbo jumbo into predictions of missing mechanistic equations. To do this, we first generate a symbolic basis that represents the space of mechanistic functions we believe this neural network should map to. Let's choose a bunch of polynomial functions:

@variables u[1:2]
+pl_overall = plot(pl_trajectory, pl_missing)
Example block output

That looks pretty good. And if we are happy with deep learning, we can leave it at that: we have trained a neural network to capture our missing dynamics.

But...

Can we also make it print out the LaTeX for what the missing equations were? Find out more after the break!

Symbolic regression via sparse regression (SINDy based)

This part of the showcase is still a work in progress... shame on us. But be back in a jiffy and we'll have it done.

Okay, that was a quick break, and that's good because this next part is pretty cool. Let's use DataDrivenDiffEq.jl to transform our trained neural network from machine learning mumbo jumbo into predictions of missing mechanistic equations. To do this, we first generate a symbolic basis that represents the space of mechanistic functions we believe this neural network should map to. Let's choose a bunch of polynomial functions:

@variables u[1:2]
 b = polynomial_basis(u, 4)
 basis = Basis(b, u);

\[ \begin{align} \varphi_1 =& 1 \\ @@ -224,8 +224,8 @@ \varphi_{1 4} =& u_2^{3} u_1 \\ \varphi_{1 5} =& u_2^{4} \end{align} - \]

Now let's define our DataDrivenProblems for the sparse regressions. To assess the capability of the sparse regression, we will look at 3 cases:

  • What if we trained no neural network and tried to automatically uncover the equations from the original noisy data? This is the approach in the literature known as structural identification of dynamical systems (SINDy). We will call this the full problem. This will assess whether this incorporation of prior information was helpful.
  • What if we trained the neural network using the ideal right-hand side missing derivative functions? This is the value computed in the plots above as . This will tell us whether the symbolic discovery could work in ideal situations.
  • Do the symbolic regression directly on the function y = NN(x), i.e. the trained learned neural network. This is what we really want, and will tell us how to extend our known equations.

To define the full problem, we need to define a DataDrivenProblem that has the time series of the solution X, the time points of the solution t, and the derivative at each time point of the solution, obtained by the ODE solution's interpolation. We can just use an interpolation to get the derivative:

full_problem = ContinuousDataDrivenProblem(Xₙ, t)
Continuous DataDrivenProblem{Float64} ##DDProblem#188370 in 2 dimensions and 21 samples

Now for the other two symbolic regressions, we are regressing input/outputs of the missing terms, and thus we directly define the datasets as the input/output mappings like:

ideal_problem = DirectDataDrivenProblem(X̂, Ȳ)
-nn_problem = DirectDataDrivenProblem(X̂, Ŷ)
Direct DataDrivenProblem{Float64} ##DDProblem#188372 in 2 dimensions and 41 samples

Let's solve the data-driven problems using sparse regression. We will use the ADMM method, which requires we define a set of shrinking cutoff values λ, and we do this like:

λ = exp10.(-3:0.01:3)
+ \]

Now let's define our DataDrivenProblems for the sparse regressions. To assess the capability of the sparse regression, we will look at 3 cases:

  • What if we trained no neural network and tried to automatically uncover the equations from the original noisy data? This is the approach in the literature known as structural identification of dynamical systems (SINDy). We will call this the full problem. This will assess whether this incorporation of prior information was helpful.
  • What if we trained the neural network using the ideal right-hand side missing derivative functions? This is the value computed in the plots above as . This will tell us whether the symbolic discovery could work in ideal situations.
  • Do the symbolic regression directly on the function y = NN(x), i.e. the trained learned neural network. This is what we really want, and will tell us how to extend our known equations.

To define the full problem, we need to define a DataDrivenProblem that has the time series of the solution X, the time points of the solution t, and the derivative at each time point of the solution, obtained by the ODE solution's interpolation. We can just use an interpolation to get the derivative:

full_problem = ContinuousDataDrivenProblem(Xₙ, t)
Continuous DataDrivenProblem{Float64} ##DDProblem#187706 in 2 dimensions and 21 samples

Now for the other two symbolic regressions, we are regressing input/outputs of the missing terms, and thus we directly define the datasets as the input/output mappings like:

ideal_problem = DirectDataDrivenProblem(X̂, Ȳ)
+nn_problem = DirectDataDrivenProblem(X̂, Ŷ)
Direct DataDrivenProblem{Float64} ##DDProblem#187708 in 2 dimensions and 41 samples

Let's solve the data-driven problems using sparse regression. We will use the ADMM method, which requires we define a set of shrinking cutoff values λ, and we do this like:

λ = exp10.(-3:0.01:3)
 opt = ADMM(λ)
DataDrivenSparse.ADMM{Vector{Float64}, Float64}([0.001, 0.0010232929922807535, 0.0010471285480508996, 0.001071519305237606, 0.0010964781961431851, 0.001122018454301963, 0.0011481536214968829, 0.001174897554939529, 0.001202264434617413, 0.0012302687708123812  …  812.8305161640995, 831.7637711026708, 851.1380382023768, 870.9635899560806, 891.2509381337459, 912.0108393559096, 933.2543007969915, 954.992586021436, 977.2372209558112, 1000.0], 1.0)

This is one of many methods for sparse regression, consult the DataDrivenDiffEq.jl documentation for more information on the algorithm choices. Taking this, let's solve each of the sparse regressions:

options = DataDrivenCommonOptions(maxiters = 10_000,
                                   normalize = DataNormalization(ZScoreTransform),
                                   selector = bic, digits = 1,
@@ -270,7 +270,7 @@
     println(eqs)
     println(get_parameter_map(eqs))
     println()
-end
Model ##Basis#188373 with 2 equations
+end
Model ##Basis#187709 with 2 equations
 States : u[1] u[2]
 Parameters : 6
 Independent variable: t
@@ -280,7 +280,7 @@
 
 Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}[p₁ => 0.4, p₂ => -0.3, p₃ => 0.1, p₄ => -0.1, p₅ => 0.1, p₆ => -1.0]
 
-Model ##Basis#188377 with 2 equations
+Model ##Basis#187713 with 2 equations
 States : u[1] u[2]
 Parameters : p₁ p₂
 Independent variable: t
@@ -290,7 +290,7 @@
 
 Pair{SymbolicUtils.BasicSymbolic{Real}, Float64}[p₁ => -0.8, p₂ => 0.7]
 
-Model ##Basis#188381 with 2 equations
+Model ##Basis#187717 with 2 equations
 States : u[1] u[2]
 Parameters : p₁ p₂ p₃ p₄
 Independent variable: t
@@ -310,7 +310,7 @@
 
 # Plot
 plot(solution)
-plot!(estimate)
Example block output

We are still a bit off, so we fine tune the parameters by simply minimizing the residuals between the UDE predictor and our recovered parametrized equations:

function parameter_loss(p)
+plot!(estimate)
Example block output

We are still a bit off, so we fine tune the parameters by simply minimizing the residuals between the UDE predictor and our recovered parametrized equations:

function parameter_loss(p)
     Y = reduce(hcat, map(Base.Fix2(nn_eqs, p), eachcol(X̂)))
     sum(abs2, Ŷ .- Y)
 end
@@ -325,9 +325,9 @@
 t_long = (0.0, 50.0)
 estimation_prob = ODEProblem(recovered_dynamics!, u0, t_long, parameter_res)
 estimate_long = solve(estimation_prob, Tsit5(), saveat = 0.1) # Using higher tolerances here results in exit of julia
-plot(estimate_long)
Example block output
true_prob = ODEProblem(lotka!, u0, t_long, p_)
+plot(estimate_long)
Example block output
true_prob = ODEProblem(lotka!, u0, t_long, p_)
 true_solution_long = solve(true_prob, Tsit5(), saveat = estimate_long.t)
-plot!(true_solution_long)
Example block output

Post Processing and Plots

c1 = 3 # RGBA(174/255,192/255,201/255,1) # Maroon
+plot!(true_solution_long)
Example block output

Post Processing and Plots

c1 = 3 # RGBA(174/255,192/255,201/255,1) # Maroon
 c2 = :orange # RGBA(132/255,159/255,173/255,1) # Red
 c3 = :blue # RGBA(255/255,90/255,0,1) # Orange
 c4 = :purple # RGBA(153/255,50/255,204/255,1) # Purple
@@ -360,4 +360,4 @@
 annotate!([(1.5, 13, text("Training \nData", 10, :center, :top, :black, "Helvetica"))])
 l = @layout [grid(1, 2)
              grid(1, 1)]
-plot(p1, p2, p3, layout = l)
Example block output +plot(p1, p2, p3, layout = l)
Example block output diff --git a/dev/showcase/ode_types/ad46406c.svg b/dev/showcase/ode_types/0df0023e.svg similarity index 67% rename from dev/showcase/ode_types/ad46406c.svg rename to dev/showcase/ode_types/0df0023e.svg index 08256e9d85a..7757efe805e 100644 --- a/dev/showcase/ode_types/ad46406c.svg +++ b/dev/showcase/ode_types/0df0023e.svg @@ -1,374 +1,374 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/ode_types/731b555e.svg b/dev/showcase/ode_types/1e68e9a2.svg similarity index 88% rename from dev/showcase/ode_types/731b555e.svg rename to dev/showcase/ode_types/1e68e9a2.svg index 90ece14cfcd..d08c559a1af 100644 --- a/dev/showcase/ode_types/731b555e.svg +++ b/dev/showcase/ode_types/1e68e9a2.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/ode_types/58302a4e.svg b/dev/showcase/ode_types/25c0334d.svg similarity index 68% rename from dev/showcase/ode_types/58302a4e.svg rename to dev/showcase/ode_types/25c0334d.svg index c37a019a300..4a7368f5e8f 100644 --- a/dev/showcase/ode_types/58302a4e.svg +++ b/dev/showcase/ode_types/25c0334d.svg @@ -1,460 +1,460 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/ode_types/40dab875.svg b/dev/showcase/ode_types/756657ee.svg similarity index 79% rename from dev/showcase/ode_types/40dab875.svg rename to dev/showcase/ode_types/756657ee.svg index 194d49a31ce..7cdbbfb90fb 100644 --- a/dev/showcase/ode_types/40dab875.svg +++ b/dev/showcase/ode_types/756657ee.svg @@ -1,136 +1,136 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/ode_types/9b60f1eb.svg b/dev/showcase/ode_types/8f6491b7.svg similarity index 69% rename from dev/showcase/ode_types/9b60f1eb.svg rename to dev/showcase/ode_types/8f6491b7.svg index 94d8cc90aec..ebfc84ccb46 100644 --- a/dev/showcase/ode_types/9b60f1eb.svg +++ b/dev/showcase/ode_types/8f6491b7.svg @@ -1,251 +1,251 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/ode_types/index.html b/dev/showcase/ode_types/index.html index 2d6d3f3f8c3..edaca3dcc36 100644 --- a/dev/showcase/ode_types/index.html +++ b/dev/showcase/ode_types/index.html @@ -153,7 +153,7 @@ 1.5362091208988309 N 1.7720406194871123 N

This gives a normal solution object. Notice that the values are all with the correct units:

print(sol[:])
Unitful.Quantity{Float64, 𝐋 𝐌 𝐓^-2, Unitful.FreeUnits{(N,), 𝐋 𝐌 𝐓^-2, nothing}}[1.5 N, 1.5362091208988309 N, 1.7720406194871123 N]

And when we plot the solution, it automatically adds the units:

using Plots
 gr()
-plot(sol, lw = 3)
Example block output

Measurements.jl: Numbers with Linear Uncertainty Propagation

The result of a measurement should be given as a number with an attached uncertainty, besides the physical unit, and all operations performed involving the result of the measurement should propagate the uncertainty, taking care of correlation between quantities.

There is a Julia package for dealing with numbers with uncertainties: Measurements.jl. Thanks to Julia's features, DifferentialEquations.jl easily works together with Measurements.jl out-of-the-box.

Let's try to automate uncertainty propagation through number types on some classical physics examples!

Warning about Measurement type

Before going on with the tutorial, we must point up a subtlety of Measurements.jl that you should be aware of:

using Measurements
+plot(sol, lw = 3)
Example block output

Measurements.jl: Numbers with Linear Uncertainty Propagation

The result of a measurement should be given as a number with an attached uncertainty, besides the physical unit, and all operations performed involving the result of the measurement should propagate the uncertainty, taking care of correlation between quantities.

There is a Julia package for dealing with numbers with uncertainties: Measurements.jl. Thanks to Julia's features, DifferentialEquations.jl easily works together with Measurements.jl out-of-the-box.

Let's try to automate uncertainty propagation through number types on some classical physics examples!

Warning about Measurement type

Before going on with the tutorial, we must point up a subtlety of Measurements.jl that you should be aware of:

using Measurements
 5.23 ± 0.14 === 5.23 ± 0.14
false
(5.23 ± 0.14) - (5.23 ± 0.14)

\[0.0 \pm 0.2\]

(5.23 ± 0.14) / (5.23 ± 0.14)

\[1.0 \pm 0.038\]

The two numbers above, even though have the same nominal value and the same uncertainties, are actually two different measurements that only by chance share the same figures and their difference and their ratio have a non-zero uncertainty. It is common in physics to get very similar, or even equal, results for a repeated measurement, but the two measurements are not the same thing.

Instead, if you have one measurement and want to perform some operations involving it, you have to assign it to a variable:

x = 5.23 ± 0.14
 x === x
true
x - x

\[0.0 \pm 0.0\]

x / x

\[1.0 \pm 0.0\]

With that in mind, let's start using Measurements.jl for realsies.

Automated UQ on an ODE: Radioactive Decay of Carbon-14

The rate of decay of carbon-14 is governed by a first order linear ordinary differential equation:

\[\frac{\mathrm{d}u(t)}{\mathrm{d}t} = -\frac{u(t)}{\tau}\]

where $\tau$ is the mean lifetime of carbon-14, which is related to the half-life $t_{1/2} = (5730 \pm 40)$ years by the relation $\tau = t_{1/2}/\ln(2)$. Writing this in DifferentialEquations.jl syntax, this looks like:

# Half-life and mean lifetime of radiocarbon, in years
 t_12 = 5730 ± 40
@@ -217,7 +217,7 @@
      0.3817 ± 0.0026
      0.3163 ± 0.0025
      0.2983 ± 0.0025

How do the two solutions compare?

plot(sol.t, sol.u, label = "Numerical", xlabel = "Years", ylabel = "Fraction of Carbon-14")
-plot!(sol.t, u, label = "Analytic")
Example block output

The two curves are perfectly superimposed, indicating that the numerical solution matches the analytic one. We can check that also the uncertainties are correctly propagated in the numerical solution:

println("Quantity of carbon-14 after ", sol.t[11], " years:")
+plot!(sol.t, u, label = "Analytic")
Example block output

The two curves are perfectly superimposed, indicating that the numerical solution matches the analytic one. We can check that also the uncertainties are correctly propagated in the numerical solution:

println("Quantity of carbon-14 after ", sol.t[11], " years:")
 println("Numerical: ", sol[11])
 println("Analytic:  ", u[11])
Quantity of carbon-14 after 5207.541628507064 years:
 Numerical: 0.5326 ± 0.0023
@@ -286,7 +286,7 @@
  [0.0127 ± 0.0026, 0.0341 ± 0.0076]

And that's it! What about comparing it this time to the analytical solution?

u = u₀[2] .* cos.(sqrt(g / L) .* sol.t)
 
 plot(sol.t, getindex.(sol.u, 2), label = "Numerical")
-plot!(sol.t, u, label = "Analytic")
Example block output

Bingo. Also in this case there is a perfect superimposition between the two curves, including their uncertainties.

We can also have a look at the difference between the two solutions:

plot(sol.t, getindex.(sol.u, 2) .- u, label = "")
Example block output

Tiny difference on the order of the chosen 1e-6 tolerance.

Simple pendulum: Arbitrary amplitude

Now that we know how to solve differential equations involving numbers with uncertainties, we can solve the simple pendulum problem without any approximation. This time, the differential equation to solve is the following:

\[\ddot{\theta} + \frac{g}{L} \sin(\theta) = 0\]

That would be done via:

g = 9.79 ± 0.02; # Gravitational constants
+plot!(sol.t, u, label = "Analytic")
Example block output

Bingo. Also in this case there is a perfect superimposition between the two curves, including their uncertainties.

We can also have a look at the difference between the two solutions:

plot(sol.t, getindex.(sol.u, 2) .- u, label = "")
Example block output

Tiny difference on the order of the chosen 1e-6 tolerance.

Simple pendulum: Arbitrary amplitude

Now that we know how to solve differential equations involving numbers with uncertainties, we can solve the simple pendulum problem without any approximation. This time, the differential equation to solve is the following:

\[\ddot{\theta} + \frac{g}{L} \sin(\theta) = 0\]

That would be done via:

g = 9.79 ± 0.02; # Gravitational constants
 L = 1.00 ± 0.01; # Length of the pendulum
 
 #Initial Conditions
@@ -305,4 +305,4 @@
 prob = ODEProblem(simplependulum, u₀, tspan)
 sol = solve(prob, Tsit5(), reltol = 1e-6)
 
-plot(sol.t, getindex.(sol.u, 2), label = "Numerical")
Example block output

Warning about Linear Uncertainty Propagation

Measurements.jl uses linear uncertainty propagation, which has an error associated with it. MonteCarloMeasurements.jl has a page which showcases where this method can lead to incorrect uncertainty measurements. Thus for more nonlinear use cases, it's suggested that one uses one of the more powerful UQ methods, such as:

Basically, types can make the algorithm you want to run exceedingly simple to do, but make sure it's the correct algorithm!

+plot(sol.t, getindex.(sol.u, 2), label = "Numerical")Example block output

Warning about Linear Uncertainty Propagation

Measurements.jl uses linear uncertainty propagation, which has an error associated with it. MonteCarloMeasurements.jl has a page which showcases where this method can lead to incorrect uncertainty measurements. Thus for more nonlinear use cases, it's suggested that one uses one of the more powerful UQ methods, such as:

Basically, types can make the algorithm you want to run exceedingly simple to do, but make sure it's the correct algorithm!

diff --git a/dev/showcase/optimization_under_uncertainty/67d2dd6c.svg b/dev/showcase/optimization_under_uncertainty/02ba5ce1.svg similarity index 82% rename from dev/showcase/optimization_under_uncertainty/67d2dd6c.svg rename to dev/showcase/optimization_under_uncertainty/02ba5ce1.svg index 263716bb531..818fe9f5bc5 100644 --- a/dev/showcase/optimization_under_uncertainty/67d2dd6c.svg +++ b/dev/showcase/optimization_under_uncertainty/02ba5ce1.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/3f2a8fb5.svg b/dev/showcase/optimization_under_uncertainty/3f2a8fb5.svg deleted file mode 100644 index 3223c77a736..00000000000 --- a/dev/showcase/optimization_under_uncertainty/3f2a8fb5.svg +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/optimization_under_uncertainty/dbbc1fb3.svg b/dev/showcase/optimization_under_uncertainty/43d0e2c6.svg similarity index 90% rename from dev/showcase/optimization_under_uncertainty/dbbc1fb3.svg rename to dev/showcase/optimization_under_uncertainty/43d0e2c6.svg index 28a9b34f5f4..15f43c7a4fd 100644 --- a/dev/showcase/optimization_under_uncertainty/dbbc1fb3.svg +++ b/dev/showcase/optimization_under_uncertainty/43d0e2c6.svg @@ -1,45 +1,45 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/612cca3a.svg b/dev/showcase/optimization_under_uncertainty/612cca3a.svg new file mode 100644 index 00000000000..e97a4a29a64 --- /dev/null +++ b/dev/showcase/optimization_under_uncertainty/612cca3a.svg @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/60770b18.svg b/dev/showcase/optimization_under_uncertainty/7028f57e.svg similarity index 89% rename from dev/showcase/optimization_under_uncertainty/60770b18.svg rename to dev/showcase/optimization_under_uncertainty/7028f57e.svg index 48f534a3b68..71fdd6b673e 100644 --- a/dev/showcase/optimization_under_uncertainty/60770b18.svg +++ b/dev/showcase/optimization_under_uncertainty/7028f57e.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/3cb11064.svg b/dev/showcase/optimization_under_uncertainty/a808ae67.svg similarity index 63% rename from dev/showcase/optimization_under_uncertainty/3cb11064.svg rename to dev/showcase/optimization_under_uncertainty/a808ae67.svg index 13dbad0ac44..301ed93e9da 100644 --- a/dev/showcase/optimization_under_uncertainty/3cb11064.svg +++ b/dev/showcase/optimization_under_uncertainty/a808ae67.svg @@ -1,551 +1,551 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/cdc698af.svg b/dev/showcase/optimization_under_uncertainty/cdc698af.svg new file mode 100644 index 00000000000..1c952ec7fa5 --- /dev/null +++ b/dev/showcase/optimization_under_uncertainty/cdc698af.svg @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/dfe0e598.svg b/dev/showcase/optimization_under_uncertainty/e8ad09fb.svg similarity index 58% rename from dev/showcase/optimization_under_uncertainty/dfe0e598.svg rename to dev/showcase/optimization_under_uncertainty/e8ad09fb.svg index 9778a54ecda..3e97875eb72 100644 --- a/dev/showcase/optimization_under_uncertainty/dfe0e598.svg +++ b/dev/showcase/optimization_under_uncertainty/e8ad09fb.svg @@ -1,551 +1,551 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/efb880b7.svg b/dev/showcase/optimization_under_uncertainty/efb880b7.svg deleted file mode 100644 index b00596004e9..00000000000 --- a/dev/showcase/optimization_under_uncertainty/efb880b7.svg +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/showcase/optimization_under_uncertainty/71c48382.svg b/dev/showcase/optimization_under_uncertainty/f1152f26.svg similarity index 90% rename from dev/showcase/optimization_under_uncertainty/71c48382.svg rename to dev/showcase/optimization_under_uncertainty/f1152f26.svg index d72a006d913..6d8e4f298b6 100644 --- a/dev/showcase/optimization_under_uncertainty/71c48382.svg +++ b/dev/showcase/optimization_under_uncertainty/f1152f26.svg @@ -1,47 +1,47 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/optimization_under_uncertainty/index.html b/dev/showcase/optimization_under_uncertainty/index.html index a857d34df5a..ede7b632153 100644 --- a/dev/showcase/optimization_under_uncertainty/index.html +++ b/dev/showcase/optimization_under_uncertainty/index.html @@ -18,14 +18,14 @@ prob = ODEProblem(ball!, u0, tspan, p) sol = solve(prob, Tsit5(), callback = ground_cb) -plot(sol, vars = (1, 3), label = nothing, xlabel = "x", ylabel = "y")Example block output

For this particular problem, we wish to measure the impact distance from a point $y=25$ on a wall at $x=25$. So, we introduce an additional callback that terminates the simulation on wall impact.

stop_condition(u, t, integrator) = u[1] - 25.0
+plot(sol, vars = (1, 3), label = nothing, xlabel = "x", ylabel = "y")
Example block output

For this particular problem, we wish to measure the impact distance from a point $y=25$ on a wall at $x=25$. So, we introduce an additional callback that terminates the simulation on wall impact.

stop_condition(u, t, integrator) = u[1] - 25.0
 stop_cb = ContinuousCallback(stop_condition, terminate!)
 cbs = CallbackSet(ground_cb, stop_cb)
 
 tspan = (0.0, 1500.0)
 prob = ODEProblem(ball!, u0, tspan, p)
 sol = solve(prob, Tsit5(), callback = cbs)
-plot(sol, vars = (1, 3), label = nothing, xlabel = "x", ylabel = "y")
Example block output

To help visualize this problem, we plot as follows, where the star indicates a desired impact location

rectangle(xc, yc, w, h) = Shape(xc .+ [-w, w, w, -w] ./ 2.0, yc .+ [-h, -h, h, h] ./ 2.0)
+plot(sol, vars = (1, 3), label = nothing, xlabel = "x", ylabel = "y")
Example block output

To help visualize this problem, we plot as follows, where the star indicates a desired impact location

rectangle(xc, yc, w, h) = Shape(xc .+ [-w, w, w, -w] ./ 2.0, yc .+ [-h, -h, h, h] ./ 2.0)
 
 begin
     plot(sol, vars = (1, 3), label = nothing, lw = 3, c = :black)
@@ -34,7 +34,7 @@
     plot!(rectangle(27.5, 25, 5, 50), c = :red, label = nothing)
     scatter!([25], [25], marker = :star, ms = 10, label = nothing, c = :green)
     ylims!(0.0, 50.0)
-end
Example block output

Considering Uncertainty

We now wish to introduce uncertainty in p[2], the coefficient of restitution. This is defined via a continuous univariate distribution from Distributions.jl. We can then run a Monte Carlo simulation of 100 trajectories via the EnsembleProblem interface.

using Distributions
+end
Example block output

Considering Uncertainty

We now wish to introduce uncertainty in p[2], the coefficient of restitution. This is defined via a continuous univariate distribution from Distributions.jl. We can then run a Monte Carlo simulation of 100 trajectories via the EnsembleProblem interface.

using Distributions
 
 cor_dist = truncated(Normal(0.9, 0.02), 0.9 - 3 * 0.02, 1.0)
 trajectories = 100
@@ -52,7 +52,7 @@
     scatter!([25], [25], marker = :star, ms = 10, label = nothing, c = :green)
     plot!(sol, vars = (1, 3), label = nothing, lw = 3, c = :black, ls = :dash)
     xlims!(0.0, 27.5)
-end
Example block output

Here, we plot the first 350 Monte Carlo simulations along with the trajectory corresponding to the mean of the distribution (dashed line).

We now wish to compute the expected squared impact distance from the star. This is called an “observation” of our system or an “observable” of interest.

We define this observable as

obs(sol, p) = abs2(sol[3, end] - 25)
obs (generic function with 1 method)

With the observable defined, we can compute the expected squared miss distance from our Monte Carlo simulation results as

mean_ensemble = mean([obs(sol, p) for sol in ensemblesol])
41.10989579799518

Alternatively, we can use the Koopman() algorithm in SciMLExpectations.jl to compute this expectation much more efficiently as

using SciMLExpectations
+end
Example block output

Here, we plot the first 350 Monte Carlo simulations along with the trajectory corresponding to the mean of the distribution (dashed line).

We now wish to compute the expected squared impact distance from the star. This is called an “observation” of our system or an “observable” of interest.

We define this observable as

obs(sol, p) = abs2(sol[3, end] - 25)
obs (generic function with 1 method)

With the observable defined, we can compute the expected squared miss distance from our Monte Carlo simulation results as

mean_ensemble = mean([obs(sol, p) for sol in ensemblesol])
34.02469076308977

Alternatively, we can use the Koopman() algorithm in SciMLExpectations.jl to compute this expectation much more efficiently as

using SciMLExpectations
 gd = GenericDistribution(cor_dist)
 h(x, u, p) = u, [p[1]; x[1]]
 sm = SystemMap(prob, Tsit5(), callback = cbs)
@@ -92,7 +92,7 @@
     scatter!([25], [25], marker = :star, ms = 10, label = nothing, c = :green)
     ylims!(0.0, 50.0)
     xlims!(minx[1], 27.5)
-end
Example block output

Looks pretty good! But, how long did it take? Let's benchmark.

@time solve(opt_prob, optimizer)
u: 3-element Vector{Float64}:
+end
Example block output

Looks pretty good! But, how long did it take? Let's benchmark.

@time solve(opt_prob, optimizer)
u: 3-element Vector{Float64}:
   0.0
   2.4428947026478425
  49.20927899180528

Not bad for bound constrained optimization under uncertainty of a hybrid system!

Probabilistic Constraints

With this approach, we can also consider probabilistic constraints. Let us now consider a wall at $x=20$ with height 25.

constraint = [20.0, 25.0]
@@ -105,7 +105,7 @@
     scatter!([25], [25], marker = :star, ms = 10, label = nothing, c = :green)
     ylims!(0.0, 50.0)
     xlims!(minx[1], 27.5)
-end
Example block output

We now wish to minimize the same loss function as before, but introduce an inequality constraint such that the solution must have less than a 1% chance of colliding with the wall at $x=20$. This class of probabilistic constraints is called a chance constraint.

To do this, we first introduce a new callback and solve the system using the previous optimal solution

constraint_condition(u, t, integrator) = u[1] - constraint[1]
+end
Example block output

We now wish to minimize the same loss function as before, but introduce an inequality constraint such that the solution must have less than a 1% chance of colliding with the wall at $x=20$. This class of probabilistic constraints is called a chance constraint.

To do this, we first introduce a new callback and solve the system using the previous optimal solution

constraint_condition(u, t, integrator) = u[1] - constraint[1]
 function constraint_affect!(integrator)
     integrator.u[3] < constraint[2] ? terminate!(integrator) : nothing
 end
@@ -128,7 +128,7 @@
     scatter!([25], [25], marker = :star, ms = 10, label = nothing, c = :green)
     ylims!(0.0, 50.0)
     xlims!(minx[1], 27.5)
-end
Example block output

That doesn't look good!

We now need a second observable for the system. To compute a probability of impact, we use an indicator function for if a trajectory impacts the wall. In other words, this functions returns 1 if the trajectory hits the wall and 0 otherwise.

function constraint_obs(sol, p)
+end
Example block output

That doesn't look good!

We now need a second observable for the system. To compute a probability of impact, we use an indicator function for if a trajectory impacts the wall. In other words, this functions returns 1 if the trajectory hits the wall and 0 otherwise.

function constraint_obs(sol, p)
     sol((constraint[1] - sol[1, 1]) / sol[2, 1])[3] <= constraint[2] ? one(sol[1, end]) :
     zero(sol[1, end])
 end
constraint_obs (generic function with 1 method)

Using the previously computed optimal initial conditions, let's compute the probability of hitting this wall

sm = SystemMap(remake(prob, u0 = make_u0(minx)), Tsit5(), callback = cbs)
@@ -170,4 +170,4 @@
     scatter!([25], [25], marker = :star, ms = 10, label = nothing, c = :green)
     ylims!(0.0, 50.0)
     xlims!(minx[1], 27.5)
-end
Example block output +endExample block output diff --git a/dev/showcase/pinngpu/index.html b/dev/showcase/pinngpu/index.html index 991a932462e..f5f7ca65e24 100644 --- a/dev/showcase/pinngpu/index.html +++ b/dev/showcase/pinngpu/index.html @@ -47,18 +47,18 @@ Dense(inner, inner, Lux.σ), Dense(inner, 1)) ps = Lux.setup(Random.default_rng(), chain)[1] -ps = ps |> ComponentArray
ComponentVector{Float32}(layer_1 = (weight = Float32[0.25604692 -0.039573513 -0.2745661; 0.04820074 0.21227898 0.07558153; … ; 0.20952594 0.0791733 -0.22192737; -0.3920144 0.31317508 -0.17576124], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = Float32[0.010857445 -0.04124142 … -0.30672556 -0.16442437; -0.3303061 0.10222617 … 0.17285798 -0.20522757; … ; 0.084477276 -0.2573819 … -0.2610652 -0.14817913; -0.25920165 0.2708837 … 0.31067517 -0.06674503], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = Float32[-0.096329935 -0.20269918 … -0.066613294 0.15708351; -0.09526188 -0.29921234 … -0.14381698 0.27521214; … ; -0.1737612 0.3452283 … 0.14100671 0.0044525014; 0.20037392 0.28446972 … 0.05159985 -0.12060427], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = Float32[-0.29029286 -0.09396603 … 0.059656277 -0.096561395; -0.060035203 0.12972231 … -0.14923385 -0.26302168; … ; -0.15834339 0.21954113 … 0.21651234 0.06843649; 0.2684092 -0.26298174 … 0.16725013 0.2908707], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_5 = (weight = Float32[0.42209798 -0.094994985 … 0.31695437 0.47139275], bias = Float32[0.0;;]))

Step 4: Place it on the GPU.

Just plop it on that sucker. We must ensure that our initial parameters for the neural network are on the GPU. If that is done, then the internal computations will all take place on the GPU. This is done by using the gpu function on the initial parameters, like:

ps = ps |> gpu .|> Float64
ComponentVector{Float64}(layer_1 = (weight = [0.25604692101478577 -0.039573512971401215 -0.274566113948822; 0.04820074141025543 0.21227897703647614 0.07558152824640274; … ; 0.2095259428024292 0.07917329668998718 -0.22192737460136414; -0.39201441407203674 0.3131750822067261 -0.17576123774051666], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = [0.010857445187866688 -0.041241418570280075 … -0.30672556161880493 -0.1644243746995926; -0.33030611276626587 0.10222616791725159 … 0.17285798490047455 -0.2052275687456131; … ; 0.08447727560997009 -0.2573818862438202 … -0.26106521487236023 -0.14817912876605988; -0.25920164585113525 0.270883709192276 … 0.31067517399787903 -0.06674502789974213], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = [-0.0963299348950386 -0.2026991844177246 … -0.06661329418420792 0.15708351135253906; -0.09526187926530838 -0.29921233654022217 … -0.1438169777393341 0.2752121388912201; … ; -0.17376120388507843 0.34522831439971924 … 0.1410067081451416 0.0044525014236569405; 0.20037391781806946 0.28446972370147705 … 0.05159984901547432 -0.1206042692065239], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = [-0.2902928590774536 -0.0939660295844078 … 0.05965627729892731 -0.09656139463186264; -0.06003520265221596 0.12972231209278107 … -0.1492338478565216 -0.26302167773246765; … ; -0.1583433896303177 0.21954113245010376 … 0.21651233732700348 0.06843648850917816; 0.26840919256210327 -0.26298174262046814 … 0.1672501266002655 0.29087069630622864], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_5 = (weight = [0.42209798097610474 -0.09499498456716537 … 0.3169543743133545 0.47139275074005127], bias = [0.0;;]))

Step 5: Discretize the PDE via a PINN Training Strategy

strategy = GridTraining(0.05)
+ps = ps |> ComponentArray
ComponentVector{Float32}(layer_1 = (weight = Float32[-0.3442004 -0.3611663 -0.4117998; 0.22323085 -0.20961043 -0.3089122; … ; -0.19198786 -0.14197959 0.20020556; 0.11389361 0.19082156 0.13814838], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = Float32[-0.33607385 -0.09277065 … 0.3379663 -0.044559084; -0.32710546 0.26206446 … 0.19823194 -0.24379234; … ; -0.18881896 0.060222518 … 0.16685754 0.04301947; 0.028929181 -0.2554285 … -0.11738047 -0.29046014], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = Float32[0.100096114 0.15065148 … 0.098413534 -0.15078755; -0.24061476 -0.2386726 … -0.046796132 0.14461473; … ; -0.22867331 -0.08203012 … 0.27762622 -0.15565164; -0.12265384 0.23365216 … 0.11563223 -0.1837626], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = Float32[-0.12700644 0.30507842 … -0.0030211648 0.14323609; -0.20609468 -0.13965623 … 0.015487145 -0.30088717; … ; -0.19129424 -0.23543282 … -0.27957034 -0.2215516; -0.20870595 0.2091135 … -0.016689086 0.097789146], bias = Float32[0.0; 0.0; … ; 0.0; 0.0;;]), layer_5 = (weight = Float32[0.23472594 0.26704675 … 0.16281638 0.252185], bias = Float32[0.0;;]))

Step 4: Place it on the GPU.

Just plop it on that sucker. We must ensure that our initial parameters for the neural network are on the GPU. If that is done, then the internal computations will all take place on the GPU. This is done by using the gpu function on the initial parameters, like:

ps = ps |> gpu .|> Float64
ComponentVector{Float64}(layer_1 = (weight = [-0.34420040249824524 -0.3611662983894348 -0.4117997884750366; 0.22323085367679596 -0.20961043238639832 -0.3089121878147125; … ; -0.19198785722255707 -0.14197959005832672 0.20020556449890137; 0.11389361321926117 0.1908215582370758 0.13814838230609894], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = [-0.3360738456249237 -0.09277065098285675 … 0.33796629309654236 -0.04455908387899399; -0.32710546255111694 0.26206445693969727 … 0.19823193550109863 -0.2437923401594162; … ; -0.18881896138191223 0.06022251769900322 … 0.1668575406074524 0.04301946982741356; 0.028929181396961212 -0.2554284930229187 … -0.11738047003746033 -0.29046013951301575], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = [0.10009611397981644 0.1506514847278595 … 0.09841353446245193 -0.15078754723072052; -0.24061475694179535 -0.23867259919643402 … -0.04679613187909126 0.14461472630500793; … ; -0.2286733090877533 -0.08203011751174927 … 0.2776262164115906 -0.15565164387226105; -0.12265384197235107 0.23365215957164764 … 0.11563222855329514 -0.1837625950574875], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = [-0.1270064413547516 0.3050784170627594 … -0.003021164797246456 0.14323608577251434; -0.2060946822166443 -0.13965623080730438 … 0.015487144701182842 -0.30088716745376587; … ; -0.19129423797130585 -0.23543281853199005 … -0.2795703411102295 -0.22155159711837769; -0.20870594680309296 0.2091134935617447 … -0.016689086332917213 0.09778914600610733], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_5 = (weight = [0.2347259372472763 0.2670467495918274 … 0.1628163754940033 0.25218498706817627], bias = [0.0;;]))

Step 5: Discretize the PDE via a PINN Training Strategy

strategy = GridTraining(0.05)
 discretization = PhysicsInformedNN(chain,
                                    strategy,
                                    init_params = ps)
 prob = discretize(pde_system, discretization)
OptimizationProblem. In-place: true
-u0: ComponentVector{Float64}(layer_1 = (weight = [0.25604692101478577 -0.039573512971401215 -0.274566113948822; 0.04820074141025543 0.21227897703647614 0.07558152824640274; … ; 0.2095259428024292 0.07917329668998718 -0.22192737460136414; -0.39201441407203674 0.3131750822067261 -0.17576123774051666], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = [0.010857445187866688 -0.041241418570280075 … -0.30672556161880493 -0.1644243746995926; -0.33030611276626587 0.10222616791725159 … 0.17285798490047455 -0.2052275687456131; … ; 0.08447727560997009 -0.2573818862438202 … -0.26106521487236023 -0.14817912876605988; -0.25920164585113525 0.270883709192276 … 0.31067517399787903 -0.06674502789974213], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = [-0.0963299348950386 -0.2026991844177246 … -0.06661329418420792 0.15708351135253906; -0.09526187926530838 -0.29921233654022217 … -0.1438169777393341 0.2752121388912201; … ; -0.17376120388507843 0.34522831439971924 … 0.1410067081451416 0.0044525014236569405; 0.20037391781806946 0.28446972370147705 … 0.05159984901547432 -0.1206042692065239], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = [-0.2902928590774536 -0.0939660295844078 … 0.05965627729892731 -0.09656139463186264; -0.06003520265221596 0.12972231209278107 … -0.1492338478565216 -0.26302167773246765; … ; -0.1583433896303177 0.21954113245010376 … 0.21651233732700348 0.06843648850917816; 0.26840919256210327 -0.26298174262046814 … 0.1672501266002655 0.29087069630622864], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_5 = (weight = [0.42209798097610474 -0.09499498456716537 … 0.3169543743133545 0.47139275074005127], bias = [0.0;;]))

Step 6: Solve the Optimization Problem

callback = function (p, l)
+u0: ComponentVector{Float64}(layer_1 = (weight = [-0.34420040249824524 -0.3611662983894348 -0.4117997884750366; 0.22323085367679596 -0.20961043238639832 -0.3089121878147125; … ; -0.19198785722255707 -0.14197959005832672 0.20020556449890137; 0.11389361321926117 0.1908215582370758 0.13814838230609894], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_2 = (weight = [-0.3360738456249237 -0.09277065098285675 … 0.33796629309654236 -0.04455908387899399; -0.32710546255111694 0.26206445693969727 … 0.19823193550109863 -0.2437923401594162; … ; -0.18881896138191223 0.06022251769900322 … 0.1668575406074524 0.04301946982741356; 0.028929181396961212 -0.2554284930229187 … -0.11738047003746033 -0.29046013951301575], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_3 = (weight = [0.10009611397981644 0.1506514847278595 … 0.09841353446245193 -0.15078754723072052; -0.24061475694179535 -0.23867259919643402 … -0.04679613187909126 0.14461472630500793; … ; -0.2286733090877533 -0.08203011751174927 … 0.2776262164115906 -0.15565164387226105; -0.12265384197235107 0.23365215957164764 … 0.11563222855329514 -0.1837625950574875], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_4 = (weight = [-0.1270064413547516 0.3050784170627594 … -0.003021164797246456 0.14323608577251434; -0.2060946822166443 -0.13965623080730438 … 0.015487144701182842 -0.30088716745376587; … ; -0.19129423797130585 -0.23543281853199005 … -0.2795703411102295 -0.22155159711837769; -0.20870594680309296 0.2091134935617447 … -0.016689086332917213 0.09778914600610733], bias = [0.0; 0.0; … ; 0.0; 0.0;;]), layer_5 = (weight = [0.2347259372472763 0.2670467495918274 … 0.1628163754940033 0.25218498706817627], bias = [0.0;;]))

Step 6: Solve the Optimization Problem

callback = function (p, l)
     println("Current loss is: $l")
     return false
 end
 
-res = Optimization.solve(prob, Adam(0.01); callback = callback, maxiters = 2500);
u: ComponentVector{Float64}(layer_1 = (weight = [-0.5539812142812816 -0.37597768526708103 -0.5615534095424002; 2.8078664922796226 0.15443583878020564 0.15648024671703853; … ; 3.1794610093995237 0.515331666816694 0.4118899214106697; 2.2794363330311214 0.6427932915325668 0.6338596189561113], bias = [2.080695299812219; -2.2785444909813677; … ; -1.5989851970747115; -0.24485802038572013;;]), layer_2 = (weight = [0.8523025607995478 0.9277152197871036 … 0.8318806324427364 0.7147826477532411; 0.7438501209929582 1.7989912491883107 … 1.657049809996447 1.1784652821937127; … ; -0.3251463861074426 -0.8827004318239057 … 0.04044984825681845 -0.28510596981245295; -1.0857052930033728 -0.1376525746418302 … 0.6127380500280053 -0.40255652510483425], bias = [0.5247693089533059; 0.6320897264749266; … ; 0.08233179758340899; 0.18919629531332002;;]), layer_3 = (weight = [-0.2252537874593599 -0.34620929781853377 … 0.9040421782854088 0.721682884649446; 0.2510077120078891 0.1477110613546821 … 0.6386158308474892 0.33922321612815753; … ; 0.16823668567768787 0.9382122327992932 … -0.7310046172048119 -0.977353733235501; 0.4169833834512716 0.8866933922835103 … -1.013556295554738 -1.1806431742828734], bias = [0.129522858484406; 0.2076326276824753; … ; -0.08620952222235467; -0.15632650796863395;;]), layer_4 = (weight = [1.0869946149077165 0.9055547235819448 … -2.9924048461390824 -0.9170114975997954; -2.6737388427737487 -1.2991493147240736 … 2.209256446033195 1.6663754865239473; … ; 1.5952689681515924 1.5347213650455986 … -1.621433719906615 -1.0606202954812634; 1.9249399926668789 0.9764724028096018 … -1.6442078537422813 -0.9820278866411704], bias = [1.0051911011075014; -1.5403263426776985; … ; 1.1669703211418239; 1.086881626783962;;]), layer_5 = (weight = [3.7821396769463713 -7.798057478349465 … 5.960652076601871 5.633889697295081], bias = [-0.7558836115586149;;]))

We then use the remake function to rebuild the PDE problem to start a new optimization at the optimized parameters, and continue with a lower learning rate:

prob = remake(prob, u0 = res.u)
-res = Optimization.solve(prob, Adam(0.001); callback = callback, maxiters = 2500);
u: ComponentVector{Float64}(layer_1 = (weight = [-0.557340900614324 -0.3626820839465872 -0.531939656403469; 2.796284934563257 0.1424885049952724 0.1868814071103004; … ; 3.233387561444243 0.5020863794496673 0.4063834006971709; 2.215100221215165 0.6587848971058016 0.6621244196167501], bias = [2.100487018477767; -2.3031638258956746; … ; -1.5402168236602007; -0.30035904893312415;;]), layer_2 = (weight = [0.5256679088432153 1.779416067044654 … 0.5688854223330941 -0.19483070221682156; 1.1836269270607436 1.9453311058973672 … 1.7520099500672306 1.317016913648018; … ; -0.3164122313534615 -0.8916861694270557 … 0.037533312701585116 -0.2851541456184894; -1.0844033238956141 -0.13893624900188453 … 0.6135247522677291 -0.40113305162872426], bias = [0.3362736429006877; 0.9798020406732453; … ; 0.07920225576657124; 0.1884102044051447;;]), layer_3 = (weight = [-0.21120039185209424 -0.3322213949371616 … 0.9278194357280822 0.7322275993543144; 0.266286827217583 0.1421362170584881 … 0.5467144151890404 0.26414184030166626; … ; 0.15659291693855543 0.9259612683480776 … -0.7517219438102096 -0.9864343540501913; 0.4034015516898247 0.8744620084328973 … -1.0321614626809015 -1.187810518048746], bias = [0.14351035425798325; 0.2020269469551431; … ; -0.0984601826895667; -0.16855766438714376;;]), layer_4 = (weight = [1.2437502141988281 0.9748253823057484 … -3.03384927794491 -1.092365410175845; -2.7985641768208405 -1.3794130234550979 … 2.1143642220883736 1.6556153546877903; … ; 1.717513737289955 1.6342388867621485 … -1.6936701103024197 -1.0861206972863116; 1.9224475332562503 0.9672802920079083 … -1.7200441374305853 -1.047678821338059], bias = [1.073662440554348; -1.620107318630463; … ; 1.2643027327063179; 1.0711856025872208;;]), layer_5 = (weight = [3.8986614135455087 -9.280188926199543 … 6.273834369709137 5.99896589826147], bias = [-1.0173403638439118;;]))

Step 7: Inspect the PINN's Solution

Finally, we inspect the solution:

phi = discretization.phi
+res = Optimization.solve(prob, Adam(0.01); callback = callback, maxiters = 2500);
u: ComponentVector{Float64}(layer_1 = (weight = [2.7701243380798233 0.3562763037423611 0.1923231790757634; 1.5606938039924294 -0.8613389626761051 -0.8887673876018362; … ; -2.48834820530836 -0.5893980367901375 -0.3064342055809568; -0.042746229215564945 -0.11470749161546752 -1.0327375899520075], bias = [0.8267217292540638; 1.2988068171993075; … ; 2.0835066061673526; 0.35635762010240574;;]), layer_2 = (weight = [0.7924637332039569 -0.501335684071993 … -0.9844692125178376 -0.7968326285066515; 0.6987827303525619 0.5625251807616888 … 0.34778067351516684 -0.30739155454791; … ; -0.7348380774635643 1.3462354895081123 … 0.3393369637425004 1.5419472360005042; -2.0555654052117713 -2.6227491636335447 … -1.2138030000469258 -0.8955226585968155], bias = [0.18717387134283187; -0.20207482219981546; … ; -0.46659607944682074; -0.07929152829753995;;]), layer_3 = (weight = [-1.3378644416470877 -0.3567027129305179 … 0.6297580723004006 -0.42433656035301015; 0.9519378903386982 -0.2525689886047693 … -0.10017644982351612 0.2893914940129167; … ; -1.7835822220744586 -1.080917723998552 … 0.5941725374332589 2.2502823708994026; -1.3026177761453888 0.3105416055420712 … 0.9149149039529506 -2.1877779799250754], bias = [-0.1213884188746474; -0.09081619359275528; … ; -0.46219137691085593; 0.0100627700725916;;]), layer_4 = (weight = [-0.40206089253984123 1.5482623419263624 … -2.2702835453299524 -0.23779079712394627; -0.564034785456264 0.8728510884224967 … -1.7311342367288096 -0.7147652202428744; … ; -1.8413855949760505 1.4730113699096135 … -3.832300959971532 -1.6763752324646661; -0.6144336346184447 1.0405395103278008 … -1.4550644144458333 -0.192605536482003], bias = [1.1243955161722612; 0.932766319645065; … ; 1.6798723666796798; 0.8103573085959724;;]), layer_5 = (weight = [4.550949731454091 4.328929278363818 … 8.539496324104961 5.545017703190696], bias = [-0.21818239635033304;;]))

We then use the remake function to rebuild the PDE problem to start a new optimization at the optimized parameters, and continue with a lower learning rate:

prob = remake(prob, u0 = res.u)
+res = Optimization.solve(prob, Adam(0.001); callback = callback, maxiters = 2500);
u: ComponentVector{Float64}(layer_1 = (weight = [2.772043539885773 0.34678107261973257 0.19865353026776822; 1.501542259177396 -0.911290617193233 -0.9644298594466937; … ; -2.5271607629005097 -0.4820098094582445 -0.3848187444078269; 0.10191422805891474 0.055082066194990384 -0.9601692228138755], bias = [0.800544978152556; 1.2986998507163603; … ; 2.1462334320468974; 0.5422453662788024;;]), layer_2 = (weight = [0.8091541625436861 -0.5202246936547195 … -1.0308772395412014 -0.7246473004053555; 0.6870483674895683 0.6010356085055083 … 0.29339043344892046 -0.259898918736952; … ; -0.6828666660911138 1.4419054787969439 … 0.3140902602492391 1.591008106761781; -2.0340097657067573 -2.8912186967507916 … -1.2661058599242436 -0.8296578686542698], bias = [0.20260888275797673; -0.2140241640235405; … ; -0.4386250654060452; -0.05800479775667805;;]), layer_3 = (weight = [-0.9626731235133401 -0.6715079864807606 … 0.6536893095934453 0.9742350335161314; 1.0423034492587473 -0.241207199789625 … -0.10780925610687181 0.23100015765302231; … ; -1.8859304427384367 -1.1187412210913212 … 0.5526767244440131 2.2050308066518336; -1.6086196354359408 1.4458421095043497 … 1.9635608104474458 -4.515943299796118], bias = [-0.36332795991744543; -0.10305141214336223; … ; -0.4883378964481778; 0.06704040639826582;;]), layer_4 = (weight = [-0.343529325657866 1.594674214048019 … -2.6113056702378947 -0.2627546197933588; -0.6573735838222611 0.8055119551541653 … -1.829233531761571 -0.7983639043826956; … ; -1.8120315519033594 1.3669781315634888 … -3.703726402561265 -0.7308020219128563; -0.7395949645245804 0.9452148484903504 … -1.4835404126608194 -0.27966880598842947], bias = [1.1690645972564035; 0.8777864305293063; … ; 1.517163464251422; 0.7328647193670186;;]), layer_5 = (weight = [4.538749452064025 4.260378005716264 … 8.32605361450336 5.461085654548801], bias = [-0.041162456701987184;;]))

Step 7: Inspect the PINN's Solution

Finally, we inspect the solution:

phi = discretization.phi
 ts, xs, ys = [infimum(d.domain):0.1:supremum(d.domain) for d in domains]
 u_real = [analytic_sol_func(t, x, y) for t in ts for x in xs for y in ys]
 u_predict = [first(Array(phi(gpu([t, x, y]), res.u))) for t in ts for x in xs for y in ys]
@@ -83,4 +83,4 @@
     gif(anim, "3pde.gif", fps = 10)
 end
 
-plot_(res)

3pde

+plot_(res)

3pde

diff --git a/dev/showcase/showcase/index.html b/dev/showcase/showcase/index.html index f5609646931..899aed825fc 100644 --- a/dev/showcase/showcase/index.html +++ b/dev/showcase/showcase/index.html @@ -1,2 +1,2 @@ -The SciML Showcase · Overview of Julia's SciML

The SciML Showcase

The SciML Showcase is a display of some cool things that can be done by connecting SciML software.

Note

The SciML Showcase is not meant to be training/tutorials, but inspirational demonstrations! If you're looking for simple examples to get started with, check out the getting started section.

Want to see some cool things that you can do with SciML? Check out the following:

+The SciML Showcase · Overview of Julia's SciML

The SciML Showcase

The SciML Showcase is a display of some cool things that can be done by connecting SciML software.

Note

The SciML Showcase is not meant to be training/tutorials, but inspirational demonstrations! If you're looking for simple examples to get started with, check out the getting started section.

Want to see some cool things that you can do with SciML? Check out the following:

diff --git a/dev/showcase/symbolic_analysis/3829f88d.svg b/dev/showcase/symbolic_analysis/adfedc50.svg similarity index 98% rename from dev/showcase/symbolic_analysis/3829f88d.svg rename to dev/showcase/symbolic_analysis/adfedc50.svg index 7f7b056f317..26858eff23b 100644 --- a/dev/showcase/symbolic_analysis/3829f88d.svg +++ b/dev/showcase/symbolic_analysis/adfedc50.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/symbolic_analysis/95aa5761.svg b/dev/showcase/symbolic_analysis/cd928673.svg similarity index 98% rename from dev/showcase/symbolic_analysis/95aa5761.svg rename to dev/showcase/symbolic_analysis/cd928673.svg index 63ca62b6ca0..cc603d96cfe 100644 --- a/dev/showcase/symbolic_analysis/95aa5761.svg +++ b/dev/showcase/symbolic_analysis/cd928673.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/symbolic_analysis/c7352007.svg b/dev/showcase/symbolic_analysis/dd10d851.svg similarity index 96% rename from dev/showcase/symbolic_analysis/c7352007.svg rename to dev/showcase/symbolic_analysis/dd10d851.svg index 319aba95a38..b9b50d8a515 100644 --- a/dev/showcase/symbolic_analysis/c7352007.svg +++ b/dev/showcase/symbolic_analysis/dd10d851.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/showcase/symbolic_analysis/index.html b/dev/showcase/symbolic_analysis/index.html index a82b3eb2e1c..27b09410679 100644 --- a/dev/showcase/symbolic_analysis/index.html +++ b/dev/showcase/symbolic_analysis/index.html @@ -23,7 +23,7 @@ pendulum_sys = structural_simplify(dae_index_lowering(traced_sys)) prob = ODAEProblem(pendulum_sys, [], tspan) sol = solve(prob, Tsit5(), abstol = 1e-8, reltol = 1e-8) -plot(sol, vars = states(traced_sys))Example block output

Explanation

Attempting to Solve the Equation

In this tutorial, we will look at the pendulum system:

\[\begin{aligned} +plot(sol, vars = states(traced_sys))Example block output

Explanation

Attempting to Solve the Equation

In this tutorial, we will look at the pendulum system:

\[\begin{aligned} x^\prime &= v_x\\ v_x^\prime &= Tx\\ y^\prime &= v_y\\ @@ -74,11 +74,11 @@ sol = solve(prob, Rodas4()) using Plots -plot(sol, vars = states(traced_sys))Example block output

Note that plotting using states(traced_sys) is done so that any variables which are symbolically eliminated, or any variable reordering done for enhanced parallelism/performance, still show up in the resulting plot and the plot is shown in the same order as the original numerical code.

Note that we can even go a bit further. If we use the ODAEProblem constructor, we can remove the algebraic equations from the states of the system and fully transform the index-3 DAE into an index-0 ODE, which can be solved via an explicit Runge-Kutta method:

traced_sys = modelingtoolkitize(pendulum_prob)
+plot(sol, vars = states(traced_sys))
Example block output

Note that plotting using states(traced_sys) is done so that any variables which are symbolically eliminated, or any variable reordering done for enhanced parallelism/performance, still show up in the resulting plot and the plot is shown in the same order as the original numerical code.

Note that we can even go a bit further. If we use the ODAEProblem constructor, we can remove the algebraic equations from the states of the system and fully transform the index-3 DAE into an index-0 ODE, which can be solved via an explicit Runge-Kutta method:

traced_sys = modelingtoolkitize(pendulum_prob)
 pendulum_sys = structural_simplify(dae_index_lowering(traced_sys))
 prob = ODAEProblem(pendulum_sys, Pair[], tspan)
 sol = solve(prob, Tsit5(), abstol = 1e-8, reltol = 1e-8)
-plot(sol, vars = states(traced_sys))
Example block output

And there you go: this has transformed the model from being too hard to solve with implicit DAE solvers, to something that is easily solved with explicit Runge-Kutta methods for non-stiff equations.

Parameter Identifiability in ODE Models

Ordinary differential equations are commonly used for modeling real-world processes. The problem of parameter identifiability is one of the key design challenges for mathematical models. A parameter is said to be identifiable if one can recover its value from experimental data. Structural identifiability is a theoretical property of a model that answers this question. In this tutorial, we will show how to use StructuralIdentifiability.jl with ModelingToolkit.jl to assess identifiability of parameters in ODE models. The theory behind StructuralIdentifiability.jl is presented in paper [4].

We will start by illustrating local identifiability in which a parameter is known up to finitely many values, and then proceed to determining global identifiability, that is, which parameters can be identified uniquely.

To install StructuralIdentifiability.jl, simply run

using Pkg
+plot(sol, vars = states(traced_sys))
Example block output

And there you go: this has transformed the model from being too hard to solve with implicit DAE solvers, to something that is easily solved with explicit Runge-Kutta methods for non-stiff equations.

Parameter Identifiability in ODE Models

Ordinary differential equations are commonly used for modeling real-world processes. The problem of parameter identifiability is one of the key design challenges for mathematical models. A parameter is said to be identifiable if one can recover its value from experimental data. Structural identifiability is a theoretical property of a model that answers this question. In this tutorial, we will show how to use StructuralIdentifiability.jl with ModelingToolkit.jl to assess identifiability of parameters in ODE models. The theory behind StructuralIdentifiability.jl is presented in paper [4].

We will start by illustrating local identifiability in which a parameter is known up to finitely many values, and then proceed to determining global identifiability, that is, which parameters can be identified uniquely.

To install StructuralIdentifiability.jl, simply run

using Pkg
 Pkg.add("StructuralIdentifiability")

The package has a standalone data structure for ordinary differential equations, but is also compatible with ODESystem type from ModelingToolkit.jl.

Local Identifiability

Input System

We will consider the following model:

\[\begin{cases} \frac{d\,x_4}{d\,t} = - \frac{k_5 x_4}{k_6 + x_4},\\ \frac{d\,x_5}{d\,t} = \frac{k_5 x_4}{k_6 + x_4} - \frac{k_7 x_5}{(k_8 + x_5 + x_6)},\\ @@ -175,4 +175,4 @@ funcs_to_check = to_check, p = 0.9) # Dict{Num, Symbol} with 2 entries: # b => :globally -# c => :globally

Both parameters b, c are globally identifiable with probability 0.9 in this case.

+# c => :globally

Both parameters b, c are globally identifiable with probability 0.9 in this case.