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

Fluent source dependent from time and temperature problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2024, 10:57
Default Fluent source dependent from time and temperature problem
  #1
New Member
 
Join Date: Mar 2024
Posts: 2
Rep Power: 0
Fierow97 is on a distinguished road
Hi everybody, I am new to fluent UDFs. My job is to define a heat source in a battery volume, extracting the data from a table which is then divided into time intervals in order to be more accurate when approximating this source data into a polynomial.
To define the source I set the UDF into time intervals using an if else if cycle. I obtained this UDF where in the first part I set an outside temperature monitor, then i set the source function. The problem I face is that starting from the 3rd interval the temperature has wrong values, increasing in an exagerated way. Where am I wrong??
Thanks in advance to anybody who will answer

---------------------------------------------------------------
---------------------------------------------------------------
#include "udf.h"

real area_tot = 0;
real tsum = 0;
int i = 0;
FILE *qvol;

DEFINE_EXECUTE_AT_END(average_temp)
{
Domain *d;
face_t f;
real A[ND_ND];
real temper;
real area;
real tavg_real;
int ID = 10000;
int cell_id = 9995;
Thread *t;
cell_t c;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);
c = Lookup_Thread(d,cell_id);


begin_f_loop(f,t) /*t identificato sopra*/
{
i++;
F_AREA(A,f,t);
area = NV_MAG(A);
temper = F_T(f,t);
area_tot += area;
tsum += temper;
}
end_f_loop(f,t)
tavg_real = F_UDMI(f,t,0) = tsum /( i * area_tot);

}

DEFINE_SOURCE(heat_source_else,c,t,ds,eqn)
{
real time = CURRENT_TIME - 20;
real source;
face_t f;
real tavg = F_UDMI(f,t,0);
begin_c_loop(c, t) /* loops over faces in a face thread */
{
if (time <= 80)
{
source = 1.293740341969334e+04 +
1.155185358507742e+03 * time -
2.379268980753591e+03 * tavg -
5.649970340744653e+01 * pow(time, 2) -
1.976396708411658e+01 * time * tavg +
1.752096173848799e+02 * pow(tavg, 2) +
1.339829964037692e+00 * pow(time, 3) +
6.257563010711130e-01 * pow(time, 2) * tavg +
2.835527245363084e-01 * time * pow(tavg, 2) -
6.547212742496961e+00 * pow(tavg, 3) -
1.372517572726491e-02 * pow(time, 4) -
1.426208700704884e-02 * pow(time, 3) * tavg +
7.545497774402981e-03 * pow(time, 2) * pow(tavg, 2) -
1.092233515427415e-02 * time * pow(tavg, 3) +
1.160103394950499e-01 * pow(tavg, 4) +
5.145914794527816e-05 * pow(time, 5) +
8.069157261724937e-05 * pow(time, 4) * tavg -
1.157443550354187e-05 * pow(time, 3) * pow(tavg, 2) -
5.689098345730353e-05 * pow(time, 2) * pow(tavg, 3) +
1.082901372206399e-04 * time * pow(tavg, 4) -
7.861770488630989e-04 * pow(tavg, 5);
}
else if (time > 80 && time <= 1560)
{
source = 3.572353433966986e+04 +
1.504725560307832e+01 * time -
4.305741709837774e+03 * tavg -
3.007670621456760e-02 * pow(time, 2) +
1.859195732546453e-01 * time * tavg +
2.884657370568110e+02 * pow(tavg, 2) +
3.713674310102147e-05 * pow(time, 3) -
1.526458940539785e-04 * pow(time, 2) * tavg -
2.028220731966852e-03 * time * pow(tavg, 2) -
1.027481185720795e+01 * pow(tavg, 3) -
1.887603697296835e-08 * pow(time, 4) -
3.512652110128167e-07 * pow(time, 3) * tavg +
1.883092302028152e-05 * pow(time, 2) * pow(tavg, 2) -
2.304064723465128e-04 * time * pow(tavg, 3) +
1.783596586083186e-01 * pow(tavg, 4) +
2.833434262501215e-12 * pow(time, 5) +
2.156423741401386e-10 * pow(time, 4) * tavg -
6.701362245916121e-09 * pow(time, 3) * pow(tavg, 2) -
3.217842108648160e-08 * pow(time, 2) * pow(tavg, 3) +
2.145009790443847e-06 * time * pow(tavg, 4) -
1.197286765135389e-03 * pow(tavg, 5);
}
else if (time > 1560 && time <= 1900)
{
source = 9.531011471749905e+06 -
3.363916338547694e+04 * time +
3.331256457378804e+05 * tavg +
4.503208628648606e+01 * pow(time, 2) -
6.947718183443817e+02 * time * tavg -
1.327004912238531e+03 * pow(tavg, 2) -
2.816703307340135e-02 * pow(time, 3) +
3.968045984613180e-01 * pow(time, 2) * tavg +
9.723870943634603e+00 * time * pow(tavg, 2) -
1.288886842505804e+02 * pow(tavg, 3) +
7.980268082497785e-06 * pow(time, 4) +
1.071912314326167e-05 * pow(time, 3) * tavg -
1.263872195054982e-02 * pow(time, 2) * pow(tavg, 2) +
2.532290242144435e-01 * time * pow(tavg, 3) -
1.454134052575408e+00 * pow(tavg, 4) -
7.470693278106096e-10 * pow(time, 5) -
4.531503740743649e-08 * pow(time, 4) * tavg +
4.756817026485388e-06 * pow(time, 3) * pow(tavg, 2) -
1.298019551282745e-04 * pow(time, 2) * pow(tavg, 3) +
1.595715190293275e-03 * time * pow(tavg, 4) -
8.289107283507393e-03 * pow(tavg, 5);
}
else if (time > 1900 && time <= 2650)
{
source = 1.334556967592067e+05 +
1.364202357062836e+03 * time -
1.604028456958695e+05 * tavg -
2.946727748042327e+00 * pow(time, 2) +
3.266616064310093e+02 * time * tavg -
1.322310937086781e+03 * pow(tavg, 2) +
2.432675706044515e-03 * pow(time, 3) -
2.982415242081833e-01 * pow(time, 2) * tavg +
5.620745389958381e+00 * time * pow(tavg, 2) -
8.724593124214688e+01 * pow(tavg, 3) -
9.268854786566970e-07 * pow(time, 4) +
1.320652320957073e-04 * pow(time, 3) * tavg -
4.858031909644004e-03 * pow(time, 2) * pow(tavg, 2) +
1.155495186556525e-01 * time * pow(tavg, 3) -
7.673718590338964e-01 * pow(tavg, 4) +
1.333096487842449e-10 * pow(time, 5) -
2.162492986745797e-08 * pow(time, 4) * tavg +
1.081528976294556e-06 * pow(time, 3) * pow(tavg, 2) -
2.839762204484407e-05 * pow(time, 2) * pow(tavg, 3) +
1.455524895059615e-04 * time * pow(tavg, 4) +
2.722899274167420e-03 * pow(tavg, 5);
}
else if (time > 2650)
{
source = -4.095300318889147e+06 +
7.823847587495723e+03 * time -
1.043765737289807e+05 * tavg -
5.825576421889270e+00 * pow(time, 2) +
1.309094467134265e+02 * time * tavg +
5.390501339365486e+02 * pow(tavg, 2) +
2.146396857180939e-03 * pow(time, 3) -
6.645451890148453e-02 * pow(time, 2) * tavg +
3.745400361652057e-02 * time * pow(tavg, 2) -
2.129175105412379e+01 * pow(tavg, 3) -
3.903416990802825e-07 * pow(time, 4) +
1.446547355408757e-05 * pow(time, 3) * tavg +
4.847441274804268e-05 * pow(time, 2) * pow(tavg, 2) -
3.187304494343842e-03 * time * pow(tavg, 3) +
4.391172638049189e-01 * pow(tavg, 4) +
2.802566549093382e-11 * pow(time, 5) -
1.133194749454201e-09 * pow(time, 4) * tavg -
1.451245741925541e-08 * pow(time, 3) * pow(tavg, 2) +
8.615177289567311e-07 * pow(time, 2) * pow(tavg, 3) -
1.897745223176266e-05 * time * pow(tavg, 4) -
2.495312174754752e-03 * pow(tavg, 5);
}
ds[eqn] = 0;
return source;
}
end_c_loop(c, t)
}
Fierow97 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
Error: WorkBench Error: Could not handle event: SolutionStatusUpdate Kieyo Fluent Multiphase 0 November 10, 2022 00:58
Averaging over iterations for steady-state simulation CFD student Fluent UDF and Scheme Programming 8 September 22, 2022 04:39
Slow calculation time on CFD server killian153 Hardware 4 July 27, 2021 08:28
laplacianFoam with source term Herwig OpenFOAM Running, Solving & CFD 17 November 19, 2019 14:47
UDF to Define Temperature Dependent Negative Heat Source ATIKADAR Fluent UDF and Scheme Programming 1 September 23, 2019 04:52


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