Finite Element Method in FEniCS: 1D Transient Heat Diffusion in detail
FEM problems can be easily solved in Python by providing the weak form of the PDE as well as the Boundary Condition and Initial Condition to Fenics. In this video, we will go over all steps in detail, incl. Function Spaces and deriving weak forms. Here are the notes: github.com/Ceyron/machine-lea...
This video is an in-detail extension of a previous video, in which we just did a quick and simple demo. Feel free to check this one out first: • Fenics Tutorial: 1D He...
You can find the source-code as written in the video (with slightly more explaining comments): github.com/Ceyron/machine-lea...
Fenics is a software that allows to easily solve Partial Differential Equations in Python. PDEs arise in many disciplines, e.g., in Continuum Mechanics for fluid and solid simulations.
-------
📝 : Check out the GitHub Repository of the channel, where I upload all the handwritten notes and source-code files (contributions are very welcome): github.com/Ceyron/machine-lea...
📢 : Follow me on LinkedIn or Twitter for updates on the channel and other cool Machine Learning & Simulation stuff: / felix-koehler and / felix_m_koehler
💸 : If you want to support my work on the channel, you can become a Patreon here: / mlsim
-------
⚙️ My Gear:
(Below are affiliate links to Amazon. If you decide to purchase the product or something else on Amazon through this link, I earn a small commission.)
- 🎙️ Microphone: Blue Yeti: amzn.to/3NU7OAs
- ⌨️ Logitech TKL Mechanical Keyboard: amzn.to/3JhEtwp
- 🎨 Gaomon Drawing Tablet (similar to a WACOM Tablet, but cheaper, works flawlessly under Linux): amzn.to/37katmf
- 🔌 Laptop Charger: amzn.to/3ja0imP
- 💻 My Laptop (generally I like the Dell XPS series): amzn.to/38xrABL
- 📱 My Phone: Fairphone 4 (I love the sustainability and repairability aspect of it): amzn.to/3Jr4ZmV
If I had to purchase these items again, I would probably change the following:
- 🎙️ Rode NT: amzn.to/3NUIGtw
- 💻 Framework Laptop (I do not get a commission here, but I love the vision of Framework. It will definitely be my next Ultrabook): frame.work
As an Amazon Associate I earn from qualifying purchases.
-------
Timestamps:
00:00 Intro
00:48 Initial-Boundary Value Problem
03:48 Initial Condition & Expected Behavior
05:12 Discretization into Finite Elements
06:14 Ansatz/Shape Function
08:16 Discrete PDE solution
11:41 Function Spaces (Lagrange Polynomials)
12:38 Code: Overview
12:51 Code: Mesh Discretization
13:34 Code: Function Space
14:59 Code: Translate IC & BC
19:40 Code Recap
20:02 Why we need the weak form?
21:06 (1) Multiply with test function
21:41 (2) Integrate over domain
22:10 (3) Integration by parts
23:13 What is the test function?
25:21 Vanishing Boundary Evaluation
25:47 Discussing the weak form
26:16 Weak form in residuum form
26:50 Discretization in time
30:27 Fenics wants multi-dim weak form
30:51 Weak form in high dim case
34:08 Multi dimensional integration by parts (divergence theorem)
40:30 Comparison with 1D case
41:25 Summary of high-dim weak form
41:59 Temporal Discretization in high-dim case
42:35 Final Weak Form for Fenics
43:36 Code: Defining Test & Trial Functions
44:38 Code: Weak Form Residuum
47:05 Code: Separate into lhs & rhs
47:49 Code: Time Loop & Simulation
50:20 Code: Adjusting Plot Visuals
51:08 Code: Running & Discussion
51:57 Outro
Пікірлер: 62
for anyone watching this in 2024 or later, do "Import dolfin as fe" and the rest of the code should work
@vishalkumar040393
Ай бұрын
does this works with dolfinx?
@alikoulani5446
Ай бұрын
@@vishalkumar040393 i dont think so, the change from dolfin to dolfinx was beyond my understanding of python and FEM maybe Herr Köhler can provide us with some new videos :D
YOU ARE EXPALINED IN A VERY GOOD WAY
@MachineLearningSimulation
Жыл бұрын
Thanks for the kind words 😊 much appreciated.
You did a good job! Thank you very much! you explained in very simple way, how to work with Fenics which is a big help is for a lot of researchers!
@MachineLearningSimulation
7 ай бұрын
Thanks a lot 😊 I'm very happy I could help. The videos are also helpful for me to solidify my knowledge. It's a win-win 😊
Thank you very much for your excellent sharing! I like your detail explanations and steps which solved lots of questions in my mind in the past......Thank you so much! A greeting from Taiwan.......
@MachineLearningSimulation
Жыл бұрын
You're very welcome :). Thanks a lot for your generous donation. I also struggled for a long time for understanding the weak form derivations and their implementations. I am super happy that my approach in teaching is helpful. ❤️
excellent video, thank you for this!
@MachineLearningSimulation
Жыл бұрын
You're very welcome!
Great video! Thank you!
@MachineLearningSimulation
Жыл бұрын
Glad you liked it!
Thank you so much dear, Now things are easy to understand.
@MachineLearningSimulation
5 ай бұрын
You're welcome :). Thanks for the kind comment!
Very useful for us, CES and SiSc students at RWTH and TUM. Vielen Dank:)
@MachineLearningSimulation
5 ай бұрын
You're welcome :). Always happy to help out fellow CSE students.
@kavoshgar9733
4 ай бұрын
@MachineLearningSimulation Actually your videos help a lot
you explained to good, kindly also make videos on Laplace equations
@MachineLearningSimulation
2 жыл бұрын
Thanks a lot for the kind words ☺️ There will a video on the poisson equation soon .
Hi thank you so much for your great video series about FeniCs. Could you please update them with the updated version of Fenics?
@MachineLearningSimulation
8 ай бұрын
You're very welcome 🤗 It is already on my To-do list. However, for now I want to focus on other topics. Might return to FEniCs in the next year 😊
thank you:)
@MachineLearningSimulation
Жыл бұрын
You're welcome!
Great video! I was wondering if one could specify custom (user-defined) trial and test functions with FEniCS
@MachineLearningSimulation
Жыл бұрын
Thanks for the comment and the kind words :). I'm unsure. You probably have to consult the fenics documentation. Until now, I've never had the need for anything beyond the standard finite Elements.
Another great video - quick question, do the trial functions need to always be zero on the boundaries, or match the boundary values (on the boundaries). If they dont equal zero on the boundaries, what happens to the boundary term? It becomes like a source term maybe? Thanks again :clap
@MachineLearningSimulation
2 жыл бұрын
You're very welcome. I'm glad you enjoy the videos 😊 The trial functions are the prototype for the unknown in the weak form, so they should match the boundary conditions you prescribe to the unknown function in the PDE. I really like your question. It portrays some of the difficulties in boundary handling with CFD. I will probably have to take the time to give it a proper answer. Maybe also in a future video. Stay tuned 😉
@icojb25
2 жыл бұрын
@@MachineLearningSimulation Hi, thanks for the answer. Imade an error, i meant the >test< functions! the one that causes the first trm of the integration by parts to go to zero. Sorry.
This was very useful!! Thank you so much!! Can you please make a video on how to solve helmholtz pde in BEMPP (boundary element method python package) for acoustic simulations?
@MachineLearningSimulation
Ай бұрын
Thanks for the kind comment ❤️ you're very welcome. I am not familiar with neither the Helmholtz pde, Nor the bempp package. As far as I see, this Helmholtz pde essentially is a poisson problem. Maybe you find this video of mine helpful: kzread.info/dash/bejne/gWuamqRrl7Pgg8Y.html
thanks for the very nice video. Does "ansatz" mean "trial" ? I get confused. Thanks.
@MachineLearningSimulation
2 жыл бұрын
You're very welcome 😊 I'm glad you liked the video. Yes, that was a little unclear in the video. Here, those two can be considered the same
Kindly make a video on phase field model for brittle material implementation in fenics.
@MachineLearningSimulation
Жыл бұрын
Hi, thanks for the comment. :) I will note your idea down, but I am not too familiar with this topic. I might cover it in the far future.
Can we also use fenics to solve the nonlinear heat equation, i.e. the case were the diffusivity depends on temperature?
@MachineLearningSimulation
Ай бұрын
I'm pretty sure this is possible. If you check out the fenics documentation you will find a section on solving nonlinear PDEs with newtons method.
Which editor are you using?
@MachineLearningSimulation
2 жыл бұрын
That's Visual Studio Code with the Python Extension. For the video, I only record the editor view.
which is better for CFD and thrmal simulations: machine learning, data science, or AI? if I want to learn one of these which one you recommend the most?
@quantitativefinance4103
2 жыл бұрын
Openfoam C++
@Michallote
2 жыл бұрын
None of those to be honest. CFD is it's own thing. Combining any of the above is subject of ongoing research. Not for begginers.
@MachineLearningSimulation
2 жыл бұрын
The three terms you mentioned are quite close and could be described as data-based science. If you want to learn CFD and thermal simulations, it's best to start from mathematical modeling. In particular, for thermal simulations in solids, the heat PDE (as also discussed in this video) is a great start. I would recommend looking a bit at the analytical and the numerical treatment of it. Afterwards, you can slowly build up to the Navier-Stokes equations. As @Mich Gordilla pointed out, the combination of CFD with any of your mentioned data-driven disciplines is at the frontier of current research. It is definitely out of the scope for a beginner. I hope that answered your question a bit :). Feel free to ask a follow-up question if something is unclear.
I want to learn fenics for constitutive modelling of viscoelastic materials Can you suggest some sources to study fenics.
@MachineLearningSimulation
2 жыл бұрын
Hey, thanks for the comment 😊 I haven't used fenics for this use case yet, but I'm certain it is a good fit for solving any PDE. A good resource to start with fenics in general is the "fenics tutorial" by h.p. langtangen. The video series I have on fenics, is also inspired by it. For your particular use case it might also be helpful to search for GitHub repos in which people might have used fenics to solve a similar problem. This can be inspiring. Good luck learning fenics 👍 P.S.: also be aware that fenics is under heavy re-development at the moment, shifting towards "fenicsx" which has a slightly different interface
@mdAman-xq5ww
2 жыл бұрын
Thanks for replying your videos helps alot.....
@MachineLearningSimulation
2 жыл бұрын
@@mdAman-xq5ww You're welcome :). I'm super happy to help!
PLEASE MAKE THE VIDEO POSSION EQUATION IN TWO DIEMENSION
@MachineLearningSimulation
Жыл бұрын
There is already a coding tutorial available: kzread.info/dash/bejne/gWuamqRrl7Pgg8Y.html 😉
@MachineLearningSimulation
Жыл бұрын
The derivations of the weak form for Poisson's equation is quite similar to those for structural mechanics. If you want more details, check out this one: kzread.info/dash/bejne/jGF60LJrndzce9o.html 😊
@minhaanees276
Жыл бұрын
@@MachineLearningSimulation oo thank you 😊
Hi please makes a video in fenicsx
@MachineLearningSimulation
Жыл бұрын
At a certain point, there will be, but I can't promise when. It is currently not on top of my interests. A big motivation for the channel, is just following my curiosity. If I stopped this, the channel would probably fade out. Hope you can understand that 😊
Hey, sehr starkes Video sind sie deutscher wenn ich fragen darf😅
@MachineLearningSimulation
2 жыл бұрын
Hi, danke für das Kommentar 😊 Genau, ich bin deutscher, merkt man leicht am Akzent, richtig?
Second 😁
@MachineLearningSimulation
2 жыл бұрын
Nice! :) Good to have you back.
@jimpal5119
2 жыл бұрын
@@MachineLearningSimulation I see you did make a FE video. A suggestion I have , which i think might interest you , is Petrov -Galerkin methods for fluids. Or just Taylor-Hood element solutions of the Stokes problem. Anyways , excellent content as always!
@MachineLearningSimulation
2 жыл бұрын
@@jimpal5119 Yes, that's a great idea. A video on FEniCS for Navier Stokes is already in the making. In my schedule it's also the next one to be uploaded next week. Stay tuned ;)
@jimpal5119
2 жыл бұрын
@@MachineLearningSimulation Damn , did not expect that! Definitely looking forward to it!
I also suggest Gridap.jl as a much closer to the written math version of FEniCS.
@MachineLearningSimulation
2 жыл бұрын
That's a great suggestion. I've also been reading a little into their docs and might do a video about the library in the future 👍