If you'd like to use RK4 in conjunction with the Finite Difference Method watch this video • MATLAB Help - Finite D... Code in this video github.com/cmo... Textbook on Numerical Methods github.com/cmo...
Hey! That helped a lot. I am currently struggling with a question that has been set and I was hoping that you could lend a hand? A subterranean structure is to be constructed in the vicinity of a tidal river. For simplicity we will assume that the site is at a constant level. Using a finite difference analysis you must analyse the underlying groundwater level and propose an appropriate pumping network to aid construction. The river through the site can be described parametrically with t ∈ [0, 1]. x = 2000t y = 462 ± 15 − 25.4t − 4028t^2 + 7004t^3 − 2763t^4 The total extent of the site is a rectangle of Lx = 2000 m Ly = 1000 m, with K = 6.2 × 10^−4 ms−1. Note that where river intersects the site the groundwater level may be assumed to be 0 m. The boundaries of the site may be modelled such that the y = 0 m has a head of 3 m and y = 1000 m has a head of 5 m. As the variation along the x boundaries are not known we assume that the flow is perpendicular to the boundary. i.e. there is no variation in head in the y direction. B1. The groundwater level across the site can be approximated using the Laplace equation. Following a similar iterative approach to the tutorial examples, solve Laplace’s equation and obtain the steady state water level within the site. Once you have obtained the hydraulic head determine the flux field to indicate the flow of water. B2. An excavation in the site, of size a = 100 m and b = 75 m, located at Px, Py=(950, 500) m is required. To ease the process of construction the water level must be lowered in the region where construction will proceed. The water level must be lowered to below -2 m within the site using a series of pumps, with a pumping rate of −1.3 × 10−3s^−1. You may select the position and number of pumps, they do not have to be within the site, but they should not be co-located - you can’t have more than one pump within 25 m of another. There is no restriction on the number of pumps but you should attempt to find an efficient design. You should design your code so it is possible to trial various pumping schemes and it should be clear how you have tested the success of your scheme. Compare the flux field with that obtained for a site with no pumping. Indicate clearly the location of your pumps.
+Ph Tang Unfortunately I have never seen a problem like this. This seems like a civil engineering question and I am an Aerospace Engineer. Unfortunately you will have to ask someone else.
Thank you so much for such content, what I would like to ask is what if my initial condition at T(x,0) is a function of x , then how can i insert such a condition to your code also one more thing is that what if i want to analyze such system with Neumann boundrey conditions. Can you please help me with that?
At 6:45 you'll notice that line 34 says T_mat(1,:) = 200; That means that there is a boundary condition where the left end of the pipe is always 200. On line 35 I have that the right end of the pipe is 150. If you want to set the initial condition of the pipe you'll need to put T_mat(2:end-1,1) = 100; That line of code says that for the first timestamp from the 2nd point on the pipe to the point right before the end the pipe temp is 100. I hope that helps.
Oh and for Neumann boundary conditions you need to redo the equations of motion and you'd have to redo a lot of the code. I'd recommend doing it by hand first.
If you want to use Neumann boundary conditions the equation on line 7 changes since the boundary condition is now a derivative. I have those equations lying around in my notes somewhere but overall the code is very similar.
I have my own textbook that I've written open source github.com/cmontalvo251/MATLAB/blob/master/Montalvo_Numerical_Methods_Textbook.pdf but I also use a textbook by Chapra www.amazon.com/Numerical-Methods-Engineers-Steven-Chapra/dp/0073401064
Hey! How do you implement an implicit method in this? What you have done is an explicit method of solving. Implicit method involves TriDiagonal Matrix, and I'm stuck there. Would be of great help if you could do a video on that? Or just guide me, either ways it's fine.
If you want to use Neumann boundary conditions the equation on line 7 changes since the boundary condition is now a derivative. I have those equations lying around in my notes somewhere but overall the code is very similar.
The governing equation is on line 7 with k values. This is the only equation I'm familiar with. If you change it to U values you'd have to go look in a thermodynamics textbook to find the answer. If you have the governing equation then you just rederive the equations of motion like I did.
Yes my apologies. The link was broken. Here's the link to the code and the book. Code in this video github.com/cmontalvo251/MATLAB/blob/master/screen_cast_codes/Heat_Equation/finite_difference_example.m Textbook on Numerical Methods github.com/cmontalvo251/LaTeX/blob/master/Numerical_Methods_Montalvo/Numerical_Methods.pdf
Carlos, what a good video and explanation! I have a question: Why for the discretization of time (Stability criterion - Carnahan), do you multiply by 0.5 and then divide in two again? It should not be (dx ^ 2)/(2 * k), without the 0.5. I am right?
Carlos, would this method be possible if Temperature is based on three coordinates, namely x,y,z? Also, the shape I'm working with is a right triangular prism.
Hey Dr., I am working on same equation with finite element method and getting negative temperature after 3rd time step can you suggest me a video to solve this same problem with FEM? Thank you, Paras.
in fact it is a question of tracing the evolution of the temperature as a function of the time since in the video you did it according to x and the time. I would like to know how to do it on matlab. if possible now since I work on it and I am blocked. An explanation on it will help me but a small video will be able to help me even more
@@bertinekouekam8648 I don't understand your question. At 11:08 I show a plot with position of the pipe on the x-axis and time on the y-axis. You're asking how to plot temperature as a function of time but I already did that.
Hi i have done some works in my college of mechanical engineering using mathlab i could say i am in a intermediary user. Could u please post the others programs u have used to get this graphic.
Thanks for Your efforts. Need the name or link for the documents which You are coding. Looking forward to hear from You. I will be tankful-for this act of kindness
You're welcome. The following text has been added to the description Code in this video github.com/cmontalvo251/MATLAB/blob/master/Screen_Cast_Codes/Heat_Equation/finite_difference_example.m Textbook on Numerical Methods github.com/cmontalvo251/MATLAB/blob/master/Numerical_Methods_Montalvo/Numerical_Methods.pdf
The pdf itself is notes I've created in Latex but all of those equations came from www.amazon.com/Numerical-Methods-Engineers-Steven-Chapra/dp/0073401064
Let me explain. x_vec is the vector created that contains the x-coordinates. T_mat is a matrix. The number of rows is the same as the length of x_vec and the number of columns contains each temperature profile for each time. So plotting T_mat(:,end) plots the last time slot T_mat(:,2) would plot the second time slot or rather the second timestep.
+Carlos Montalvo This is the PDE I was trying to solve: U′′x−U′x+U2=cos2(x)−sin(x)+cos(x) in which, exact solution is: U=cos(x). I had problem with applying Neumann BC to it. Dirichlet is working fine but not von Neumann.
+Carlos Montalvo the equation: www.hostmath.com/Show.aspx?Code=U_x%5E%7B%5Cprime%5Cprime%7D-U_x%5E%5Cprime%2BU%5E%7B2%7D%3Dcos%5E%7B2%7D(x)-sin(x)%2Bcos(x)
+Carlos Montalvo Hey I got it to work. Give me a day or so to post the solution. I ended up using a blended RK4 FDM approach which has pretty good convergence. Obviously there are other ways but the method I will post does just fine.
Thanks Dr. Very nice and informative lecture. Can you please make a lecture on how to solve (i) nonlinear system of ODE with reaction diffusion term, (ii) solving nonlinear system of coupled ODE; both using finite difference scheme
Hi Dr Please. I needed an algorithm to solve the equations Telegraphic equations or Propagation equations of transmission line by method FDTD.( for my university project)
Dr. Carlos Montalvo they are bulk matter equations in electrical engineering (edit: and applied physics) that model the propagation of electromagnetic fields along a wire. The model assumes microscopic resistance, capacitance, and inductance of finite elements of the wire. The equations are called the “telegrapher equations” and resemble modified wave equations. Typically, in electrical circuit design we assume that the bulb or whatever turns on immediately after the switch is turned on. However, a tiny amount of time is required to transmit this signal. For high frequency circuits or dimensionally large circuits (relative to the wavelength of the incident radiation in the wire) we need to account for this delay, hence the discretization of the conductor via telegrapher equations. Another approach is to solve the Maxwell equations of electromagnetism, it this requires an understanding of Green’s functions and potential functions (which isn’t too bad once you look at the math). Usually, such math cannot be resolved analytically, which I guess is why the OP was watching this video. I’m a dropout (cashier) so I have limited experience & training with these things lol. I just heard about these equations in the grapevine. Awesome channel btw 100% subbed 😊👏🏽🎊🥇🤓
I'm trying to solve 1D laplace heat equation for a plate using the FDM. Do you have any advice as to how i can the code step by step and plot contours as my matlab skills are mediocre.
I don't think that would work to be honest. ode45 uses an adaptive timestep and finite difference method is a fixed timestep. But maybe it would work? Seems kind of difficult though.
Thanks for the suggestion.If you could help me how to solve simultaneous differential algebraic equations(1st order) where one initial condition is known(It is required as we have to discretize the space not the time)...then I could probably do it myself
Dr. Carlos Montalvo well what you have done it's partial differential equation right?so I was just asking if the ordinary differential equation can be done in the same way...
This is the indirect method. Also see this for Fisher equation. www.sciencedirect.com/science/article/pii/S0895717797000150/pdf?md5=0165428fb9a79afade595e3eb72bd48e&pid=1-s2.0-S0895717797000150-main.pdf&_valck=1
I am solving four coupled pdes in 1D and want to make one dependent variable value constant after particular time so it cant go below zero and I will use its zero value for further simulation to get desired value of other dependent variables.
@@CarlosMontalvo251 ok sir if we want to stop one variable after some time so it can not affect the other one how we can do that in the coupled pdes system
@@bediumang if you're using ode45 that may be more difficult. However if you are using RK4, you can set the variable to a constant in your for loop. That might be an interesting video to make.
Good day Dr. Carlos, May God bless you for putting off such tutorial. please I still need your help for 2D PDE TUTORIAL (I MWAEN YOU SHOULD EXTEND THE ABOVE TUTORIAL TO 2D). THANKS
Sir, i m trying to solve three partial differential equation ,where two is linear and one is non-linear. They have three unknown and these equation are related. Can u pliz help in dealing with 3 unknown variables
To solve multiple equations simultaneously you just need to stack them in vector format and integrate them simultaneously. In this tutorial I show how to integrate a 2 state system using RK4. PDE's aren't much different. fastlabtutorials.blogspot.com/2015/03/everything-you-need-to-know-to-code.html?view=classic
“Numerical Methods for Engineers, 7th Ed.”, S. Chapra and R. Canale, McGraw-Hill, ISBN 9781259318726. “Essential MATLAB and Octave” J. Rogel-Salazar, CRC Press, 2015. ISBN 9781482234633
clear clc close all %%% Heat Constant - Heat Capacitance k=2; %%% Length of the pipe L = 10; %%% Number of Elements N = 10; %% Discretize our Xspace x_vec = linspace(0,L,N); dx = x_vec(2)-x_vec(1); %% Discretize time dt = 0.5*dx^2/(2*k); t_vec = 0:dt:10; %%% Allocate memory for Temp T_mat = zeros (length(x_vec),length(t_vec)); %%% Initial Conditions for the Temprature T_mat(1,:) = 200; T_mat(end,:) = 150; %%% Integrate using Euler's and FDM put together for tdx = 1:length(t_vec)-1 for idx = 2:length(x_vec)-1 T_mat (idx,tdx+1)= T_mat(idx,tdx) + k*dt/dx^2 * (T_mat(idx+1,tdx)-2*T_mat(idx,tdx)+T_mat(idx-1,tdx)); end end [tt,xx] = meshgrid(t_vec,x_vec); mesh(xx,tt,T_mat) xlabel('X coordinate (m)') ylabel('Time (sec)') zlabel('Temperature (F)')