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

Multiphase UDF Parse Error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 13, 2020, 06:05
Default Multiphase UDF Parse Error
  #1
New Member
 
Nederland
Join Date: Sep 2020
Posts: 9
Rep Power: 6
mdmtramper is on a distinguished road
Hello everyone!

I am trying to interpret two UDFs to describe the non-Newtonian behaviour of blood in a multiphase simulation. I have written two DEFINE_PROPERTY functions, included in the text below. However, if I want to interpret them, FLUENT keeps giving me the 'parse error' after starting at the 'Domain *plasma_domain' line.

I have tried numerous things, and also tried to delete the Get_Domain and Lookup_Thread sections in my code. But if I did that, the initialization gave me a mtp_9999 error and the whole simulation immediately quit.

I have no idea what to do next, so maybe someone here has an idea? I know that my mesh is correct, since I used it for a range of other simulations as well. I am using ANSYS version 19.1 and have to run simulations via an external hpc cluster (using max 16 nodes). Maybe that has an influence as well, but I cannot even get the simulation working on my own computer (because I keep getting the parse error / mtp_9999 error).

Thanks in advance!

#include "udf.h"
DEFINE_PROPERTY(granular_viscosity_rbc, cell, thread)
{

int phase_domain_index, ID = 2;

Domain *mixture_domain;
mixture_domain = Get_Domain(1);

Domain *plasma_domain;
plasma_domain = Get_Domain(2);

Domain *rbc_domain;
rbc_domain = Get_Domain(3);

Thread* mixture_thread;
mixture_thread = Lookup_Thread(mixture_domain,ID);


real muplasma = 0.006;
real murbc = 0.01;
real mumix = 0.0037;
real eps_rbc = 0.45;
real lambda = 0.110;
real m = 9.106;
real n = 0.749;
real sr = 500;

Thread* mixture_thread;
Thread* subthread;

sub_thread_loop(subthread, mixture_thread, phase_domain_index)
{
if(subthread == Lookup_Thread(plasma_domain,ID))
{
muplasma=C_MU_L(cell,subthread);
}
else if(subthread == Lookup_Thread(rbc_domain,ID))
{
sr = C_STRAIN_RATE_MAG(cell,subthread);
eps_rbc = C_VOF(cell,subthread);
}
}

n = 0.8092*pow(eps_rbc ,3.) - 0.8246*pow(eps_rbc ,2.) - 0.3503*eps_rbc + 1.;
m = 122.28*pow(eps_rbc ,3.) - 51.213*pow(eps_rbc ,2.) + 16.305*eps_rbc + 1.;
mumix = m* pow( (1.+ pow((lambda*sr) ,2.) ),((n-1.)/2.) );
murbc = (mumix*muplasma -(1.-eps_rbc)*muplasma)/eps_rbc;
return murbc;
}

#include "udf.h"
DEFINE_PROPERTY(density_rbc,cell,thread)
{
int phase_domain_index;
int ID=2;

Domain *mixture_domain;
Domain *plasma_domain;
Domain *rbc_domain;

Thread *mixture_thread;
Thread *subthread;

real rhoplasma = 10;
real rhorbc = 10;
real vof = 0.45;
real rhomix = 1080;

sub_thread_loop(subthread, mixture_thread, phase_domain_index)
{
if(subthread == plasma_domain)
{
rhoplasma = C_R(cell,subthread);
}
else if(subthread == rbc_domain)
{
vof = C_VOF(cell,subthread);
}
rhorbc = (rhomix - (rhoplasma*(1-vof)))/(vof+1e-4);
}
return rhorbc;
}
mdmtramper is offline   Reply With Quote

Old   October 14, 2020, 17:31
Default
  #2
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
hello I am not a proffessional in writing a UDF, but I've tried different things for writing UDF for multiphase flow and this UDF structure works with me, you can use the same thing:

DEFINE_ADJUST(adjust_water_vapor, mixture_domain)
{
mixture_domain = Get_Domain(1); /* returns mixture domain pointer (DOMAIN_SUPER_DOMAIN will return the same pointer as Get_Domain(1).*/

Thread *tf = Lookup_Thread(mixture_domain, ID); /*surface (face thread) thread which is the mixture_domain for multiphase*/

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


mp_thread_loop_f(tf, mixture_domain, pt)

if (DOMAIN_ID(tf) == 2) /* you point to the phase domain inside the thread in my case point to the vapor, you can read from phases*/

{

begin_f_loop(f,tf)
{
tc = THREAD_T0(tf);
c = F_C0(f,tf);
pt = THREAD_SUB_THREADS(tc);
ti = pt[0];
.........................





}
end_f_loop(f,tf)
}
}
sajaalrifai is offline   Reply With Quote

Old   October 15, 2020, 07:07
Default
  #3
New Member
 
Nederland
Join Date: Sep 2020
Posts: 9
Rep Power: 6
mdmtramper is on a distinguished road
Dear sajaalrifai,

Thanks for your response! I have tried implementing your solution. However, i still get the parse error after the Lookup_Thread command.It almost seems like my FLUENT doesn't recognise the lookup_thread command. Are there any other recommendations or possibilities? Furthermore, if you use the line Thread *tf = Lookup_Thread(mixture_domain, ID); is it on purpose that you do not define the ID beforehand?

Thanks in advance!
mdmtramper is offline   Reply With Quote

Old   October 16, 2020, 07:09
Default Floating point error
  #4
New Member
 
Nederland
Join Date: Sep 2020
Posts: 9
Rep Power: 6
mdmtramper is on a distinguished road
Dear all,

I have updated the first part of the code to the following:
#include "udf.h"
DEFINE_PROPERTY(granular_viscosity_rbc , cell , thread_rbc)
{
int phase_domain_index , ID=2;
Thread *mixthread;
Thread *subthread;
Domain *mixture_domain;
mixture_domain = Get_Domain(1);
mixthread = Lookup_Thread(mixture_domain ,ID);
/* predefine variables */
real muplasma=0.001;
real murbc;
real mumix;
real eps_rbc;
real lambda=0.110;
real m;
real n;
real sr;
Domain *plasma_domain;
Domain *rbc_domain;
/* get domain numbers of plasma and rbc */
plasma_domain = Get_Domain(2);
rbc_domain = Get_Domain(3);
/* loop over all threads */
sub_thread_loop(subthread , mixthread , phase_domain_index)
{
/* viscosity in plasma thread is muplasma */
if ( subthread == Lookup_Thread(plasma_domain ,ID) )
{
muplasma = C_MU_L(cell , subthread);
}
else if ( subthread == Lookup_Thread(rbc_domain ,ID) )
{
sr = C_STRAIN_RATE_MAG(cell ,subthread); /* shear rate from rbc, could be the
wrong one */
eps_rbc = C_VOF(cell , subthread);
}
}
n = 0.8092*pow(eps_rbc ,3.) - 0.8246*pow(eps_rbc ,2.) - 0.3503*eps_rbc + 1.;
m = 122.28*pow(eps_rbc ,3.) - 51.213*pow(eps_rbc ,2.) + 16.305*eps_rbc + 1.;
mumix = m* pow( (1.+ pow((lambda*sr) ,2.) ),((n-1.)/2.) );
murbc = (mumix*muplasma -(1.-eps_rbc)*muplasma)/eps_rbc;
/*if (cell %50000==0)
{
Message("muplasma = %f\n", muplasma);
Message("strainrate = %f\n",sr);
Message("vof = %f\n",eps_rbc);
Message("n = %f\n",n);
Message("m = %f\n",m);
Message("mumix %f\n",mumix);
Message("murbc %f\n",murbc);
Message(" %f\n",);
}*/
return murbc;
}

Additionally, I am compiling the udf's instead of compiling. Now I don't get a syntax/parse error. However, I get a floating point exception error when trying to run the simulation.

Do you have any suggestion(s) for this problem?

Kind regards,

Michelle
mdmtramper is offline   Reply With Quote

Old   October 16, 2020, 08:34
Default
  #5
New Member
 
SAJA AL-RIFAI
Join Date: Feb 2020
Posts: 11
Rep Power: 6
sajaalrifai is on a distinguished road
hello, I don't exactly know what's your error. but it seems that you put everything in one UDF. I means I don't think you can loop over all domains one time in one UDF.
you need to determine where is this UDF gonna apply. Like zone (ID)nor wall ID or shadow ID.

for example: this incorrect:
if ( subthread == Lookup_Thread(plasma_domain ,ID) )
{
muplasma = C_MU_L(cell , subthread);
}

here you have to start a C-loop to loop over the cells


I suggest to you



Thread *cell_threads=Lookup_Thread(mixture_domain, ID);
Domain *mixture_domain;
cell_t cell;
Thread **pt;
mp_thread_loop_c(cell_threads, mixture_domain, pt)
if (DOMAIN_ID(cell_threads) == 2) /* you are going to loop in phase 2*/
{
begin-c-loop(cell, cell_threads)
{

muplasma = C_MU_L(cell , cell_threads);

}
end-c-loop(cell, cell_threads)
}

also if you have multispecies in one phase you can use inside the c-loop:
pt = THREAD_SUB_THREADS(cell_threads);
ti = pt[0]; /* this pointer to the species number one in the target phase.

you can expands also your UDF to ther phase by using else if:

else if (DOMAIN_ID(cell_threads) == 3) /* you are going to loop in phase 3*/
{
begin-c-loop(cell, cell_threads)
{


}
end-c-loop(cell, cell_threads)
}




I suggest to you to see example in the UDF manual and builds your UDF.
Your UDF is totally wrong .
sajaalrifai is offline   Reply With Quote

Reply

Tags
get_domain, multiphase, non-newtonian, parse error, 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
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 3 December 30, 2019 01:21
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 20:43
Errors in UDF shashank312 Fluent UDF and Scheme Programming 6 May 30, 2013 21:30
[swak4Foam] installing funkySetFields igo OpenFOAM Community Contributions 1 November 20, 2012 21:16
user subroutine error CFDUSER CFX 2 December 9, 2006 07:31


All times are GMT -4. The time now is 06:28.