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

Code writing

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 1, 2005, 07:38
Default Code writing
  #1
Frank Scheuerpflug
Guest
 
Posts: n/a
Hello everybody, I am student in the 8th semester and currently trying to write my first 2D Code which is a Code for solving the integral Euler equations. Unfortunatly the code delivers just rubbish values and I don't know exactly why, but suppose that I have made a mistake during discretization... If anybody could help me, I'd like to send you the governing equations I use and the discretized ones, maybe you can find the mistake...
  Reply With Quote

Old   May 1, 2005, 20:51
Default Re: Code writing
  #2
zxaar
Guest
 
Posts: n/a
if u r seeing very arbit values such as in E+20s etc, then it is sometimes because you might be assuming that arrays are initialised to values of zero and instead they are initialised to garbaged values, check this aspect.
  Reply With Quote

Old   May 2, 2005, 05:09
Default Re: Code writing
  #3
Frank Scheuerpflug
Guest
 
Posts: n/a
thanks for posting, but this is not my mistake. I'm sure I did the discretization wrong...
  Reply With Quote

Old   May 2, 2005, 05:15
Default Re: Code writing
  #4
versi
Guest
 
Posts: n/a
For a beginner, perhaps the best way is to start from 1D Euler code, test it against Riemann solutions. You may refer to textbooks and their codes.
  Reply With Quote

Old   May 2, 2005, 05:20
Default Re: Code writing
  #5
zxaar
Guest
 
Posts: n/a
is ur solver coupled or segreggated??
  Reply With Quote

Old   May 2, 2005, 10:11
Default Re: Code writing
  #6
Frank Scheuerpflug
Guest
 
Posts: n/a
I don't know what "coupled" and "segreggated" means. I just take the integral 2D unsteady Euler equations for a polar coordinate system and discretize them in time with an explicit Euler scheme: dVALUE/dt = (VALUE(t+dt,x)- VALUE(t,x))/dt This way the conservation of mass delivers me the density at the next timestep. With this information the conservation of impulse delivers me the velocity at the next timestep. With this information the conservation of energy delivers me the temperature and pressure (ideal gas equation) at the next timestep. You see, I use a "shooting"-method that allowes me to compute the state at a point P at the next timelevel just by considering point P and its neighbourpoints at the current timelevel. Maybe I shouldn't use explicit Euler for time discretization, but I like it cause i am a beginner and it's the easiest way and I don't have to solve any equation system...
  Reply With Quote

Old   May 2, 2005, 11:24
Default Re: Code writing
  #7
ag
Guest
 
Posts: n/a
You are going to have to solve the entire system of equations at the same time step. That's what "coupled" means, and from what I can gather by your description that's not what you are doing. First-order Euler is fine for a simple algorithm as long as your time-step is very small, but you can't solve the equations in a step by step fashion unless you explicitly build in the equation segregation (i.e. a pressure-based scheme).
  Reply With Quote

Old   May 2, 2005, 12:41
Default Re: Code writing
  #8
Frank Scheuerpflug
Guest
 
Posts: n/a
Ok thank you, so what would you recommend me to do? Should I use an implicit time discretization technique? Or is there also a fine explicit method, perhaps a Runge-Kutta technique?

And could you please explain the following sentence you wrote (I just understand the first part): "First-order Euler is fine for a simple algorithm as long as your time-step is very small, but you can't solve the equations in a step by step fashion unless you explicitly build in the equation segregation (i.e. a pressure-based scheme"
  Reply With Quote

Old   May 2, 2005, 13:30
Default Re: Code writing
  #9
ag
Guest
 
Posts: n/a
It sounds from your description that you are solving the equations sequentially. This is typically done using a segregated solver, but segregated solvers usually utilize a pressure-based form of the equations and involve constructing an iterative process together with an equation to couple the velocity, pressure, and density fields (velocity and pressure only if the flow is incompressible). Assuming you are solving the compressible form of the equations in a density-based form, you need to update all of the flow field quantities (density, velocity, and energy) at the same time, i.e. you don't get density at time level n+1 and then use that to get velocity at time n+1, and so on. That's what it sounds like you are doing from your description, and if that's what you are doing then that may be your problem.
  Reply With Quote

Old   May 2, 2005, 15:33
Default Re: Code writing
  #10
Frank Scheuerpflug
Guest
 
Posts: n/a
Hey ag, thanks a lot for trying to help me with my problems. But I got problems with your answers as well... I have lots of literature on the topic (e.G. Ferziger and Peric, Anderson, Hirsch among others) but none of them tells me what a "segregated solver" or a "pressure-" or a "density based form of the equations" is. I have never heard of these things. What books do you refer to?

You know, I try to solve the integral mass, momentum and energy equations for a 2D, unsteady, compressible, frictionless case. For example my equation of mass conservation is:

d(|roh*dV)/dt = -|roh*v*n*dS

with

| meaning an integral Symbol

V Volume

roh density

dS incremental part of the element's surface

v velocity vector

n surface normal vector

The other equations look similar. Those are called the integral Euler equations and I discretize them with a Finite Volume method (but maybe the wrong one). And I do not have any iterative processes in my code (I try to avoid these cause they're more difficult to implement). Hope you know what I mean...
  Reply With Quote

Old   May 3, 2005, 09:02
Default Re: Code writing
  #11
Guillaume
Guest
 
Posts: n/a
If you have the Ferziger and Peric book, try to get their codes (see the last pages). This will be a good start.
  Reply With Quote

Old   May 3, 2005, 15:42
Default Re: Code writing
  #12
travis
Guest
 
Posts: n/a
If you know how th use the Eullers explicit method you may want to try the Crank Nicolson method it is more stable than the Eullers explicit method. Here is a website that has some info on the crank Nicolson, you could aslo google it. http://math.fullerton.edu/mathews/n2...colsonMod.html
  Reply With Quote

Old   May 10, 2005, 15:32
Default Re: Code writing
  #13
Eid
Guest
 
Posts: n/a
Hye guys. Can anyone help me with writing a code for particle image velocimetry.
  Reply With Quote

Old   May 10, 2005, 16:57
Default Re: Code writing
  #14
Frank Scheuerpflug
Guest
 
Posts: n/a
Thanks to you for all your responses. I still haven't solved my problem but am working on it and because of your opinions I am now quite sure that my problem is that I am using an explicit solver. Books are not replaceable, but learning CFD just from them is a hard piece of work. Thanks for your responses!
  Reply With Quote

Old   May 10, 2005, 23:57
Default Re: Code writing
  #15
ag
Guest
 
Posts: n/a
There is no reason that an explicit scheme should not be stable as long as you remain within the stability limits. Going to an implicit scheme will not help you if you have a discretization problem. In fact, your problem will still be present, because the RHS of your system of equations will be the same as the discretized spatial terms from the explicit scheme. You need to get an explicit scheme working before moving to an implicit scheme.
  Reply With Quote

Old   May 19, 2005, 06:02
Default Re: Code writing
  #16
Nick
Guest
 
Posts: n/a
HI!

You may try to do the FLIC or Large Cells methods for that. They work quiet well for Euler's equ-s. I'm working now with DNS/LES methods in FLIC-Large Cells decartelization and they work quiet well, even for explicit procedures in finite difference representation. If you want i can sent you a scheme of the algorithm.

Best Regards.
  Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a CFD code Ernesto FLUENT 2 March 27, 2007 17:38
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08:10
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07
public CFD Code development Heinz Wilkening Main CFD Forum 38 March 5, 1999 12:44


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