CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Modelling porosity as a function of temperature

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By macfly

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 2, 2015, 11:29
Default Modelling porosity as a function of temperature
  #1
New Member
 
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13
woody85 is on a distinguished road
In my case i want to model the porosity as a function of temperature. my code looks like this:

Code:
#include "udf.h"

DEFINE_PROFILE{dir1, t, i}
 {
	cell_t c;
	begin_c_loop(c,t)

		real temp = C_T(c,t);
	    
		if (temp > 1300.)
			C_PROFILE(c,t,i) = 13.7 - (temp - 1300) * 0.0015 + pow(temp - 1300,2.) *0.0000075;
		else if (temp > 1500.)
			C_PROFILE(c,t,i) = 0.01;
		else
			C_PROFILE(c,t,i) = 13.7;
		
	end_c_loop(c,t)
 }
 
 DEFINE_PROFILE{dir2, t, i}
 {
	cell_t c;
	begin_c_loop(c,t)

		real temp = C_T(c,t);
	    
		if (temp > 1300.)
			C_PROFILE(c,t,i) = 13.7 - (temp - 1300) * 0.0015 + pow((temp - 1300),2.0) *0.0000075;
		else if (temp > 1500.)
			C_PROFILE(c,t,i) = 0.01;
		else
			C_PROFILE(c,t,i) = 13.7;
		
	end_c_loop(c,t)
 }
But i always get the following error:

New_UDF.c.8748.5.c: line 8: parse error.

which is a little bit confusing.

thx for your help
woody85 is offline   Reply With Quote

Old   January 5, 2015, 11:14
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
- the accolades should be replaced with parentheses
- you should not use "temp" because it shadows previous definition

Quote:
Originally Posted by woody85 View Post
DEFINE_PROFILE{dir1, t, i}
{
cell_t c;
begin_c_loop(c,t)

real temp = C_T(c,t);

if (temp > 1300.)
C_PROFILE(c,t,i) = 13.7 - (temp - 1300) * 0.0015 + pow(temp - 1300,2.) *0.0000075;
else if (temp > 1500.)
C_PROFILE(c,t,i) = 0.01;
else
C_PROFILE(c,t,i) = 13.7;

end_c_loop(c,t)
}

DEFINE_PROFILE{dir2, t, i}
{
cell_t c;
begin_c_loop(c,t)

real temp = C_T(c,t);

if (temp > 1300.)
C_PROFILE(c,t,i) = 13.7 - (temp - 1300) * 0.0015 + pow((temp - 1300),2.0) *0.0000075;
else if (temp > 1500.)
C_PROFILE(c,t,i) = 0.01;
else
C_PROFILE(c,t,i) = 13.7;

end_c_loop(c,t)
}
woody85 likes this.
macfly is offline   Reply With Quote

Old   January 7, 2015, 06:27
Default
  #3
New Member
 
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13
woody85 is on a distinguished road
thx for your help - now it seems to work !
woody85 is offline   Reply With Quote

Old   January 13, 2015, 04:33
Default
  #4
New Member
 
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13
woody85 is on a distinguished road
Is this formulation of the UDF also valid for transient simulations ?
woody85 is offline   Reply With Quote

Old   January 13, 2015, 07:48
Default
  #5
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Yes it is valid.
macfly is offline   Reply With Quote

Old   January 13, 2015, 09:43
Default
  #6
New Member
 
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13
woody85 is on a distinguished road
Quote:
Originally Posted by macfly View Post
Yes it is valid.
Thx, i only have one problem left, i want to model more or less a simplified melting process of a porous media. The lines i posted are only a part of my code.

So far the melting is built up correctly, but when for some reason the temperatur in my cell decreases, the whole thing is reversible, which in my case is not realistic, as the molten liquid, flows to the bottom.

I want to ensure, that once my cell reached a certain temperature, the porosity cannot decrease again.
woody85 is offline   Reply With Quote

Old   January 13, 2015, 20:30
Default
  #7
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
I don't understand why you code dir1 and dir2 since the equation/conditions are the same. Code only one DEFINE_PROFILE and load the same property for both directions.

Porosity should be between 0 and 1, values like 13.7 and the jump at 1500 look weird.

Regarding the reversibility problem, you will have to store previous timestep values in a UDMI and compare them with current timestep values. Then write some if condition that keeps the porosity constant if T current timestep < T previous timestep. See this post for an example: http://www.cfd-online.com/Forums/flu...tml#post372530
macfly is offline   Reply With Quote

Old   January 14, 2015, 04:26
Default
  #8
New Member
 
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13
woody85 is on a distinguished road
First of all thanks for your help.

As i mentioned this is only a part of my code, i don´t wanted to upload the whole thing here because it´s to long. In the code i also modelled the pressure drop. Actually i copied the line for the inertial resistance. This is not identical in all directions in my case at the beginning. Therefore i had to use two values. Nevertheless the code for the porosity looks exactly the same onle the values change, they have to be between 0 and 1, as allready mentoined by you.

Thanks for the help regarding the reversibility problem. I will have a closer look on this.
woody85 is offline   Reply With Quote

Old   January 14, 2015, 05:56
Default
  #9
New Member
 
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13
woody85 is on a distinguished road
Dear MacFly, thx for your help.

The condition you suggested will not work out:

"Then write some if condition that keeps the porosity constant if T current timestep < T previous timestep"

because this condition would only work for 1 timestep. if i have temperature decrease for more timesteps, the condition would only look for the last timestep and can´t know that my material is allready melted e.g. 10 timesteps ago.

Therefor i suggested to take the porosity itself as condition. If the porisity 1 timestep ahead =1, then it should also be 1 in the next timestep. unfortunatly this doesnt work out so well yet, mainly to my lack of udf-experience.

my actual version of the UDF now looks like this:

Code:
 DEFINE_PROFILE(por, t, i)
 {
	cell_t c;
	begin_c_loop(c,t)

		real val_temp = C_T(c,t);
	    
		if (val_temp > 1500.)
			{
				C_PROFILE(c,t,i) = 1;    
				C_UDMI(c,t,1) = 1;    
			}
		else if (val_temp > 1300. && val_temp < 1500.)
			{
				C_PROFILE(c,t,i) = val_temp*0.000425 + 0.3575;
				C_UDMI(c,t,1) = val_temp*0.000425 + 0.3575;
			}
		else
			{
				C_PROFILE(c,t,i) = 0.91;
				C_UDMI(c,t,1) = 0.91;
			}	
			
		C_UDMI(c,t,0) = C_UDMI(c,t,1) /*not working */

	end_c_loop(c,t)
 }
The idea was to store the actual value of the porosity in den UDMI, and at the end i want to store the actual value of the UDMI, so that i can use the values in the next timestep (not working yet). Here i made an mistake.

The next steps would be to make an if condition, to check if the porosity in the timestep before was 1 or not, if the value was 1, then overwrite the actual value of the cell with the value 1.
woody85 is offline   Reply With Quote

Old   January 14, 2015, 10:55
Default
  #10
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Quote:
Originally Posted by woody85 View Post
if i have temperature decrease for more timesteps, the condition would only look for the last timestep and can´t know that my material is allready melted e.g. 10 timesteps ago.
If you need to know if material was already melted what about using a boolean variable?
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] How to define to right point for locationInMesh Mirage12 OpenFOAM Meshing & Mesh Conversion 7 March 13, 2016 15:07
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 06:42
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 15:11
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 07:59


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