# 2D backward staggered SIMPLE MATLAB turbulent

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

 May 25, 2012, 15:49 2D backward staggered SIMPLE MATLAB turbulent #1 Member   Michael Moor Join Date: May 2012 Location: Ireland Posts: 30 Rep Power: 6 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 Last edited by michaelmoor.aero; May 25, 2012 at 15:51. Reason: include convection-diffusion and hybrid differencing scheme

 May 31, 2012, 17:32 SIMPLE Algorithm #2 New Member   Join Date: May 2012 Location: USA Posts: 14 Rep Power: 6 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! Maanieh.h likes this.

 June 7, 2012, 11:49 #3 Member   Michael Moor Join Date: May 2012 Location: Ireland Posts: 30 Rep Power: 6 no problem, i got your email and have replied to it, a work in progress, but the basics are there

 September 19, 2012, 12:34 #4 Senior Member   Join Date: Dec 2011 Location: Madrid, Spain Posts: 134 Rep Power: 7 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.

September 21, 2012, 04:33
#5
Member

Michael Moor
Join Date: May 2012
Location: Ireland
Posts: 30
Rep Power: 6
Quote:
 Originally Posted by michujo 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

January 27, 2013, 10:37
Simple
#6
New Member

Hsn Mnh
Join Date: Jan 2013
Location: Beirut, Lebanon
Posts: 9
Rep Power: 5
Quote:
 Originally Posted by michaelmoor.aero 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

 January 27, 2013, 11:21 #7 Super Moderator     Praveen. C Join Date: Mar 2009 Location: Bangalore Posts: 255 Blog Entries: 6 Rep Power: 10 A good way to publicly share matlab code is on matlab central http://www.mathworks.in/matlabcentral/ __________________ http://twitter.com/cfdlab

 January 27, 2013, 11:25 . #8 New Member   Hsn Mnh Join Date: Jan 2013 Location: Beirut, Lebanon Posts: 9 Rep Power: 5 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 !

 January 29, 2013, 12:41 #9 Senior Member     p ding Join Date: Mar 2009 Posts: 312 Rep Power: 10 where is my little gifts? I think you should show the basis respect to me.

 January 29, 2013, 21:10 #10 Member   Michael Moor Join Date: May 2012 Location: Ireland Posts: 30 Rep Power: 6 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!

January 29, 2013, 21:15
#11
Member

Michael Moor
Join Date: May 2012
Location: Ireland
Posts: 30
Rep Power: 6
Quote:
 Originally Posted by michaelmoor.aero 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!

 February 10, 2013, 11:02 ! #12 New Member   Hsn Mnh Join Date: Jan 2013 Location: Beirut, Lebanon Posts: 9 Rep Power: 5 Nobody helped me !

February 11, 2013, 06:02
#13
Member

Michael Moor
Join Date: May 2012
Location: Ireland
Posts: 30
Rep Power: 6
Quote:
 Originally Posted by Maanieh.h 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...

 February 12, 2013, 08:01 Thanks MichaelMore #14 New Member   Hsn Mnh Join Date: Jan 2013 Location: Beirut, Lebanon Posts: 9 Rep Power: 5 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.

February 15, 2013, 17:02
#15
Member

Michael Moor
Join Date: May 2012
Location: Ireland
Posts: 30
Rep Power: 6
Quote:
 Originally Posted by Maanieh.h 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.

 February 15, 2013, 17:45 #16 Member   G. S. Join Date: Nov 2010 Posts: 53 Rep Power: 7 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...

 April 15, 2013, 07:13 need fvm code for SIMPLE #17 New Member   hellboy Join Date: Apr 2013 Posts: 1 Rep Power: 0 please send me code at anjaneya4@gmail.com thanks!!!

 May 1, 2013, 14:51 Blog proposal #18 New Member   Join Date: May 2012 Location: USA Posts: 14 Rep Power: 6 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.

 February 1, 2016, 11:47 Matlab code for steady incompressible laminar flow #19 New Member   Debayan Join Date: Jan 2016 Posts: 1 Rep Power: 0 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

 Thread Tools 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 On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Jenner Main CFD Forum 1 December 2, 2006 12:21 Jenner Main CFD Forum 2 November 20, 2006 06:22 Q Main CFD Forum 3 November 16, 2005 04:37 gorka Main CFD Forum 13 April 2, 2003 05:19 Kirill Main CFD Forum 4 November 5, 2002 10:04

All times are GMT -4. The time now is 20:31.