CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Unsteady udf, velocity step (http://www.cfd-online.com/Forums/fluent/36267-unsteady-udf-velocity-step.html)

CJ April 5, 2005 04:02

Unsteady udf, velocity step
 
Is it possible to write a unsteady udf such that:

t<2 velocity=20

t>2 velocity=30

I have used this sinusoidal function previously (below), but would like to have a simple step change as above

DEFINE_PROFILE(unsteady_velocity, thread, position) {

face_t f;

begin_f_loop(f, thread)

{

real t = RP_Get_Real("flow-time");

F_PROFILE(f, thread, position) = 25. + 5.0*sin(10.*t);

}

end_f_loop(f, thread) }

CJ April 5, 2005 09:36

Re: Unsteady udf, velocity step, more help pls!
 
I have this error: cpp -IC:\FLUENT.INC\fluent6.0/src -IC:\FLUENT.INC\fluent6.0/cortex/src -IC:\FLUENT.INC\fluent6.0/client/src -IC:\FLUENT.INC\fluent6.0/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" time.cError: time.c: line 13: parse error.

with this program:

#include "udf.h"

DEFINE_PROFILE(unsteady, thread, position) {

face_t f;

begin_f_loop(f, thread)

{

real t = RP_Get_Real("flow-time");

if (t < 2)

F_PROFILE(f, thread, position) = 50

else

F_PROFILE(f, thread, position) = 20

}

end_f_loop(f, thread) }

can anyone please help and point out any obvious mistakes, or if this is even possible?

swarup April 5, 2005 10:23

Re: Unsteady udf, velocity step, more help pls!
 
CJ, Try this. This will work.

DEFINE_PROFILE(unsteady_pressure,thread,position) {

face_t f; real t=CURRENT_TIME;

begin_f_loop(f,thread)

{

if(t<2)

F_PROFILE(f,thread,position)=50.0;

else

F_PROFILE(f,thread,position)=20.0; }

end_f_loop(f,thread)

}

CJ April 5, 2005 16:23

Re: Unsteady udf, velocity step, more help pls!
 
Thankyou for your help, and it certainly seems to be closer, but i now get this error:

cpp -IC:\FLUENT.INC\fluent6.0/src -IC:\FLUENT.INC\fluent6.0/cortex/src -IC:\FLUENT.INC\fluent6.0/client/src -IC:\FLUENT.INC\fluent6.0/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" time3.cError: time3.c: line 6: CURRENT_TIME: undeclared variable

i have tried numerous ways to sort it but none seem to work. any more advice please?

CJ April 5, 2005 16:26

Re: Unsteady udf, velocity step, more help pls!
 
Sorry, this is what generated the error:

#include "udf.h"

DEFINE_PROFILE(unsteady_pressure, thread, position) {

face_t f;

real t = current_time;

begin_f_loop(f, thread)

{

if(t<2)

F_PROFILE(f, thread, position) = 50.0;

else

F_PROFILE(f, thread, position) = 20.0;

}

end_f_loop(f, thread) }

swarup April 6, 2005 10:14

Re: Unsteady udf, velocity step, more help pls!
 
CJ,

i have tried this UDF earlier in connexion with unsteady pressure. that's why the UDF name is unsteady_pressure. we have to use CURRENT_TIME and not current_time. hope this will resolve.

Swarup.

CJ April 7, 2005 03:51

Re: Unsteady udf, velocity step, more help pls!
 
It just says this instead:

cpp -IC:\FLUENT.INC\fluent6.0/src -IC:\FLUENT.INC\fluent6.0/cortex/src -IC:\FLUENT.INC\fluent6.0/client/src -IC:\FLUENT.INC\fluent6.0/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" time3.cError: time3.c: line 6: CURRENT_TIME: undeclared variable

Im not sure of the problem if yours works but mine does not. Different versions of Fluent (I have 6.0)?

Luca April 7, 2005 04:44

Re: Unsteady udf, velocity step, more help pls!
 
CURRENT_TIME is not avaiable in Fluent 6.0. Try with RP_Get_Real("flow-time").

ram April 7, 2005 11:08

Re: Unsteady udf, velocity step
 

CJ April 8, 2005 03:15

Re: Unsteady udf, velocity step, more help pls!
 
At last, it works! Thanks everyone.

pUl| April 8, 2005 04:20

Re: Unsteady udf, velocity step, more help pls!
 
Sounds good, However, one word of caution for others who may be writing udfs to incorporate models. Just because a UDF compiles fine and fluent seems to have no problems accomodating it, one should not assume that the UDF is correct. The best way to confirm is to test and check whether the UDF is really doing what you want it to do.

For instance, if you are writing a custom drag model, start by trying to write the schiller-naumann law in a UDF (which is already implemented in fluent) so that you can compare the results and check for yourself.

All the Best!

Best Regards,

Srinath Madhavan


All times are GMT -4. The time now is 09:37.