CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   2D backward staggered SIMPLE MATLAB turbulent (https://www.cfd-online.com/Forums/main/102238-2d-backward-staggered-simple-matlab-turbulent.html)

 michaelmoor.aero May 25, 2012 15:49

2D backward staggered SIMPLE MATLAB turbulent

Hello everyone!
My name is Michael Moor, I'm doing my MEng in Aeronautical engineerring, and my thesis is to develop my own CFD code in MATLAB, including turbulence (2D only, i'll only be doing the prandtl mixing length and k-epsilon models). I have started to solve a simple convection-diffusion flow between two stationary plates, and tried to incorporate inflow-outflow boundary conditions, with a hybrid differencing scheme.

I'd like to think that I am 85% finished... firstly i want to solve for laminar flow, and then include turbulence models once the basic model is working... so far I have:

- Created a backward staggered grid. I have included he un-used nodes i1 and j1, just to make it more clear, and to keep matrix dimensions the same. The way that I have manipulated and defined the matrices also allows for the same indexing as used by Versteeg, hopefully making it easier to read!
- employed a hybrid differencing scheme
- used predominantly matrix manipulation (on advice) to construct all of the coefficients and equations... a few "for loops" to keep the order of the u, v, p' and scalar cells the same
- included the often neglected source term which comes from the derivation of the NS equations (is it overly important? it may be causing my divergence...
- solved for u*, v* and p', although the coefficient matrices for v* and p' are not diagonally dominant, the v* gauss seidel still converges, but the p' does not, i.e. the pressure correction is not converging... I am wondering if that is because I have made a mistake with the boundary conditions (which I am also slightly perplexed about, a common theme I have seen in these posts!) or is it simply because of the initial poor guess?

- used the Gauss seidel method for solving the momentum and pressure correction equations ( I have followed as closely as I can to Versteeg and Malalasakera).

-"solved" for the new pressure and new velocites using the converged u* and v* values, as well as the unconverged p' values

- I am about to attempt to get the whole process to iterate...

BUT, before I try and start iterating the process, I am new to this forum and am not sure where to go or how to allow people to see my code and help me, I am not a particularly strong programmer, it has been a long hard slog, but everything is fairly explicit and I have annotated the code pretty well, I think that it would help beginners, (if it is correct, plus, I am basically a beginner myself!!), and similarly help me by allowing people to forward their suggestions, or more importantly to point out mistakes that I have made.

I would greatly appreciate your help in 1. looking at my code yourself and offering suggestions/correcting mistakes 2. helping me to get more help and understanding (not necessarily from you as I am sure that you are very busy)/ spread my work to help others with similar problems and to get them to help me!

I hope that you are still an active member and can help me out, i'd really appreciate it!!

Best Regards,
Michael Moor

 Hoggs17 May 31, 2012 17:32

SIMPLE Algorithm

Good to know there are other people out there interested in the same type of engineering problems as myself. I'm a mech. engineering grad student with emphasis in fluid dynamics/heat transfer.

I've been looking on-line for sample codes in attempts to guide me in creating my own finite volume CFD code in MATLAB but there hasn't been much help. My programming background is weak so it's difficult for me to jump right in and develop my own code. I've read up on several books to familiarize myself with the physics behind the solutions but I've had difficulty in finding good code that I can learn from.

If I come across anything or develop any code that might help you I'll be sure to let you know in case it would help you. May I see your sample code? I might be able to offer up a few tips from what I do know so far. Thanks!

 michaelmoor.aero June 7, 2012 11:49

no problem, i got your email and have replied to it, a work in progress, but the basics are there

 michujo September 19, 2012 12:34

Hi Michael, sorry for the late reply but your thread came up after a forum search. It turns out I'm also trying to develop my own 2D incompressible CFD code in MATLAB following Versteeg & Malalasekera. So far I'm only able to solve the convection-diffusion equation for a general variable phi (assuming a velocity field), but I'm struggling to code the fluid flow solver part.

Hopefully we can share some knowledge/experiences/problems and solutions.

About your convergence problem: did you try to under-relax the solution of the p' equation? I think a value of omega~0.2 (relaxation coefficient) is recommended in Versteeg & Malalasekera.

Cheers,
Michujo.

 michaelmoor.aero September 21, 2012 04:33

Quote:
 Originally Posted by michujo (Post 382596) Hi Michael, sorry for the late reply but your thread came up after a forum search. It turns out I'm also trying to develop my own 2D incompressible CFD code in MATLAB following Versteeg & Malalasekera. So far I'm only able to solve the convection-diffusion equation for a general variable phi (assuming a velocity field), but I'm struggling to code the fluid flow solver part. Hopefully we can share some knowledge/experiences/problems and solutions. About your convergence problem: did you try to under-relax the solution of the p' equation? I think a value of omega~0.2 (relaxation coefficient) is recommended in Versteeg & Malalasekera. Cheers, Michujo.
Hi Michujo,
I have succesfully completed the solver, using both Simple and Simplec. If you provided me with an address, I would be more than happy to share it with you, and to help you through it! It was constructed in such a way as to be educational, so I hope that it will be of help to you!

Best Regards,
Michael Moor

 Maanieh.h January 27, 2013 10:37

Simple

Quote:
 Originally Posted by michaelmoor.aero (Post 382926) Hi Michujo, I have succesfully completed the solver, using both Simple and Simplec. If you provided me with an address, I would be more than happy to share it with you, and to help you through it! It was constructed in such a way as to be educational, so I hope that it will be of help to you! Best Regards, Michael Moor
Hello Michael , can i also see the SIMPLE code ?? cause I am stuck with problems in flow and in discr. the momentum equation .. Can I see the SIMPLE code of yours ??

I would appreciate a reply ..
Thanks

 praveen January 27, 2013 11:21

A good way to publicly share matlab code is on matlab central

http://www.mathworks.in/matlabcentral/

 Maanieh.h January 27, 2013 11:25

.

I posted here because the friends in here are talking about the subject that Im having problems in .. I would like to share codes via email and not to publicly share them .. Thanks paraveen for ur reply !

 ztdep January 29, 2013 12:41

where is my little gifts? I think you should show the basis respect to me.

 michaelmoor.aero January 29, 2013 21:10

Hello everyone, my apologies for the delay!

I am more than happy to help you, just send me an email and I can forward it on! I was/am hoping to make my own small website to post it, but I must first put it on the MATLAB site as previously suggested!

As ztdep has correctly stated, all of my work would not have come about without his invaluable help, thanks again!

 michaelmoor.aero January 29, 2013 21:15

Quote:
 Originally Posted by michaelmoor.aero (Post 404909) Hello everyone, my apologies for the delay! I am more than happy to help you, just send me an email and I can forward it on! I was/am hoping to make my own small website to post it, but I must first put it on the MATLAB site as previously suggested! As ztdep has correctly stated, all of my work would not have come about without his invaluable help, thanks again!
also ding, check your gmail!

 Maanieh.h February 10, 2013 11:02

!

Nobody helped me !

 michaelmoor.aero February 11, 2013 06:02

Quote:
 Originally Posted by Maanieh.h (Post 406980) Nobody helped me !
if you read my post correctly, the you can see that i have offered to help and that i would be happy ti forward on the code in an email address that you provide...

 Maanieh.h February 12, 2013 08:01

Thanks MichaelMore

Oh Im so Sorry I didn't think your post was directed to me .. I would be honored to send you me email : huss.ma3@gmail.com

Sorry once again for any mis-communication.:)

 michaelmoor.aero February 15, 2013 17:02

Quote:
 Originally Posted by Maanieh.h (Post 407381) Oh Im so Sorry I didn't think your post was directed to me .. I would be honored to send you me email : huss.ma3@gmail.com Sorry once again for any mis-communication.:)
that is no problem at all! apologies for the delay. i have sent the file to the address supplied, again, all thanks to ztdep, the true mastermind! ;) please let me know how helpful/unhelpful it is, especially as i tried tomake it basic and educational.

 gerardosrez February 15, 2013 17:45

hello people,

Perhaps we should do something like a blog just for us, Michael and Ding both know me I'm in the same situation like many of you and them, developing incompressible 2d code. In my case I'm using the cvfem approach with collocated variables and still stucked in inflow and outflow problems, also dedicating some time to improve my code making it faster using less for loops...

It would be great if there is a way to share more directly experiences and advices with you guys...

Let me know your proposals about a way to keep constantly in toouch

Best regards

Hi michael and ding, long time we dont chat...

 FVM_CFD_GUY April 15, 2013 07:13

need fvm code for SIMPLE

please send me code at anjaneya4@gmail.com

thanks!!!

 Hoggs17 May 1, 2013 14:51

Blog proposal

I would be interested in keeping in touch with all fellow members who are interested in similar topics. I seem to make a little progress in my code but then I bang my head against the keyboard for a few weeks until it's resolved.

If we had a place to go to ask questions I believe it would make our research struggles much less painful. Let me know what you guys decide to do and I'd happily participate.

 ribhu February 1, 2016 11:47

Matlab code for steady incompressible laminar flow

Hi Michael,

I have made matlab codes for simple convection diffusion problems with a known velocity field as given in Versteeg book. But finding difficulty to solve the momentum equation fpr a laminar in compressible steady flow. I would be very grateful if you could send me your code. My email id is dasguptadebayan@gmail.com

Regards

Debayan

 All times are GMT -4. The time now is 06:19.