Ansys Learning Forum Forums Discuss Simulation Fluids Importing the working torque into UDF Reply To: Importing the working torque into UDF

sdarmayuda
Subscriber

Hallo everyone,


I have found how to retrieve the torque from Fluent. However, there is still error in the code after I intepreted the UDF code. it says "line 14: parse error". I think it is about the macro DEFINE_TRANSIENT_PROFILE. Can somebody help to show me the mistakes about this macro? Thank you very much.


Here is my UDF Code:


**************************************************************************


#include "udf.h"


DEFINE_ON_DEMAND(wall_forces) 


{ 


Domain * domain = Get_Domain (1); /* For multiphase flow, you need to set the Sub domain */ 


Thread *t; 


real CG[3], force[3], moment[3]; 


t = Lookup_Thread (domain, 13); /* 13 is the ID of the wall to be determined. */ 


NV_S (CG, =, 0.0); /* coordinates of the center position to find the moment. */ 


Compute_Force_And_Moment (domain, t, CG, force, moment, TRUE); 


Message("f=(%e, %e, %e), m=(%e, %e, %e)n", force[0], force[1], force[2], moment[0], moment[1], moment[2]); 


/* force [0], force [1], force [2] are respectively x, y, z-direction forces, Is the sum of the force by the force and the shear stress due to pressure. */ 


}


 


DEFINE_TRANSIENT_PROFILE(testudf, CURRENT_TIME)


{


real omega_ts=0.0; /*starting omega*/


real omega_tf=600.0; /*final omega*/


real Jt=0.000554; /*Moment Inertia of the Turbin*/


real delta_t=0.0001; /*delta t simulation*/


real CURRENT_TIMESTEP;


real CURRENT_TIME;


real alpha_t; /*angular acceleration*/


Thread *t;


cell_t c;


t=Lookup_Thread(domain,9); /*Cell Zone ID = 9*/


 


begin_c_loop (c,t)


{


alpha_t= 15*moment[0]/Jt; /*there are 15 blades, x axis as rotation axis*/


omega_ts+=alpha_t*CURRENT_TIMESTEP;


 


if (omega_ts > omega_tf)


{omega_ts = omega_tf;}


 


THREAD_VAR(t).fluid.omega=omega_ts;


}


end_c_loop (c,t)


 


}