
[Sponsors] 
August 2, 2013, 05:40 
CFD for multiphase flow in porous media

#1 
New Member
Ahamadi
Join Date: Aug 2013
Posts: 8
Rep Power: 4 
hello!
I am trying to develop a code of calculations for assisted oil recovery (thermal steam injection methods), it is my thesis, I have almost completed my codes (I work in matlab), but I 'have problems with the results that bother my head for months. I did everything I tried everything, but I do not understand what is the source of these problems that really breaks my head, so I opened discussing this for your comments and RECOMMENDED; any remark will be useful. here's the problem: when I run my program, I find results that have no physical meaning. sometimes complex or negative pressures, same things for temperature and saturation, and sometimes it nor anything but matlab displays Nan. I checked all programs in the discretization of equations (I work with finite volume), the equations themselves etc.. everything seems correct but I met his problems in my results. I do not understand anything at all, so if anyone can give me some lines of thought on the possible causes I would be very grateful. is that this kind of problem often when developing a computer code? What are the possible causes? Thank you for your advice and comments 

August 2, 2013, 05:55 

#2 
Senior Member
Join Date: Dec 2011
Location: Madrid, Spain
Posts: 133
Rep Power: 6 
Hi, I have no idea about your specific case but it looks there might be some bugs in your code. I could suggest checking the following:
 Is it possible that you might be dividing by a variable that is zero at some point? hence the NaN.  Are you taking the power or root square of a variable somewhere in your code? If the variable, for whatever reason (numerical dispersion for instance) becomes negative somewhere in your domain, the code could yield either NaN or even amplify this negative value that will grow until it crashes (in this case I'd suggest clipping the variable to zero).  Just a regular bug (you mistook a variable for another, + for , * for /, * for ^, etc) I suggest you perform a very simple simulation of a well documented case for which analytical solution exists and compare it to your results. If it works fine then go for a complex case. If it crashes then reduce the number of iterations until you find the exact number of iterations that make your code crash, or one iteration less (the code just about to crash). Find exactly the variable that is going wild and try to trace back the bug (insert prints everywhere in your code checking the values of the variables you suspect are wrong at every line). Good luck . Cheers, Michujo. 

August 2, 2013, 09:10 

#3 
New Member
Ahamadi
Join Date: Aug 2013
Posts: 8
Rep Power: 4 
hi!
I tried to check the code line by line and I noticed that this is from the second iteration time code starts to give poor results. from my remarks temperature becomes negative quenormarlement then it should not be the case (especially since this is the temperature in Kelvin), the problem is that I do not understand why. I tried searching but I can not find. I can not know what is causing this wrong temperature value. I continue to work on it but I do not know where to look, I really need your help, it's been almost a year since I'm stuck on the progress of my work because of these results! Thank you all for your comment and advice 

August 2, 2013, 09:18 

#4 
Senior Member
Join Date: Dec 2011
Location: Madrid, Spain
Posts: 133
Rep Power: 6 
Hi. That is good news. Now start pulling the string and see where it leads you:
 How is the temperature calculated? => go to that line and check that all the variables that appear in the temperature equation are OK (print them on screen). Either some variable used is wrong or there is a mistake in the expression for the temperature calculation, check that. Let us know. Cheers, Michujo. P.S.(1): Just out of curiosity. How is it possible that you've been stuck fro a year and nobody helped you? Your project seems to be fairly complicated. Is it a MSc thesis? PhD? job? Don't you have a supervisor? P.S.(2): Can you send the whole code or it is confidential? 

August 2, 2013, 15:19 

#5 
New Member
Ahamadi
Join Date: Aug 2013
Posts: 8
Rep Power: 4 
hi!
Thank you for the interest you wear to my problem. the temperature in the code is one of the primary unknown of the model consitutes of continuity equations of each fluid phase, momentum and one energy equation. so the temperature appears in the equation of energy and is one of the unknowns of the system discretized by the finite volume methods . The project that I am trying to do is my doctoral dissertation (PhD thesis), I have a supervisor but it does nothing, so I work alone and I can not find people who can help me to give me ideas or discuss a problem that does not work. Even my supervisor that he barely hear what I have to say, even if he listens he did not tell me if it is a good work or not, and if I have a problem who I do not understand, he never has the time for a discution. in short, that he avoids discussing together what works and what does not. So I am left to myself for this work, I am motivated to finish my thesis, so after all these problems, but I went up there and I'm stuck on these results I've done everything but I do not undestand where is the problem and, he said nothing to me, that's why I opened the debate on this site I hope you can help me. when the code is for the lab, but if someone can help me, I can send it to him. All the way it is I who have done everything in this code, no person in the lab will help me so if someone wants to help me out why not show the code. If you think you can help me give me your email and I will send thank you for your help 

August 5, 2013, 04:40 

#6 
Senior Member
Join Date: Dec 2011
Location: Madrid, Spain
Posts: 133
Rep Power: 6 
Hi, that's sad news. Your supervisor does not seem to give a **** about his students...
Anyway, if you want to get any help you must state very clearly what your problem is and give all the details (equations being solved, method, etc). For the particular case you mentioned you could start by defining it (equations solved, geometry, boundary and initial conditions, is it steady or unsteady, ...). Also include pictures that might help us better understand your problem such as the temperature field, highlighting the regions where the problem appears... Good luck. Michujo. 

August 6, 2013, 10:49 

#7 
Member
Ren/Xingyue
Join Date: Jan 2010
Location: Nagoya , Japan
Posts: 44
Rep Power: 7 
Hi,
I have been in that situation for nearly 3 years. Professors' suggestion is normally based on your results unless they have knowledge on CFD. If your code with a NAN problems, it means a long way is needed to succeed. In the process I wrote my own model, I tracked the variables to find the source of problems. 1. Write the value of variables on your screen to find which one become NAN firstly. 2. Check the section that computed the variable you find in step 1. People do make mistakes, be more careful. I struggled in my model for 3 months for the mistake in the computation of the CFL number. Hope that can help you Ren 

August 8, 2013, 12:43 

#8 
New Member
Ahamadi
Join Date: Aug 2013
Posts: 8
Rep Power: 4 
hello!
thank you for the various comments and ideas who you give me, it helps me a lot because now I can not find the Nan though, I have not SUCCESSFUL stabilize my code. Now another problem I have observed is the following: for linearization of my systems of equations, i use the NewtonRaphson method, and the resolution of the linear system I use the GMRES iterative method, the problem I currently facing is that apparently the calculation of values that may have a physical sense, but the newtonRaphson method does not converge , what do you think of that? after several test to understand what wrong I had the idea to change the GMRES method using the method of conjugate gradient, this method does not show me Nan but complex values still appear. do you think I should implicate in all my model where it is possible that this is the method of conjugate gradients is missing and I have to satisfy of GMRES and try understand why Newton Raphson method does not converge? What do you recommend for the nonconvergence of the NewtonRaphson method? Thank you very much for your support and comments that help me a lot 

October 3, 2013, 04:42 

#9 
New Member
Ahamadi
Join Date: Aug 2013
Posts: 8
Rep Power: 4 
Thank you, friends. your various RECOMMENDED brought their fruits. I managed to find solutions to most of my problems thanks to your advice. Now the other problem I have is a problem of convergence of the NewtonRaphson algorithm I utise for solving the matrix sytem. I tried to work on the relaxation coefficient, but still I do not get convergence. I once obtained a convergence but the results did not vary over time. What can you advise me on that?
Thank you again for your comment and advice 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
multiphase flow in porous media  zhou  FLUENT  2  August 9, 2012 07:10 
Recommended CFD porous media textbooks  siw  Main CFD Forum  1  January 3, 2012 11:03 
Multiphase flow & porous media  Hisham  OpenFOAM  3  April 10, 2011 07:04 
Multiphase Porous Media Flow  Convergence Issues  VT_Bromley  FLUENT  5  March 23, 2011 11:38 
Two phase flow in porous media  Madhavi Krishnan  FLUENT  3  June 6, 2005 05:52 