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

UDF code to add the resistance to the Wind Turbine ?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 15, 2020, 09:47
Default UDF code to add the resistance to the Wind Turbine ?
  #1
New Member
 
YUNUS CELIK
Join Date: May 2017
Posts: 8
Rep Power: 8
ynsclk23 is on a distinguished road
Hello everyone,
I am working on the vertical axis wind turbine in ANSYS Fluent. My aim is to monitor the turbine rotational acceleration from rest by considering the inertia of the turbine. I used simple 6DOF to do it (it works fine). However, I need to consider the resistance torque to observe its effect on the turbine acceleration. Therefore, I have created a UDF to do this, but it is giving the error while interpreting it to the fluent. Any idea to deal with will be appreciated. Thanks in advance.
Best regards,
Yunus




#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.03; /Moment Inertia of the Turbin/
real delta_t=0.000727221; /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= 3*(moment[0]-(moment[0]*0.1))/Jt; /there are 3 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)
}
ynsclk23 is offline   Reply With Quote

Old   May 15, 2020, 09:51
Default Interpretatoin
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Interpreter cannot handle structures and references, as well as Message command. Either use Compiled UDF or use profile file.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 15, 2020, 10:11
Default
  #3
New Member
 
YUNUS CELIK
Join Date: May 2017
Posts: 8
Rep Power: 8
ynsclk23 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Interpreter cannot handle structures and references, as well as Message command. Either use Compiled UDF or use profile file.


Dear Vinerm,

As you suggested I have complied the UDF. However, still gives an error like "line 14: parse error."
I do not know to sort it out.

Thanks you
ynsclk23 is offline   Reply With Quote

Old   May 15, 2020, 10:17
Default Argument
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
That''s because you are using CURRENT_TIME as argument to a function. This is a macro define inside Fluent and cannot be used as a variable. Use some generic name, say, stime, _time, etc.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 15, 2020, 10:20
Default
  #5
New Member
 
YUNUS CELIK
Join Date: May 2017
Posts: 8
Rep Power: 8
ynsclk23 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
That''s because you are using CURRENT_TIME as argument to a function. This is a macro define inside Fluent and cannot be used as a variable. Use some generic name, say, stime, _time, etc.

Dear Vinerm,

Thank you for your valuable comment. If you have time could you modify the UDF code, which is above, for 2D turbine case for me? I am quite new with the UDF codding. I will appreciate your efforts on this.

Best regards,
Yunus
ynsclk23 is offline   Reply With Quote

Old   May 15, 2020, 10:34
Default Torque
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Why do you want to use a UDF? You can just apply an expression or profile or a constant value.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 15, 2020, 10:42
Default
  #7
New Member
 
YUNUS CELIK
Join Date: May 2017
Posts: 8
Rep Power: 8
ynsclk23 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Why do you want to use a UDF? You can just apply an expression or profile or a constant value.

Hi Vinerm,

I tried to use an expression but I was not able to do this before running the simulation in Fluent. All I need is to give some loss in the torque (for example 10% loss in aerodynamic torque), and calculate the turbine rotational acceleration with this reduced torque.

Best reagrds,
Yunus
ynsclk23 is offline   Reply With Quote

Old   May 15, 2020, 10:49
Default Code Changes
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Multiple changes are required in the code. Here is modified DEFINE_ON_DEMAND code. You can execute this one to print moment values and then use that information to determine how much torque you want to apply.

Domain *domain = Get_Domain (1);
Thread *t;
real CG[ND_ND], force[ND_ND], moment[ND_ND];
t = Lookup_Thread(domain, 13);
NV_S (CG, =, 0.0);
Compute_Force_And_Moment(domain, t, CG, force, moment, TRUE);
Message("f=(%f, %f)\t m=(%f, %f)\n", force[0], force[1], moment[0], moment[1]);
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 15, 2020, 10:51
Default
  #9
New Member
 
YUNUS CELIK
Join Date: May 2017
Posts: 8
Rep Power: 8
ynsclk23 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Multiple changes are required in the code. Here is modified DEFINE_ON_DEMAND code. You can execute this one to print moment values and then use that information to determine how much torque you want to apply.

Domain *domain = Get_Domain (1);
Thread *t;
real CG[ND_ND], force[ND_ND], moment[ND_ND];
t = Lookup_Thread(domain, 13);
NV_S (CG, =, 0.0);
Compute_Force_And_Moment(domain, t, CG, force, moment, TRUE);
Message("f=(%f, %f)\t m=(%f, %f)\n", force[0], force[1], moment[0], moment[1]);


Dear Vinerm,

I really appreciated your efforts. I will try and let you know.

Best regards,
Yunus
ynsclk23 is offline   Reply With Quote

Old   May 15, 2020, 11:10
Default
  #10
New Member
 
YUNUS CELIK
Join Date: May 2017
Posts: 8
Rep Power: 8
ynsclk23 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Multiple changes are required in the code. Here is modified DEFINE_ON_DEMAND code. You can execute this one to print moment values and then use that information to determine how much torque you want to apply.

Domain *domain = Get_Domain (1);
Thread *t;
real CG[ND_ND], force[ND_ND], moment[ND_ND];
t = Lookup_Thread(domain, 13);
NV_S (CG, =, 0.0);
Compute_Force_And_Moment(domain, t, CG, force, moment, TRUE);
Message("f=(%f, %f)\t m=(%f, %f)\n", force[0], force[1], moment[0], moment[1]);

Hi Vinerm,

I tried only the this part in the UDF, but while Compiling it gives this error " 'nmake' is not recognized as an internal or external command, operable program or batch file."

that is the part I try to compile
#include "udf.h"



DEFINE_ON_DEMAND(wall_forces)
{

Domain *domain = Get_Domain (1);
Thread *t;
real CG[ND_ND], force[ND_ND], moment[ND_ND];
t = Lookup_Thread(domain, 13);
NV_S (CG, =, 0.0);
Compute_Force_And_Moment(domain, t, CG, force, moment, TRUE);
Message("f=(%f, %f)\t m=(%f, %f)\n", force[0], force[1], moment[0], moment[1]);
}
ynsclk23 is offline   Reply With Quote

Old   May 15, 2020, 12:41
Default nmake
  #11
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Compilation requires compiler, MS VC++ for Windows, to be installed. Then Fluent must be started from developer command prompt.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply


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
Error code: 126 when loading parallel UDF Coop Fluent UDF and Scheme Programming 0 July 13, 2018 08:33
Wind Turbine - Rotation of the Baldes moonomid CFX 32 March 18, 2016 19:34
Ducted wind turbine (BC for the shroud) Pepita CFX 4 June 29, 2013 07:09
State of the Art in CFD for wind turbine modeling SET_WIND Main CFD Forum 0 October 9, 2012 06:01
FSI - Wind Turbine AUN CFX 13 August 29, 2012 16:44


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