
[Sponsors] 
March 30, 2015, 09:57 
Fetching face temperature(F_T) at zero TIMESTEPS

#1 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear all,
I am currently doing a project on wood sphere gasification, where there will be a sphere in the middle of a cylindrical flow domain having "velocityinlet" on one side and "pressureoutlet" on other side. While, since the gasification involves devolatilization (evaporation in simple). There will be a mass flow of gases from the surface of the sphere. This is dependent on "time, mass, surface area and surrounding temperature". Thankfully with the help of a member of this group, I was able to obtain the mass flow rate from the sphere surface which is currently "dependent" on "time" and "mass". As a next step I was trying to include "flow domain (cylinder)" temperature as a variable deciding the mass flow rate from the surface of the sphere. I have proceeded with a separate zone surrounding the sphere inside a cylinder. Using this Zone ID, I am trying to use F_T(f,t,i) to find the temperature of the sphere surrounding. If I use the code having F_T(f,t,i) or C_T(c,t,i). The solver is giving ACCESS VIOLATION error. From what I have seen in some cases, "Energy equation usually starts solving after few iterations say 3 or 4 iterations. QUESTION: Is this the reason for ACCESS VIOLATION error?? Any help on this regard will be of great use for me. Thanks in advance, Bharadwaj B S Last edited by Bharadwaj B S; March 31, 2015 at 01:34. 

March 30, 2015, 16:19 

#2 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
Before we get started, check you have the energy equation enabled under models (this oversight is common). If you're still receiving this access violation error then try restricting your access to C_T until after the first iteration (if statement checking the current time step/iteration).
Typically, the reason for an access violation error is when you're trying to access a variable that doesn't exist (or perhaps is empty/NULL). I'd be surprised if the temperature is not available from the first iteration because we initialise the temperature field before solving. 

March 31, 2015, 01:32 
Energy is ON

#3 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear e,
I have switched on "energy equation". I also thought of same error. But that part I think it is clear. I will try by starting the code after few "time steps" say 4 or 5. And will let you know as soon as possible. And one more question. "Do I have to make a "face" or "cell loop" to get the temperature of the zone or the command "C_T(c,t,i) or F_T(f,t,i)" in single is enough to fetch the temperature of the surrounding zone??. Because currently I have used face looping with F_T macro, is that what is giving an error of "ACCESS VIOLATION"?? Thank you, Bharadwaj B S 

March 31, 2015, 02:29 

#4 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
Try both C_T and F_T to determine if either or both of these macros cause the access violation error. The local temperature in a cell is given by the macro C_T; I'm unsure why you're looping or looking at face temperatures.


March 31, 2015, 02:38 
Thank you.

#5 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear e,
I will try both C_T and F_T, I was quizzed about looping. Now I will try with only "C_T and F_T" in single. Thank you, Bharadwaj B S 

April 3, 2015, 06:16 
reason

#6 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear e,
I am using face looping because I want to find the average temperature of a zone (fluid flow). And use that value in some other function. I tried with F_T(f,t,i); it is working fine. It is not giving access violation. But it is showing divergence TEMPERATURE. This is the code I am using. UDF DEFINE_ADJUST(tempt_calc,d) { Thread *t2; face_t f2; real tempt=0.0; d = Get_Domain(1); t2 = Lookup_Thread(d,ID2); Message("At is %e\n",At);/*from previous function for surface area*/ begin_f_loop(f2,t2) { tempt=tempt+(F_T(f2,t2)*F_UDMI(f,t,0)); /*F_UDMI(f,t,0) is from previous function for "surface area"*/ } end_f_loop(f2,t2) tempt=tempt/F_UDMI(f,t,0);/*area avging*/ F_UDMI(f2,t2,1)=tempt; Message("Averaged tempt is %e\n",F_UDMI(f2,t2,1); } When I use this I am getting "Divergence error". So I changed the cycle type of ENERGY to "F cycle" and Stabilization method to BCGSTAB. The simulation runs but The temperature keeps on "increasing" every TIMESTEP (transient analysis). Please go through the UDF and suggest me for changes so that I can get a constant value of average temperature or at least, least varying average temperature. Thanks in advance, Bharadwaj B S 

April 3, 2015, 07:30 

#7  
Senior Member
Join Date: Nov 2013
Posts: 1,197
Rep Power: 15 
Quote:
1. The simulation runs, and the temperature in your simulation (the one you get when you plot temperatures) is increasing. 2. The simulation runs, and the number that this UDF shows ("Averaged tempt is ..." is increasing. Which one is it? Or both? 

April 3, 2015, 08:38 
2nd

#8 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
Its second one which is increasing. Thank you, Bharadwaj B S 

April 3, 2015, 08:47 

#9 
Senior Member
Join Date: Nov 2013
Posts: 1,197
Rep Power: 15 
Ok, then the mistake must be in your current UDF.
Looking at the code, I am surprised it compiles. You use variables "f" and "t" that are not defined. So you multiply the temperature of the cell in the loop by F_UDMI of an undefined face. This is very strange. But after that, you divide your result by that same unknown F_UDMI. So first you multiply, then you divide. So it does nothing... And then you say "F_UDMI(f2,t2,1)=tempt;". What is f2 supposed to be here? You used f2 inside the loop, but you are now outside the loop. It is undefined here... Didn't you get errors and warnings when you compiled this UDF??? 

April 3, 2015, 08:55 
Definition

#10 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear e,
f and t are declared GLOBALLY but I did not know that I have to define them with numbers. F_UDMI(f,t,0) is from a previous function which is for calculation of surface area of sphere which is present inside a cylindrical flow domain. Here F_UDMI(f,t,0) is the area of a sphere surface which is already calculated. f2,t2 are related to the zone surrounding the sphere which is a cylindrical flow domain. I saw one example where temperature is calculated as area average. IF I AM WRONG IN CONCEPT OR IN UDF, CORRECT ME, please. Message is to know what is the value of tempt after completion of the loop. Please correct me if I am anywhere wrong. I am still learning how to write UDF. Thank you, Bharadwaj B S 

April 3, 2015, 08:59 
Mistake

#11 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
I should have mentioned all this before. Its a mistake from my side. Please pardon me. Thank you, Bharadwaj B S 

April 3, 2015, 09:03 

#12 
Senior Member
Join Date: Nov 2013
Posts: 1,197
Rep Power: 15 
It's ok, I see you are still learning. But it is hard to say what you did wrong, when I don't know why you did things.
I have tried to put comments next to your code, guessing what you tried to do. Can you check if I guessed your intentions right? (Especially the last three comments?) Code:
DEFINE_ADJUST(tempt_calc,d) { Thread *t2; /*t2 will be the thread of ID2*/ face_t f2; /*f2 will be the face in the loop */ real tempt=0.0; /*tempt will be the sum of temperatures */ d = Get_Domain(1); /* get the domain */ t2 = Lookup_Thread(d,ID2); /* make t2 the required thread */ Message("At is %e\n",At); /*from previous function for surface area*/ begin_f_loop(f2,t2) /*let f2 be all faces of the thread */ { tempt=tempt+(F_T(f2,t2)*F_UDMI(f,t,0)); /*add the temperature of f2 to "tempt", with the surface area of the ball as weight factor? */ } end_f_loop(f2,t2) tempt=tempt/F_UDMI(f,t,0); /*divide "tempt" by the surface area of the ball?*/ F_UDMI(f2,t2,1)=tempt; /* what is the goal of this? */ Message("Averaged tempt is %e\n",F_UDMI(f2,t2,1); } 

April 3, 2015, 09:07 
Okay

#13 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
I think I should have used the area of the CYLINDRICAL flow domain area instead of the sphere i.e, using f2 and t2 I should have found out the area of ID2(zone). Yes it is totally conceptually wrong. Am I interpreting it in correct way? Thank you, Bharadwaj B S 

April 3, 2015, 09:10 
F_UDMI(f2,t2,1) use

#14 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
I just wanted to store the value of final value of tempt to F_UDMI(f2,t2,1). Is that possible? Thank you, Bharadwaj B S 

April 3, 2015, 09:14 

#15  
Senior Member
Join Date: Nov 2013
Posts: 1,197
Rep Power: 15 
Quote:
If that is so, then you are interpreting it in the wrong way. I said that I did not understand why you did some things, and asked you to clarify this. I did not make any judgement about if it was conceptually wrong or right, only that I did not understand it. Quote:


April 3, 2015, 09:18 
Sorry

#16 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
Yes I was about to store that value in UDM (F_UDMI(f2,t2,1)) so that I could use that in other calculations. Thank you, Bharadwaj B S 

April 3, 2015, 09:26 

#17 
Senior Member
Join Date: Nov 2013
Posts: 1,197
Rep Power: 15 
So you goal is to make the value available in other calculations.
And you attempted method was to use a UDM. But a UDM is in this case not a good method. If you use a UDM, memory is reserved for all cells in your domain. So if you have a simulation with one million cells, you can store one million numbers in your UDM, one for each cell. But you don't need to store one number for every cell, you only need to store one number for your entire simulation. So a UDM is not the best choice. What I would do, is simply make "tempt" a global variable. So declare it outside this function. In that way, all functions can access it. But you still haven't explained what the goal of doing manipulations with F_UDMI(f,t,0) in your code is. I don't understand that. What did you try to achieve with that? 

April 3, 2015, 09:36 
Clarification.

#18 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
I was confused, I have used the surface area of sphere instead of flow domain. And I think I should have multiplied the MAGNITUDE of area Vector of the flow domain instead of total area(At of sphere), i.e, here "At" is the total calculated area of sphere previously I had assigned the total surface area of the sphere "At" to F_UDMI(f,t,0). So I thought by multiplying and dividing "At" I would get the area averaged temperature. But I think I should have multiplied by magnitude of "area vector" of FLUID DOMAIN and then at the end of loop I should have DIVIDED by TOTAL AREA of FLUID DOMAIN. Instead I did a mistake by multiplying and dividing tempt with SAME NUMBER. So it was of no use. And that too the surface area values are of SPHERE. Thank you, Bharadwaj B S 

April 3, 2015, 09:39 

#19 
Senior Member
Join Date: Nov 2013
Posts: 1,197
Rep Power: 15 
Hi,
I think you are now thinking in the right direction! But maybe you now understand that assigning the total surface area of the sphere to F_UDMI(f,t,0) was a silly idea; you should have just assigned it to the global variable "At". 

April 3, 2015, 09:43 
Yes

#20 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 5 
Dear pakk,
Yes my mind never thought of using GLOBAL variable. And I was only aware of storing a value by using UDMs. Huge thanks from my side. I will make the changes accordingly. And run the simulations. Will post the results as soon as possible. Thanks a ton, Bharadwaj B S 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Maximum number of iterations exceeded chtmultiregionsimpleFoam  Moncef  OpenFOAM Running, Solving & CFD  10  May 31, 2017 18:04 
Extrusion with OpenFoam problem No. Iterations 0  Lord Kelvin  OpenFOAM Running, Solving & CFD  8  March 28, 2016 11:08 
Courantnumber explodes after a lon while (icoFoam)  Rody  OpenFOAM Running, Solving & CFD  6  January 29, 2014 05:27 
Micro Scale Pore, icoFoam  gooya_kabir  OpenFOAM Running, Solving & CFD  2  November 2, 2013 14:58 
pisoFoam with kepsilon turb blows up  Some questions  Heroic  OpenFOAM Running, Solving & CFD  26  December 17, 2012 04:34 