CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Code writing (https://www.cfd-online.com/Forums/main/9091-code-writing.html)

Frank Scheuerpflug May 1, 2005 07:38

Code writing
 
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...

zxaar May 1, 2005 20:51

Re: Code writing
 
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.

Frank Scheuerpflug May 2, 2005 05:09

Re: Code writing
 
thanks for posting, but this is not my mistake. I'm sure I did the discretization wrong...

versi May 2, 2005 05:15

Re: Code writing
 
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.

zxaar May 2, 2005 05:20

Re: Code writing
 
is ur solver coupled or segreggated??

Frank Scheuerpflug May 2, 2005 10:11

Re: Code writing
 
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...

ag May 2, 2005 11:24

Re: Code writing
 
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).

Frank Scheuerpflug May 2, 2005 12:41

Re: Code writing
 
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"

ag May 2, 2005 13:30

Re: Code writing
 
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.

Frank Scheuerpflug May 2, 2005 15:33

Re: Code writing
 
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...

Guillaume May 3, 2005 09:02

Re: Code writing
 
If you have the Ferziger and Peric book, try to get their codes (see the last pages). This will be a good start.

travis May 3, 2005 15:42

Re: Code writing
 
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

Eid May 10, 2005 15:32

Re: Code writing
 
Hye guys. Can anyone help me with writing a code for particle image velocimetry.

Frank Scheuerpflug May 10, 2005 16:57

Re: Code writing
 
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!

ag May 10, 2005 23:57

Re: Code writing
 
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.

Nick May 19, 2005 06:02

Re: Code writing
 
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.


All times are GMT -4. The time now is 21:34.