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

UDS problem

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 14, 2017, 23:48
Default UDS problem
  #1
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
Hi everyone. I am writing a udf for three-phase-flow.After I hooked it to my model,it initialised well but can't calculate.Below are my udf.
#include"udf.h"
#include"unsteady.h"

DEFINE_ADJUST(store_gradient,d)
{
real unit_normal;
Thread *big_thread,*mixture_thread,*small_thread;
cell_t cell;
int current_iter,domainid,threadid1,threadid2;
current_iter=(nres==0)?(0)(int)count2[nres-1]);
domainid=8;
threadid1=1;
threadid2=2;
mixture_thread=Lookup_Thread(d,domainid);
big_thread=THREAD_SUB_THREAD(mixture_thread,thread id1);
small_thread=THREAD_SUB_THREAD(mixture_thread,thre adid2);
if((current_iter==0)&&(CURRENT_TIME==0))
{
begin_c_loop(cell,big_thread)
{
C_UDMI(cell,big_thread,0)=0;
C_UDMI(cell,big_thread,1)=0;
C_UDMI(cell,big_thread,2)=0;
C_UDMI(cell,big_thread,3)=0;
C_UDMI(cell,big_thread,4)=0;
}
end_c_loop(cell,big_thread)
begin_c_loop(cell,small_thread)
{
C_UDMI(cell,small_thread,5)=0;
C_UDMI(cell,small_thread,6)=0;
C_UDMI(cell,small_thread,7)=0;
C_UDMI(cell,small_thread,8)=0;
C_UDMI(cell,small_thread,9)=0;
}
end_c_loop(cell,small_thread)
}
if (!Data_Valid_P())
return;
begin_c_loop(cell,big_thread)
{
C_UDSI(cell,big_thread,0)=0;
C_UDSI(cell,big_thread,1)=0;
C_UDSI(cell,big_thread,2)=0;
}
end_c_loop(cell,big_thread)
Message("helloworld");
return;
}

real integrand(real scale,real density,real diameter,real tension,real dissipation)
{
real answer;
answer=exp(-12*diameter*diameter*tension/(density*2.047*pow(scale,11.0/3.0)*pow(dissipation,2.0/3.0)))/pow(scale,4.0);
return answer;
}
real integrand1(real scale,real density,real diameter,real tension,real dissipation)
{
real answer;
answer=exp(-12*diameter*diameter*tension/(density*2.047*pow(scale,11.0/3.0)*pow(dissipation,2.0/3.0)))/pow(scale,11.0/3.0);
return answer;
}
DEFINE_PROPERTY(diameter,c,t)
{
real diameter1,surface_tension,density_of_continuous,vi scosity,voidreturn;
Thread *mixture_thread,*big_thread;
int threadid;
threadid=1;
density_of_continuous=998.2;
surface_tension=0.0719404;
viscosity=0.001003;
mixture_thread=THREAD_SUPER_THREAD(t);
big_thread=THREAD_SUB_THREAD(mixture_thread,thread id);
voidreturn=1;
if(C_VOF(c,t)==0)
diameter1=0.0008;
else
{
diameter1=1.78*pow(sqrt(surface_tension/((density_of_continuous-(C_R(c,big_thread)*C_VOF(c,big_thread)+C_R(c,t)*C_ VOF(c,t))/(C_VOF(c,big_thread)+C_VOF(c,t)))*9.81)),0.889)*po w(viscosity/density_of_continuous,0.0836)/pow(C_D(c,mixture_thread)*C_VOF(c,t)/(C_VOF(c,big_thread)+C_VOF(c,t)),0.0279);
}
return (diameter1);
}
Attachment is what I did in user defined scalar dialog box. All my three scalars have the same setting.
Attached Images
File Type: jpg 12345.jpg (20.8 KB, 5 views)
C_Zhang is offline   Reply With Quote

Old   September 14, 2017, 23:50
Default
  #2
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
My udf seems strange because it's too long and all parts excluded in this webpage have been set between /* and */ so they won't execute.
C_Zhang is offline   Reply With Quote

Old   September 14, 2017, 23:54
Default
  #3
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
I am sure the problem is on UDS because when I set 42nd,43rd and 44th line between /* and */, it works well.
Those lines are
C_UDSI(cell,big_thread,0)=0;
C_UDSI(cell,big_thread,1)=0;
C_UDSI(cell,big_thread,2)=0;
C_Zhang is offline   Reply With Quote

Old   September 15, 2017, 00:00
Default
  #4
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
I will appreciate any of your help
C_Zhang is offline   Reply With Quote

Old   September 15, 2017, 02:07
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Hello,

you are using multi-phase flow, do I not know how to start such cases properly.
However, you are using begin_c_loop(cell,big_thread) and begin_c_loop(cell,small_thread) to set/calculate variables for specific regions.
But what values do these variable have at other regions?

I did not test it, but what if UDS values should be defined everywhere?
In that case you need loop over all threads to initialize UDS values, but then you may modify values of UDS variables in specified regions.

I hope my idea is clear.

Best regards,
Zorin Alexander
AlexanderZ is offline   Reply With Quote

Old   September 15, 2017, 02:12
Default
  #6
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
Dear Zorin
Thank you for your help first.
UDS is only used to calculate the second order gradient of void fraction of each secondary phase in my UDF. Do you have any suggestions?
C_Zhang is offline   Reply With Quote

Old   September 15, 2017, 02:22
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Try to use loop over all threads for UDS for initialization

Code:
cell_t cell;
Thread *thread;
thread_loop_c (thread,domain)
{
		begin_c_loop (cell,thread)
               {
                   C_UDSI(cell,thread,0)=0.0;
		end_c_loop (cell,thread)
	       }
}
C_Zhang likes this.
AlexanderZ is offline   Reply With Quote

Old   September 15, 2017, 02:25
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
or you may try to use big_thread directly, however, I have never tried it before:

Code:
thread_loop_c (big_thread,domain)
{
		begin_c_loop (cell,big_thread)
               {
                   C_UDSI(cell,big_thread,0)=0.0;
		end_c_loop (cell,big_thread)
	       }
}
AlexanderZ is offline   Reply With Quote

Old   September 15, 2017, 02:32
Default
  #9
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
I'm sorry maybe I gave you too little information.
Actually, I want to get the second order gradient of void fraction for each secondary phase, but I don't know how to do. This way is found from some predecessors' threads here in this forum. Since I don't know its detail, I may have made some mistakes on using UDS as well as on setting something in GUI. Do you know some effective ways to get second order gradient?
Thank you very much
C_Zhang is offline   Reply With Quote

Old   September 15, 2017, 02:33
Default
  #10
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
Oh! your reply is so quick, I should read it first
C_Zhang is offline   Reply With Quote

Old   September 15, 2017, 02:52
Default
  #11
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
looping over all threads in subdomain works! But I am still confused. Why do I have to loop over all threads in subdomain?
C_Zhang is offline   Reply With Quote

Old   September 15, 2017, 03:30
Default
  #12
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by C_Zhang View Post
looping over all threads in subdomain works! But I am still confused. Why do I have to loop over all threads in subdomain?
Frankly speaking, I do not know,
may be the reason is that fluent tries to calculate scalar everywhere, so without initialization it gives error

Best regards
AlexanderZ is offline   Reply With Quote

Old   September 15, 2017, 03:36
Default
  #13
Member
 
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 8
C_Zhang is on a distinguished road
Thank you.Fluent is a mysterious software
C_Zhang 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
UDS problem with wall boundary condition Alex F. FLUENT 15 September 21, 2015 09:28
a stupid UDS problem bgu Fluent UDF and Scheme Programming 0 August 18, 2013 06:52
Velocity profiles problem behind the elbow (3D problem) kabat73 FLUENT 8 May 9, 2010 04:26
natural convection problem for a CHT problem Se-Hee CFX 2 June 10, 2007 06:29
Adiabatic and Rotating wall (Convection problem) ParodDav CFX 5 April 29, 2007 19:13


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