CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   This UDF code was not working :( (https://www.cfd-online.com/Forums/fluent/243546-udf-code-not-working.html)

Sumin Lee June 24, 2022 08:57

This UDF code was not working :(
 
Dear Mr. / Ms.,

I made a code for UDF. My purpose was to simulate the opening and closing of the butterfly valve in the pipe in 3D. But The code was not working. Even in fluent, the code is loaded as UDF in fluent.

There is the code below.

#include "udf.h"
#include "math.h"
#include "dynamesh_tools.h"

DEFINE_CG_MOTION(motion, dt, vel, omega, time, dtime)
{
real u = 5.0;
real a = 1.0;
real t1 = u/a;
real t2 = t1 +0.1;
real t3 = t2 +t1;
real angular;

if ( time < t1) {
angular = -0;
omega[1]= angular;
}
else if ( (time > t1) && (time <=t2)) {
angular = -900;
omega[1]= angular;
}
else if ( (time > t2) && (time <=t3)) {
angular = -0;
omega[1]= angular;
}
else {
angular = -0;
omega[1]= angular;
}
NV_S (omega, =, 0.0);
}

I want to that the butterfly valve stays open for 5 seconds, closes in 0.1 seconds, and stays closed for 5 seconds.

AlexanderZ June 30, 2022 00:24

remove last line
Code:

NV_S (omega, =, 0.0);

Sumin Lee June 30, 2022 07:18

I'm sorry, the way you told me didn't solve the problem.


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