CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Question Regarding MacCormack Technique

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 3 Post By RcktMan77
  • 1 Post By sangeet
  • 1 Post By sangeet

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 6, 2010, 21:51
Default Question Regarding MacCormack Technique
  #1
Senior Member
 
Zach Davis
Join Date: Jan 2010
Location: Los Angeles, CA
Posts: 101
Rep Power: 16
RcktMan77 is on a distinguished road
I'm somewhat of a beginner/student to CFD development, and I'm making my way through John D. Anderson's "Computational Fluid Dynamics: The Basics With Applications" wherein Maccormack's finite differencing technique is being utilized to solve the flowfield for a quasi-1D, subsonic inflow-supersonic outflow isentropic nozzle. The governing flow equations are reduced for a quasi-1D Euler flow, and cast in strong conservation form. In writing my own program to solve this problem, I have been able to match Anderson's results for the first step in time. However, my code becomes unstable as I advance further in time, and I'm unable to obtain a stable solution using the Courant number, grid spacing, and time steps that Anderson specifies.

I'm wondering if this may have something to do with my implementation of calculating the time increment itself, which Anderson is a little vague in how he himself handles this. I know that for each grid point the time increment is calculated, and he in turn picks the minimum time increment calculated across each grid point to advance the solution to the next time step (global time marching approach). However, I'm left wondering if this is repeated for each time iteration, or if this minimum time increment calculated for the first time step is used for subsequent iterations. I have implemented the former approach, and I see that as the solution steps forward in time the minimum time increment calculated across all the grid points diminishes; eventhough, the grid spacing remains constant. Is this normal, or should the time increment remain constant while the solution marches in time? Any insights would be most helpful.

Thanks.
RcktMan77 is offline   Reply With Quote

Old   August 9, 2012, 14:47
Default 1d Maccormack
  #2
New Member
 
Jeroen Wink
Join Date: Aug 2012
Posts: 1
Rep Power: 0
jeroen_wink is on a distinguished road
Hi Rcktman77,

Recently I was trying to do the same example from Anderson and I experience the same problem. The absolute value of the divergence seems to scale with the timestep but no matter what the timestep is, the solution diverges. Since you encountered this problem a couple of years ago, do you perhaps know what the problem was?

With kind regards.
Jeroen Wink
jeroen_wink is offline   Reply With Quote

Old   October 1, 2012, 18:10
Default Anderson's CFD book page 336
  #3
New Member
 
Kurt J. Kloesel
Join Date: Oct 2012
Posts: 1
Rep Power: 0
kjkloesel is on a distinguished road
Jeroen Wink - I think I have stumbled onto the same error. I have coded this thing twice, one in C++ and then again in Excel (first step). The central problem begins on page 336. Once I get the calculations to the end of the predictor step (page 349) , I can't get the same answers for F1, F2, F3 (row 15). The calculations work for row 16 and that's OK. I have tried a couple of things. 1.) Not using primitives in the calculation of J2. 2.) Fixing the d(Area)/dx at rows 0 and 30. I am unsure why he claims one needs the primitives calculated on the top of page 349, because the iteration loops can be closed without that calculation, and then one just extracts the primitives at the end of looping, as needed. The web rumors that a solutions manual exists, maybe we can unravel the mystery from this documentation. I'm not sure how any graduate student could turn in re-coded Anderson with out it being somewhat obvious.
Thanks,
kjkloesel is offline   Reply With Quote

Old   September 12, 2015, 15:02
Default
  #4
Member
 
mechiebud
Join Date: Jan 2015
Posts: 49
Rep Power: 11
mechiebud is on a distinguished road
Quote:
Originally Posted by jeroen_wink View Post
Hi Rcktman77,

Recently I was trying to do the same example from Anderson and I experience the same problem. The absolute value of the divergence seems to scale with the timestep but no matter what the timestep is, the solution diverges. Since you encountered this problem a couple of years ago, do you perhaps know what the problem was?

With kind regards.
Jeroen Wink
jeroen_wink Even I have encountered the same problem. Could you please guide me how it was resolved?
mechiebud is offline   Reply With Quote

Old   September 14, 2015, 20:16
Default
  #5
Senior Member
 
Zach Davis
Join Date: Jan 2010
Location: Los Angeles, CA
Posts: 101
Rep Power: 16
RcktMan77 is on a distinguished road
Hi all,

Apologies for the delayed response. It has been about 5 years since I re-visited this problem, so it took me some time to refresh my memory. I looked over my original question, and immediately noted what I originally thought as ambiguous regarding the time step, was in fact stated pretty explicitly in the book. Namely, that global time stepping is used throughout all of the example problems. The time step is calculated at each grid point using Eq. 7.67 and the minimum value from all of the interior points is used for advancing the solution in time (i.e. this value doesn't change once initially calculated).

I'm not sure whether this is the same issue you're encountering, but I went back and wrote a program in fortran to solve the problem which I think does so adequately. It doesn't appear to diverge after 1400 iterations at least. I've attached the fortran source for you to review. Please excuse the formatting of the output files. I didn't spend much time formatting them how I intended. Also a lot of the code could probably be re-factored to reduce some redundancy, but I felt it was probably best to be as explicit as possible to show the steps as Anderson has written them.

Lastly, for whatever reason the forums here don't appear to recognize the f90 extension, so I've renamed my fortran source file using the *.f extension. It's probably best if you rename the attachment prior to compiling using the f90 extension.

Please don't hesitate to contact me if you have any additional questions about this problem.

Best Regards,


Zach
Attached Files
File Type: f maccormack.f (5.4 KB, 44 views)
RcktMan77 is offline   Reply With Quote

Old   September 15, 2015, 12:31
Default
  #6
Member
 
mechiebud
Join Date: Jan 2015
Posts: 49
Rep Power: 11
mechiebud is on a distinguished road
Thanks a lot for your response.
mechiebud is offline   Reply With Quote

Old   June 19, 2017, 14:33
Default
  #7
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 9
sangeet is on a distinguished road
Hello,
I have the same problem with my code, the solution always diverges. I did take a look at the FORTRAN code and did try to follow but as i dont know fortran very well maybe i have been making some mistakes. My solution still diverges. Please take a look at my c++ code and see if you can help me out. I have been stuck on this for days. I am at my wit's end.
Attached Files
File Type: txt Quasi-1d nozzle conservation form.txt (5.4 KB, 15 views)
sangeet is offline   Reply With Quote

Old   June 22, 2017, 03:42
Default Solved
  #8
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 9
sangeet is on a distinguished road
Hello again,
So i figured out the the bug. It was a mistake in the calculation of the required flux terms in the corrector step. I have attached the C++ code if someone else faces this problem.
Attached Files
File Type: txt Quasi-1d (copy).txt (3.1 KB, 14 views)
ashishmagar600 likes this.
sangeet is offline   Reply With Quote

Old   June 28, 2017, 15:55
Default
  #9
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 10
ashishmagar600 is on a distinguished road
hii ...

first of all thanks for the code. but let me ask, the book also describes solving the problem of the subsonic-supersonic nozzle with the non-conservation form of governing equations. However, when I coded the same thing, the solution diverges, and program blew up.

Please check if there are possible errors in my code.

Thanks a lot.
Attached Images
File Type: jpg t_stp_0-01.jpg (19.4 KB, 21 views)
Attached Files
File Type: txt fresh.txt (4.3 KB, 19 views)

Last edited by ashishmagar600; June 29, 2017 at 14:20.
ashishmagar600 is offline   Reply With Quote

Old   July 6, 2017, 14:36
Default
  #10
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 9
sangeet is on a distinguished road
Quote:
Originally Posted by ashishmagar600 View Post
hii ...

first of all thanks for the code. but let me ask, the book also describes solving the problem of the subsonic-supersonic nozzle with the non-conservation form of governing equations. However, when I coded the same thing, the solution diverges, and program blew up.

Please check if there are possible errors in my code.

Thanks a lot.
Hello!
I must apologize for replying this late but i have been a bit busy. After i saw your code, some errors are apparent. You have enforced the the boundary conditions at the inlet and the outlet at the initialization itself. Anderson meant that you should enforce these while solving the flow. You solve for the internal points only and then you extrapolate the value of velocity at inlet and the values of the other primitive floating variables at outlet after each computation. And there is also an error in your solver loop. For the predictor part you are okay but the corrector part needs the predicted value at the inlet at the first step because its uses backward difference. but you havent stored the predicted value of i=0 anywhere. You should run the predictor part on all the internal points separately and then extrapolate predicted values at i=0 and then run the corrected part separately and then finally extrapolate the final values at i=0 and at i=N-1.

Hope this helps
ashishmagar600 likes this.
sangeet is offline   Reply With Quote

Old   July 8, 2017, 16:56
Default solved
  #11
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 10
ashishmagar600 is on a distinguished road
Hii..

Quote:
You have enforced the the boundary conditions at the inlet and the outlet at the initialization itself. Anderson meant that you should enforce these while solving the flow. You solve for the internal points only and then you extrapolate the value of velocity at inlet and the values of the other primitive floating variables at outlet after each computation. And there is also an error in your solver loop. For the predictor part you are okay but the corrector part needs the predicted value at the inlet at the first step because its uses backward difference. but you havent stored the predicted value of i=0 anywhere. You should run the predictor part on all the internal points separately and then extrapolate predicted values at i=0 and then run the corrected part separately and then finally extrapolate the final values at i=0 and at i=N-1.
Thank you for your response. I have debugged the code following your instructions, and have found converged solution.

thanks a lot.
Attached Files
File Type: txt non-consrve.txt (3.2 KB, 16 views)
ashishmagar600 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unanswered question niklas OpenFOAM 2 July 31, 2013 17:03
question about implementing boundary conditions saygin Main CFD Forum 0 July 6, 2006 08:08
Solutions of Nozzle Flows by MacCormack Technique worasit Main CFD Forum 5 September 29, 2003 12:38
CHANNEL FLOW: a question and a request Carlos Main CFD Forum 4 August 23, 2002 06:55
question K.L.Huang Siemens 1 March 29, 2000 05:57


All times are GMT -4. The time now is 02:45.