|
[Sponsors] |
Solution tends to wrong (or not wanted) value |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 9, 2020, 20:31 |
Solution tends to wrong (or not wanted) value
|
#1 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
Hi all,
I am having problems with my UDRGM. It is a real gas model that below 500 K applies an ideal-gas formulation. However, even though the density and Cp are being calculated properly, the final temperature tends to a very different solution from the ideal gas and therefore my final density (and all other variables) is not the right one. In order to show you what is going on I have attached a .zip file with the mesh (a 2D simple channel), a journal file (that executes everything for you) and the 2 UDRGMs (one with ideal-gas formulation and the other with real-gas formulation). You can compile and execute the simulations in your computer and check yourselves (it takes less than 1 min to run). As you will observe, if we use the ideal UDRGM after reaching the ideal-gas formulation, the new solution spreads and it is equal to the previous solution (see image "IDEAL-UDRGM-propagation"). Nonetheless, if we load the real UDRGM after reaching the ideal-gas solution, the solution spreads with a very different values of temperature and the final temperature field is completely different from the ideal-gas solution (see REAL-UDRGM-propagation), and they should be identical since the formulations are the same. If the CP is the same in the simulations (Cp=1004.16 J/(Kg K) and constant below 500 K), the density, enthalpy and other quantities formulations are the same in both UDRGMs and the boundary conditions are the same, what can cause the dramatic change of temperature? |
|
April 12, 2020, 17:24 |
UDRGM retrieving the wrong temperature
|
#2 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
I acknowledged by placing a message warning that the total temperature from the inlet is passed in the functions for calculating the entropy and the enthalpy instead of the temperature and this is spreaded to the entire domain. I mean here:
double ANYNAME_enthalpy(cell_t cell, Thread *thread, double T, double Rho, double P, double yi[]) double ANYNAME_entropy(cell_t cell, Thread *thread, double T, double Rho, double P, double yi[]) Since the total temperature is higher than the static temperature, it makes my simulation to converge to a higher temperature value. Is it posible to retrieve the static temperature instead the total temperature at this functions? Or how could I avoid this error at the boundary? Last edited by Captain Convergence; April 12, 2020 at 19:47. |
|
April 13, 2020, 09:02 |
Temperature
|
#3 |
Senior Member
|
Fluent returns static temperature and not total temperature for these or any other macros. You can observe that for the ideal gas density calculation. The density depends only on static temperature and not on total temperature.
__________________
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 13, 2020, 10:05 |
|
#4 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
I am running a 2D channel where the static temperature is 287 at Mach 5. In order to have that static temperature, I need a total temperature of 1722.98 Kelvin at the inlet and outlet. My UDFs for Enthalpy and Entropy look like this:
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ /* ENTHALPY UDF */ /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ double REAL_enthalpy(cell_t cell, Thread *thread, double Temp, double density, double P, double yi[]) { double cp = REAL_specific_heat(cell, thread, Temp, density, P, yi); /* Cp = 1004.16 J/(Kg K) IF Temp < 500 Kelvin*/ double h = Temp * cp; if (Temp>500){ Message("Enthalpy Temp Warning, Temp: %f K\n", Temp); } return h; /* (J/Kg) */ } /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ /* ENTROPY UDF */ /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ double REAL_entropy(cell_t cell, Thread *thread, double Temp, double density, double P, double yi[]) { double RGAS = Runiv/MW0; double s = REAL_specific_heat(cell, thread, Temp, density, P, yi) * log(fabs(Temp / TDatum)) + RGAS * log(fabs(PDatum / P)); if (Temp>500){ Message("Entropy Temp Warning, Temp: %f K\n", Temp); } return s; /* (J/Kg/K) */ } I have attached one screeshot 1 iteration after the initialization with a temperature of 287K. As you can observe, the messages that I set inform me that the variable Temp passed from the solver is 1722.98 Kelvin which is the total temperature and it is used to calculate the CP in the enthalpy function. Since the Cp function in the enthalpy function is given the Total temperature instead of the static temperature, the outcome is a highter Cp and thus a higher enthalpy that raises my static temperature from 287 Kelvin to 465 Kelvin. |
|
April 13, 2020, 10:21 |
|
#5 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
if instead of calculating the CP in each loop I leave it as constant:
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ /* ENTHALPY UDF (INTERPOLATION) */ /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ double REAL_enthalpy(cell_t cell, Thread *thread, double Temp, double density, double P, double yi[]) { double cp = 1004.16; // J/(Kg K) double h = Temp * cp; if (Temp>500){ Message("Enthalpy Temp Warning, Temp: %f K\n", Temp); // CHECK POSITION!! } return h; /* (J/Kg) */ } /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ /* ENTROPY UDF */ /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ double REAL_entropy(cell_t cell, Thread *thread, double Temp, double density, double P, double yi[]) { double RGAS = Runiv/MW0; double cp = 1004.16; // J/(Kg K) double s = cp * log(fabs(Temp / TDatum)) + RGAS * log(fabs(PDatum / P)); if (Temp>500){ Message("Entropy Temp Warning, Temp: %f K\n", Temp); } return s; /* (J/Kg/K) */ } I am still having the same temperature warnings but now the static temperature does not change because the Cp remains constant (See the attached image). But there is an enthalpy calculation error because it is being calculated (apparently) with the Total Temperature. |
|
April 13, 2020, 10:43 |
Temperature
|
#6 |
Senior Member
|
Try reporting both, temperature as well as dynamic temperature. Certainly, there are some cells that will have static temperature equal to total temperature. It has got nothing to do with your boundary condition.
__________________
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 13, 2020, 10:54 |
|
#7 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
And how can I retrieve the dynamic temperature in the UDRGM enthalpy function? Can it be obtained from the variables "cell_t cell" and "Thread *thread"? I tried to find information about their format but I only found information for regular UDFs.
|
|
April 13, 2020, 11:16 |
Dynamic Temperature
|
#8 |
Senior Member
|
There is no direct macro to fetch dynamic temperature. All you need is to fetch velocity for the cell. If velocity is 0, so would be dynamic temperature. Dynamic temperature is given as
__________________
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 13, 2020, 12:13 |
|
#9 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
I added the highlighted to my UDF
/*-------------------------------------------------------------------*/ double REAL_enthalpy(cell_t cell, Thread *thread, double Temp, double density, double Pabs, double yi[]) { double Temp2 = C_T(cell,thread); double Pabs2 = C_P(cell,thread); double cp = REAL_specific_heat(cell, thread, Temp2, density, Pabs2, yi); /* Cp = 1004.16 J/(Kg K) IF Temp < 500 Kelvin*/ double h = Temp2 * cp; if (Temp>500){ Message("Enthalpy Temp Warning, Temp: %f K P: %f Pa\n", Temp, Pabs); Message("Enthalpy Other Monitors, Temp2: %f K P2: %f Pa\n", Temp2, Pabs2); } return h; /* (J/Kg) */ } /*-------------------------------------------------------------------*/ As I was suspecting, fluent is retrieving by default the total pressure and total temperature at least in the entropy and enthalpy functions (see the attached image). Now I have to check again all my functions to make sure that the right temperatures and pressures are being used. |
|
April 13, 2020, 13:26 |
|
#10 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
I have obtained the static Pressure and static Temperature in every UDRGM function by using these commands at the beginning of each function:
Temp = C_T(cell,thread); Pabs = C_P(cell,thread); Unfortunately now I have the opposite issue and the temperature tends to 0 Kelvin. I have attached the contours of dynamic temperature and static temperature. It doesn't go to 0 because I have limited the minimum temperature to 200 Kelvin. For some reason that I cannot understand there are many extrange interactions at the inlet. Honestly I don't know why I am having so many issues with this simple case and what else I should try... |
|
April 14, 2020, 04:31 |
T and P
|
#11 |
Senior Member
|
I did not observe any difference in temperature and pressure returned by Fluent and C_T and C_P. Fluent does return absolute static pressure and absolute static temperature and NOT total values. Do note that there will be difference during the initialization. You have to run the case for at least 1 iteration.
__________________
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 14, 2020, 06:01 |
|
#12 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
Then the only thing left is that my Enthalpy dependence on the Cp makes the density-based solver converge to very extrange values at the inlet. Which shouldn't occur because the Cp is constant below 500 K but maybe within the solver the calculations tend to higher or lower values of temperature and that's why I have the error at the inlet.
|
|
April 14, 2020, 07:03 |
Boundary
|
#13 |
Senior Member
|
Inlet is a boundary where user specifies the values. Fluent does not do any calculation at Inlet. The only calculation is for static temperature that is determined from simple relation between stagnation temperature, static temperature, material properties, and Mach.
__________________
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 14, 2020, 07:13 |
|
#14 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 |
Is there any possibility to keep that static temperature as constant with a user-defined value?
|
|
April 14, 2020, 07:15 |
Fixed Values
|
#15 |
Senior Member
|
If you want to keep static temperature fixed throughout the cell zone, then go to cell zone conditions, enabled Fixed Values, and then fix temperature to any value you want. Fixing static temperature at the inlet is not possible for ideal or real gas because it is not independent of the flow.
__________________
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Stable but wrong solution in VOF method | Ulixes | FLUENT | 0 | May 1, 2017 15:08 |
Ansys CFD POST constructs a solution history from wrong file. | Wingman | ANSYS | 2 | November 28, 2016 18:01 |
grid dependancy | gueynard a. | Main CFD Forum | 19 | June 27, 2014 22:22 |
Naca 0012 (compressible and inviscid) flow convergence problem | bipulsaha | FLUENT | 1 | July 6, 2011 08:51 |
Wall functions | Abhijit Tilak | Main CFD Forum | 6 | February 5, 1999 02:16 |