|
[Sponsors] |
How to write an UDF : polynomial equation as a source of energy |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 25, 2020, 13:09 |
How to write an UDF : polynomial equation as a source of energy
|
#1 |
New Member
Chaatouf Dounia
Join Date: Jun 2019
Posts: 11
Rep Power: 6 |
Hello everyone,
I'm trying to write a UDF (source term), I have a polynomial equation but I have no idea how to write it, I tried using DEFINE_SOURCE but it didn't work, please, can someone help me in this. #include "udf.h" #include<math.h> DEFINE_SOURCE(Energy_source, c, ct, S, dS) { real source; real flow_time; real t = CURRENT_TIME; { if ((t>0)&&(t<39600)) { source =((0.3179*pow((t/3600),4.0))-(8.4583*pow((t/3600),3.0))+(50.847*pow((t/3600),2.0))+(31.165*(t/3600))+327.88)*(0.81/0.001); } else { source=0; } } return source; } I'll be so grateful for any help. Best regards and best wishes, Dounia |
|
February 25, 2020, 15:19 |
Polynomial
|
#2 |
Senior Member
|
The expression is correct, however, there would be conflicts. First, do not use t as variable name. This is an internally defined variable. You can use flow_time that you already have in your code but not in use. So, set
real flow_time = CURRENT_TIME; Secondly, all the values provided by the Fluent to the UDF and from the UDF to the Fluent are always in SI. Calculations can be done in any units within a UDF but while returning values to Fluent, the values have to be in SI. So, CURRENT_TIME is always in s. Therefore, you do not need to divide by 3600; if that is the reason you are dividing it by. Thirdly, time is never negative. So, no need to mention t>0 since it always is. Furthermore, since this is an energy source term, you need to take first derivative of the polynomial with respect to temperature and write it as S[dS] = first derivative in term Since in the current equation there is no temperature dependence, you can simply mention it as S[dS] = 0.;
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
February 26, 2020, 12:25 |
|
#3 |
New Member
Chaatouf Dounia
Join Date: Jun 2019
Posts: 11
Rep Power: 6 |
Thank you very much for answering me,
it doesn't give me an error anymore, I really appreciate it, Best regards, Dounia |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Tabulated thermophysicalProperties library | chriss85 | OpenFOAM Community Contributions | 62 | October 2, 2022 03:50 |
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 | tlcoons | OpenFOAM Installation | 13 | April 20, 2016 17:34 |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 05:18 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 11:44 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 19:08 |