|
[Sponsors] |
February 5, 2014, 05:54 |
Boundary condition temerature profile
|
#1 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
Hello,
I have been working on transient analysis with considering the below code but I have strange results. is there anyone to help me to find my problem? (indeed I divide the temperature profile to some branches to get accurate fitting curve, that's why I have more than one equation in the code) Code:
/*********************************************************************** UDF example.c UDF for specifying transient temperature profile boundary condition S ************************************************************************/ #include "udf.h" #include "mem.h" DEFINE_PROFILE(TempS_Profile, thread, position) { real x[ND_ND]; real y; real t1=10019; real t2=13529; real t3=20009; real t4=29999; real t5=40019; real t6=50009; real t7=59999; real t8=70019; real t9=80009; real theProfile; face_t f; begin_f_loop(f, thread); { F_CENTROID(x,f,thread); y = CURRENT_TIME; if(y<=t1) { theProfile=(-2E-13*pow(y,3.))+(3E-08*pow(y,2.))+(9E-06*pow(y,1.))+283.78; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t2 && y>t1) { theProfile=(1E-11*pow(y,3.))-(4E-07*pow(y,2.))+(0.0061*pow(y,1.))+257.77; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t3 && y>t2) { theProfile=(-4E-11*pow(y,3.))+(2E-06*pow(y,2.))-(0.035*pow(y,1.))+482.71; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t4 && y>t3) { theProfile=(4E-12*pow(y,3.))-(3E-07*pow(y,2.))+(0.0091*pow(y,1.))+203.7; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t5 && y>t4) { theProfile=(-7E-12*pow(y,3.))+(7E-07*pow(y,2.))-(0.0233*pow(y,1.))+550.94; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t6 && y>t5) { theProfile=(9E-12*pow(y,3.))-(1E-06*pow(y,2.))+(0.0575*pow(y,1.))+566.62; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t7 && y>t6) { theProfile=(1E-12*pow(y,3.))-(2E-07*pow(y,2.))+(0.0094*pow(y,1.))+171.39; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t8 && y>t7) { theProfile=(-6E-12*pow(y,3.))+(1E-06*pow(y,2.))-(0.0849*pow(y,1.))+2180.8; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t9 && y>t8) { theProfile=(-1E-11*pow(y,3.))+(3E-06*pow(y,2.))-(0.2083*pow(y,1.))+5510.9; F_PROFILE(f, thread, position) =theProfile; } else { theProfile=(-6E-11*pow(y,3.))+(1E-05*pow(y,2.))-(1.2143*pow(y,1.))+33813; F_PROFILE(f, thread, position) =theProfile; } } end_f_loop(f,thread) } regards, |
|
February 6, 2014, 15:04 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Your equations give the following profile:
Code:
#time #temperature 0 283.779999 1000 283.818787 2000 283.916412 3000 284.071594 4000 284.283203 5000 284.549988 6000 284.870789 7000 285.244385 8000 285.669586 9000 286.145203 10000 286.670013 11000 289.779999 12000 290.649994 13000 291.440002 14000 274.950012 15000 272.709991 16000 270.869995 17000 269.190002 18000 267.429993 19000 265.350006 20000 262.709991 21000 299.544006 22000 301.291992 23000 302.967987 24000 304.596008 25000 306.200012 26000 307.803986 27000 309.432007 28000 311.108002 29000 312.855988 30000 292.940002 31000 292.803009 32000 292.764008 33000 292.781006 34000 292.812012 35000 292.815002 36000 292.747986 37000 292.569000 38000 292.235992 39000 291.707001 40000 290.940002 41000 1863.409058 42000 1884.411987 43000 1905.682983 44000 1927.276001 45000 1949.244995 46000 1971.644043 47000 1994.526978 48000 2017.947998 49000 2041.961060 50000 2066.620117 51000 263.240997 52000 259.997986 53000 256.666992 54000 253.253998 55000 249.764999 56000 246.205994 57000 242.582993 58000 238.901993 59000 235.169006 60000 -609.200012 61000 -638.986023 62000 -668.968018 63000 -699.182007 64000 -729.664001 65000 -760.450012 66000 -791.575989 67000 -823.078003 68000 -854.992004 69000 -887.354004 70000 -920.200012 71000 2265.489990 72000 2332.820068 73000 2401.830078 74000 2472.459961 75000 2544.649902 76000 2618.340088 77000 2693.469971 78000 2769.979980 79000 2847.810059 80000 2926.899902 81000 -30821.759766 82000 -31601.679688 83000 -32391.119141 84000 -33190.441406 85000 -34000.000000 86000 -34820.160156 87000 -35651.281250 88000 -36493.718750 89000 -37347.839844 90000 -38214.000000 91000 -39092.558594 92000 -39983.878906 93000 -40888.320312 94000 -41806.238281 95000 -42738.000000 96000 -43683.960938 97000 -44644.480469 98000 -45619.921875 99000 -46610.640625 |
|
February 9, 2014, 12:09 |
|
#3 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
thank you very much for reply,
I couldnt get the correct equations through excell (it gives me the same as what I had before) thus, i decided to use a constant value (interval value) instead of equation and the solutions are converged. when I implmenting another code (please see the second code) represent the properties for a material within the model. agian i have "converge problem" and it gives me wrong results. would you please check it? regards, Code:
/*********************************************************************** UDF example.c UDF for specifying transient temperature profile boundary condition S ************************************************************************/ #include "udf.h" #include "mem.h" DEFINE_PROFILE(TempS48h_Profile, thread, position) { real x[ND_ND]; real y; real t1=5000; real t2=10000; real t3=15000; real t4=20000; real t5=25000; real t6=30000; real t7=35000; real t8=40000; real t9=45000; real t10=50000; real t11=55000; real t12=60000; real t13=65000; real t14=70000; real t15=75000; real t16=80000; real t17=85000; real t18=90000; real t19=100000; real t20=105000; real t21=110000; real t22=115000; real t23=120000; real t24=125000; real t25=130000; real t26=135000; real t27=140000; real t28=145000; real t29=150000; real t30=155000; real t31=160000; real t32=165000; real t33=170000; real theProfile; face_t f; begin_f_loop(f, thread); { F_CENTROID(x,f,thread); y = CURRENT_TIME; if(y<=t1) { theProfile=284; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t2 && y>t1) { theProfile=285.29; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t3 && y>t2) { theProfile=287.63; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t4 && y>t3) { theProfile=292.81; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t5 && y>t4) { theProfile=301.56; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t6 && y>t5) { theProfile=308.1; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t7 && y>t6) { theProfile=313.5; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t8 && y>t7) { theProfile=313.84; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t9 && y>t8) { theProfile=316.92; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t10 && y>t9) { theProfile=316.7; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t11 && y>t10) { theProfile=313.42; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t12 && y>t11) { theProfile=308.56; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t13 && y>t12) { theProfile=301.89; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t14 && y>t13) { theProfile=296.57; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t15 && y>t14) { theProfile=293.96; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t16 && y>t15) { theProfile=290.69; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t17 && y>t16) { theProfile=288.19; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t18 && y>t17) { theProfile=284.4; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t19 && y>t18) { theProfile=284.14; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t20 && y>t19) { theProfile=285.66; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t21 && y>t20) { theProfile=288; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t22 && y>t21) { theProfile=294.43; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t23 && y>t22) { theProfile=302.8; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t24 && y>t23) { theProfile=309.24; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t25 && y>t24) { theProfile=314.52; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t26 && y>t25) { theProfile=317; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t27 && y>t26) { theProfile=316.4; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t28 && y>t27) { theProfile=312.67; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t29 && y>t28) { theProfile=307.45; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t30 && y>t29) { theProfile=300.74; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t31 && y>t30) { theProfile=296.03; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t32 && y>t31) { theProfile=293.46; F_PROFILE(f, thread, position) =theProfile; } else if (y<=t33 && y>t32) { theProfile=290.2; F_PROFILE(f, thread, position) =theProfile; } else { theProfile=284.5; F_PROFILE(f, thread, position) =theProfile; } } end_f_loop(f,thread) } /*********************************************************************** udfexample.c UDF for specifying heat source heat sink ************************************************************************/ #include "udf.h" DEFINE_SOURCE(energy_udf,c,t,dS,eqn) { real source; real temp1=281; real temp2=558; real temp3=288; real temp4=293; real temp5=296; real temp6=297; if(N_TIME > 0) { if (C_T(c,t) > C_T_M1(c,t)) /* UDF for increasing temperature*/ { if (C_T_M1(c,t) >= 280.140 && C_T(c,t) <= 300.20) if(temp<=temp1) { source=1.5; dS[eqn] =0; } else if (temp<=temp2 && temp>temp1) { source=558; dS[eqn] =0; } else if (temp<=temp3 && temp>temp2) { source=2583; dS[eqn] =0; } else if (temp<=temp4 && temp>temp3) { source=9643; dS[eqn] =0; } else if (temp<=temp5 && temp>temp4) { source=18395; dS[eqn] =0; } else if (temp<=temp6 && temp>temp5) { source=22918; dS[eqn] =0; } else { source=24477; dS[eqn] =0; } } else if (C_T(c,t) < C_T_M1(c,t)) /* UDF for decreasing temperature */ { if (C_T_M1(c,t) <= 295.57 && C_T(c,t) >= 278.32) { if(temp<=temp1) { source=23147; dS[eqn] =0; } else if (temp<=temp2 && temp>temp1) { source=21972; dS[eqn] =0; } else if (temp<=temp3 && temp>temp2) { source=19300; dS[eqn] =0; } else if (temp<=temp4 && temp>temp3) { source=4765; dS[eqn] =0; } else if (temp<=temp5 && temp>temp4) { source=12; dS[eqn] =0; } else if (temp<=temp6 && temp>temp5) { source=4.7; dS[eqn] =0; } else { source=1.2; dS[eqn] =0; } } } } return source; } |
|
February 9, 2014, 16:59 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
No, I am not going to do your work.
If you want to learn something, I am very willing to help you. If you just want me to fix your errors, I'll pass. I have shown you how you can test your udf: compare what your udf should do to what your udf actually does. Now you do it. If you can not do this, do the best you can, and show your intermediate results here, and I'll help. But at least try... |
|
February 10, 2014, 15:35 |
|
#5 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
thanks for your reply,
I used constant value (interval values) instead of using equations, in order to be sure of temperature profile for boundary condition. however, it takes a lot of time to do such a this but i have no other way. and finally, the result is acceptable of meaning. in next step, I have face with another problem with strange result, when I implementing another code for my source term (pleas see the code) and can't find my problem. any help please? regards, Code:
/*********************************************************************** udfexample.c UDF for specifying heat source heat sink ************************************************************************/ #include "udf.h" DEFINE_SOURCE(energy_udf,c,t,dS,eqn) { real source; real temp1=281; real temp2=285; real temp3=287; real temp4=290; real temp5=294; real temp6=297; real temp7=282; real temp8=287; real temp9=292; if(N_TIME > 0) { if (C_T(c,t) > C_T_M1(c,t)) /* UDF for increasing temperature*/ { if (C_T_M1(c,t) >= 280 && C_T(c,t) <= 300) if(temp<=temp1) { source=(65*pow(temp,1.))-18199; dS[eqn] =65; } else if (temp<=temp2 && temp>temp1) { source=(193.75*pow(temp,1.))-54377.75; dS[eqn] =193.75; } else if (temp<=temp3 && temp>temp2) { source=(2192*pow(temp,1.))-615111; dS[eqn] =2192; } else if (temp<=temp4 && temp>temp3) { source=(488.34*pow(temp,1.))-138214.7; dS[eqn] =488.34; } else if (temp<=temp5 && temp>temp4) { source=(1560.5*pow(temp,1.))-449143; dS[eqn] =1560.5; } else if (temp<=temp6 && temp>temp5) { source=(4424.7*pow(temp,1.))-1291.208; dS[eqn] =4424.7; } else { source=(498.34*pow(temp,1.))-125087; dS[eqn] =498.34; } } else if (C_T(c,t) < C_T_M1(c,t)) /* UDF for decreasing temperature */ { if (C_T_M1(c,t) <= 295 && C_T(c,t) >= 278) { if(temp<=temp7) { source=(-156*pow(temp,1.))+66516; dS[eqn] =-156; } else if (temp<=temp8 && temp>temp7) { source=(-527.8*pow(temp,1.))+171363.6; dS[eqn] =0; } else if (temp<=temp9 && temp>temp8) { source=(-2635.6*pow(temp,1.))+776302.2; dS[eqn] =-2635.6; } else { source=(-2234*pow(temp,1.))+659035; dS[eqn] =-2234; } } } } return source; } |
|
February 10, 2014, 18:36 |
|
#6 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
If you want to learn something, I am very willing to help you. If you just want me to fix your errors, I'll pass. I have shown you how you can test your udf: compare what your udf should do to what your udf actually does. Now you do it. If you can not do this, do the best you can, and show your intermediate results here, and I'll help. But at least try... |
||
February 16, 2014, 11:24 |
|
#7 |
Senior Member
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0 |
I think I Have sorted the problem was showed up by equations within the code (still not sure).
the problem was end point and start point of each equation indeed. because, in the last version that I submitted, there was non continuously (as I put randomly some points regarding just to check them). so with changing the equation with power 3 to power 1 it was solved. I faced with another problem, don't understand where is the problem. until 19000sec the results are converged with time step size 30sec with 250iteration and 2880time steps.afterward, not convergence... where is my mistake? regards, Code:
/*********************************************************************** UDF example.c UDF for specifying transient temperature profile boundary condition ************************************************************************/ #include "udf.h" #include "mem.h" DEFINE_PROFILE(TempS_Profile, thread, position) { real x[ND_ND]; real y; real t1=10000; real t2=20000; real t3=30000; real t4=40000; real t5=50000; real t6=60000; real t7=70000; real t8=80000; real theProfile; face_t f; begin_f_loop(f, thread); { F_CENTROID(x,f,thread); y = CURRENT_TIME; if(y<=t1) { theProfile=(0.0003*pow(y,1.))+283; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t2 && y>t1) { theProfile=(0.0012*pow(y,1.))+274; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t3 && y>t2) { theProfile=(0.0013*pow(y,1.))+272; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t4 && y>t3) { theProfile=(0.0006*pow(y,1.))+293; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t5 && y>t4) { theProfile=(-0.0006*pow(y,1.))+341; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t6 && y>t5) { theProfile=(-0.0013*pow(y,1.))+376; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t7 && y>t6) { theProfile=(-0.0006*pow(y,1.))+334; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else if (y<=t8 && y>t7) { theProfile=(-0.0007*pow(y,1.))+341; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } else { theProfile=(-0.0003125*pow(y,1.))+310; begin_f_loop(f,thread) { F_PROFILE(f, thread, position) =theProfile; } end_f_loop(f,thread) } } end_f_loop(f,thread) } /*********************************************************************** udfexample.c UDF for heat source heat sink ************************************************************************/ #include "udf.h" DEFINE_SOURCE(energyPOW2,c,t,dS,eqn) { real source; if(N_TIME > 0) { if (C_T(c,t) > C_T_M1(c,t)) { if (C_T_M1(c,t) >= 287 && C_T(c,t) <= 300.20) { source = (101.6*pow(temp,2.))-(57581*pow(temp,1.))+8E+06; dS[eqn] = (202.4*pow(temp,1.))-(57581); } } else if (C_T(c,t) < C_T_M1(c,t)) { if (C_T_M1(c,t) <= 295.57 && C_T(c,t) >= 278.32) { source =(133.25*pow(temp,2.))-(74998*pow(temp,1.))+1E+07; dS[eqn] =(266.5*pow(temp,1.))-74998; } } } return source; } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
Velocity profile boundary condition | Tuca | FLOW-3D | 1 | April 23, 2013 13:02 |
No-slip condition for non-resolved boundary layer in open channel banks | Lupocci | Main CFD Forum | 1 | January 17, 2013 04:11 |
velocity profile inlet boundary condition question | Lcw | FLUENT | 3 | August 3, 2012 06:53 |
applying profile data as a boundary condition | vadivel | CFX | 1 | June 9, 2007 08:11 |