CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Importing the calculated torque into my UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 18, 2017, 11:40
Question Importing the calculated torque into my UDF
  #1
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
Hallo,

I'm quite new and still learning this program. I'm trying to simulate a hydrodynamic coupling. It consists of two part, Pump side and Turbine side (A screenshoot of the model is available). The rotational velocity of the pump side is constant. The rotational velocity of the turbine side is changing in respect of time and depends on the value of the working torque (from the fluid to the turbine's blade).

I've made a plane on my turbine's geometry and the working torque (Moment) on the turbine can displyed using 'monitors' and 'reports'.

And now I'm going to use this value, so the turbine's rotational velocity can change in respect of time.

1. How can I Import this value into my UDF? Which variable are used in this case?
2. While I was trying to Interpret my UDF File, this warning came 'line 23: structure reference not implemented'. Can someone Show/tell me the mistakes?
3. Will this UDF executed in every iteration? Or will it just be executed once? I dont know if i should write the looping in the UDF or not.

Here is my UDF File.

************************************************** *********
#include "udf.h"
#define Niter 25 /* iteration update interval */
#define omg_ts 0.0 /* starting omega */
#define omg_tf 600.0 /* final omega */
#define Jt 0.000554 /* Moment Inertia of the Turbin*/

DEFINE_ADJUST(testudf,d)
{
int zoneID;
int iter = (nres==0)?(1):((int)count2[nres-1]);
float omgt;
Thread *tc;
zoneID = 2;
tc = Lookup_Thread(domain,zoneID);
if ( (iter%Niter)==0 )
{
del_omgt = Mt/Jt;
omgt = omg_ts + del_omgt*(iter/Niter);
if ( omgt > omg_tf ) omgt = omg_tf;
THREAD_VAR(tc).fluid.omega = omgt;
}
}

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

I'm new and therefore I really appreciate any Reply and any help. Thanks in advance.

Best regards,
Darma Yuda
Attached Images
File Type: png mesh3.PNG (114.0 KB, 11 views)

Last edited by sdarmayuda; October 19, 2017 at 04:58. Reason: Additional Question
sdarmayuda is offline   Reply With Quote

Old   November 3, 2017, 09:40
Default
  #2
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
Hallo,

I have adjusted my code again. I think it should be better than the last one.

********************************
#include "udf.h"
DEFINE_ADJUST(testudf,d)
{
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; /*time step simulation*/
real alpha_t; /*angular acceleration, delta t*/
Thread *t;
cell_t c;
t=Lookup_Thread(d,9); /*Zone ID = 9*/
begin_c_loop (c,t)
{
alpha_t= Mt/Jt; /*M = J*alpha, but how can I retrieve the value of Mt?*/
omega_ts+=alpha_t*delta_t;
if (omega_ts > omega_tf)
{omega_ts = omega_tf;}
THREAD_VAR(t).fluid.omega=omega_ts; /*I'm not sure if this Syntax correct*/
}
end_c_loop (c,t)
}
*********************************

1. In this case I'm using cell loop. Is that correct?

2. How should I retrieve the calculated torque Mt and input to my UDF Code? In your case, you have F_Flux(f,t). But I can't find a way to retrieve the torque working on the body. Is there a list of variable for the Fluent Parameter (like rotational velocity and torque) ? Because I can only find a cell and face variable.

I would really appreciate any help and tipps. Thanks in advance.

Best regards,
Darma Yuda
sdarmayuda is offline   Reply With Quote

Old   November 22, 2017, 13:23
Default
  #3
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
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)
}
sdarmayuda is offline   Reply With Quote

Reply

Tags
hydrodynamic coupling, udf, velocity


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replicating Scalable Wall Function with a UDF yousefaz FLUENT 0 August 4, 2017 03:30
Torque calculation of film cooled blades Inkyom CFX 0 March 6, 2017 22:18
Rotor Torque Prediction jason OpenFOAM Running, Solving & CFD 7 August 16, 2016 10:34
Why air’s torque is negative and water’s torque is positive? Jackzm CFX 3 December 16, 2015 17:27
Calculated torque to low Adam S CFX 3 September 6, 2010 08:34


All times are GMT -4. The time now is 16:04.