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

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Search this Thread Display Modes
June 16, 2017, 09:54
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: 7
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
 Values at 0 time steps.jpg (131.0 KB, 84 views) Values at 50 time steps.jpg (153.1 KB, 34 views) Values at 500 time steps.jpg (117.5 KB, 29 views)
Attached Files
 Quasi-1d nozzle conservation form .txt (5.7 KB, 69 views)

 June 16, 2017, 10:54 #2 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,291 Rep Power: 67 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.

 June 16, 2017, 11:49 #3 Member   Sangeet Join Date: Jun 2017 Location: India Posts: 43 Rep Power: 7 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?

June 16, 2017, 12:08
#4
Senior Member

Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,291
Rep Power: 67
Quote:
 Originally Posted by sangeet 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

 June 19, 2017, 10:33 #5 Member   Sangeet Join Date: Jun 2017 Location: India Posts: 43 Rep Power: 7 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.

 June 19, 2017, 14:01 #6 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,291 Rep Power: 67 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.

 June 21, 2017, 02:05 #7 Member   Sangeet Join Date: Jun 2017 Location: India Posts: 43 Rep Power: 7 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.

June 22, 2017, 02:41
Solved
#8
Member

Sangeet
Join Date: Jun 2017
Location: India
Posts: 43
Rep Power: 7
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
 Quasi-1d (copy).txt (3.1 KB, 63 views)

 June 22, 2017, 03:06 #9 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,291 Rep Power: 67 good, I suggest to check the difference between first order upwind and high order discretization

 September 28, 2018, 10:09 #10 Member   Join Date: Feb 2018 Posts: 91 Rep Power: 7 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

October 21, 2019, 18:30
#11
New Member

hajo jllon
Join Date: Jun 2019
Posts: 5
Rep Power: 5
Quote:
 Originally Posted by charles4allme 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

March 8, 2020, 10:35
Shock capturing : MacCormack scheme with Artificial Viscosity
#12
New Member

NotSteve
Join Date: Mar 2020
Posts: 3
Rep Power: 5
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
 Shock.jpg (12.7 KB, 24 views) Shock_Anderson.JPG (45.0 KB, 24 views)

April 24, 2020, 19:33
#13
New Member

Konstant Kampir
Join Date: Apr 2020
Posts: 1
Rep Power: 0
Quote:
 Originally Posted by CrushedToucan96 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 .

 Tags anderson, nozzle flow, quasi-1d

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Ijaz FLUENT 9 January 11, 2014 04:36 Jas Main CFD Forum 10 March 30, 2013 12:26 Luca Main CFD Forum 1 November 30, 2008 14:13 belinda FLUENT 5 July 12, 2006 17:42 jim Main CFD Forum 2 May 21, 2002 04:05

All times are GMT -4. The time now is 17:42.

 Contact Us - CFD Online - Privacy Statement - Top