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

udf for correct adjacent cell T

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2018, 14:03
Default udf for correct adjacent cell T
  #1
New Member
 
Adam
Join Date: Dec 2017
Posts: 13
Rep Power: 8
Adam_PHD is on a distinguished road
Hello Guys;


I am working on heat transfer in the naturally aspirated diesel engine. Currently, I use Ansys Fluent to simulate the total cycle of the engine my goal is to correct the estimate of the heat flux using 0d udf coupling to 3d CFD.

Fluent generally uses the wall law which underestimates the heat flux so the idea of correct the latter via the implementation of a UDF which is used to calculate the flow by phenomenological laws (Whoshni-Hohenberg).


My problem is that I can not define the domain of computing; the combustion chamber, precisely how to define in UDF: the temperature (TC) of the cell adjacent to the walls?

Please orient me to his
Adam_PHD is offline   Reply With Quote

Old   February 23, 2018, 03:00
Default
  #2
New Member
 
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9
doruk is on a distinguished road
Hello,

This is my code down below for single domain. If there are different domains you can try to use the code

domain = Get_Domain(1); //1 is the id of the domain you are working on

You can check the id at the boundary conditions section at user interface in Fluent.


DEFINE_ADJUST(FixWallTemp, domain)
{
Thread *t,*tf,*t0;
face_t f;
cell_t c,c0;

tf = Lookup_Thread(domain,29); //for my case wall id was 29


begin_f_loop (f,tf)
{

c0=F_C0(f,tf); // adjacent cell id
t0 = F_C0_THREAD(f,tf); // adjacent cell thread

C_T(c0,t0)=0.0; // makes the temperature 0 for adjacent c
}
end_f_loop (f,tf)
}

Best Regards,
Doruk
doruk is offline   Reply With Quote

Old   February 23, 2018, 11:21
Default udf change my boundary condition
  #3
Member
 
Reza khodadadi
Join Date: Apr 2011
Location: https://t.me/pump_upp
Posts: 32
Rep Power: 15
reza_65 is on a distinguished road
Send a message via ICQ to reza_65 Send a message via AIM to reza_65 Send a message via Yahoo to reza_65
Hi Formers,

I would like to change my boundary condition from wall to velocity inlet if the maximum temperature of the whole domain reaches 500.
Can you please help me with it?

Best Regards,
Reza
reza_65 is offline   Reply With Quote

Old   February 24, 2018, 09:52
Default
  #4
New Member
 
Adam
Join Date: Dec 2017
Posts: 13
Rep Power: 8
Adam_PHD is on a distinguished road
Hi guys ;
This is my code down below for ic engine, my problem is adjacent cell definition

DEFINE_ADJUST(total_volume,fluid-ch-down)
{
Thread *t;
double total_volume=0.0;
double total_temperature=0.0;
double total_pressure=0.0;

cell_t c;

/* Integrate volume_1. */
/**loop*over*all*cell*threads*in*the*domain ....[3.1]....*/
thread_loop_c(t,cylindre_qurd)
{
begin_c_loop(c,t)
total_volume += C_VOLUME(c,t);
total_temperature += C_T(c,t)*C_VOLUME(c,t);
total_pressure += C_P(c,t)*C_VOLUME(c,t);
}
end_c_loop(c,tc)

volume_udf = total_volume;
temperature_udf = total_temperature/total_volume;
pressure_udf = total_pressure/total_volume;

a1 = 1./(pow(volume_udf,0.06));
aa2=pressure_udf*0.00001;
a2 = pow(aa2,0.8);
a3 = 1./(pow(temperature_udf,0.4));
a4 = pow(Sp,0.8);
htc_udf = 130*a1*a2*a3*a4;
heat_flux=htc_udf*(tc-twall)

}

DEFINE_PROFILE(heat_transfer_coefficient,t,cylindr e_tri)
{
face_t f;

begin_f_loop(f,t)
{
F_PROFILE(f,t,cylindre_tri)=htc_udf;
}
end_f_loop(f,t)
}

DEFINE_PROFILE(temperature_interieure_gaz,t,cylind re_tri)
{
double temperature_int;
face_t f;
if (temperature_udf<=200)
{
temperature_int=360;
}
else
{
temperature_int=temperature_udf;
}
begin_f_loop(f,t)
{
F_PROFILE(f,t,cylindre_tri)=temperature_int;
}
end_f_loop(f,t)
}

DEFINE_EXECUTE_AT_END(affichage_resultats)
{
# define volume_integrale_udf "integrale_volume_udf.txt"
# define temperature_integrale_udf "integrale_temperature_udf.txt"
# define heat_transfer_empirique "HTC_coef_empirique.txt"
# define pressure_integrale_udf "integrale_pressure_udf.txt"

double temperature2;
FILE *fp1;
FILE *fp2;
FILE *fp3;
FILE *fp4;

Domain*d;
Thread *t;
real sum_temper=0.0;
cell_t c;
d = Get_Domain(1);

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
sum_temper+= C_T(c,t)*C_VOLUME(c,t);
}
end_c_loop(c,t)
}

fp1=fopen(volume_integrale_udf, "a");
fprintf (fp1," %g %g \n", CURRENT_TIME, volume_udf);
fclose (fp1);

fp2=fopen(temperature_integrale_udf, "a");
fprintf (fp2," %g %g \n", CURRENT_TIME,temperature_udf);
fclose (fp2);

fp3=fopen(pressure_integrale_udf, "a");
fprintf (fp3," %g %g \n", CURRENT_TIME, pressure_udf);
fclose (fp3);

fp4=fopen(heat_transfer_empirique, "a");
fprintf (fp4," %g %g %g \n", CURRENT_TIME, htc_udf, qid);
fclose (fp4);
}
Adam_PHD is offline   Reply With Quote

Old   February 24, 2018, 09:58
Default
  #5
New Member
 
Adam
Join Date: Dec 2017
Posts: 13
Rep Power: 8
Adam_PHD is on a distinguished road
i want to estimate and apply Hohenberge heat flux as boundary condition :
h(θ)=130 V^(-0.06) P^(0.8) T_G^(-0.4) (S ̅_p+1.4)^(0.8)
Attached Images
File Type: png hohenberg.PNG (2.7 KB, 9 views)
Adam_PHD is offline   Reply With Quote

Old   February 25, 2018, 21:27
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
in your code you use
Code:
DEFINE_ADJUST(total_volume,fluid-ch-down)
{
what is fluid-ch-down here?

usually there should be the name of domain (however, I have no experience in simulations of diesel engines)

So now your call your domain as fluid-ch-down

But later you've stated loop of threads using other name
Code:
thread_loop_c(t,cylindre_qurd)
{
Now cylindre_qurd

I think it may be a problem.

On the other hand, you didn't describe what problems do you have.
It is impossible to help you without information.

Best regards
AlexanderZ is offline   Reply With Quote

Old   February 26, 2018, 04:48
Question Queries on thread_c_loop
  #7
New Member
 
sat_fire's Avatar
 
Satyam
Join Date: Jun 2017
Posts: 7
Rep Power: 9
sat_fire is on a distinguished road
hi everyone,
I am writing UDF for Energy source term for a zone.my domain consist of two zones. so while writing UDF i am using thread_c_loop(t,d). This thread will work on every cells of zone where i will attach this UDF or it will work on all cells of domain including both zone.
sat_fire is offline   Reply With Quote

Old   February 26, 2018, 19:39
Default
  #8
New Member
 
Adam
Join Date: Dec 2017
Posts: 13
Rep Power: 8
Adam_PHD is on a distinguished road
thanks Doruk and AlexanderZ;

i want to estimate and apply 0d Hohenberge heat flux as boundary condition :
h(θ)=130 V^(-0.06) P^(0.8) T_G^(-0.4) (S ̅_p+1.4)^(0.8)

V , P , T_G is from Fluent domain from last step

/* Integrate volume_1. */
/**loop*over*all*cell*threads*in*the*domain ....[3.1]....*/
thread_loop_c(t,cylindre_qurd)
{
begin_c_loop(c,t)
total_volume += C_VOLUME(c,t);
total_temperature += C_T(c,t)*C_VOLUME(c,t);
total_pressure += C_P(c,t)*C_VOLUME(c,t);
}
end_c_loop(c,tc)

volume_udf = total_volume;
temperature_udf = total_temperature/total_volume;
pressure_udf = total_pressure/total_volume;


After i will estimate heat flux by
heat_flux=htc_udf*(C_T(c0,t0)-twall)

and apply it to cylinder wall
Help me please guys, I tried much time but without good results

Regardssss
Attached Images
File Type: png heat flux.PNG (49.4 KB, 10 views)
Adam_PHD is offline   Reply With Quote

Old   February 27, 2018, 03:33
Default
  #9
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 sat_fire View Post
hi everyone,
I am writing UDF for Energy source term for a zone.my domain consist of two zones. so while writing UDF i am using thread_c_loop(t,d). This thread will work on every cells of zone where i will attach this UDF or it will work on all cells of domain including both zone.
read your post. There is no question! What did you think about?

Regarding energy source:
energy source will be generated only in zones (every cell of that zone), you had defined with rate from UDF

Best regards
AlexanderZ 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
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
How to access temp. of adjacent two cell centre sat_fire Fluent UDF and Scheme Programming 2 February 16, 2018 05:03
cell wall distance using C_WALL_DIST(c,t) or other udf zhixin Fluent UDF and Scheme Programming 11 April 18, 2016 11:17
Using UDF in fuel cell addon module qwe2077 FLUENT 5 February 12, 2015 04:25
how to find the index of the adjacent cell of one cell? jing113cn Fluent UDF and Scheme Programming 2 July 8, 2010 04:26


All times are GMT -4. The time now is 17:58.