PETSc Tutorial: Implicit 1D Heat Diffusion

  Рет қаралды 3,591

Machine Learning & Simulation

Machine Learning & Simulation

Күн бұрын

Пікірлер: 26
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
A small correction: I wrongly spelled PETSc as "PetSc" in the video. The source-code on GitHub has been fixed: github.com/Ceyron/machine-learning-and-simulation/blob/main/english/petsc/petsc_python_simple_heat_diffusion_1d.py And a pointer to the great collection of petsc4py demos, that could help you get started in more complicated scenarios (also with MPI): gitlab.com/petsc/petsc4py/-/tree/master/demo
@Ken-v1w
@Ken-v1w 8 ай бұрын
Thank you for sharing this useful tutorial. Hope to see more contents about PETSc and petsc4py!
@MachineLearningSimulation
@MachineLearningSimulation 8 ай бұрын
Thanks for the kind comment 😊. Yes, I do have some more PetSc videos on my To-do list. There is a lot to show. For now, I follow more closely what I also do in my PhD, but there is definitely the plan to continue with the PetSc series at some point 😊
@asdf7777asd
@asdf7777asd 4 ай бұрын
Thaks for sharing this useful tutorial.
@MachineLearningSimulation
@MachineLearningSimulation 3 ай бұрын
You're welcome 🤗
@SO-dl2pv
@SO-dl2pv 2 жыл бұрын
Thank you very much for sharing your amazing work! Could you please do more videos about PETSc, I can't find any useful resources on internet to learn it. Thank you
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
Hey :) Thanks for the comment, really appreciate your feedback. Sure, there will of course be more videos on PETSc, but unfortunately not in the near future. I am currently trying to continue on some older Playlists. Maybe in ~2 months I will return to the PETSc Playlist. :) In the meantime, maybe you find this collection of demos helpful: gitlab.com/petsc/petsc4py/-/tree/master/demo
@chenguangzhang8292
@chenguangzhang8292 2 жыл бұрын
Great job! By the way, what's the editor or IDE you were using? I like its rendering of equations.
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
Thanks a lot for the feedback, :) Much appreciated. I am using VS Code, the equations consist of Unicode symbols. I use the website www.unicodeit.net/ for this.
@chenguangzhang8292
@chenguangzhang8292 2 жыл бұрын
@@MachineLearningSimulation Thank you. I always dream of an editor that can render markdown comments in-place within the code. I guess there is still a long way to go. Anyway, thanks for the website!
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
​@@chenguangzhang8292 You're welcome :) Maybe you find this helpful: marketplace.visualstudio.com/items?itemName=devzstudio.emoji-snippets
@jerryli30
@jerryli30 2 жыл бұрын
thank you, this is very useful for my summer research! We are changing the implementation of one of our solvers from scipy to PETSc
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
Wonderful! :) I'm glad I could help.
@OdhranOC
@OdhranOC 2 жыл бұрын
Very useful stuff. Love the Python simulations. One question - why use manual differencing schemes when there exists packages like odeint or solve_ivp? Also I am curious to know if you know of other channels like this that use Python for CFD simulations?
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
Good question! And thanks for the kind words. :) It's indeed possible. We could frame a mapping from a previous state to the derivative d(u)/d(t) as a function and then feed it into any ode integrator. Indeed, it can actually be beneficial, for instance, if we are not too interested in the temporal trajectory and then an adaptive integrator can make quite large time steps. I was not doing it here has two reasons: 1) It would be a bit too complicated. This video was aimed to be a super simple introduction to PetSc, and it can be quite some fiddling to get the interface with functions etc. correct. But, of course, that does not mean it's impossible. PetSc also has many great ODE steppers, and could use them in this semi-discrete "method-of-lines"-fashion 2) An argument against using ODE integrators is that the overall order of convergence of any discretized PDE is dominated by the order of convergence of the approximation with the lowest order. In other words: If we used a Runge-Kutta 4 integrator, which is consistent of order 4, and keep a Central difference approximation to the second derivative, which is consistent of order 2, our total order of convergence would be 2. Then we somehow used "a more expensive integrator" than necessary. Therefore, one commonly tries to balance the order of consistencies between all involved operators. Btw, that's also the reason one mostly only sees commercial CFD codes up to order 2 in convergence, with 2 being kind of the sweet spot there. But order of convergence is not everything. The usually interesting quantity is the efficiency of a numerical scheme, kind of defined as accuracy over computational cost. It is super hard to assess and highly problem- and scheme-dependent. In some cases, therefore, you see a higher efficiency when using a high-order ODE integrator together with a second-order spatial approximation. And regarding your question for KZbin channel. There are not much yet, unfortunately. That's also the reason this channel here exists ;). So I would extremely appreciate if you could spread the word and recommend the channel to your peers and colleagues. Though, one channel I liked was kzbin.info
@uqyge
@uqyge 2 жыл бұрын
really nice work
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
Thanks a lot
@learnmore_today
@learnmore_today 2 жыл бұрын
Thank you for the video. Could you please do the same video but with Fortran ? I couldn't find anything as straightforward with Petsc in Fortran. And if you could make it in two parts it will be great: One without MPI and one with MPI. Thanks again!
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
You're very welcome :). Thanks for the comment. I want to continue in the PETSc playlist, but I am currently working on the other series. I think I will return to it in a couple of months and will then also focus on implementations in FORTRAN. :) There is so much to show from PETSc, also with regard to MPI-based parallelism. Sorry for the potential delay between the comment and release of the video. Maybe you can find help on the PETSc website until then.
@learnmore_today
@learnmore_today 2 жыл бұрын
@@MachineLearningSimulation I'll be waiting. Thanks again!
@lodo9787
@lodo9787 Жыл бұрын
How can I open PETSC?
@MachineLearningSimulation
@MachineLearningSimulation Жыл бұрын
Hi, thanks for the comment 😊 I'm not quite sure what you mean. Do you want to install petsc4py (the package I used in this video), then I'd suggest to take a look at the installation instructions. This might be what you're looking for: www.mcs.anl.gov/petsc/petsc4py-current/docs/usrman/install.html
@qwm1007
@qwm1007 2 жыл бұрын
A bit hard but interesting. Thank you.
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
Hey, thanks for the feedback :) I would be interested to know what spots in the video were particularly difficult? I could use that as input to put more emphasis on certain parts in the next video. Happy to hear your thoughts :)
@qwm1007
@qwm1007 2 жыл бұрын
@@MachineLearningSimulation I was confused by PETSc notations, but other things are clear. Why do we need line 110, why do we need to initialize it?
@MachineLearningSimulation
@MachineLearningSimulation 2 жыл бұрын
​@@qwm1007 Hey, I can understand the confusion. petsc4py has a rather un-pythonic interface. The initialization is kind of an artifact of how you would program MPI software. Take a look here: mpitutorial.com/tutorials/mpi-hello-world/ MPI_Init is always the first call to the MPI library on a node before any other MPI commands are allowed. It basically takes all the necessary flags the python file is execute with (which are saved in the sys.argv list) and extracts what is relevant for it. By this PETSc also figured out that we wanted the monitoring which we do towards the end of the video. Hope that helped :)
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 121 М.
The longest mathematical proof ever
19:30
Dr. Trefor Bazett
Рет қаралды 48 М.
Как не носить с собой вещи
00:31
Miracle
Рет қаралды 1 МЛН
Я сделала самое маленькое в мире мороженое!
00:43
Кушать Хочу
Рет қаралды 4,9 МЛН
小蚂蚁会选到什么呢!#火影忍者 #佐助 #家庭
00:47
火影忍者一家
Рет қаралды 120 МЛН
Oh, wait, actually the best Wordle opener is not “crane”…
10:53
Implementation of Heat diffusion equation (1D) using python | PDE with Python
25:22
What P vs NP is actually about
17:58
Polylog
Рет қаралды 114 М.
Map Men vs. Geoguessr
28:07
Jay Foreman
Рет қаралды 991 М.
Implicit Method for single-phase flow equations
20:58
PGE 323M Reservoir Engineering III (Simulation)
Рет қаралды 4,8 М.
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Рет қаралды 252 М.
Solving the heat equation | DE3
14:13
3Blue1Brown
Рет қаралды 1,3 МЛН
Fourier Neural Operators (FNO) in JAX
1:06:55
Machine Learning & Simulation
Рет қаралды 9 М.
Как не носить с собой вещи
00:31
Miracle
Рет қаралды 1 МЛН