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

Using output parameter as input parameter within the same simulation

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By MKuhn

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2017, 00:35
Smile Using output parameter as input parameter within the same simulation
  #1
New Member
 
Join Date: Aug 2016
Posts: 14
Rep Power: 10
jjfm20 is on a distinguished road
Hello guys,

Hope you're well, I need to use the mass-average-weighted total temperature of an outlet as the backflow temperature input of the same outlet, I guess is kinda an iterative process but I don't have any clue of how to do so... Hope you can help me with steps or something like that.

Regards.
jjfm20 is offline   Reply With Quote

Old   October 27, 2017, 10:31
Default
  #2
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
Hi,

I'm also facing a similar problem. I need to calculate the new rotational velocity based on the torque given from the last iteration. Have you found the solution? I'll be very grateful if you can share it here. Thanks.

Best regards,
Darma Yuda
sdarmayuda is offline   Reply With Quote

Old   October 27, 2017, 18:55
Default
  #3
New Member
 
Join Date: Aug 2016
Posts: 14
Rep Power: 10
jjfm20 is on a distinguished road
Hi Darma Yuda,

I did solved it but it needed a UDF for the iterative part, you should check this possibility.

Regards.
jjfm20 is offline   Reply With Quote

Old   October 30, 2017, 06:21
Default
  #4
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
Hi jjfm20,

Thanks for your reply. I see. Right now, I'm trying to simulate the fluid coupling which consist of pump and turbine side. The pump's rotational velocity is set to constant for now. And the turbine side should rotate because the torque from the fluid. (This torque will accelerate the turbine side). I have tried to write an UDF for this case but the udf is not right yet.

**********************************************
#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 delta_t 0.001 /* Delta-t Simulation */

DEFINE_ADJUST(testudf,domain)
{
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 )
{
Mt = 15*parameter-1; /*The moment was calculated per blade, There is 15 blade*/
del_omgt = Mt/Jt;
omgt = omg_ts + del_omg*(iter/Niter);
if ( omgt > omg_tf ) omgt = omg_tf;
THREAD_VAR(tc).fluid.omega = omgt;
}
}
******************************************

1. Do you mind pointing my mistakes from my UDF-code out? Or if you still have your UDF, do you mind sharing it?
2. Just to make sure, so will our UDF only be read by Fluent once at the beggining of the calculation? I thought at first that, this UDF will be read at every iteration.
I really appreciate your help. Thanks for your help once again.

Best regards,
Darma Yuda

Last edited by sdarmayuda; November 2, 2017 at 09:42. Reason: UDF code
sdarmayuda is offline   Reply With Quote

Old   October 30, 2017, 21:36
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Your UDF does nothing. You do not use any flow variable inside the code.
To see, if the UDF is hooked by fluent you may use Message functions.

Best regards.
AlexanderZ is offline   Reply With Quote

Old   October 31, 2017, 12:31
Default
  #6
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
Hi AlexanderZ,

Thanks for the reply. Can you give me some more tipps or referenz regarding this flow variable? http://jullio.pe.kr/fluent6.1/help/html/udf/node108.htm I should find the variable for the rotational velocity right? I can only find the velocity in u,v, w direction.

Actually I also am trying to input the torque resulted by the fluid into code, by i don't know how I could obtain the variable? Should I use the tool "Output Parameter" and create a new parameter? Or does Fluent already have a certain variable for this measurement? I'd be very grateful if you can give me some tipps. Thanks you very much once again.

Best regards,
Darma Yuda
sdarmayuda is offline   Reply With Quote

Old   November 2, 2017, 10:17
Default It works only with a UDF
  #7
Senior Member
 
Moritz Kuhn
Join Date: Apr 2010
Location: Germany, Dresden
Posts: 218
Rep Power: 17
MKuhn is on a distinguished road
Using calculated values from a outlet boundary in a inlet boundary works only with an UDF. The tool "output parameter" does'nt help.
This UDF calculateds first an average temperature at the boundary with the ID 24, which is the input for the calculation of the temperature for an inlet stream.

#include "udf.h"
DEFINE_PROFILE(calc_inlet_temp,thread,nv)
{
Domain *d;

real temp=0.;
real flux=0.;
real temp_in;
real temp_in_min = 183;

face_t f;
Thread *t;
d = Get_Domain(1);
t= Lookup_Thread(d, 24);

begin_f_loop(f,t)
{
flux+=F_FLUX(f,t);
temp+=F_T(f,t)*F_FLUX(f,t);
}
end_f_loop(f,t)

temp=temp/flux;

temp_in=2.0573E-5*temp*temp*temp-1.4976E-2*temp*temp+3.8548*temp-150.22;

if (temp_in < temp_in_min){temp_in=temp_in_min;}

begin_f_loop(f,thread)
{
F_PROFILE(f, thread, nv) = temp_in;
}
end_f_loop(f,thread)
flux=0.;
}
sdarmayuda likes this.
MKuhn is offline   Reply With Quote

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

Thank you very much for your help. I have adjusted my UDF Code to yours.

********************************
#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. I think I should use cell loop instead of face loop, because it is about rotational velocity of the Body. Is that correct?

2. If the tool "Output Parameter" doesn't help, 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.

3. So will this UDF Code be read/executed only once? Or will it be read every time step? I'm using delta_t= time step of my simulation. I assume that Fluent will read the part of my code from "begin_c_loop ..." until "end_c_loop(c,t)" at every time step. But I'm not so sure about that.


Thanks once again for your help and your code.

Best regards,
Darma Yuda
sdarmayuda is offline   Reply With Quote

Old   November 2, 2017, 16:36
Default
  #9
Senior Member
 
Moritz Kuhn
Join Date: Apr 2010
Location: Germany, Dresden
Posts: 218
Rep Power: 17
MKuhn is on a distinguished road
Hello sdarmayuda

Sorry but I'm not an expert in UDF, I just adopted an existing UDF to my case. Concerning your questions:
1. Just try cell loop instead of face loop
2. No idea, maybe an UDF expert knows where a list with all available variables exists.
3. The UDF will be read every time step

Moritz
MKuhn is offline   Reply With Quote

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

I see. Thank you very much for your help. I'll try to ask in Fluent UDF and Scheme Programming then.

Best regards,
Darma Yuda
sdarmayuda is offline   Reply With Quote

Old   November 5, 2017, 21:27
Default
  #11
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Use ANSYS Fluent Customization Manual to find build-in macros (you call them variables) that are avaliable in fluent.

Instead of DEFINE_ADJUST function I'm suggesting you use DEFINE_PROFILE or even 2.3.41.DEFINE_TRANSIENT_PROFILE.

DEFINE_PROFILE is the common tool to modify boundary conditions in Fluent.

Best regards,
AlexanderZ is offline   Reply With Quote

Old   November 6, 2017, 09:53
Default
  #12
New Member
 
Darma Yuda
Join Date: Sep 2017
Location: Germany
Posts: 18
Rep Power: 9
sdarmayuda is on a distinguished road
Hi AlexanderZ,

Thank you for your reply. I'm following your suggestion and change my UDF to DEFINE_TRANSIENT_PROFILE. But I still can't find the macro that let me use the calculated torque. I'm using Fluent 17.2 Academic. (I'm using the built in manual and this source https://www.sharcnet.ca/Software/Ans...f/flu_udf.html)

Can only the torque be calculated using the pressure*blade-area*arm? Here is my UDF.

******************************************
#include "udf.h"

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(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*CURRENT_TIMESTEP;

if (omega_ts > omega_tf)
{omega_ts = omega_tf;}

THREAD_VAR(t).fluid.omega=omega_ts;
}
end_c_loop (c,t)

}
************************************************** *

Thank you very much for your help. I'm really looking forward to your further reply.

Best regards,
Darma Yuda
sdarmayuda 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
input and output files openFoam Salim OpenFOAM 0 March 8, 2017 20:41
Accessing output parameter value in scheme nnvoro Fluent UDF and Scheme Programming 1 October 11, 2014 15:53
Incompressible simulation brugiere_olivier SU2 2 April 15, 2014 11:12
I/O NO_WRITE, eliminating some output for very large lagrangian simulation sswearingen46 OpenFOAM Running, Solving & CFD 5 April 14, 2014 19:34
Output Excel File in Transient Simulation Soon CFX 5 July 11, 2005 07:11


All times are GMT -4. The time now is 21:43.