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

HELP: Solver not changing to desired outlet - UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2017, 12:17
Exclamation HELP: Solver not changing to desired outlet - UDF
  #1
New Member
 
Outside US and Canada
Join Date: Apr 2017
Location: Malaysia
Posts: 1
Rep Power: 0
Kuna833 is on a distinguished road
Hi guys,

I am using fluent for my final year project and I'm having trouble with my UDF for specifying multiple threads.

I am doing a transient boundary condition problem on a intake manifold for my university's FSAE team. The data that I have for the engine is a series of pressure curves for the inlet of intake runners.

I have already simplified the data into piecewise functions whereby during the intake phase, the pressure is a function of [31400*sin(2028.65*t) - 101325] and it is set to 101325 kpa other times. I've done 4 sets of piecewise functions for each cylinder (although in the code theres only for 3 intake runners for now)

The piecewise function is for 2 full engine cycles at 12000 RPM. I've attached my UDF code for your reference.

I'm using DES

#include "udf.h"

DEFINE_ON_DEMAND(domian_id)
{
Domain *domain;
domain = Get_Domain(1);
}

/************************************************** ***************************************
CYLINDER 1
************************************************** ***************************************/

DEFINE_ADJUST(centroids, domain)
{
int ID1 = 7;
Thread *thread1 = Lookup_Thread(domain, ID1);
}

DEFINE_PROFILE(pressure_cyl1, thread1, p1)
{
real y[ND_ND];
face_t f;
real t = CURRENT_TIME;
real pressure1;

if ((t>=0) && (t<0.00394444))
{
pressure1=31400*sin(2028.65*t) - 101325;
}

if ((t>=0.00394444) && (t<0.01))
{
pressure1=101325;
}
if ((t>=0.01) && (t<0.01394444))
{
pressure1=31400*sin(2028.65*t) - 101325;
}
if ((t>=0.01394444) && (t<0.0275))
{
pressure1=101325;
}

begin_f_loop(f, thread1);
{
F_CENTROID(y,f,thread1);
t = y[1];
F_PROFILE(f, thread1, p1) = pressure1;
}
end_f_loop(f, thread1)
}

/************************************************** ***************************************
CYLINDER 4
************************************************** ***************************************/

DEFINE_ADJUST(centroids, domain)
{
int ID4 = 10;
Thread *thread4 = Lookup_Thread(domain, ID4);
}

DEFINE_PROFILE(pressure_cyl4, thread4, p4)
{

real y[ND_ND];
face_t h;
real t = CURRENT_TIME;
real pressure4;

if ((t>=0) && (t<0.005))
{
pressure4=101325;
}
if ((t>=0.005) && (t<0.00894444));
{
pressure4=31400*sin(2028.65*t) - 101325;
}
if ((t>=0.00894444) && (t<0.015));
{
pressure4=101325;
}
if ((t>=0.015) && (t<0.01894444));
{
pressure4=31400*sin(2028.65*t) - 101325;
}
if ((t>=0.01894444) && (t<0.025));
{
pressure4=101325;
}


begin_f_loop(h, thread4)
{
F_CENTROID(y,h,thread4);
t = y[1];
F_PROFILE(h, thread4, p4) = pressure4;
}
end_f_loop(h, thread4)
}

/************************************************** ***************************************
CYLINDER 3
************************************************** ***************************************/

DEFINE_ADJUST(centroids, domain)
{
int ID3 = 9;
Thread *thread3 = Lookup_Thread(domain, ID3);
}

DEFINE_PROFILE(pressure_cyl3, thread3, p3)
{

real y[ND_ND];
face_t l;
real t = CURRENT_TIME;
real pressure3;

if ((t>=0) && (t<0.0075))
{
pressure3=101325;
}

if ((t>=0.0075) && (t<0.01144444));
{
pressure3=31400*sin(2028.65*t) - 101325;
}
if ((t>=0.01144444) && (t<0.0175));
{
pressure3=101325;
}
if ((t>=0.0175) && (t<0.02144444));
{
pressure3=31400*sin(2028.65*t) - 101325;
}
if ((t>=0.02144444) && (t<0.0275));
{
pressure3=101325;
}


begin_f_loop(l, thread3)
{
F_CENTROID(y,l,thread3);
t = y[1];
F_PROFILE(l, thread3, p3) = pressure3;
}
end_f_loop(l, thread3)
}

Here is the problem:
The UDF code can be interpreted without issues. But when I run the code, only the first intake runner has flow through it. I need the flow through all 4 runners varying with time. And from the solution animation it seems that all the pressure variation takes place in the first intake runner only.

Here's what I've done:
-using pressure outlet BC
-set the UDM to 1
-used Lookup_Thread to specify thread pointer to specific outlets (the thread ID was obtained from the BC menu)
- used 'real y[ND_ND]' since all the surface normal of the outlet is along the y axis (in the negative direction btw).
-Placed all of the profiles in a single UDF
-Restart fluent and reset the setup tab in workbench before every run.
-using single processor
-Inlet is set to constant inlet pressure BC

I'm using DES for the solver model. Not sure if this might be important. If switching models would make a difference then please let me know.

I've read through the Fluent UDF manual, tutorial guide, and gone through this forum a few times but I've yet to find anything that works. Any help at this moment will be greatly appreciated.

This is my first time using Ansys Fluent and coding in C. So please go easy on me. Thank you in advance for your help.

Regards,
Kuna
Kuna833 is offline   Reply With Quote

Old   April 13, 2017, 03:08
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Kuna833 View Post
Here's what I've done:
-using pressure outlet BC
And I hope that as 'value' for each pressure outlet BC you specify "pressure_cyl1", "pressure_cyl2" and so on.
Quote:
-set the UDM to 1
You are not using any UDM in your code so I don't see the point of this, but it will not do any harm.
Quote:
-used Lookup_Thread to specify thread pointer to specific outlets (the thread ID was obtained from the BC menu)
I can not follow this. All "DEFINE_ADJUST" macros in your code do nothing. You apparently want to specify where the BC is used in the code; this is not the right place, you should do this in Fluent. Like I indicated three points above.
Quote:
- used 'real y[ND_ND]' since all the surface normal of the outlet is along the y axis (in the negative direction btw).
In the code, 'y' is just a name. The results of the code will not change if you use 'x' or 'z' or 'sillyname'.
If you say 'real y[ND_ND]' to the interpreter, all it knows is that 'y' is a vector with real components. The interpreter has no idea which values you want to be there, until you tell the interpreter this. You never tell this to the interpreter. And later on, you ask the interpreter to give you y[1]. This is the second component (counting starts at 0) of this unknown vector. The interpreter will give you the value that happens to be in memory (or an error). Luckily for you, you never use the value: you assign it to 't', and never use 't' anymore.

Luckily for you, the solution is easy: just remove the lines with y. You don't need them.

Quote:
-Placed all of the profiles in a single UDF
This is very good.
pakk is offline   Reply With Quote

Reply

Tags
fsae, intake manifold, switching to an opening, thread, udf


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
PEMFC model with FLUENT brahimchoice FLUENT 22 April 19, 2020 15:44
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 07:26
UDF for pressure outlet (resistance) Lilly Fluent UDF and Scheme Programming 0 October 15, 2014 06:22
UDF for Mass Flow at the Outlet: ERROR ACCESS VIOLATION I-mech Fluent UDF and Scheme Programming 1 May 23, 2014 12:37
UDF for species-mass-fraction gradient at outlet sisir FLUENT 0 June 9, 2007 02:40


All times are GMT -4. The time now is 14:56.