Skip to content

Commit f0c7a90

Browse files
author
Brad Carman
committed
2 parents 5f93405 + 5fd0147 commit f0c7a90

File tree

5 files changed

+82
-95
lines changed

5 files changed

+82
-95
lines changed

docs/make.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ using Documenter, ModelingToolkitCourse
33

44
pages = [
55
"Home" => "index.md",
6-
"Syllabus" => "syllabus.md",
76
"lectures/lecture1.md",
87
"lectures/lecture2.md",
98
"lectures/lecture3.md",

docs/src/index.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1-
# ModelingToolkit Course
1+
# ModelingToolkit Course: Composable System Modeling and Its Compilation
22

3+
## 18.S191 Special Subject in Mathematics: Composable System Modeling and Its Compilation
34

5+
Traditionally, modeling physical systems often requires a deep understanding of the physics and equations of motions or states, simplifying the differential equations using conservation laws and constraints, and finally implementing simplified equations in a scientific computing language to numerically solve them. However, this workflow is tedious and not expressive. A simple change in the underlying physical system often requires a complete re-derivation of the simplified equations. A composable modeling system frees domain experts from the time-consuming derivation, simplification, and implementation by allowing them to model each physical component separately and hierarchically, thereby enabling them to build more accurate and complex models without compromising the simulation performance. In this course, we will dive into the practice of implementing composable physical models and the compilation process of the model system using the ModelingToolkit.jl acausal modeling framework in Julia. Students will learn the mathematics and numerical methods behind solving industry-scale models, covering topics such as differential-algebraic equations (DAEs), modern techniques in implicit integrators (backwards differentiation formulae (BDFs)), symbolic manipulation of equations via techniques like Pantelides algorithm and tearing of nonlinear systems, and more. Applications for solving real-world problems like modeling battery systems of electric vehicles, efficient control of hydraulic and HVAC systems, and more will be used to demonstrate how these techniques are used in industrial settings.
6+
7+
## Syllabus
8+
9+
Prerequisites: While this course will be mixing ideas from symbolic computing, numerical differential equations, and topics from mechanical engineering, no one in the course is expected to have covered all of these topics before. Understanding of calculus, linear algebra, and programming is essential. The course is considered self-contained starting from the basic building blocks of undergraduate differential equations. Problem sets will involve use of Julia, a Matlab-like environment (little or no prior experience required; you will learn as you go), for doing acausal modeling via the ModelingToolkit.jl system.
10+
11+
Textbook & Other Reading: There is no textbook for this course. For a textbook that covers the practical parts of doing modeling and simulation in an acausal way, Michael Tiller's "Modelica by Example" is a good reference (see https://mbe.modelica.university/). For a textbook that covers the algorithms of acausal modeling compilers, there is no recommended textbook and lecture notes will be supplied as a primary source.
12+
13+
Grading: The final project proposal (due January 15th) is 25%, and 75% for the final project (due February 2nd). Final projects will be submitted electronically via email.
14+
15+
## Final Project
16+
17+
The final project can take two forms:
18+
19+
1. Developing an acausal model of some real-world system.
20+
2. Implementation and analysis of a new acausal modeling compiler feature.
21+
3. Implementation and analysis of numerical methods for acausal models.
22+
23+
A final project proposal is due January 19th and the final project is due on the last day of the course. The last day will be final project presentations where the work is demonstrated to the class.
24+
25+
The final project's deliverable can take two different forms:
26+
27+
1. A final project writeup: a 5-10 page paper using the style template from the [_SIAM Journal on Numerical Analysis_](http://www.siam.org/journals/auth-info.php) (or similar) explaining what was done, along with a Github repository package with the components of the model and docs/tests which demonstrate the successful composed model.
28+
2. A pull request to one of the libraries (ModelingToolkit, ModelingToolkitStandardLibrary, OrdinaryDiffEq, NonlinearSolve, etc.). For this version of the project, it is sufficient to supply a pull request to MTK/MSL with a description of the feature being implemented, tests of the transformation, and documentation showcasing its correct action on test models.
29+
30+
We expect the work to be roughly the same for the two routes, where the 1st would entail more theory and mathematical writeup while the latter is more focused on code and documentation. Note that any project considering doing a new acausal modeling feature should heavily consider doing the pull request route as writing a toy acausal modeling compiler within the timeframe of the course is likely to be unsuccessful.
31+
32+
Note that many of these projects are starter projects towards publications. If you're interested in continuing this work after the IAP towards a publication, please discuss during the project selection page so the project can be appropriately scoped.
33+
34+
### Project Type 1 Ideas: Developing an Acausal Model of A Real-World System
35+
36+
The following sources can be used as inspiration:
37+
38+
* Modelica "other" libraries (https://modelica.org/libraries/)
39+
* Modelica Standard Library (https://github.com/modelica/ModelicaStandardLibrary)
40+
41+
42+
### Project Type 2 Ideas: Implementation and analysis of a new acausal modeling compiler feature
43+
44+
* Automated Laplace and Fourier transforms
45+
* Automated function transformation of observables (i.e. log-transform states to enforce positivity)
46+
* Symbolic generation of sensitivity analysis equations (https://github.com/SciML/ModelingToolkit.jl/issues/39)
47+
* Lamperti transformation of stochastic differential equations (https://github.com/SciML/ModelingToolkit.jl/issues/140)
48+
* Automated conversion of distributed delay equations into ODEs (https://github.com/SciML/ModelingToolkit.jl/issues/45)
49+
* Specialized nonlinear solvers based on strongly connected components
50+
* Inline integration (https://people.inf.ethz.ch/fcellier/Pubs/OO/esm_95.pdf)
51+
* Automated detection of events from discontinuities in the ODE/DAE definition
52+
* Polynomial chaos expansions for fast uncertainty quantification
53+
* DCP on OptimizationSystem to automatically transform nonlinear optimization problems to convex optimization problems (http://cvxr.com/cvx/doc/dcp.html)
54+
* Common subexpression elimination in Symbolic code generation
55+
* Extendable C code generation maps from Symbolics
56+
* Direct-quadrature-zero transformation for multibody systems and robotics (https://en.wikipedia.org/wiki/Direct-quadrature-zero_transformation)
57+
* Pryce's algorithm for DAE index reduction (https://link.springer.com/article/10.1023/A:1021998624799, https://inria.hal.science/hal-03104030v2/document)
58+
59+
### Project Type 3 Ideas: Implementation and analysis of numerical methods for acausal models
60+
61+
* Adaptive order Radau methods (https://www.sciencedirect.com/science/article/pii/S037704279900134X)
62+
* Parallel Rosenbrock and FIRK methods
63+
* Handling the difficulties of BDFs in DAE systems (i.e. handling known deficiencies in the DFBDF algorithm)
64+
* New time stepping schema for Rosenbrock methods for DAE interpolation performance
65+
* Investigation of nonlinear solver globalization schemes for difficult DAE initialization problems
66+
67+
## Tentative Schedule
68+
69+
* January 10th: Introduction to the course, Guest lecture: Brad Carman, introduction to acausal modeling for physical systems with ModelingToolkit
70+
* January 12th: Guest lecture: Brad Carman, developing high-fidelity models of hydraulic systems
71+
* January 15th: Martin Luther King Day!
72+
* January 17th: Real numerical methods for implicit equations and stiff ordinary differential equations (ODEs), i.e., Jacobian-free Newton-Krylov, adaptive time stepping, dense output, sparse automatic differentiation, event handling.
73+
* January 18th (Make up day for MLK day): Continuing discussion of stiff ODEs and onto numerical methods for differential-algebraic equations (DAEs). Rosenbrock methods, Backwards-Differentiation Formulae (BDF), fully-implicit Runge-Kutta methods.
74+
* January 19th: Finishing the discussion on stiff ODEs and DAEs. If time allows, discussion of handling inverse problems (parameter estimation), adjoint methods, uncertainty quantification, and the connections to reverse-mode AD.
75+
* January 22nd: Discussion and interactive workshop on debugging difficult stiff ODE/DAE models (featuring Brad Carman and Yingbo Ma).
76+
* January 24th: Guest Lecture: Yingbo Ma. How acausal model compilers work: index reduction. Pantelides algorithm, dummy derivatives, and demonstrations.
77+
* January 26th: Guest Lecture: Yingbo Ma. How acausal model compilers work: Tearing of nonlinear systems and alias elimination.
78+
* January 29th: Guest Lecture: Yingbo Ma. How acausal model compilers work: Loop rerolling, specialized optimizations for multibody systems, and other generated code robustness and performance optimizations.
79+
* January 31st: TBD based on what is not sufficiently covered earlier in the course.
80+
* February 2nd: Final project presentations!

docs/src/lectures/lecture3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ u' = f(u,p,t)
1313
where ``u(t_0) = u_0`` is known, to solve this equation on a time span from ``t \in [t_0, t_f]`` is known as the Initial Value Problem (IVP). The most basic method for handling this type of equation is known as Euler's method, which is given by the linear approximation of the derivative. Let ``u_n`` be the numerical approximation to ``u(t_0 + nh)`` at time ``t_n = t_0 + nh`` where ``h`` is the time discretization size, then can approximate via a Taylor Series expansion:
1414

1515
```math
16-
u(t+(n+1)h) = u(t+nh) + h u'(t+nh) + \frac{1}{2}h^2 u''(t) + \mathcal{O}(h^3)
16+
u(t+(n+1)h) = u(t+nh) + h u'(t+nh) + \frac{1}{2}h^2 u''(t+nh) + \mathcal{O}(h^3)
1717
```
1818

1919
which motivates the approximation by dropping the higher order terms:
@@ -65,10 +65,10 @@ LTE = u(t+(n+1)h) - u_{n+1}
6565
LTE = (u(t+nh) + h u'(t+nh) + \mathcal{O}(h^2)) - (u_n + h f(u_n,p,t_n))
6666
```
6767
```math
68-
LTE = (u(t+nh) + h u'(t+nh) + \frac{1}{2}h^2 u''(t) + \mathcal{O}(h^3)) - (u(t+nh) + h u'(t+nh))
68+
LTE = (u(t+nh) + h u'(t+nh) + \frac{1}{2}h^2 u''(t+nh) + \mathcal{O}(h^3)) - (u(t+nh) + h u'(t+nh))
6969
```
7070
```math
71-
LTE = \frac{1}{2}h^2 u''(t) + \mathcal{O}(h^3)
71+
LTE = \frac{1}{2}h^2 u''(t+nh) + \mathcal{O}(h^3)
7272
```
7373

7474
### Global Truncation Error in Euler's Method

docs/src/lectures/lecture4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ This form is slightly more general since one can consider the mass matrix form a
468468
that $f(u',u,t)$ has a linear partial derivative with respect to the ``u'`` term, with $-M$
469469
being that derivative. Thus it allows for example ``u_1'^2``.
470470

471-
Though note that this the mass matrix and the implicit ODE definitions are not a substantial
471+
Though note that the mass matrix and the implicit ODE definitions are not a substantial
472472
difference as via a variable definition ``u_i = u_1^3`` and other tricks you can rewrite a
473473
term with nonlinear derivatives into one with linear derivative relationships, and thus
474474
arrive at a mass matrix form (with a larger set of equations). The semi-explicit ODE however

docs/src/syllabus.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)