|
[Sponsors] |
UDFs for Energy Source & Water Vapour Concentration Source |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 13, 2020, 07:10 |
UDFs for Energy Source & Water Vapour Concentration Source
|
#1 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
Hi Guys,
I am attempting to model the effect of crops in a heated closed greenhouse. The crops have been modelled as a porous medium domain with a sink for both energy and water vapour concentration. The source/sink term for the energy and water vapour concentration are given by equations and I have written UDFs to model these variables. Kindly take a look and advice, thank you very much and much appreciated. /*Energy Sink Term for the Crop-Zone*/ #include "udf.h" #define rho 1.225 #define Ca 1006.25 #define Lad 3 #define L 0.405 #define v crop_zone velocity /*air velocity within the crop zone*/ #define Tcrop crop_zone temperature /*temperature of the crop zone*/ #define Tair fluid temperature /*temperature inside the greenhouse*/ DEFINE_SOURCE (crop_zone_energy_source, c, t, dS, eqn) { real source; ra = 305 * ((L/v) exp0.5); source = -2 * rho * Lad * Ca * ((Tcrop - Tair)/ ra); dS[eqn] = 0.0; return source; } /*Water Vapour Sink Term for the Crop-Zone*/ #include "udf.h" #define rho 1.225 #define lambda 2.45*10e6 #define Le 0.86 #define Lad 3 #define rs 290 #define Wcrop crop_zone water vapour source /*water vapour within the crop zone*/ #define Wair fluid water vapour source /*water vapour within the greenhouse*/ DEFINE_SOURCE (crop_zone_water vapour_source, c, t, dS, eqn) { real source; source = -rho * lambda * ((Le) exp1/3) * Lad ((Wcrop -Wair) / (ra + rs)); dS[eqn] = 0.0; return source; } |
|
April 14, 2020, 04:12 |
Source Terms
|
#2 |
Senior Member
|
Syntactically, the UDF will work with proper values assigned to the parameters. However, dS[eqn] should not be set to 0 if the parameters in the source equation are not constant. In dS[eqn], S is source and eqn is the field variable to which the source is being applied. So, for energy equation, T is eqn. Consequently, if energy source is a function of T, then dS[eqn] should be first derivative of source term with T and not 0. If that is the not the case, then the UDF is alright and will work.
__________________
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. |
|
April 17, 2020, 03:47 |
|
#3 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
I apologize for the late response. I was not able to quickly respond due to the network disruptions because of the pandemic. Thank you very much for the response. That is the case and dS should not be set to 0.
I set it as follows for the cropzone energy sink term: dS[eqn] = - ((2 * rho * Lad * Ca ) / r) What do you think? |
|
April 17, 2020, 06:00 |
Derivative
|
#4 |
Senior Member
|
If and are constants, then dS[eqn] has to be 0. However, if those are not constant, then those have to be written in terms of field temperature T and then the gradient should be computed. The gradient you have computed is correct only if is equal to T and is constant.
__________________
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. |
|
April 17, 2020, 10:01 |
|
#5 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
It is a heated closed greenhouse and as such Tcrop and Tair are not constants. As heat is added to the greenhouse air, Tair will continue rise. The crops continously absorb heat from the air and as such Tcrop will also continue to rise up to a point. Its seems my computation was wrong. How do you suggest the gradient should be computed to reflect that Tcrop and Tair are not constants, and they are written in terms of field temperature T?
|
|
April 17, 2020, 10:42 |
Air Temperature
|
#6 |
Senior Member
|
Since you solving for the air domain, . As far as is concerned, this does not belong to the temperature of the zone to which you are applying source term. Hence, this would be constant as far as source is concerned. So, the derivative will be
However, will be equal to T if you do not consider non-equilibrium heat transfer model for the porous zone. And then, your source term will be 0, which it should be.
__________________
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. |
|
April 17, 2020, 11:34 |
|
#7 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
I see your point now. Thank you very much for your help. Much appreciated.
|
|
May 2, 2020, 21:31 |
Transient Simulation
|
#8 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
Quote:
The UDFs we discussed were okay for steady-state simulation. Is there any modification that is required if they are to be applied in transient simulation? Temperatures, for instance, vary during the day. Thank you very much for your assistance, much appreciated |
|
May 3, 2020, 15:34 |
Transient
|
#9 |
Senior Member
|
As far as Fluent is concerned, there is no change required. However, user has to ensure that the formulation is logical. You can use same UDF for transient, except then Fluent will consider the value supplied by the UDF in terms of per unit time. So, it will further multiply the term returned by UDF with the time-step and apply that as source.
__________________
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. |
|
May 4, 2020, 03:23 |
|
#10 | |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
Quote:
Thanks, Much appreciated |
||
May 25, 2020, 08:14 |
Compiling Errors
|
#11 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
Code:
..\..\src\Ta.cpp(11): error C2086: 'real S0avg': redefinition ..\..\src\Ta.cpp(9): note: see declaration of 'S0avg' ..\..\src\Ta.cpp(11): error C2086: 'real volume': redefinition ..\..\src\Ta.cpp(10): note: see declaration of 'volume' ..\..\src\Ta.cpp(11): error C2086: 'real vol_tot': redefinition ..\..\src\Ta.cpp(10): note: see declaration of 'vol_tot' ..\..\src\Ta.cpp(12): error C2059: syntax error: 'empty declaration' ..\..\src\Ta.cpp(18): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(18): error C2789: 'cell_loop_last': an object of const-qualified type must be initialized ..\..\src\Ta.cpp(18): note: see declaration of 'cell_loop_last' ..\..\src\Ta.cpp(18): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(20): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(20): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(21): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(21): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(22): error C2065: 'S0': undeclared identifier ..\..\src\Ta.cpp(22): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(22): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(25): error C2065: 'S0': undeclared identifier ..\..\src\Ta.cpp(27): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(27): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(29): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(29): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(30): error C2064: term does not evaluate to a function taking 1 arguments ..\..\src\Ta.cpp(30): error C2064: term does not evaluate to a function taking 1 arguments ..\..\src\Ta.cpp(32): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(32): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(33): error C2065: 'thread': undeclared identifier ..\..\src\Ta.cpp(33): error C2065: 'cell': undeclared identifier ..\..\src\Ta.cpp(59): error C3872: '0xac': this character is not allowed in an identifier ..\..\src\Ta.cpp(59): error C3688: invalid literal suffix '�?�'; literal operator or literal operator template 'operator ""�?�' not found ..\..\src\Ta.cpp(62): error C3872: '0xac': this character is not allowed in an identifier ..\..\src\Ta.cpp(62): error C3688: invalid literal suffix '�?�'; literal operator or literal operator template 'operator ""�?�' not found I hope you are well. I finished writing the UDF but ran into some errors during compiling. I fixed all the issues apart from calculations of average temp. and average species mass fractions. I am also attempting to store the value of sensible heat for post-processing but I get an error. It seems I am not able to use the word "source" twice for storage. A little background: 1. The porous crop zone is in thermal equilibrium with the air flowing through it so I thought I would use the volume-weighted average temp. value of the fluid domain of the entire greenhouse as Temp-air in sensible heat and transpiration calculations 2. Did the same with water vapor, Species-0. 3. All the equations used are above the associated code. Is there a code I could write to initialize the UDMIs? Thank you, much appreciated. Last edited by Morice; May 31, 2020 at 22:20. Reason: Improper Code and used in a wrong number |
|
May 25, 2020, 10:37 |
Errors
|
#12 |
Senior Member
|
There are multiple syntactical errors in the code. Go through each line that is reported in the compilation, such as, 9, 10, 11, 12, 18, etc. Each of these line has errors. E.g., there are no variables defined by the names of cell and thread, however, those are being used as the arguments for the loop. There are some variables being redefined, such as, S0avg, volume, vol_tot. Go through each line and try to remove those errors.
__________________
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. |
|
May 25, 2020, 21:37 |
Compiling Errors
|
#13 |
Member
Join Date: Oct 2019
Posts: 35
Rep Power: 6 |
Good Morning,
Thank you for your fast response, much appreciated. Will do. Thanks |
|
Tags |
udf energy source |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] How to use finite area method in official OpenFOAM 2.2.0? | Detian Liu | OpenFOAM Meshing & Mesh Conversion | 4 | November 3, 2015 03:04 |
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 | Seroga | OpenFOAM Community Contributions | 9 | June 12, 2015 17:18 |
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error | FerdiFuchs | OpenFOAM Community Contributions | 27 | April 16, 2014 15:14 |
UDFs for Scalar Eqn - Fluid/Solid HT | Greg Perkins | FLUENT | 0 | October 13, 2000 23:03 |
UDFs for Scalar Eqn - Fluid/Solid HT | Greg Perkins | FLUENT | 0 | October 11, 2000 03:43 |