ModelingToolkit.jl
ModelingToolkit.jl copied to clipboard
Documentation: Tutorial on ODE/DAE systems coming from semi-discretized PDE System modelling
As a newcomer to Julia and MTK, I struggled to find tutorials and resources about modelling of large DAEs stemming from semi-discretization PDE systems, where generally PDEs can have a time derivative term or not.
Such Systems arise often in practice, See for example the derivation of such a system in this post. I think, it is worthwhile to devote a tutorial page in the MTK documentation for such kind of systems.
More specifically, I think the tutorial should cover up-to-date and best practice approaches for:
-
Building an MTK System with scalar and array variables, with the array variables representing the solved variable field of the discretized PDE
-
Constructing a numerical problem out of that system. Describe rationale for choice of
ODEProblem
,DAEProblem
ofODAEProblem
system in problem building. What is best in which situation, what is already fully functional and what is limited/feature incomplete for the time being -
Definition of initial values/guesses for the variables of the system, most importantly of the discretized array variables.
-
Structural simplification of the system and further usage of the simplified system without having to set the initial values again
-
Solving the simplified and non-simplified system in mass matrix form and in fully implicit form using IDA. Usage of sparsity and symbolic Jacobian in both of these cases.
-
Plotting of the solved (and observed) variables, especially of the array variables: Plotting certain (or all) elements of the array variables over time as well as plotting all elements of an array variable over a different (e.g. spatial) coordinate for a given point in time
-
Hints and possibly demonstration of further tricks to improve performance of the numerical solution, if there are any
Being a newcomer myself, I can certainly not help with the coding part of the tutorial, but I am happy to assist in the overall narrative and can provide text and ideas, if need be. I already have a first MTK implementation of the system I linked to above, if that is of any help.
Merge with #1459 for MTK handling of DAE systems. I would add:
- symbolic arithmetic of parameters. At present, just numeric arithmetic is allowed;
- numeric evaluation of jacobian corresponding to the symbolic
calculate_jacobian
; - domains/intervals of parameters and variables in
ODAEProblem
as inPDEProblem
.
Have you come across MethodOfLines.jl
? It doesn't do everything you list here yet, but I think it's all within scope. @xtalax
@finmod MethodOfLines.jl
handles most of this, please reach out either with an issue there or on the julia slack @Alex Jones
with a system that you are trying to solve and I'd be happy to support you getting it working.
Hi,
I appreciate the offered support in using MethodOfLines.jl for automatic discretization of PDEs. Infact, this is part of my use case and so I definitely see myself coming back to that offer when the time comes.
However, this issue did not aim at the matter of MethodOfLines.jl (of any other package that might support the specific modeling task described in the original post. The modelling task was rather mentioned to demonstrate the need for telling newcomers in a streamlined way how to use MTK for such systems, going a bit beyond the examples and tutorials that are typically presented in talks and topics about MTK.
So in my opinion, this issue still has its reason to exist.
Am 17.03.2022 um 11:36 schrieb xtalax @.***>:
@finmod MethodOfLines.jl handles most of this, please reach out either with an issue there or on the julia slack @Alex Jones with a system that you are trying to solve and I'd be happy to support you getting it working.
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.
@xtalax Submitted a demo DAE problem specified in MTK at https://github.com/SciML/MethodOfLines.jl/issues/50 .
I agree with @rschiemann1 that a tutorial on DAE problems should remain in MTK where it is likely to get good visibility. MethodOfLines
is one of the solutions available to solve these DAE problems along with other issues like structural identifiability, sensitivity analysis and jacobian analysis. The common denominator provided by MTK is a symbolic specification as you would write it on paper without the clustering of definining functions
.
Another spectacular use of MTK is https://github.com/qojulia/QuantumCumulants.jl
Bump. If there is any interest from the main MTK developers to realize such a documentation, I am willing to help.
It would be nice. While people should be using MethodOfLines.jl for this specifically (and the tutorial should mention that), I think it would be good to have such a non-trivial example presented as a tutorial for how to use MTK. A good demo that is both non-trivial but also "large" is always a partial differential equation, so this makes sense. And showing how you can do algebraic boundary conditions would be a plus to show why MTK is so useful in this domain.
Maybe to keep people on their toes, doing a finite volume or something might be a way to twist it, but then again, for this kind of thing, simplifying out as much as possible is always good.
Thanks. Okay, so how should we get this started?
Try writing something, check it against MethodOfLines.jl, and start asking questions until the script works! Feel free to post WIP stuff to get help.
@rschiemann1 I have submitted a model DAE/ODE Problem specified in MTK with domains and BCs #50 to MethodOfLines as a prototype for a tutorial
@rschiemann1 I have submitted a model DAE/ODE Problem specified in MTK with domains and BCs #50 to MethodOfLines as a prototype for a tutorial
I just checked your model problem. To be honest, I don't see the connection to MethodOfLines (the code models a DAE problem, what is there to discretize?), but besides, it is a nice piece of code demonstrating some good approaches.
I have a few issues open here. As soon as they are closed, I will go ahead and try to get the tutorial done. When time has come, I will post WIP codes & text here.
I just checked your model problem. To be honest, I don't see the connection to MethodOfLines (the code models a DAE problem, what is there to discretize?),
@rschiemann1 Method of Lines.jl is a recent development to SciML aimed at showing when MOL is appropriate and when it is not.
The DAE tutorial that is required in MTK should mimic the methological steps and flowchart in https://reference.wolfram.com/language/tutorial/NDSolveDAE.html. How to code a DAE system: parameters, functions, equations, domains, constraints, re-arrange the DAE problem, index-lowering, numerical methods applicable and available in SciML etc. There is a ample section on examples in the Wolfram tutorial and the AkzoNobel example has been implemented in Julia here https://benchmarks.sciml.ai/html/DAE/ChemicalAkzoNobel.html but with no explanation on why and which numerical solution is being used and, again, this was before MethodOfLines.jl.
Thanks! Ok, so how should we get this started?
There's already multiple tutorials on this topic in http://methodoflines.sciml.ai/dev/ . Please open a more specific issue on MethodOfLines.jl if there's any issues with those tutorials