CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How fluent solver work inside the fluent? (https://www.cfd-online.com/Forums/fluent-udf/251132-how-fluent-solver-work-inside-fluent.html)

Chhotelal1234 July 28, 2023 07:27

How fluent solver work inside the fluent?
 
I want to know, how Fluent Solver takes the variable and calculates the value when uploading the UDF function.

In a simple case, I upload only the DEFINE INIT function and initialized the problem, the value is not getting the true value.
#include "udf.h"

#define M 0.25
#define RHO 1600
#define E 0.4
#define Tref 300
#define Tin 300


int last_timestep = -1;

DEFINE_INIT(initial_humidity, d)
{
real Tabs, w, a, b, C, Pvs, RH;
Thread *t;
cell_t c;

thread_loop_c(t, d)
{
begin_c_loop(c, t)
{
C_T(c, t) = Tin;

Tabs = C_T(c, t);

Pvs = 0.1 * exp(27.0214 - (6887 / Tabs) - (5.31 * log(Tabs / 273.16))); /* Eq(25) */
b = 2.667e-7 * pow((1 - (Tabs / 641.7)), -23.438);
C = 1 / (4e5 * pow(Tabs, -2.1166));
a = b * pow(1000 * M, 1 / C);
RH = 1 - exp(-a / Tabs); /* Eq (15) */

if (RH > 0.99)
{
RH = 0.99;
}

w = (Pvs * RH * 0.62189) / (101.3 - Pvs * RH); /* Eq (26) */

}
end_c_loop(c, t)
Message ("realative humidity:%f\n", w);
Message ("Pv:%f\n", Pvs);
Message ("RH:%f\n", RH);
}
}

================================================== ============================
Error is coming, and the value getting Zero at the initial condition
initial_humidity
Done.
realative humidity:0.000000
Pv:0.000000
RH:0.000000

================================================== ============================

Node 10: Process 22992: Received signal SIGSEGV.

thedal July 30, 2023 06:13

Which variable are you trying to initialize here?

You are initializing temperature as Tin and calling C_T again to calculate some function. Why?

thedal July 30, 2023 06:20

Also try
begin_c_loop_all(c, t) instead and check what happens.
DEFINE_INIT is executed only once during initialization.

thedal July 30, 2023 06:32

I think the formulation is correct. only problem could be with the begin_c_loop(c, t)

Chhotelal1234 July 30, 2023 07:46

I want to initialize the relative humidity value here. I do the same thing to replace by begin_c_loop_all(c, t) but the same error is coming
relative humidity:0.000000
Pv:0.000000
RH:0.000000

================================================== ============================

Node 5: Process 27536: Received signal SIGSEGV.

= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= RANK 10 PID 21372 RUNNING AT DESKTOP-MGARH2C
= EXIT STATUS: -1 (ffffffff)
================================================== =================================
The fl process could not be started.

Chhotelal1234 July 30, 2023 08:19

This may occur by not defining the allocating memory. it might be right.


All times are GMT -4. The time now is 01:16.