CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   unsteady inlet velocity udf (https://www.cfd-online.com/Forums/fluent/35223-unsteady-inlet-velocity-udf.html)

jill December 4, 2004 08:15

unsteady inlet velocity udf
 
The udf i am using for my inlet is similar to that of the "unsteady flow in a tube" example from the user's guide. I am modeling a "T" intersection where there are two inlets with different velocity profiles. i have created two udf's and they both compile using the interpreted udf. the problem that i encounter is when i try to set up the bc's. it seems as though i am not able to use both udf's at the same time (one for inlet A and the other for inlet B). If I compile the udf for inlet A and set up the bc everything works fine but then if i try to compile the udf for inlet B I get, "Error: chip exec: function XXX not found". If i try to compile both of them and then set the bc's only the later of the two are in the pulldowns. Can anyone help me? Thank you.

jill

Luca December 4, 2004 08:47

Re: unsteady inlet velocity udf
 
Maybe I have misunderstood but I think you should compile your 2 UDFs in a single file. So put your code in 1 file and compile it. Then you can hook both of them.Luca

jill December 4, 2004 08:55

Re: unsteady inlet velocity udf
 
No you didn't misunderstand....your response makes a lot of sense and it works now. Thank you very much.

Luca December 4, 2004 08:56

Re: unsteady inlet velocity udf
 
you're welcome. Luca

Momo38 February 9, 2015 06:22

Hi. I am not very good at programming. Like the case above was solved by combining the two program in one file. But I do not know how to combine it in one file. Here is my 2 program files,

#include "udf.h"
#define T_HOT 306.0
#define T_COLD 300.0
#define KTC_HOT 0.66 /* High thermal conductivity when hot */
#define KTC_COLD 0.64 /* Low thermal conductivity when cold */

DEFINE_PROPERTY(fmwcnt_thermal_conductivity, c, ct)
{
real temp, ktc_turbulent;

temp = C_T(c,ct);

if (temp == T_HOT)
ktc_turbulent = KTC_HOT;

else if (temp == T_COLD)
ktc_turbulent = KTC_COLD;

else
ktc_turbulent = KTC_COLD + (temp - T_COLD)*
(KTC_HOT - KTC_COLD)/(T_HOT - T_COLD);

return ktc_turbulent;
}


Here is the second program,
#include "udf.h"
#define T_HOT 306.0
#define T_COLD 300.0
#define MU_HOT 7.81e-4 /* Low viscosity when hot */
#define MU_COLD 8.81e-4 /* High viscosity when cold */

DEFINE_PROPERTY(fmwcnt_viscosity, c, ct)
{
real temp, mu_turbulent;

temp = C_T(c,ct);

if (temp == T_HOT)
mu_turbulent = MU_HOT;

else if (temp == T_COLD)
mu_turbulent = MU_COLD;

else
mu_turbulent = MU_COLD + (temp - T_COLD)*
(MU_HOT - MU_COLD)/(T_HOT - T_COLD);

return mu_turbulent;
}



Thanks

CeesH February 9, 2015 08:13

Hi,

Basically combining it in one file just means
- 1 set of headers and define functions
- 2 functions put in the body.

So for you that would give:

Code:

#include "udf.h"
#define T_HOT 306.0
#define T_COLD 300.0
#define KTC_HOT 0.66 /* High thermal conductivity when hot */
#define KTC_COLD 0.64 /* Low thermal conductivity when cold */
#define MU_HOT 7.81e-4 /* Low viscosity when hot */
#define MU_COLD 8.81e-4 /* High viscosity when cold */

DEFINE_PROPERTY(fmwcnt_thermal_conductivity, c, ct)
{
real temp, ktc_turbulent;

temp = C_T(c,ct);

if (temp == T_HOT)
ktc_turbulent = KTC_HOT;

else if (temp == T_COLD)
ktc_turbulent = KTC_COLD;

else
ktc_turbulent = KTC_COLD + (temp - T_COLD)*
(KTC_HOT - KTC_COLD)/(T_HOT - T_COLD);

return ktc_turbulent;
}

DEFINE_PROPERTY(fmwcnt_viscosity, c, ct)
{
real temp, mu_turbulent;

temp = C_T(c,ct);

if (temp == T_HOT)
mu_turbulent = MU_HOT;

else if (temp == T_COLD)
mu_turbulent = MU_COLD;

else
mu_turbulent = MU_COLD + (temp - T_COLD)*
(MU_HOT - MU_COLD)/(T_HOT - T_COLD);

return mu_turbulent;
}

Then, save this whole thing under one name and compile in FLUENT. FLUENT will recognize it's actually 2 different UDFs.

ghost82 February 9, 2015 08:16

Hi,
simply put them in one files, and do not duplicate headers files (.h) and global variables:

Code:

#include "udf.h"
#define T_HOT 306.0
#define T_COLD 300.0
#define KTC_HOT 0.66 /* High thermal conductivity when hot */
#define KTC_COLD 0.64 /* Low thermal conductivity when cold */
#define MU_HOT 7.81e-4 /* Low viscosity when hot */
#define MU_COLD 8.81e-4 /* High viscosity when cold */

DEFINE_PROPERTY(fmwcnt_thermal_conductivity, c, ct)
{
real temp, ktc_turbulent;

temp = C_T(c,ct);

if (temp == T_HOT)
  ktc_turbulent = KTC_HOT;

else if (temp == T_COLD)
  ktc_turbulent = KTC_COLD;

else
  ktc_turbulent = KTC_COLD + (temp - T_COLD)*(KTC_HOT - KTC_COLD)/(T_HOT - T_COLD);

return ktc_turbulent;
}


DEFINE_PROPERTY(fmwcnt_viscosity, c, ct)
{
real temp, mu_turbulent;

temp = C_T(c,ct);

if (temp == T_HOT)
  mu_turbulent = MU_HOT;

else if (temp == T_COLD)
  mu_turbulent = MU_COLD;

else
  mu_turbulent = MU_COLD + (temp - T_COLD)*(MU_HOT - MU_COLD)/(T_HOT - T_COLD);

return mu_turbulent;
}

Hihi too late :D

Momo38 February 10, 2015 02:47

Thanks CeesH and ghost82. The UDF can run by interpreted and it gives what I want. But I cant compiled due to the path error. Izzit compulsory to compiled it?

Thanks

ghost82 February 10, 2015 06:04

It is not mandatory to compile this udf. You can interpret it without problems.


All times are GMT -4. The time now is 19:52.