CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   How to define unsteady term in scaler function? (http://www.cfd-online.com/Forums/fluent/28620-how-define-unsteady-term-scaler-function.html)

olivia June 19, 2001 12:04

How to define unsteady term in scaler function?
 
Hi: I want to define unsteady term in scaler function . But it have some error message in line 6 message is UDS:undeclared variable.

Can anyone know how to solve this problem? Thanks!!

#include "udf.h"

DEFINE_SOURCE(usr_ensource, cell, thread, ds, eqn) {

real lg,l,unst;UDS

unst = DEFINE_UDS_UNSTEADY(c, t, i);

l = 2440.0;

lg = l * ( 1.0 + 8.31 * exp(-1.0 * 0.436 * C_UDSI(c,t,i) ) );

source = 1.0 / 0.5 * unst * lg;

return source; }


Lanre June 19, 2001 15:38

Re: How to define unsteady term in scaler function
 
First, a C error: Instead of: real lg,l,unst;UDS

Try: real lg,l,unst;

Second, your UDF needs to define the two parts of the unsteady term for the UDS: one for the central coefficient and the other for the source term (See Section 2.5.13 of the UDF Guide).

Your UDF for the unsteady term of your UDS should be:

#include "udf.h"

#define rho 1000

DEFINE_UDS_UNSTEADY(uds_unsteady, cell, thread, i, apu, su)

{

real time_step, vol, rho, phi_old, phi_curr;

time_step= RP_Get_Real("physical-time-step");

vol = C_VOLUME(cell,thread);

*apu = -rho*vol/time_step; /*central coefficient part*/

phi_old = C_STORAGE_R(cell,thread,SV_UDSI_M1(i));

phi_curr = C_UDSI(cell,thread,i);

*su = rho*vol*phi_old/time_step; /*source term part*/

}


olivia June 20, 2001 08:26

Re: How to define unsteady term in scaler function
 
Thanks Lanre.
I wrote the following code, but it still have some errors, Could you help me again , Thank you very much!!

My error messages are :

Error: test11.c: line 29: parse error.
Error: test11.c: line 31: invalid lvalue in assignment.

My code is as following :

#include "udf.h"
#include "math.h"
#define rho 1000
#define l 2440.0
DEFINE_UDS_UNSTEADY(uds_unsteady, cell, thread, i, apu, su)

{
/* rho, */
float time_step, vol, phi_old, phi_curr;

time_step= RP_Get_Real("physical-time-step");

vol = C_VOLUME(cell,thread);

*apu = -rho*vol/time_step; /*central coefficient part*/

phi_old = C_STORAGE_R(cell,thread,SV_UDSI_M1(i));

phi_curr = C_UDSI(cell,thread,i);

*su = rho*vol*phi_old/time_step; /*source term part*/

}

DEFINE_SOURCE(usr_ensource, cell, thread, ds, eqn)
{
real uscl, source;
void unst, lg;
unst = DEFINE_UDS_UNSTEADY(uds_unsteady, cell, thread, eqn, apu, su);
uscl = C_UDSI(cell,thread,eqn);
lg = l * ( 1.0 + 8.31 * exp(-1.0 * 0.436 *uscl) );
source = 1.0 / 0.5 * unst * lg;
return source;
}

Lanre June 20, 2001 10:54

Re: How to define unsteady term in scaler function
 
I neglected to mention you have to implement the UDF as a compiled UDF.

The function takes your relation to modify the time-derivative term and applies it through the unsteady UDS term macro:

#include "udf.h" #include "math.h" #define rho 1000 #define l 2440.0 DEFINE_UDS_UNSTEADY(uds_unsteady, cell, thread, i, apu, su)

{

float time_step, vol, phi_old, phi_curr, lg, uscl,el;

float A;

time_step= RP_Get_Real("physical-time-step");

vol = C_VOLUME(cell,thread);

el = 1.0;

uscl = C_UDSI(cell,thread,i);

lg = el * ( 1.0 + 8.31 * exp(-1.0 * 0.436 *uscl) );

A = 1.0/0.5*lg;

*apu = -rho*vol/time_step * A; /*central coefficient part*/

phi_old = C_STORAGE_R(cell,thread,SV_UDSI_M1(i));

/*phi_curr = C_UDSI(cell,thread,i);*/

*su = rho*vol*phi_old/time_step * A; /*source term part*/

}


vsmkrm298 October 29, 2012 23:15

Hi everyone,
I am trying to solve the Navier-Stokes equations and Continuity equation for low reynolds number flow, so i just need to neglect the advection term in Navier stokes equation, is this possible in fluent? If yes, please tell me how.

fariba.j December 3, 2012 15:40

source term for uds
 
Hi, I want to write a source tem by udf for uds,. my scalar is concentration and my source term includes concentration(uds), but i don't know how i define variable of this equation in udf! in my udf, i wrote "user scalar 0" instead of my variable , but fluent gave me an error
for example my scalar is concentratin(C), and my source term is: kC^2


All times are GMT -4. The time now is 08:21.