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

problem in definition of secondary phase volume fraction in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 17, 2016, 12:00
Default problem in definition of secondary phase volume fraction in UDF
  #1
New Member
 
hadi
Join Date: Aug 2015
Posts: 8
Rep Power: 10
hadii is on a distinguished road
Dear my friends, I have problem in definition of secondary phase volume fraction in UDF for using in 2-phase mixture model in fluent. UDF is as follows. it is interpreted successfully by fluent but after iteration fluent report this error: (FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()). how I can define secondary phase volume fraction in source term and slip velocity? Please help me!!

/************************************************** *************
UDF for a defining a custom slip velocity in a 2-phase
mixture problem
************************************************** **************/
#include "udf.h"
#define M0 1e-6
#define xw 0.1
#define yw -0.005
#define con 5213.0
#define dp 0.00000001
#define muf 8.55e-4
DEFINE_SOURCE(x_mom,c,t,dS,eqn)
{
real x[ND_ND];
real x1, y1, Temp, phi, term, source;
x1 = x[0];
y1 = x[1];
C_CENTROID(x,c,t);
Temp = C_T(c,t);
phi = C_VOF(c,t);/*phi=volume fraction of secondary phase*/
term = (pow((x1-xw),2.)+pow((y1-yw),2.))*(pow((x1-xw),2.)+pow((y1-yw),2.));
source = -0.001648*con*(x1-xw)*phi/(term*Temp);
dS[eqn] = 0.;
return source;
}
DEFINE_SOURCE(y_mom,c,t,dS,eqn)
{
real x[ND_ND];
real x1, y1, Temp, phi, term, source;
x1 = x[0];
y1 = x[1];
C_CENTROID(x,c,t);
Temp = C_T(c,t);
phi = C_VOF(c,t);/*phi=volume fraction of secondary phase*/
term = (pow((x1-xw),2.)+pow((y1-yw),2.))*(pow((x1-xw),2.)+pow((y1-yw),2.));
source = -0.001648*con*(y1-yw)*phi/(term*Temp);
dS[eqn] = 0.;
return source;
}
/************************************************** *************
UDF for defining a custom slip velocity in a 2-phase
mixture problem
************************************************** **************/
DEFINE_VECTOR_EXCHANGE_PROPERTY(custom_slip,c,mixt ure_thread,
second_column_phase_index,first_column_phase_index ,vector_result)
{
real x[ND_ND];
real x1 = x[0];
real y1 = x[1];
real Temp=C_T(c,mixture_thread);
real phi = C_VOF(c,mixture_thread);/*phi=volume fraction of secondary phase*/
real term= (pow((x1-xw),2.)+pow((y1-yw),2.))*(pow((x1-xw),2.)+pow((y1-yw),2.));
real fx = -0.001648*con*(x1-xw)*phi/(term*Temp);
real fy = -0.001648*con*(y1-yw)*phi/(term*Temp);
vector_result[0] =
fx*pow(dp,3)/(3.0*muf*dp);

vector_result[1] =
fy*pow(dp,3)/(3.0*muf*dp);
}
hadii is offline   Reply With Quote

Old   July 17, 2016, 17:02
Default
  #2
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 10
Zbynek is on a distinguished road
Access violation tells you that you are trying to access a variable that is not available. I think that in your case the problem is that you are trying to access VOF on the mixture level but the volume fraction will be much more likely defined on the phase level. So I would recommend to try to get sub-thread of the mixture thread and access the VOF through these.
Zbynek is offline   Reply With Quote

Old   July 18, 2016, 03:08
Default
  #3
New Member
 
hadi
Join Date: Aug 2015
Posts: 8
Rep Power: 10
hadii is on a distinguished road
Quote:
Originally Posted by Zbynek View Post
Access violation tells you that you are trying to access a variable that is not available. I think that in your case the problem is that you are trying to access VOF on the mixture level but the volume fraction will be much more likely defined on the phase level. So I would recommend to try to get sub-thread of the mixture thread and access the VOF through these.
************************************************** **********************************************
Dear Zbyenk thanks for your quick reply. I would be very grateful if you mention how I can define secondary phase volume fraction by get sub-thread of the mixture thread?
hadii is offline   Reply With Quote

Old   July 18, 2016, 11:55
Default
  #4
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 10
Zbynek is on a distinguished road
What you are looking for is the macro THREAD_SUB_THREAD(args). Just have a look in the Fluent Customization (UDF) Manual. There are a lot of examples of the procedure. Even directly in the section of the macro you used, DEFINE_VECTOR_EXCHANGE_PROPERTY, there is an example that uses the definition of sub-threads to obtain density of the phases. The approach to obtain the phase volume fractions is the same.

Code:
Thread *pt, *st;

pt = THREAD_SUB_THREAD(mixture_thread, second_column_phase_index);
st = THREAD_SUB_THREAD(mixture_thread, first_column_phase_index);
where pt and st are pointers to the phase threads.
Zbynek is offline   Reply With Quote

Old   July 18, 2016, 15:52
Default
  #5
New Member
 
hadi
Join Date: Aug 2015
Posts: 8
Rep Power: 10
hadii is on a distinguished road
Dear Zbynek
how I can define secondary void fraction in source terms where define_source macro [DEFINE_SOURCE(x_mom,c,t,dS,eqn)] dose not allow to define extra arguments such as :
Thread *pt, *st;

pt = THREAD_SUB_THREAD(mixture_thread, second_column_phase_index);
st = THREAD_SUB_THREAD(mixture_thread, first_column_phase_index);
Thanks again
hadii is offline   Reply With Quote

Old   July 18, 2016, 16:27
Default
  #6
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 10
Zbynek is on a distinguished road
If the passed thread t in the DEFINE_SOURCE macro is the mixture thread, then the secondary phase sub-thread should be:

Code:
ts = THREAD_SUB_THREAD(t,1);
Again, check for example the Guide's example on Degassing Boundary Condition. And read the theory on multiphase macros, then everything will become much more clear to you.
Zbynek is offline   Reply With Quote

Old   July 19, 2016, 04:38
Default
  #7
New Member
 
hadi
Join Date: Aug 2015
Posts: 8
Rep Power: 10
hadii is on a distinguished road
Dear Zbynek; based on your comment I defined a sub-domain to specify secondary phase but after interpretation of UDF, Fluent reports these errors:
line 10: parse error.
line 11: parse error.
line 12: x1: undeclared variable
@@@@@@@@@@@@@@@@@@@@@@@@@@
#include "udf.h"
#define xw 0.1
#define yw -0.005
#define con 5213.0
DEFINE_SOURCE(ymom, c, t, dS, eqn)
{
real source;
Thread *ts;
ts = THREAD_SUB_THREAD(t,1);
real x[ND_ND];
/*line10*/
real x1, y1, Temp, phi, term, source;
/*line11*/
x1 = x[0];
/line12*/
y1 = x[1];
C_CENTROID(x,c,t);
Temp = C_T(c,t);
phi = C_VOF(cell,ts);
term = (pow((x1-xw),2.)+pow((y1-yw),2.))*(pow((x1-xw),2.)+pow((y1-yw),2.));
source = -0.001648*con*(x1-xw)*phi/(term*Temp);
dS[eqn] = 0.;
return source;
}
hadii is offline   Reply With Quote

Old   July 19, 2016, 06:43
Default
  #8
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 10
Zbynek is on a distinguished road
Cannot see any problem on those lines. On line 16 change cell to c. Simple approach how to find a problem is to comment out all lines that you can except the return value and its declaration. Then add line by line and you will see exactly what the problem is.
Zbynek is offline   Reply With Quote

Old   July 19, 2016, 09:46
Default
  #9
New Member
 
hadi
Join Date: Aug 2015
Posts: 8
Rep Power: 10
hadii is on a distinguished road
Those errors are due to definition of subdomain for secondary phase i.e. Thread *ts;
ts = THREAD_SUB_THREAD(t,1);
when I remove it works.
hadii is offline   Reply With Quote

Old   July 20, 2016, 04:46
Default
  #10
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 10
Zbynek is on a distinguished road
No, that's not the problem. First of all, you declare source twice. Remove one of the declarations.

Code:
#include "udf.h"

#define xw 0.1
#define yw -0.005
#define con 5213.0

DEFINE_SOURCE(ymom, c, t, dS, eqn)
{
Thread *ts;
ts = THREAD_SUB_THREAD(t,1);

real x[ND_ND];
real x1, y1, Temp, phi, term, source;

C_CENTROID(x,c,t);
x1 = x[0];
y1 = x[1];
Temp = C_T(c,t);
phi = C_VOF(c,ts);
term = (pow((x1-xw),2.)+pow((y1-yw),2.))*(pow((x1-xw),2.)+pow((y1-yw),2.));

source = -0.001648*con*(x1-xw)*phi/(term*Temp);
dS[eqn] = 0.;

return source;
}
Secondly, do not interpret the function but compile it. It seems that the interpreter struggles with the THREAD_SUB_THREAD macro, but it compiles all fine.
Zbynek 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
multiphase turbulance case floating error harsha_kulkarni OpenFOAM Running, Solving & CFD 3 February 18, 2016 05:06
Finding Volume fraction at outlet when it changes its phase. praveen.jpk Main CFD Forum 1 August 18, 2014 07:18
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 21:14
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 11:16
How to set volume fraction in two phase flow Kamel FLUENT 2 March 23, 2007 00:06


All times are GMT -4. The time now is 03:38.