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

UDF for multiphase species transport (calculate the thread face temperature and press

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 24, 2020, 09:09
Post UDF for multiphase species transport (calculate the thread face temperature and press
  #1
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
I have tried to write udf to adjust some values on a specific domain during the simulation of species transport in porous material using multiphase Eularian model, i have two phases; the primary phase (which is mixture water vapor and some gases), and the secondary phase (water liquid).
Below is my code used adjust function, the problem is i need to calculate species mass fraction density .....etc. and in the same loop i need to calculate the adjacent cell temperature and thread face temperature and pressure, i used the mp_thread_loop_f() and pointer for the primary phase to be able to loop the calculation over the primary phase. the problem is i cannot calculate the right thread face temperature and pressure, the code returned infinite value of face temperature as the solution converge. I cannot use F_T(f,tf) and F_P(f,tf) directly because the tf should be a pointer for the primary phase inside the mp_thread_loop_f() .
any suggestion to calculate the right face temperature and pressure in the same loop.

[PHP]DEFINE_ADJUST(temp_pressure_check, mixture_domain)
{
mixture_domain = Get_Domain(1);
Thread *tf = Lookup_Thread(mixture_domain, ID);

Thread *cell_thread; //cell thread in the
domain (in all the domain)//
Thread *tc;
cell_t c;
face_t f;
int phase_domain_index;
Domain *subdomain; // is for phase
Thread **pt;


mp_thread_loop_f(tf, mixture_domain, pt)

{
begin_f_loop(f,pt[0])
{
tc = THREAD_T1(pt[0]); // shadow cell thread

c = F_C1(f,pt[0]); // adjacent cell

Y_i= C_YI(c,tc,0);
wall_temp = F_T(f,tc); //*** problem: i need to
//calculate the F_T(f,tf) but i
//cannot use the the thread pointer

wall_press = F_P(f,tc) + operating_P;

............
}

end_f_loop(f,pt[0])
}
}
sajaalrifai is offline   Reply With Quote

Old   February 25, 2020, 08:32
Default Issues with the code
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
1. You need to remove first line since Fluent is returning value for the mixture_domain. No need to use Get_Domain to fetch it

2. Fluent does not accept // for comment. You need to use /* */. Otherwise, it could lead to inexplicable errors.

3. ID is undefined

4. You are using wrong thread in the begin_f_loop {} end_f_loop. It has to be mesh thread, i.e., tf, and not pt[0]. With the loop, to access something, you have to either use tf or pt[0], depending upon whether data belongs to the phase or not. Such as, F_U belongs to phase but F_AREA does not.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 25, 2020, 08:57
Default
  #3
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
thank you vinerm for your reply,

1. this part from my UDF, the ID defined in the other part.

2. i need to loop over the primary phase in the thread domain tf, the only way i found is to use the pointer to the primary phase in the begin_f_loop {} end_f_loop and this already mentioned in the ansys UDF manual, and itis works with i got reasonable results for the species mass fraction and density.
my problem is i cannot calculate the face temperature and pressure inside the same loop because i am looping over phase not over cells and walls.

saja
sajaalrifai is offline   Reply With Quote

Old   February 25, 2020, 09:09
Default Implications
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
My point being, you should use tf in face loop and not pt. This way, you can access F_T and F_P as well as use F_YI or C_YI from pt. The reason is that pt is already available from the mp_thread_loop_f while the f for a particular tf becomes available only when begin_f_loop gets these two arguments. Look at the following

Code:
mp_thread_loop_c(t,domain,pt)
    if (FLUID_THREAD_P(t))
      {
	cell_t  c;
	begin_c_loop_int (c,t)
	  {
	    real c_vol = C_VOLUME(c,t);
            totvolume += c_vol;
	    if (C_VOF(c,pt[gp]) > 0.7)
	      {
		pvol += C_VOF(c,pt[gp])*c_vol;
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 25, 2020, 11:21
Default
  #5
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
thank you Vinerm,

I solved the problem by calculating the face temperature and pressure in another ADJUST function, and I saved the values in the UDMI, then used this values in the mp_thread_loop_f loop.
this way have worked with me and gave me a good results, but its costs me use two ADJUST functions in the same time for the same thread domain.

i will try your way and see whats gonna happen.

thank you
SAJA
sajaalrifai is offline   Reply With Quote

Old   February 25, 2020, 11:24
Default Good
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Nice to know that there is some solution that works.
sajaalrifai likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 2, 2020, 12:50
Question
  #7
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
Hello Vinerm,

i went back to your suggestion due to some problems in my codes, your suggestion is to use the statement: if (FLUID_THREAD_P(t)) to indicate the phase that i have, but this macro or function return true in case of the phase liquid, otherwise return solid phase.
in my case i have the primary phase (which is a mixture of some gases) and the secondary phase which is the water liquid. I need the pointer work on the primary phase (gas mixture), do you have any suggestion how to employ this if-statement to indicate to the mixture of gases under the: mp_thread_loop_f(t,domain,pt).

thank you
Saja
sajaalrifai is offline   Reply With Quote

Old   March 2, 2020, 12:58
Default Solid or Fluid
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
The macro I shared is not meant for phase threads, rather for mesh threads to check if it is of type Fluid or type Solid. For phase thread, you simply fetch it's ID using DOMAIN_ID and compare if it is equal to the one given in Phases panel.

if(DOMAIN_ID(0) == 2)

Replace 2 with the number for gas phase from Phases panel.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 5, 2020, 11:48
Smile Adjust function for multiphase species transport
  #9
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
Hello Vinerm,

Thank you so much for your advice's, after struggling weeks in the loop, i have wrote an adjust function can calculate the face temperature, cell temperature and pressure, cell mass fraction (for the primary phase)and density for multiphase species transport, and here is my loop:

DEFINE_ADJUST(calculate_Var, mixture_domain)
{


mixture_domain = Get_Domain(1);
Thread *tf = Lookup_Thread(mixture_domain, ID);
Thread *cell_thread;
Thread *tc;
cell_t c;
face_t f;
Thread **pt;
Thread *ti;

mp_thread_loop_f(tf, mixture_domain, pt)

if (DOMAIN_ID(tf) == 2)

{
begin_f_loop(f,tf)
{
tc = THREAD_T0(tf); /*adjacent cell thread*/
c = F_C0(f,tf); /*adjacent cell*/

pt = THREAD_SUB_THREADS(tc);

ti = pt[0]; /* pointer for the primary phase*/

Y_i= C_YI(c,ti,0);

rho_g = C_R(c,tc);

wall_temp = F_T(f,tf);

wall_press = F_P(f,tf) + operating_P;

cell_temp = C_T(c,ti);

cell_press = C_P(c,ti) + operating_P;

}

end_f_loop(f,tf)
}
}


Thank you
sajaalrifai is offline   Reply With Quote

Old   March 5, 2020, 11:53
Default Good
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
That's good, Saja.

First line is not needed since Fluent already provides the value of mixture_domain. Do note that in every DEFINE_ function, Fluent only expects names of variables, not their values. Fluent provides their values to be used in the code.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 5, 2020, 12:01
Smile
  #11
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
thank you,
i will remove the first line,
thank you so much for your helping and time
sajaalrifai 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
chemical reaction - decompostition La S. Hyuck CFX 1 May 23, 2001 01:07


All times are GMT -4. The time now is 14:45.