Тёмный
No video :(

Simulating Pipe Flow on a Staggered Grid in Python | with Inflow & Outflow 

Machine Learning & Simulation
Подписаться 23 тыс.
Просмотров 13 тыс.
50% 1

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 60   
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Note that some people refer to pipe flow also as channel flow. This is common in the OpenFoam community: www.openfoam.com/documentation/guides/latest/doc/verification-validation-turbulent-plane-channel-flow.html Thanks to @hk318i for pointing this out.
@trasor486
@trasor486 8 месяцев назад
usually i dont write comments, but i must say this video is the most usefull thing i found in a whole week of research in the entiry internet explaining how to implement things on a staggered grid practicly. I finally solved elastic wave equation on a staggered grid with your help. Thanks for that!!!
@MachineLearningSimulation
@MachineLearningSimulation 8 месяцев назад
Thank you so much for this amazing feedback ❤️ Before I created this video, I also struggled for a long time with a staggered grid implementation. No-one really practically walked me through how to navigate the "indexing-mess". So, I am very happy that this video is of great help! Thanks again for this kind feedback. :)
@h.e.a311
@h.e.a311 Год назад
excellent teacher, I learned from you
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Thanks :). You're welcome!
@haroldvallereyes2131
@haroldvallereyes2131 10 месяцев назад
What a great video!!!! Thanks for sharing this to everyone
@MachineLearningSimulation
@MachineLearningSimulation 10 месяцев назад
Thanks a lot 😊
@akingungormus7428
@akingungormus7428 9 месяцев назад
Genuinely amazing video and very well explained too! Definitely subscribed :D
@MachineLearningSimulation
@MachineLearningSimulation 8 месяцев назад
Thanks :). And welcome to the channel!
@kseniastern381
@kseniastern381 3 месяца назад
Thank you for the video. Very informative and helps a lot. I have a small question: Why there is no density in the equations? In NS equation it is exist. And one bigger question: Is it possible to include the heat transfer into this code with the same scheme as pressure update, or should be there a different way?
@pablobaezlinero4141
@pablobaezlinero4141 Год назад
Very nice video! As an interesting question, would it be possible to add a leakage in the pipe wall into this simulation? Keep this amazing content!
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Thanks for the kind words, appreciate it a lot 😊 I'm sure this is possible, similar to the outflow to the right, you could have a patch of the top boundary to be of a similar type. One then just has to ensure that the global mass inflow and mass outflow match (to ensure global incompressibility). One thing I am worried about though, is that depending on the size of the leakage (I think the smaller, the worse), you could already run into the turbulent flow regime for which this simulation is no longer accurate. However, I don't have any experience with leakage simulations, so take these words with a grain of salt. I hope they are still helpful 😊.
@AJ-et3vf
@AJ-et3vf 2 года назад
Awesome video! Thank!
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Thanks :)
@Rau379
@Rau379 4 месяца назад
Hello, thank you for the tutorial. It is very helpful. Could you answer a doubt? In the pressure boundary condition, could I do the Homogeneous Neumann everywhere and specify in a node ( any node inside the domain) pressure =0? Therefore, there aren't infinite solution, but one solution with zero in node which was specified.
@MachineLearningSimulation
@MachineLearningSimulation 4 месяца назад
You're very welcome. 😊 Yes, that's one way to fix the additional degree of freedom when solving pressure poisson problems.
@jimpal5119
@jimpal5119 2 года назад
Hi , very interesting video. As a suggestion , you could make a video about the numerical solution of elasticity equations. Keep it up!
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Great suggestion! This will definitely come in the future. Computational Fluid Dynamics, as presented so far, is just one of many nice simulation topics. I will note your suggestion down. Do you maybe have a concrete example, you think is particularly interesting?
@jimpal5119
@jimpal5119 2 года назад
@@MachineLearningSimulation Thank you for your quick response. Right now I'm trying to develop a 2d thermoelasticity solver , to simulate arc welding. Instead of FE , I'm experimenting with FV and FD schemes. It's quite an interesting take , since most elasticity solvers are FE based. Plus the elasticity equations are not as well covered (online at least) , so I think a lot of people will be interested. All the best !
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
@@jimpal5119 That's a great insight. I will note that particular application down. In particular, I would like to also have some FEM tutorials, including the challenges in assembles the sparse global matrix. You are right, elasticity equations are usually way less covered than NS equations for fluid flow.
@ariffatahillah2081
@ariffatahillah2081 7 дней назад
Hello, thank you for your tutorial video what if the pipe wall is elastic, like a blood vessel?
@MachineLearningSimulation
@MachineLearningSimulation 3 дня назад
Hi, thanks for the great question and for the kind feedback. 😊 Unfortunately, I don't have experience with modeling blood vessels. My first guess would be to decide how the fluid and the wall interact. If it is only the wall deforming, one could apply the movement as a respective Dirichlet boundary condition on the flow field. However, since the domain changes, it might require remeshing (and as such unstructured meshes) if no immersed boundary method is used. Either way, I guess that this might be beyond this simple method I presented in the video.
@michalislefkiou5505
@michalislefkiou5505 2 года назад
Again, amazing video! I would like to ask how do you make these nice Introduction comments with the figures?
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Hi, many thanks for the kind words. I'm happy that you're enjoying the videos. What exactly do you mean by introduction comments? Are you referring to the thumbnail, the section before the intro, the doc string in python or sth else?
@michalislefkiou5505
@michalislefkiou5505 2 года назад
@@MachineLearningSimulation for the doc string
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Oh, yes probably you mean how to create the charts and the mathematical characters. For the latter I use a website called "Unicode it", you could just Google "latex to Unicode". The charts are created by the "unicodecharts" library in Julia. I then just copy / paste them into the doc string?
@sudeephalder8792
@sudeephalder8792 Год назад
@@michalislefkiou5505 Can you please tell me where this scripts is written , I mean where ( terminal or something like that ???? I am using spyder , but it is not showing any plot even though I have used matplotlib for the same code and the code is running without producing the plots . please help
@atharvnaik
@atharvnaik 8 месяцев назад
Do you also include the ghost cells when you make the plots for velocity ?
@MachineLearningSimulation
@MachineLearningSimulation 8 месяцев назад
In the plotting section of the final code (github.com/Ceyron/machine-learning-and-simulation/blob/26de0997676a49bfcaab305076ae9795ef1d4420/english/simulation_scripts/pipe_flow_with_inlet_and_outlet_python.py#L552 ), the staggered grid (with the ghost cells) is transformed into a vertex centered collocated grid (without any ghost ceels). This includes the value on the boundary (that should adhere to the prescribed BCs). Ultimately, this grid is plotted. Hope that answers the question 😊. Let me know if it is still unclear.
@manostsistrakis8241
@manostsistrakis8241 Год назад
Hi. I really like your series of videos although this one has me a bit confused about the ghost cells. I am not entirely sure what they are referring to. Do we use them to refer to the boundary cell edges and if so why, for example, do we need to use the inside = -outside formula for the no slip condition instead of just setting them to zero?
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Hi, thanks for the comment and the kind feedback :). Ghost cells are cells that lie outside the domain, often used to enforce the boundary condition. We need them for the staggered grid, since some degrees of freedom do not end up lying directly on the boundary (but half a cell-length adjacent to it). Take for instance the y-velocities on the left boundary of the domain. In order to enforce a Dirichlet BC, we had to prescribe the value of the quantity on the boundary. We can do so by setting the average of the two to the desired. In a sense, this is just a linear interpolation between the value inside the domain closest to the boundary and the one in the ghost cell. Let's assume we had a wall (=no-slip) BC, where the value is homogeneous (=0). Then, we would get (v_out + v_in)/2 = 0. If you rearrange, you see that we enforce a homogeneous Dirichlet BC by v_out = - v_in Hope that helped :)
@manostsistrakis8241
@manostsistrakis8241 Год назад
@@MachineLearningSimulation Thank you for the quick feedback. Your answer makes perfect sense I am just not used to this method yet. I am trying to implement the staggered grid method to the lid-driven cavity problem because when I make the mesh finer I get a RunTimeWarning.
@MachineLearningSimulation
@MachineLearningSimulation Год назад
@@manostsistrakis8241 You're welcome :). The RunTimeWarning seems more like you are encountering NaNs (Not a Number) in your computation, which often happens if your simulation turns unstable. Probably, a staggered grid will not help you there. Your problem might be in an unstable choice of the delta-t.
@aliabdullah2474
@aliabdullah2474 Год назад
Hi! your videos have helped me a lot. I have to write a Large eddy simulation (LES) code for a turbulent flow in a duct/pipe. Can you suggest to me some video or literature which is as detailed and comprehensive as your videos?.
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Hi, thanks so much for the kind feedback :). I am happy if the videos are of help. Be aware that the solution strategies presented here are more proof-of-concept type approaches, they lack certain properties that you would for correct CFD simulations. Unfortunately, there are no equally comprehensible resources (yet) that go beyond toy examples. Some general literature recommendations are "Computational methods for fluid dynamics " by Ferziger and Peric as well as "The finite volume method in computational fluid dynamics" by Moukalled which comes with examples in MATLAB and OpenFOAM.
@mohamedelmalah6716
@mohamedelmalah6716 Год назад
Thanks a lot for the video. Many Thanks for your efforts. Could I ask you for something please, it would be great if you put a picture of the grid marking on it which is row 0, row -1 and so on and also for columns mark them. which is -2 and so on. It would clear any confusion.
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Hi, thanks for the comment, the kind word and the suggestion 😊 Can you elaborate a bit on this picture? How is it different from the one that is already in the docstring in the beginning of the file? If you already have a good visualization in an image format, feel free to open a pull request on GitHub 😊, then everyone could benefit.
@mohamedelmalah6716
@mohamedelmalah6716 Год назад
@@MachineLearningSimulation Hi, Thanks for the kind reply. I meant if you can add numbers beside rows and columns on the grid. During the video, you explain it by voice , I mean adding on every column if you could its number .In line code 290 , where is the column ( -2) . The video is very well prepared and as I am beginer, I could understand the method but my confusion is where is row number (-1) , where is column (-2) . That is why I asked , if you could put the numbers on columns and rows. You did by voice in some parts but it would be very helpful if you upload a picture with the structured grid with ghost cells but with numbering each row and each column and I do not know how to use GitHub. But I hope I could elaborate what I mean.
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Got you 👍 At the moment, my time is a bit limited to create such an image. If I remember correctly, then there are elaborate schematics in Versteeg's book.
@vishalkumar040393
@vishalkumar040393 4 месяца назад
Do you use fenicsx?
@MachineLearningSimulation
@MachineLearningSimulation 4 месяца назад
I haven't used it (yet). It's probably to be preferred over the legacy FEniCs.
@sudeephalder8792
@sudeephalder8792 Год назад
I am not having the plots , following error is showing. " operands could not be broadcast together with shapes (140,13) (14,139) " on the line of " updating x velocity ". Please help
@MachineLearningSimulation
@MachineLearningSimulation Год назад
Did you use the vanilla version from GitHub or did you do any modifications of the file? :)
@sudeephalder8792
@sudeephalder8792 Год назад
That problem has been resolved, but sir , I am not getting the steady state, before reaching to the steady state the flow is getting vanished . Can you pl tell me the possible mistakes for it?? I have used the same boundary condition And one more thing , can you please reply to my mail, I guess I would require you going forward, if possible kindly reply me in my mail. I have already sent you a mail.
@rahulagarwal2555
@rahulagarwal2555 2 года назад
Hello, I have been trying to solve the temperature equation on this grid; however, I am getting broadcasting error. Can you kindly help with this?
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
I can try ;)
@rahulagarwal2555
@rahulagarwal2555 2 года назад
@@MachineLearningSimulation Hey, Thanks for reply. I have written the code, but it doesn't seems to run as expected. Is it possible if you can check it once?
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Unfortunately, I can't check full code bases, that exceeds my available time 😅 If you can reduce it to a minimal working example and post it here, I will give a look.
@rahulagarwal2555
@rahulagarwal2555 2 года назад
@@MachineLearningSimulation Hey, thanks for the reply. Here is the code pertaining to energy equation only - - - # Initial condition temperature_prev = np.ones_like(pressure_prev) temperature_next = np.ones_like(temperature_prev) temperature_centered = np.zeros((N_POINTS_Y, n_points_x)) # For visualization for iter in tqdm(range(N_TIME_STEPS)): temperature_diffusion = ( ( + temperature_prev[1:-1, 2: ] + temperature_prev[2: , 1:-1] + temperature_prev[1:-1, :-2] + temperature_prev[ :-2, 1:-1] - 4 * temperature_prev[1:-1, 1:-1] ) / ( cell_length**2 ) ) temperature_advection_x = ( ( velocity_x_prev[ :-2, :-1] + velocity_x_prev[ :-2, 1: ] + velocity_x_prev[2: , :-1] + velocity_x_prev[2: , 1: ] ) / 4 * ( temperature_prev[1:-1, 2: ] - temperature_prev[1:-1, :-2] ) / ( 2 * cell_length ) ) temperature_advection_y = ( ( velocity_y_prev[ :-1, :-2] + velocity_y_prev[ :-1, 2: ] + velocity_y_prev[1: , :-2] + velocity_y_prev[1: , 2: ] ) / 4 * ( temperature_prev[ :-2, 1:-1] - temperature_prev[2: , 1:-1] ) / ( 2 * cell_length ) ) temperature_next[1:-1, 1:-1] = ( temperature_prev[1:-1, 1:-1] + TIME_STEP_LENGTH * ( temperature_diffusion - ( temperature_advection_x + temperature_advection_y ) ) ) # Advance in time temperature_prev = temperature_next # Visualization if iter % PLOT_EVERY == 0: for j in range(0, np.size(N_POINTS_Y) - 1): for i in range(0, np.size(n_points_x) - 1): temperature_centered[i][j] = ( temperature_next[i][j] + temperature_next[i+1][j] + temperature_next[i][j+1] + temperature_next[i+1][j+1] ) / 4 plt.contourf( coordinates_x, coordinates_y, temperature_centered, levels=20, )
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
@@rahulagarwal2555 Can you also send the error message that is printed when you run the code?
@aliabdullah2474
@aliabdullah2474 2 года назад
Hi! Great work. I just wanted a bit of help with the equation used to update the velocities (u + dt ⋅ (− ∂p/∂x + ν ∇²u − ∂u²/∂x − v ∂u/∂y)). Can you refer me some literature where I can find its derivation? I will be grateful for your help.
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
Hi, thanks for the comment :). This update process arises, once you discretize the momentum equation with an Explicit Euler time stepping. This introduces a u at the next point in time and one at the current point in time. Then, you rearrange for the u at the next point in time. You can do this, because for this video all other terms in the equation (diffusion & convection) are treated explicitly. In simple terms, the NS equations are: du/dt + convection = - pressure grad + diffusion Then you discretize (u_next - u_prev)/dt + convection_prev = - pressure_grad_prev + diffusion_prev Then you rearrange for u_next u_next = u_prev + dt * (- pressure_grad_prev + diffusion_prev - convection_prev) Hope that helped :)
@aliabdullah2474
@aliabdullah2474 2 года назад
@@MachineLearningSimulation Thank you so much it clear now.
@MachineLearningSimulation
@MachineLearningSimulation 2 года назад
@@aliabdullah2474 Beautiful, you're very welcome!
Далее
Flow over backward facing step simulation in Python
42:07
Coding Adventure: Simulating Fluids
47:52
Просмотров 1,8 млн
Reforged | Update 0.30.0 Trailer | Standoff 2
02:05
Просмотров 682 тыс.
But How DO Fluid Simulations Work?
15:12
Просмотров 375 тыс.
Writing a Turbulence Simulation in Julia
43:11
Просмотров 6 тыс.
Fourier Neural Operators (FNO) in JAX
1:06:55
Просмотров 7 тыс.