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

Solution to Quasi 1D converging-diverging nozzle problem (euler equations) blowing up

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2017, 09:54
Default Solution to Quasi 1D converging-diverging nozzle problem (euler equations) blowing up
  #1
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 8
sangeet is on a distinguished road
Hello,
I am currently trying to generate a numerical solution to a converging-diverging, subsonic-supersonic 1D nozzle flow problem. I am using Maccormack's technique to solve the Euler equations. I have already done it using the non-conservation form of the governing equations. I am now trying to solve it using the strong conservation form of the equations, but the solution keeps blowing up after a few time steps. I have checked for syntactical errors or logical errors in my C++ code but i am unable to pin down exactly what i am doing wrong.
I have attached my C++ code and a few photos of the output.
I will try to describe my code here as best as i can.
I have 5 functions in my C++ code:
1-initial_values()=assigns initial values to the primitive variables and the area value at all grid points
2-conservation_form_initialization()=calculates the solution vector and flux vector terms at all the grid points from the initial values of the primitive variables.
3-time_step()=Calculates the time step satisfying the CFL criterion for linear PDEs at each grid point and chooses the lowest.
4-time_march()=Using Mccormack's technique marches one step forward in time
5-display_values()=just displays values with some formatting
All variables are non-dimensionalized.
I believe i have included enough comments in the code to help you understand whats going on in the code.

If it helps, i am currently following the anderson book on CFD (CFD-The Basics with Applications) chapter 7.
Attached Images
File Type: jpg Values at 0 time steps.jpg (131.0 KB, 84 views)
File Type: jpg Values at 50 time steps.jpg (153.1 KB, 34 views)
File Type: jpg Values at 500 time steps.jpg (117.5 KB, 29 views)
Attached Files
File Type: txt Quasi-1d nozzle conservation form .txt (5.7 KB, 70 views)
sangeet is offline   Reply With Quote

Old   June 16, 2017, 10:54
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
I can suggest to check for the numerical stability constraint you are using. Furthermore, start to debug the code using a first order discretization so that you are sure to have a monotone scheme. If it works then go check if higher order discretization is correct.
FMDenaro is offline   Reply With Quote

Old   June 16, 2017, 11:49
Default
  #3
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 8
sangeet is on a distinguished road
So you are suggesting to try a first order method first and then if it's stable then to go for the Maccormak scheme?
And the numerical stability constraint is correct because I am following the scheme in the anderson book and the solution is stable.
I will try to use a first order method though
Thank you!

PS: the numerical scheme works in the book though, can this mean that there's​ something wrong with my own implementation and not the scheme?
sangeet is offline   Reply With Quote

Old   June 16, 2017, 12:08
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by sangeet View Post
So you are suggesting to try a first order method first and then if it's stable then to go for the Maccormak scheme?
And the numerical stability constraint is correct because I am following the scheme in the anderson book and the solution is stable.
I will try to use a first order method though
Thank you!

PS: the numerical scheme works in the book though, can this mean that there's​ something wrong with my own implementation and not the scheme?
yes, a bug in a code is quite common...for this reason you should start with a very simple upwind discretization
FMDenaro is offline   Reply With Quote

Old   June 19, 2017, 10:33
Default
  #5
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 8
sangeet is on a distinguished road
Hello again,
From what I understand from a first order upwind scheme it's a backward difference in space?
I know i am supposed to make it converge for the first order scheme and then converge it again for the higher order method such as Maccormak's.
When I edited the time marching function to use the first order method, my solution blew up even faster I believe. But I don't understand how I am supposed to converge it for the first order method. I must apologize for troubling you with a possibly trivial debugging but I can't understand what I should change to make the program converge.
sangeet is offline   Reply With Quote

Old   June 19, 2017, 14:01
Default
  #6
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
If your code doesn't work with a first order upwind and you fulfilled all the numerical stability constraints I suppose you have a bug in the code.
FMDenaro is offline   Reply With Quote

Old   June 21, 2017, 02:05
Default
  #7
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 8
sangeet is on a distinguished road
Thank you.
That is what i suspected from the start but my problem is that i cannot figure out exactly where in the algorithm the mistake lies. I have gone through the code countless amount of times but I can't figure it out. But i understand that going through some one else's code is just mostly disorienting as we need to figure out what variables are what. Thank you for your help. On the bright side i did learn something new. I am a beginner so i didn't know about that a first order method is used to converge a code first.

PS: I will post my code here if i manage to somehow figure it out.
sangeet is offline   Reply With Quote

Old   June 22, 2017, 02:41
Thumbs up Solved
  #8
Member
 
Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 8
sangeet is on a distinguished road
Hello,
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, 65 views)
sangeet is offline   Reply With Quote

Old   June 22, 2017, 03:06
Default
  #9
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
good, I suggest to check the difference between first order upwind and high order discretization
FMDenaro is offline   Reply With Quote

Old   September 28, 2018, 10:09
Default
  #10
Member
 
Join Date: Feb 2018
Posts: 91
Rep Power: 8
charles4allme is on a distinguished road
Hello,

I really need your assistance. I am relatively new at using 1D equations, because I went straight into 3D. I now have to develop a 1D ventilation model so am using your code to understand basic implementation of 1D in C++. Am going through the Anderson book in order to understand your code. My question at the moment is what method you used for calculating the time step and why you used T. Am assuming T is temperature. The method for calculating time step in your code doesn't seem to fit with the methods in Anderson book, unless am misinterpreting your code. I look forward to hearing from you.

Regards,
charles
charles4allme is offline   Reply With Quote

Old   October 21, 2019, 18:30
Default
  #11
New Member
 
hajo jllon
Join Date: Jun 2019
Posts: 5
Rep Power: 6
Jauo is on a distinguished road
Quote:
Originally Posted by charles4allme View Post
Hello,

I really need your assistance. I am relatively new at using 1D equations, because I went straight into 3D. I now have to develop a 1D ventilation model so am using your code to understand basic implementation of 1D in C++. Am going through the Anderson book in order to understand your code. My question at the moment is what method you used for calculating the time step and why you used T. Am assuming T is temperature. The method for calculating time step in your code doesn't seem to fit with the methods in Anderson book, unless am misinterpreting your code. I look forward to hearing from you.

Regards,
charles
Well i Think he is first guessing a value for dt and then calculates all other dts' and kinda sorts the array to find the minimum thats whats happening in that if statement.

there is a Vectorized form of the solution using Python that may help
https://github.com/JayJoeAy/Q1DNozzleVec
Jauo is offline   Reply With Quote

Old   March 8, 2020, 10:35
Default Shock capturing : MacCormack scheme with Artificial Viscosity
  #12
New Member
 
NotSteve
Join Date: Mar 2020
Posts: 3
Rep Power: 6
CrushedToucan96 is on a distinguished road
Hello, After being succesful in solving all the problems in Chapter 7 of Anderson, i tried the shock capturing part where we induce a normal shock at the divergent portion of the CD nozzle. Although my results match the ones shown in the book for zero artificial viscosity, For Cx = 0.2 [Adjustment factor] my values go complex and blow up. Has anybody else come across this issue?
Attached Images
File Type: jpg Shock.jpg (12.7 KB, 26 views)
File Type: jpg Shock_Anderson.JPG (45.0 KB, 25 views)
CrushedToucan96 is offline   Reply With Quote

Old   April 24, 2020, 19:33
Default
  #13
New Member
 
Konstant Kampir
Join Date: Apr 2020
Posts: 1
Rep Power: 0
Pikno is on a distinguished road
Quote:
Originally Posted by CrushedToucan96 View Post
Hello, After being succesful in solving all the problems in Chapter 7 of Anderson, i tried the shock capturing part where we induce a normal shock at the divergent portion of the CD nozzle. Although my results match the ones shown in the book for zero artificial viscosity, For Cx = 0.2 [Adjustment factor] my values go complex and blow up. Has anybody else come across this issue?
If that happens then either your boundary or the initial conditions are wrong. I had the same issue in the subsonic isentropic flow and the subsonic supersonic one and it was the initial or boundary conditions . If you are in the conservative analysis try to check how you input pressure and S factors .
Pikno is offline   Reply With Quote

Reply

Tags
anderson, nozzle flow, quasi-1d


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
Nozzle Flow - Divergence Problem Ijaz FLUENT 9 January 11, 2014 04:36
Future CFD Research Jas Main CFD Forum 10 March 30, 2013 12:26
unsteady 1-D euler equations in a nozzle Luca Main CFD Forum 1 November 30, 2008 14:13
problem with nozzle flow belinda FLUENT 5 July 12, 2006 17:42
multigrid solution of 2d euler equations jim Main CFD Forum 2 May 21, 2002 04:05


All times are GMT -4. The time now is 05:40.