🚀 Interested in learning Python for #science and #Engineering applications? Enroll in my #Udemy course for a complete bootcamp on mastering the essentials! 🔗www.udemy.com/course/python-for-science-engineering-the-bootcamp/?referralCode=24D9604B8C46B65E9E7E
As straightforward as this solution is, I believe it needs to be mentioned: this approach is extremely inefficient. It has time complexity O(N^2), which renders the method practically useless when applied to models/systems with a large number of cells (which ultimately is what one will have when doing serious work). A much more efficient code can be made by adjusting to use scipy's sparse module and solvers for sparce matrices. A good video nonetheless, if you want to get a preview of how the finite-difference method works ;) just mentioning a relevant computational aspect
Using a pre built library/code will render a math video useless. I, like many others, have come here to learn math not a fancy python library. Good work younes!
No need for the cheeky answer, I was just trying to mention the info for people who are more interested in the performance aspect and are maybe looking for such implementations. @@jawadmansoor2456
@@ssrini2002 I couldn't find any videos actually, there are a couple of websites with code examples, just google "python diffusion sparse matrix" and you'll find them quickly. Although, seeing as there's no videos about this, I might make one myself :)
If you are getting an "IndentationError: unexpected indent" this means there is a problem with the indentation (tabbing) of the line, make sure to delete the tabs and manually re do it.
Thank you for your feedback ^^ Personally I am not that familiar with cuda (though this surely is motivating me to make a video about it 🤔) However there are several techniques you can use drastically improuve the speed (method I discoreved after making the video) * writing the main calculations as a function, then using numba's jit to optimize the computation (by chacing it, ...) * Important note: since the result of each iteration is more or less dependent on the one before, parallezing will most likely not work, however one trick you can use is to vectorize the code by, instead of writing it in form of a loop, you replace it by some sort of linear system of equations A*T = b, which will be way faster since it uses linear algebra to find the solution (using numpy)
keep going bro , we need more solving physics problem using python , I hope if you have a vid about heat diffusion resolution for rectangular section fins and temperature profiles and thanks in advance bro
The formulas represent an approximation of derivative via a method called "the finite difference method" often called FDM, this method represent a simple but powerfull technique for solving differential equation related problems (especially flow/heat problems) If you want to learn more about it I suggest you to watch another video I made (part 1) th-cam.com/video/ZuxAZxguv-0/w-d-xo.html
Could anyone explain why is it necessary to use a copy of array u in the scheme equation? I know that it gives slightly different results if we just rewrite u array in each loop, thanks
Hello! We use a separate copy of the array `u` because it represents the temperature distribution at a specific time, `t`. When we discretize our equation in time and space, we get: u[t+1, i] = (dt * a / dx^2) * (u[t, i-1] - 2 * u[t, i] + u[t, i+1]) + u[t, i] In this equation, `u[t, ...]` represents the temperature distribution at time `t`. By updating `u` using a while loop, we ensure that the computation of the distribution at all nodes is accurate for time `t`. If we don't use a copy of `u`, we end up computing the solution at `t+1` using a mixture of data from both `t` and `t+1`. For example, without a copy, `u` is updated dynamically, and when computing each node [i], the left node [i-1] is used from time `t+1` while the right node [i+1] is still from time `t`. This leads to: u[t+1, i] = (dt * a / dx^2) * (u[t+1, i-1] - 2 * u[t, i] + u[t, i+1]) + u[t, i] This does not conform to the established numerical scheme. I hope this clarifies why it's necessary to use a copy of the array `u` in the scheme equation. Let me know if you have any other questions! :)
Thank you for this tutorial. Please show me how to plot 3D graph of Riemann Zeta function where we can see the pole at s = 1 + j0, and trivial as well as nontrivial zeroes; the vertical axis shows the magnitude of the output and the color codes the phase angle. Thank you very much beforehand.
That true thank you for letting me knoy, I will fix it in the Git-Hub code. If we have `n` interval we always have `n+1` nodes. When considering the simple example of a 1 meter long rod with two nodes, lenght = 1, and dx = 1 meaning nodes = lenght//dx + 1
🚀 Interested in learning Python for #science and #Engineering applications? Enroll in my #Udemy course for a complete bootcamp on mastering the essentials!
🔗www.udemy.com/course/python-for-science-engineering-the-bootcamp/?referralCode=24D9604B8C46B65E9E7E
Incrível, mano! Recentemente fiz um trabalho sobre a equação de calor e seu vídeo me deu uma nova perspectiva do que eu havia feito. Parabéns!
Stability of solution also accuracy comparing with another solutions .. Thanks alot .
This might be the subject of the next video, Thank you for you suggestion!
As straightforward as this solution is, I believe it needs to be mentioned: this approach is extremely inefficient. It has time complexity O(N^2), which renders the method practically useless when applied to models/systems with a large number of cells (which ultimately is what one will have when doing serious work). A much more efficient code can be made by adjusting to use scipy's sparse module and solvers for sparce matrices.
A good video nonetheless, if you want to get a preview of how the finite-difference method works ;) just mentioning a relevant computational aspect
Using a pre built library/code will render a math video useless. I, like many others, have come here to learn math not a fancy python library.
Good work younes!
No need for the cheeky answer, I was just trying to mention the info for people who are more interested in the performance aspect and are maybe looking for such implementations. @@jawadmansoor2456
Could you recommend a video that uses that library please?
@@ssrini2002 I couldn't find any videos actually, there are a couple of websites with code examples, just google "python diffusion sparse matrix" and you'll find them quickly.
Although, seeing as there's no videos about this, I might make one myself :)
Thank you for your comment @vikinja121 and for the clarification
Awesome tutorial! I recommend you use libraries like manim for 3d visualizations as well!
in line 52 (5:49) it says "IndentationError: unexpected indent" after having copied and pasted the code from your github
If you are getting an "IndentationError: unexpected indent" this means there is a problem with the indentation (tabbing) of the line, make sure to delete the tabs and manually re do it.
Wonderful! Tank you!
can you use this method if one of your boundary conditions is on T'(x=L), not T(x=L)?
Hi! It's very awesome video and very straight forward! A quick question, do you know if there's any chance to speed up the process with cuda?
Thank you for your feedback ^^
Personally I am not that familiar with cuda (though this surely is motivating me to make a video about it 🤔) However there are several techniques you can use drastically improuve the speed (method I discoreved after making the video)
* writing the main calculations as a function, then using numba's jit to optimize the computation (by chacing it, ...)
* Important note: since the result of each iteration is more or less dependent on the one before, parallezing will most likely not work, however one trick you can use is to vectorize the code by, instead of writing it in form of a loop, you replace it by some sort of linear system of equations A*T = b, which will be way faster since it uses linear algebra to find the solution (using numpy)
What software do you use @Younes
If you mean for making the simulation i only used Visual Studio Code (for python IDLE)
keep going bro , we need more solving physics problem using python , I hope if you have a vid about heat diffusion resolution for rectangular section fins and temperature profiles and thanks in advance bro
I will be sure to make these in the future, thank you for your feedback!
Hello Sir is there the possibility you can help me with a project in which I will need to use BTCS for a heat transfer problem ?!
where do you take all formulas, for example that for get dd_ux and dd_uy ^
The formulas represent an approximation of derivative via a method called "the finite difference method" often called FDM, this method represent a simple but powerfull technique for solving differential equation related problems (especially flow/heat problems)
If you want to learn more about it I suggest you to watch another video I made (part 1) th-cam.com/video/ZuxAZxguv-0/w-d-xo.html
Could anyone explain why is it necessary to use a copy of array u in the scheme equation? I know that it gives slightly different results if we just rewrite u array in each loop, thanks
Hello!
We use a separate copy of the array `u` because it represents the temperature distribution at a specific time, `t`. When we discretize our equation in time and space, we get:
u[t+1, i] = (dt * a / dx^2) * (u[t, i-1] - 2 * u[t, i] + u[t, i+1]) + u[t, i]
In this equation, `u[t, ...]` represents the temperature distribution at time `t`. By updating `u` using a while loop, we ensure that the computation of the distribution at all nodes is accurate for time `t`.
If we don't use a copy of `u`, we end up computing the solution at `t+1` using a mixture of data from both `t` and `t+1`. For example, without a copy, `u` is updated dynamically, and when computing each node [i], the left node [i-1] is used from time `t+1` while the right node [i+1] is still from time `t`. This leads to:
u[t+1, i] = (dt * a / dx^2) * (u[t+1, i-1] - 2 * u[t, i] + u[t, i+1]) + u[t, i]
This does not conform to the established numerical scheme.
I hope this clarifies why it's necessary to use a copy of the array `u` in the scheme equation. Let me know if you have any other questions! :)
Please make more videos of coding on heat transfer and fluid mechanics. Thank you very much!
could you do code of "Tutorial: How to simulate the wave equation" video by Nils Berglung
Great suggestion thank you ^^' ! I will plan on doing this video about the wave equation it will be an interessting subject (in a couple of weeks)
@@YounesLab thanks
Nice one! :)
Thank you for this tutorial. Please show me how to plot 3D graph of Riemann Zeta function where we can see the pole at s = 1 + j0, and trivial as well as nontrivial zeroes; the vertical axis shows the magnitude of the output and the color codes the phase angle. Thank you very much beforehand.
Thank you for your Comment. Very Interesting function and Idea, I will look forward into making it.
Formula for dx is incorrect, it should be dx = length / (nodes-1)
That true thank you for letting me knoy, I will fix it in the Git-Hub code.
If we have `n` interval we always have `n+1` nodes. When considering the simple example of a 1 meter long rod with two nodes, lenght = 1, and dx = 1 meaning nodes = lenght//dx + 1
Bro kindly make more videos in hindi