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

UDF for Defining different Density calculation formula for different Cell-zones.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 2, 2022, 13:20
Post UDF for Defining different Density calculation formula for different Cell-zones.
  #1
New Member
 
shubham
Join Date: Dec 2021
Posts: 1
Rep Power: 0
shubham is on a distinguished road
Hello all,
I have a problem in defining Density. I am simulating multiphase simulation where density is a function of Temperature and composition. For that I want to define two different density calculation formula in two different cell zones.

For this I am using the following UDF:



#include "udf.h"
#include "math.h"
#include "materials.h"
#include "threads.h"

/* I want to define two different DENSITY variation in two different cell zones. */

DEFINE_PROPERTY(cell_density,c,t)
{
real rho;
int i;

real T;
real xch4;
Material *sp;
Domain *mixture_domain;
mixture_domain = Get_Domain(3); // domain id of liquid phase = 3
Thread *tc1,*tc2;
tc1 = Lookup_Thread(mixture_domain,14); //14 is Domain id of bottom zone
tc2 = Lookup_Thread(mixture_domain,15); //15 Domain id of middle zone


if (t == tc1) //when thread pointer at bottom zone xch4 remain constant
{
mixture_species_loop(THREAD_MATERIAL(t),sp,i)

{
T = C_T(c,t);
xch4 = 0.89;
rho = (-0.8292 - (0.5407*xch4))*(T - 100) - (250.15*xch4) + 690.73;

}
//return rho;

}

else if (t == tc2) //when thread pointer at middle zone Temperature remain constant
{
mixture_species_loop(THREAD_MATERIAL(t),sp,i)

{
T = 111.67;
xch4 = C_YI(c,t,1);
rho = (-0.8292 - (0.5407*xch4))*(T - 100) - (250.15*xch4) + 690.73;
}
//return rho;

}

return rho;


}







The UDF compiles without any problems. However, as soon as it starts,
the simulation begins to diverge. Without UDF, the simulation runs without a hitch.
I can't seem to figure out what the issue is.
Does anyone have an idea what this can be due to?

Many thanks in advance.
Attached Files
File Type: c rho_mix_2 - Copy.c (1.1 KB, 1 views)
shubham is offline   Reply With Quote

Old   June 10, 2022, 01:48
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
i think you don't need these lines:
Code:
mixture_species_loop(THREAD_MATERIAL(t),sp,i)
most likely concentration macro leads to error
Code:
xch4 = C_YI(c,t,1);
it is possible, that at 0 moment concentration is not defined yet, but you are trying to use it for calculations, that will lead to problems if that is the case.
You may try to define some specific value for initialization (when time = 0) explicitly to bypass possible issue.

make sure you are using correct index for material either, which you put as 1
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
mixture density, multiphase mixture model, udf


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
UDF in case with DPM modle POSTHU Fluent UDF and Scheme Programming 0 March 3, 2021 08:21
[snappyHexMesh] Creating multiple multiple cell zones with snappyHexMesh - a newbie in deep water! divergence OpenFOAM Meshing & Mesh Conversion 0 January 23, 2019 05:17
UDF for current density in PEM fuel cell sajjad haider FLUENT 2 February 22, 2012 19:16
Cells with t below lower limit Purushothama Siemens 2 May 31, 2010 22:58
REAL GAS UDF brian FLUENT 6 September 11, 2006 09:23


All times are GMT -4. The time now is 17:27.