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

Use DEFINE_ADJUST change boundary condition

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 19, 2010, 02:17
Question Use DEFINE_ADJUST change boundary condition
  #1
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
dear all friends:
now,i have some trouble in solving question about how to change boundary condition.details as follow:
boudary condition:heat flux q2=a1*qe^(-1/3)[Twall-268-4qe*(a2+a3+a4*qe^(1/3)))
qe is heat flux that Fluent compute itself.That is to say,i write a udf about boundary heat flux,and use macro DEFINE_ADJUST to modify boundary condition(heat flux) based on whether fabs((q2-qe)/q2)<=0.05.
it is my code:
#include "udf.h"
DEFINE_PROFILE(my_flux,thread,i)
{
face_t f;
Thread*t0=THREAD_T0(thread);
cell_t c0;
real a1,a2,a3,a4,T,qe,q2,xw[ND_ND],xc[ND_ND],dx[ND_ND],dy;
real flow_time,current_timestep;
a1=3.27e4;
a2=2.63e-4;
a3=2.08e-6;
a4=3.05987e-5;
flow_time=RP_Get_Real("flow-time");
current_timestep=CURRENT_TIMESTEP;
if(flow_time<=current_timestep)
{ begin_f_loop(f,thread)
{
F_PROFILE(f,thread,i)=-1000;
}end_f_loop(f,thread)
}
else
{ begin_f_loop(f,thread)
{
c0=F_C0(f,thread);
F_CENTROID(xw,f,thread);
C_CENTROID(xc,c0,t0);
NV_VV(dx,=,xc,-,xw);
dy=ND_MAG(dx[0],dx[1],dx[2]);
qe=(0.6*C_LIQF(c0,t0)+2.24*(1-C_LIQF(c0,t0)))*(F_T(f,thread)-C_T(c0,t0))/dy;/*heat flux computed through fluent itself*/
q2=a1*pow(qe,-1/3)*(F_T(f,thread)-268-4*qe*(a2+a3+a4*pow(qe,1/3)));/*gived boundary condition heat flux*/
if((fabs(q2-qe)/q2)<=0.2)/*judge q2 and qe */
F_PROFILE(f,thread,i)=0.6*qe+0.4*q2;
else if((fabs(q2-qe)/q2)<=0.1)
F_PROFILE(f,thread,i)=0.8*qe+0.2*q2;
else
F_PROFILE(f,thread,i)=q2;
}end_f_loop(f,thread)
}
}
temperature limited to 1.000000e+000 in 10000 cells on zone 2 in domain 1
iter continuity x-velocity y-velocity energy time/iter
62 2.3745e+09 4.9106e-02 8.2004e-02 5.1416e+19 0:00:06 18
temperature limited to 5.000000e+003 in 10000 cells on zone 2 in domain 1
63 3.2869e+08 6.5883e-02 1.1955e-01 4.4575e+25 0:00:08 17
temperature limited to 1.000000e+000 in 10000 cells on zone 2 in domain 1
64 2.5771e+09 5.0354e-02 8.0179e-02 3.3946e+22 0:00:06 16
temperature limited to 5.000000e+003 in 10000 cells on zone 2 in domain 1
65 2.6958e+08 8.3365e-02 1.4457e-01 3.2549e+28 0:00:05 15
Error: Floating point error: invalid number
Error Object: ()
how to do that? I need your help,
liurengtong123 is offline   Reply With Quote

Old   May 23, 2010, 22:57
Default
  #2
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
about my question ,i will tell more details as follows:
I want to simulate water solidification in a tank. I will give a boundary condition(heat flux) and this boundary heat flux qe=f(qe).

liurengtong123 is offline   Reply With Quote

Old   May 25, 2010, 22:02
Default
  #3
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
This is my code about DEFINE_ADJUST,i want to write a program that can link DEFINE_ADJUST and DEFINE_PROFILE in order to realize change boundary condition.please help me!!!Big thanks!!!
DEFINE_ADJUST(my_adjust,d)
{
int ID=6;
Thread*thread=Lookup_Thread(d,ID);
cell_t c;
cell_t c0;
face_t f;
Thread*t0=THREAD_T0(thread);
real a1,a2,a3,a4,T,qe,q2,xw[ND_ND],xc[ND_ND],dx[ND_ND],dy;
real flow_time,current_timestep;
a1=3.27e4;
a2=2.63e-4;
a3=2.08e-6;
a4=3.05987e-5;

if(!Data_Valid_P())
return;
thread_loop_f(thread,d)
{
begin_f_loop(f,thread)
{

c0=F_C0(f,thread);
F_CENTROID(xw,f,thread);
C_CENTROID(xc,c0,t0);
NV_VV(dx,=,xc,-,xw);
dy=ND_MAG(dx[0],dx[1],dx[2]);
qe=(0.6*C_LIQF(c0,t0)+2.24*(1-C_LIQF(c0,t0)))*(F_T(f,thread)-C_T(c0,t0))/dy;
q2=a1*pow(qe,-1/3)*(F_T(f,thread)-268-4*qe*(a2+a3+a4*pow(qe,1/3)));
if(fabs((q2-qe)/q2)<=0.05)
F_UDMI(f,thread,0)=q2;
else
F_UDMI(f,thread,1)=0.8*q2+0.2*qe;
}end_f_loop(f,thread)
}
}
liurengtong123 is offline   Reply With Quote

Old   June 22, 2010, 12:20
Default
  #4
ljp
New Member
 
Join Date: Apr 2010
Posts: 15
Rep Power: 16
ljp is on a distinguished road
Hi,

I'm wondering if you have solved the problem you posted a while ago, or got any ideas on how to solve it. I have a much similar problem in trying to change the boundary condition by using either DEFINE_ADJUST or DEFINE_PROFILE. Thank you very much.

Regards,
ljp
ljp is offline   Reply With Quote

Old   June 22, 2010, 17:26
Default
  #5
New Member
 
omid
Join Date: Mar 2010
Posts: 17
Rep Power: 16
om1234 is on a distinguished road
hi
i'm not experienced with heat transfer and either i cant understand some parts of ur udf.but as i know:
1. c0 ,c1 r used when u wanna store/access to values of an interior faces and in boundary condition u dont need to do that and the values of the cell face is enoughg. [Thread*t0=THREAD_T0(thread);
cell_t c0;]
2.i can tell u if the int ID=6 is ur desired boundary u dont need to use define_adjust and u can write both of them in DEFINE_PROFILE.nevertheles to link the adjust to profile, u need to define the number of memory that u use in your problem e.g if your boundary is subdevided into 20 parts and u need to define qe in all of them so u should change the no. of memory(define>user define>memory) in fluent to 20 and use this order :for(k=0;k<n_udm;k++),F_UDMI(f,t,k) and if u store the q2 in memory in define_adjust and u wanna use it in define_profile u need to access to memory or vise versa:e.g
begin_f_loop(f,thread)
{
for(k=0;k<n_udm;k++)
c0=F_C0(f,thread);
F_CENTROID(xw,f,thread);
C_CENTROID(xc,c0,t0);
NV_VV(dx,=,xc,-,xw);
dy=ND_MAG(dx[0],dx[1],dx[2]);
qe=(0.6*C_LIQF(c0,t0)+2.24*(1-C_LIQF(c0,t0)))*(F_T(f,thread)-C_T(c0,t0))/dy;/*heat flux computed through fluent itself*/
q2=F_UDMI(f,t,k);
and the other lines.

Last edited by om1234; June 22, 2010 at 20:04.
om1234 is offline   Reply With Quote

Old   June 22, 2010, 17:32
Default
  #6
New Member
 
omid
Join Date: Mar 2010
Posts: 17
Rep Power: 16
om1234 is on a distinguished road
although u can use printf("name:%f\n",value) to show the values in graph window.it's very helpfull
om1234 is offline   Reply With Quote

Old   June 23, 2010, 04:56
Default
  #7
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
I have no idea about my posted question ,i am confused.I feel it is very difficult.My boundary condition is a coupled condition.qe=f(qe).
liurengtong123 is offline   Reply With Quote

Old   July 12, 2010, 12:53
Default Can you elaborate?
  #8
TDi
Member
 
Tim Diller
Join Date: Mar 2010
Location: Austin, TX
Posts: 32
Rep Power: 16
TDi is on a distinguished road
Quote:
Originally Posted by liurengtong123 View Post
I have no idea about my posted question ,i am confused.I feel it is very difficult.My boundary condition is a coupled condition.qe=f(qe).
Can you help us understand what the trouble is? It is not clear where you are having difficulty.

Are you having difficulty setting up the boundary conditions? Do you want to know how to link your UDF to the problem? Is there a compile error? Do you need help with the math?
TDi is offline   Reply With Quote

Old   July 12, 2010, 13:18
Default
  #9
New Member
 
Dave Smith
Join Date: Jul 2010
Posts: 27
Rep Power: 16
davesmith_01 is on a distinguished road
Hi

Eventually I want to write a UDF for a pitching airfoil, which pitches up and down continuously. However I first want to learn about dynamic meshing in fluent, so I want to try the tutorial on fluent about cyl3d.msh, but I do not have this fiel, once I understand this I was going to write a code and try using the udf and dynamic meshing together, does anyone have cyl3d.msh?

Thanks

Or have you got a code for pitching an airfoil whilst oncoming flow is heading towards the airfoil? If I can have a look I will understand the process of writing this better
davesmith_01 is offline   Reply With Quote

Old   July 12, 2010, 23:57
Default
  #10
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Quote:
Originally Posted by TDi View Post
Can you help us understand what the trouble is? It is not clear where you are having difficulty.

Are you having difficulty setting up the boundary conditions? Do you want to know how to link your UDF to the problem? Is there a compile error? Do you need help with the math?
my problem is as follow:
First,i suppose boundary heat fllux q=constant,through macro DEFINE_PROFILE(f,thread) pass q to Fluent, every interation,i will judge if fabs(q2-qe)/qe<=0.05. if yes, continue to interate,if no, i want to change boundary heat flux as like q=02*qe+0.8*q2, then pass q to Fluent ,start a new interation,then judge again as above.
Now, my problem is that i do not know how to write a UDF reallize this process.How to change boundary heat flux through DEFINE_ADJUST macro.
liurengtong123 is offline   Reply With Quote

Old   July 17, 2010, 23:26
Default
  #11
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Quote:
Originally Posted by liurengtong123 View Post
my problem is as follow:
First,i suppose boundary heat fllux q=constant,through macro DEFINE_PROFILE(f,thread) pass q to Fluent, every interation,i will judge if fabs(q2-qe)/qe<=0.05. if yes, continue to interate,if no, i want to change boundary heat flux as like q=02*qe+0.8*q2, then pass q to Fluent ,start a new interation,then judge again as above.
Now, my problem is that i do not know how to write a UDF reallize this process.How to change boundary heat flux through DEFINE_ADJUST macro.
anybody help me!!I need your help !! This problem confused me for many months.
liurengtong123 is offline   Reply With Quote

Old   July 29, 2010, 03:54
Default
  #12
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Quote:
Originally Posted by liurengtong123 View Post
anybody help me!!I need your help !! This problem confused me for many months.
anybody can help me,i need your help, I hope somebody can help me!! Big thanks!!
liurengtong123 is offline   Reply With Quote

Old   September 13, 2010, 05:12
Default
  #13
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
anybody can help me,i need your help, I hope somebody can help me!! Big thanks!!
liurengtong123 is offline   Reply With Quote

Old   October 19, 2010, 20:29
Default
  #14
New Member
 
Brandon Hathaway
Join Date: Oct 2010
Location: Minneapolis
Posts: 9
Rep Power: 16
Hathaway is on a distinguished road
Send a message via ICQ to Hathaway
I believe I have a similar problem as you. I am trying to adjust a boundary condition each iteration based on the temperature of the faces along the boundary as calculated by the previous iteration. (e.g. the boundary condition is q=f(T), where yours is similar with q=f(q)). I was watching your thread for a solution, but it appears none have come.

I have found a means of fixing my problem that I will describe for you. My UDF contains both a DEFINE_PROFILE and a DEFINE_ADJUST macro.

I use the DEFINE_PROFILE macro as the set boundary condition when setting up the problem. The macro not only sets the boundary flux for the first iteration, but also reads and outputs the zone_id number and the property_id number associated with that boundary condition.

The DEFINE_ADJUST macro then reads the property_id and zone_id written in the DEFINE_PROFILE macro and looks up the appropriate thread pointer for the boundary of interest. Next, it loops through the boundary and reads the information needed to determine the new boundary flux (in my case it reads temperature, in your case, read whatever you need). Lastly it uses the F_PROFILE(f,t,i) macro to assign the new flux value, where 'i' is the property_id saved from the DEFINE_PROFILE macro earlier.

I've simplified down the code I'm using to post here. Now it acts as if i'm starting with an initial flux of 190 [W/m^2-K] then applying a heat flux to each face corresponding to a convection condition for a bulk fluid temperature of 375 [K] with a convection coefficient of 6 [W/m^2-K].
Code:
q = 6 * ( 375 - T )
After hooking both the DEFINE_PROFILE macro to the boundary condition, and the DEFINE_ADJUST macro to the entire simulation, everything seems to run as desired. The initial value is loaded for the first iteration, then each iteration thereafter obtains a newly calculated flux boundary condition.

Code:
#include "udf.h"

FILE *fid;

DEFINE_PROFILE(flux_setget,t,i)
{
  face_t f;
  int zoneid = THREAD_ID(t);

  /* Write the property and thread id values for the flux condition to file */
  fid = fopen("flux-ids", "w");
  fprintf(fid, "%d, %d\n", zoneid, i);
  fclose(fid);
  
  /* Set initial profile values */
  begin_f_loop(f,t)
  {
    F_PROFILE(f,t,i) = 190;
  }
  end_f_loop(f,t)
}

DEFINE_ADJUST(flux_adjuster, domain)
{
  int iprop;
  int izone;
  real temp;
  real newflux;
  Thread *t;
  face_t f;

  /* Read in the property and thread id values stored by the BC UDF */
  fid = fopen("flux-ids", "r");
  fscanf(fid,"%d, %d", &izone, &iprop);
  fclose(fid);

  /* Get the thread pointer based on the obtained zone id */
  t = Lookup_Thread(domain, izone);
  
  /* Read the needed data, then calculate and set the new flux values */
  begin_f_loop(f,t)
  {
    temp = F_T(f,t);
    newflux = 6 * (375 - temp);
    F_PROFILE(f,t,iprop) = newflux;
  }
  end_f_loop(f,t)
}
Hopefully something similar will work for you.
Hathaway is offline   Reply With Quote

Old   November 16, 2010, 08:56
Default
  #15
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
my boundary heat flux is q=f(q).So,first of all ,i must assume boundary heat flux q=A(arbitrary constant).Fluent calculate itself after one timestep,judge q and f(q),if fabs([q-f(q)]/q)<=5%,so Fluent enter next timestep calculation;If fabs([q-f(q)]/q)>5%,so give boundary heat flux q1=0.7*q+0.3*f(q) to Fluent,Fluent calculate in the same timestep.
how to write UDF ?thanks
liurengtong123 is offline   Reply With Quote

Old   November 23, 2010, 02:36
Default
  #16
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Quote:
Originally Posted by Hathaway View Post
I believe I have a similar problem as you. I am trying to adjust a boundary condition each iteration based on the temperature of the faces along the boundary as calculated by the previous iteration. (e.g. the boundary condition is q=f(T), where yours is similar with q=f(q)). I was watching your thread for a solution, but it appears none have come.

I have found a means of fixing my problem that I will describe for you. My UDF contains both a DEFINE_PROFILE and a DEFINE_ADJUST macro.

I use the DEFINE_PROFILE macro as the set boundary condition when setting up the problem. The macro not only sets the boundary flux for the first iteration, but also reads and outputs the zone_id number and the property_id number associated with that boundary condition.

The DEFINE_ADJUST macro then reads the property_id and zone_id written in the DEFINE_PROFILE macro and looks up the appropriate thread pointer for the boundary of interest. Next, it loops through the boundary and reads the information needed to determine the new boundary flux (in my case it reads temperature, in your case, read whatever you need). Lastly it uses the F_PROFILE(f,t,i) macro to assign the new flux value, where 'i' is the property_id saved from the DEFINE_PROFILE macro earlier.

I've simplified down the code I'm using to post here. Now it acts as if i'm starting with an initial flux of 190 [W/m^2-K] then applying a heat flux to each face corresponding to a convection condition for a bulk fluid temperature of 375 [K] with a convection coefficient of 6 [W/m^2-K].
Code:
q = 6 * ( 375 - T )
After hooking both the DEFINE_PROFILE macro to the boundary condition, and the DEFINE_ADJUST macro to the entire simulation, everything seems to run as desired. The initial value is loaded for the first iteration, then each iteration thereafter obtains a newly calculated flux boundary condition.

Code:
#include "udf.h"
 
FILE *fid;
 
DEFINE_PROFILE(flux_setget,t,i)
{
  face_t f;
  int zoneid = THREAD_ID(t);
 
  /* Write the property and thread id values for the flux condition to file */
  fid = fopen("flux-ids", "w");
  fprintf(fid, "%d, %d\n", zoneid, i);
  fclose(fid);
 
  /* Set initial profile values */
  begin_f_loop(f,t)
  {
    F_PROFILE(f,t,i) = 190;
  }
  end_f_loop(f,t)
}
 
DEFINE_ADJUST(flux_adjuster, domain)
{
  int iprop;
  int izone;
  real temp;
  real newflux;
  Thread *t;
  face_t f;
 
  /* Read in the property and thread id values stored by the BC UDF */
  fid = fopen("flux-ids", "r");
  fscanf(fid,"%d, %d", &izone, &iprop);
  fclose(fid);
 
  /* Get the thread pointer based on the obtained zone id */
  t = Lookup_Thread(domain, izone);
 
  /* Read the needed data, then calculate and set the new flux values */
  begin_f_loop(f,t)
  {
    temp = F_T(f,t);
    newflux = 6 * (375 - temp);
    F_PROFILE(f,t,iprop) = newflux;
  }
  end_f_loop(f,t)
}
Hopefully something similar will work for you.
first of all,thanks for giving me help,i write my code as follows:
[CODE]#include "udf.h"
FILE*fid;DEFINE_PROFILE(heat_flux,t,i)
{
face_t f;
int zoneid=THREAD_ID(t);
fid=fopen("flux-ids","w");
fprintf(fid,"%d,%d\n",zoneid,i);
fclose(fid);
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=-1000;
}end_f_loop(f,t)
}[DEFINE_ADJUST(flux_adjust,domain)
{
int iprop;
int izone;
Thread*thread=Lookup_Thread(domain,izone);
Thread*t0=THREAD_T0(thread);
cell_t c;
cell_t c0;
face_t f;
real a1,a2,a3,a4,T,qe,q2,xw[ND_ND],xc[ND_ND],dx
[ND_ND],dy;
a1=3.27e4;
a2=2.63e-4;
a3=2.08e-6;
a4=3.06e-5;
fid=fopen("flux-ids","r");
fscanf(fid,"%d,%d",&izone,&iprop);
fclose(fid);
if(!Data_Valid_P())
return;thread_loop_f(thread,domain)
{
begin_f_loop(f,thread)
{
c0=F_C0(f,thread);
F_CENTROID(xw,f,thread);
C_CENTROID(xc,c0,t0);
NV_VV(dx,=,xc,-,xw);
dy=ND_MAG(dx[0],dx[1],dx[2]);
qe=(0.6*C_LIQF(c0,t0)+2.24*(1-C_LIQF(c0,t0)))
*(F_T(f,thread)-C_T(c0,t0))/dy;/*water or ice heat
flux*/
q2=a1*(pow(q2,-1/3))*(268+4*fabs(q2)*
(a2+a3+a4*fabs(pow(q2,1/3)))-F_T(f,thread));/*heat pipe
heat flux*/
if(fabs((q2-qe)/q2)>=0.005)
F_PROFILE(f,thread,iprop)=0.3*qe+0.7*q2;
else
F_PROFILE(f,thread,iprop)=0.5*qe+0.5*q2;
}end_f_loop(f,thread)
}
}
interpreted can succeed,but Fluent appear wrong information when it iterate.
Updating solution at time levels N and N-1.
done.
iter continuity x-velocity y-velocity energy time/iter
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: ()
Help me please
liurengtong123 is offline   Reply With Quote

Old   November 28, 2010, 23:08
Default
  #17
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Hi,first of all,thanks for your suggestion.
Now,i want to give you some deatils about my difficulties,so please give your email to me.
I hopely want to abtain your help,thanks very much!!!
My email is :liurengtong@163.com
liurengtong123 is offline   Reply With Quote

Old   December 9, 2010, 23:01
Default
  #18
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Hi
every one ,now i need your help .
I give detail about my problem through a picture .
Attached Images
File Type: jpg 未命名.jpg (31.0 KB, 160 views)
liurengtong123 is offline   Reply With Quote

Old   December 10, 2010, 11:23
Default
  #19
TDi
Member
 
Tim Diller
Join Date: Mar 2010
Location: Austin, TX
Posts: 32
Rep Power: 16
TDi is on a distinguished road
I am able to do something similar with only DEFINE_PROFILE. At every time step, I check the value of a virtual thermocouple and adjust the heat flux to a radiant heater using a control law.

Here's my code for your reference. Note that there is another function called at the beginning that returns the location of the cells I'm using as my virtual thermocouples. Also, note that this same DEFINE_PROFILE is used to control 8 separate heater surfaces (4 actual surfaces and 4 shadow faces).

Code:
DEFINE_PROFILE(heater_control,boundary_thread,i){
  /*i is the boundary property index, known to Fluent*/
  face_t face_thread;
  int zone_ID = THREAD_ID(boundary_thread);
  int j=0;
  real flow_time = RP_Get_Real("flow-time");
  real cell_temp;
  real error;
  real this_power;

  /*
    Set the temperature control measurement point and the index
    variable based on the value of zone_ID.
  */
  if(power[0]<=0){init();}

  switch(zone_ID){
  case FB_LEFT_ZONE:
    j=FB_LEFT;
    break;
  case FB_LEFT_SHADOW_ZONE:
    j=FB_LEFT_SHADOW;
    break;
  case BB_CENTER_LEFT_ZONE:
    j=BB_CENTER_LEFT;
    break;
  case BB_CENTER_LEFT_SHADOW_ZONE:
    j=BB_CENTER_LEFT_SHADOW;
    break;
  case BB_CENTER_RIGHT_ZONE:
    j=BB_CENTER_RIGHT;
    break;
  case BB_CENTER_RIGHT_SHADOW_ZONE:
    j=BB_CENTER_RIGHT_SHADOW;
    break;
  case FB_RIGHT_ZONE:
    j=FB_RIGHT;
    break;
  case FB_RIGHT_SHADOW_ZONE:
    j=FB_RIGHT_SHADOW;
    break;
  default:
    printf("\nDid not identify zone_ID.");
    break;
  }
  /*printf("\nDEFINE_PROFILE: flow time = %1.3e\t previous_time[%d] = %1.3e.",flow_time,j,previous_time[j]);*/
  if (flow_time > previous_time[j] + 0.5){/*This prevents multiple control efforts per time step*/
    
    /*Record the temperature of the virtual thermocouple*/
    cell_temp = C_T(c[j],t[j]);

    /*Heater control algorithm is proportional with control variable epsilon*/
    error = (set_temp[j]-cell_temp);
    printf("\n\tepsilon = %1.2e",error);
    epsilon[j][0] = epsilon [j][1];
    epsilon[j][1] = epsilon [j][2];
    epsilon[j][2] = error;

    u[j][0] = u[j][1];
    u[j][1] = u[j][2];
    u[j][2] = alpha * error;
    if(u[j][2] > 1){u[j][2]=1.0;}
    if(error>0){
	heater_state[j] = power[j]*u[j][2];
    }
    else{heater_state[j]=0;}/* Don't let the heater be a cold sink! */

    printf("\nHeater power in zone %d set to %1.3e.",zone_ID,heater_state[j]);
    printf("\n\tcontrol variable is %1.2e.",u[j][2]);
  
    previous_time[j]=flow_time;

    this_power = heater_state[j];
    begin_f_loop(face_thread,boundary_thread){
      F_PROFILE(face_thread,boundary_thread,i)=this_power;
    }
    end_f_loop(f,thread)
  }
}
I hope this can help you.
TDi is offline   Reply With Quote

Old   December 11, 2010, 00:34
Default
  #20
New Member
 
Rengtong Liu
Join Date: May 2010
Posts: 15
Rep Power: 16
liurengtong123 is on a distinguished road
Hi
thank you for giving me some suggestion.
I want to talk about my problem in detail ,so please give me your Email in order to discuss about it.
My Email :liurengtong@163.com
Thanks very much!!!
liurengtong123 is offline   Reply With Quote

Reply

Tags
fluent, 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
Wind turbine simulation Saturn CFX 60 July 17, 2024 06:45
How to change boundary condition from command fluent87 FLUENT 8 September 11, 2019 14:27
Time dependant pressure boundary condition yosuke1984 OpenFOAM Verification & Validation 3 May 6, 2015 07:16
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 18:44
inlet velocity boundary condition murali CFX 5 August 3, 2012 09:56


All times are GMT -4. The time now is 16:34.