Help regarding 1D compressible flow (Sod Shock tube)
1 Attachment(s)
Hi all,
I am coding up a 1D compressible flow solver via Lax-Friedrichs method (for now), however have run into a when calculating certain quantities, such as velocity. In other words, I believe my implementation is correct, however something is not being properly updated per time step. I have attached my code for proper documentation. Thoughts: My way of updating at each time step is to have U_current = U_new. EDIT: Just for clarification, I am not sure what I am doing wrong as my plots for pressure, velocity, and density are not right |
Still having issues
1 Attachment(s)
Hi All,
I am still having issues with my 1D compressible solver. I have narrowed it down to the time step, however I am not sure what I'm doing wrong in the process of updating it. If someone point/help me in the right direction I would heavily appreciate it. Code:
clear; |
I am not completely familiar with the language you are using, but it looks to me like you are overwriting values during your update that should not be overwritten until you complete the entire sweep. You construct u(i,j+1) and then use that value for u(i,j) in the next pass through the j-loop.
|
Thanks
Hi agd,
I am using Matlab for my language. In terms of Code:
for j=1:nt P.S. I'm new to CFD |
OK - I see what your code is doing now. I'll look at it a little more and see if anything looks wrong. One thing you can try for debugging is to turn off the boundary conditions and see if your code will maintain a uniform set of conditions. Sometimes that can quickly point to a problem.
|
The conservation equations as you have written them are not correct. Is that simply an error in how you wrote them in your post, or did you code them up that way?
|
Equations
1 Attachment(s)
Hi,
I coded them up two different ways to see if what you said was an issue, however the issue does not change. Code:
clear; Link: http://bender.astro.sunysb.edu/hydro...ible/Euler.pdf The link I provided above is to illustrate the equations I'm solving not the method. The part in which really stumps me (and maybe you can have wisdom on that) is why I keep getting NaNs in my arrays. I spent a couple hours debugging with no luck. I believe if I did not get "NaNs" in my arrays I would have a complete solution as it looks very close. |
the RHS of your system must have the minus sign...
|
for i=1:nx U1(i,j) = r(i,j); U2(i,j) = r(i,j)*u(i,j); U3(i,j) = r(i,j).*E(i,j); F1(i,j) = r(i,j)*u(i,j); F2(i,j) = r(i,j)*u(i,j).^2 + p(i,j); F3(i,j) = u(i,j)*(r(i,j).*E(i,j) + p(i,j)); end
why do you mix the operators "*" and ".*" in the for cycle? they are different operations in matlab |
Hi,
Thanks for pointing that out. That was a mistake in terms of not putting the - sign, however in the code I already took that into account. In terms of wrongly using .* and * I have fixed that and is below. Code:
clear; |
Stupid question - are you sure that you are obeying the stability limit for the Lax-Friedrichs scheme?
|
CFL condition
Hi agd,
Yes I am. I've made sure there is no instability aside the downfalls of the method. |
Quote:
that's never a stupid question ;) he wrote an arbitrary dt and the cfl does not appear explicitly computed: b = 0.5; a = -0.5; nx = 101; dx = (b-a)/(nx-1); x = zeros(nx,1); tMax = 0.15; dt = 0.004; |
remember to estimate that dt/dx = 0.4 and the velocity should be considered as convective and sound velocity
|
Thanks
1 Attachment(s)
Hi agd and FMDenaro,
I have managed to get my 1d compressible flow solver to work. There were some things I did different: 1. I used the Local Lax Friedrichs which provided a more robust method. There were no small oscillations 2. The indexing I was using was running me into trouble, i.e. the time index 3. I adjusted my CFL condition Thank you for the help :) |
Hello!!Could you post the right code after your changes?
|
hello i need lax friedrich matlab codes for 1D shock tube problem. Is there any one to help me?
|
I need your codes
|
hello selig can you post your codes after correction i need your codes
|
All times are GMT -4. The time now is 13:03. |