Use DEFINE_ADJUST change boundary condition
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, |
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). |
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) } } |
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 |
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. |
although u can use printf("name:%f\n",value) to show the values in graph window.it's very helpfull
|
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 elaborate?
Quote:
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? |
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 |
Quote:
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. |
Quote:
|
Quote:
|
anybody can help me,i need your help, I hope somebody can help me!! Big thanks!!
|
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 ) Code:
#include "udf.h" |
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 |
Quote:
[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 |
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 |
1 Attachment(s)
Hi
every one ,now i need your help . I give detail about my problem through a picture . |
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){ |
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!!! |
Click on my name to the left to send a private message. I do not wish to give out my email address. Thanks.
|
3D dynamic mesh tutorial
Hi people,
I was attempting the 3D adiabatic compression tutorial with dynamic meshing and I haven't got the file cyl3d_new.msh. If anyone can send me the file please it will be greatly appreciated. Thanks. My email: darren.camilleri90@gmail.com |
Hi, I am trying to simulate the 3-D flow dynamics of bubble column (gas-liquid flow using euler-lagrange simulation) using FLUENT. I am filling only half the column with water and trying rest to patch with air.
Could anyone suggest the right way to patch gas-liquid in the bubble column? Also, how do you really model gas-liquid free surface flow in Bubble Column? Thanks. I appreciate your help. Quiyoom http://www.cfd-online.com/Forums/ima...er_offline.gif http://www.cfd-online.com/Forums/ima...tons/quote.gif |
My problem is similar to the one discussed here. I need to specify the flux of scalars at the boundary. They are neither constant nor are they known before hand.
I followed the procedure suggested by you. I use the define_profile to initialise the flux value to zero and write the zone id and uds id to a file. This is happening. I then access the corresponding files depending on the thread id, read the values from the files and use F_PROFILE to assign the flux values from stored memory. I have used solve/set/expert to save the gradients. When i hook the ADJUST udf and run, fluent shuts down. What could be the problem? Thanks in advance |
Not using Fluent these days
Hi, and thanks for the interest in this thread. I should let you know that I am not an active Fluent user anymore (for 3 years now) and will not be able to respond to further inquiry at present.
|
Quote:
I want to change UDS boundary value i mean i want to use transient value , you know how can i do this with Define Adjust? Regards, |
Quote:
Hello, do you get any information on your problems? My problem is the same as you. Thank you in advanced! |
use DEFINE_PROFILE macro
|
Quote:
I need to apply the gradient of C_UDSI on the surface, does DEFINE_PROFILE work? I find that the GUI have two options, which is Flux and Value for UDS boundary condition. |
Hey guys,
I'm working on something similar, was wondering if maybe you solved yours. I've got a simple flow problem with: INLET = Pressure OUTLET = mass flow rate at some location I've got a user surface where I can calculate flow velocity. I want a UDF that can update the mass flow rate at the outlet based on the velocity calculated at the user surface. Any thoughts? do I need to use the DEFINE_ADJUST macro? |
All times are GMT -4. The time now is 17:28. |