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

how to define fluctuating volume fraction at inlet

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By `e`

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 11, 2015, 05:15
Unhappy how to define fluctuating volume fraction at inlet
  #1
New Member
 
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15
Bridges is on a distinguished road
Guys, thank you for spending time on this post!

I really need some help from you guys!

I'm currently trying to simulate a 2-phase pipe flow. I'm trying to set the 2-phase inlet with fluctuating air volume fraction, something like:

from 0 to 1 sec ------> air volume fraction = 0.2 + 0.2*t
from 1 to 2 sec ------> air volume fraction = 0.4 - 0.2*t


Could I know how to write a udf to control that?

I've tried the following code similar to what I did for fluctuating velocity:

#include "udf.h"
DEFINE_PROFILE(volume_fraction, thread, position)
{
real t, v_f;
face_t f;

begin_f_loop(f,thread)
{
t = RP_Get_Real("flow-time");
{
if(t>0 && t<=1)
{
v_f = 0.2 + 0.2*t;
}
else if(t>1 &&t<=2)
{
v_f = 0.4 - 0.2*t;
}
}
F_PROFILE(f,thread,position) = v_f;
}
end_f_loop(f,thread)
}

However, I'm getting error message as follows:

error C2223: left of '-> nelements' must point to struct/union
error C2223: left of '-> storage' must point to struct/union

Can anyone please help me on this? Thank you so much! I'm a newbee in udf. Have a nice day guys!
Bridges is offline   Reply With Quote

Old   March 11, 2015, 05:53
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Did the fluctuating velocity DEFINE_PROFILE UDF work, and can you provide the code?

Also, try to stay consistent with naming variables such as DEFINE_PROFILE(volume_fraction, t, i). You may trip the compiler and/or solver up, if for example thread or position were special variables or functions used by Fluent.
Bridges likes this.
`e` is offline   Reply With Quote

Old   March 12, 2015, 02:19
Default
  #3
New Member
 
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15
Bridges is on a distinguished road
Thanks for the reply!

It works for fluctuating velocity. The code is as follows:

#include "udf.h"
DEFINE_PROFILE(inlet_velocity, thread, position)
{
real t, v;
face_t f;

begin_f_loop(f,thread)
{
t = RP_Get_Real("flow-time");
{
if(t>0 && t<=1)
{
v = 1.5 + 1.5*t;
}
else if(t>1 &&t<=2)
{
v_f = 3 - 1.5*t;
}
}
F_PROFILE(f,thread,position) = v;
}
end_f_loop(f,thread)
}


It works pretty well.

Let me try with renaming the variables. Thanks a lot!
Bridges is offline   Reply With Quote

Old   March 12, 2015, 04:07
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by Bridges View Post
Thanks for the reply!

It works for fluctuating velocity. The code is as follows:

#include "udf.h"
DEFINE_PROFILE(inlet_velocity, thread, position)
{
real t, v;
face_t f;

begin_f_loop(f,thread)
{
t = RP_Get_Real("flow-time");
{
if(t>0 && t<=1)
{
v = 1.5 + 1.5*t;
}
else if(t>1 &&t<=2)
{
v_f = 3 - 1.5*t;
}
}
F_PROFILE(f,thread,position) = v;
}
end_f_loop(f,thread)
}


It works pretty well.

Let me try with renaming the variables. Thanks a lot!
Strange... This one should not work, since you mixed up "v" and "v_f"...
pakk is offline   Reply With Quote

Old   March 12, 2015, 22:20
Default
  #5
New Member
 
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15
Bridges is on a distinguished road
Quote:
Originally Posted by pakk View Post
Strange... This one should not work, since you mixed up "v" and "v_f"...
So sorry. That was a typo. should be v instead of v_f
Bridges is offline   Reply With Quote

Old   March 12, 2015, 22:35
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The UDF doesn't appear to have any obvious errors, which leaves the implementation. Are you sure you're compiling and hooking the UDF correctly (same way as the velocity b.c.)?
`e` is offline   Reply With Quote

Old   March 12, 2015, 22:49
Default
  #7
New Member
 
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15
Bridges is on a distinguished road
Quote:
Originally Posted by `e` View Post
The UDF doesn't appear to have any obvious errors, which leaves the implementation. Are you sure you're compiling and hooking the UDF correctly (same way as the velocity b.c.)?
Thank you so much for your reply!

I was unable to compile the udf.

It kept showing me the error message:

error C2223: left of '-> nelements' must point to struct/union
error C2223: left of '-> storage' must point to struct/union

and "...The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64)..."

I couldn't hook the udf to fluent.
Bridges is offline   Reply With Quote

Old   March 12, 2015, 23:08
Default
  #8
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
I'm wondering if it's something to do with the variable names. Try renaming the DEFINE_PROFILE variables as I suggested earlier and rename 't' to 'myTime' or something to make absolutely sure that Fluent isn't trying to use these variables for another purpose.

If that fails, then I suppose try stripping back the code to the very basics (no time dependency, constant value etc) to see which line is causing you grief because the error is not providing a line number to work from.
`e` is offline   Reply With Quote

Old   March 13, 2015, 05:29
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
And please be sure that you copied the right code here. (The code that gives the errors.)

The code that worked that you put here had a typo. How can that happen, when you copy-paste? I am not trying to annoy you, but please make sure the code we are looking at is the correct code, and has no typos.
pakk is offline   Reply With Quote

Old   March 16, 2015, 00:53
Default
  #10
New Member
 
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15
Bridges is on a distinguished road
Quote:
Originally Posted by `e` View Post
I'm wondering if it's something to do with the variable names. Try renaming the DEFINE_PROFILE variables as I suggested earlier and rename 't' to 'myTime' or something to make absolutely sure that Fluent isn't trying to use these variables for another purpose.

If that fails, then I suppose try stripping back the code to the very basics (no time dependency, constant value etc) to see which line is causing you grief because the error is not providing a line number to work from.
Thank you so much for your suggestions!

I managed to use "profile file" instead of using udf. I found profile is slightly simpler to use, just a bit tedious. Need to manually type all the time instance.
Bridges is offline   Reply With Quote

Old   March 16, 2015, 01:03
Default
  #11
New Member
 
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15
Bridges is on a distinguished road
Quote:
Originally Posted by pakk View Post
And please be sure that you copied the right code here. (The code that gives the errors.)

The code that worked that you put here had a typo. How can that happen, when you copy-paste? I am not trying to annoy you, but please make sure the code we are looking at is the correct code, and has no typos.
So sorry about that. I was running simulation on another computer. I typed my thread according to the script on the other computer. I should have double checked it.
Bridges is offline   Reply With Quote

Old   April 7, 2017, 11:04
Default
  #12
bss
New Member
 
Bahador
Join Date: Jun 2016
Posts: 3
Rep Power: 10
bss is on a distinguished road
Sorry, I thought i knew the problem.
bss is offline   Reply With Quote

Reply

Tags
fluctuating flow, 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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
volume fraction = nan Virtual-iCFD OpenFOAM Running, Solving & CFD 8 June 12, 2015 19:15
How to define the phase volume fraction in CEL expression huangxianbei CFX 1 November 1, 2013 05:24
mpirun interFoam very stable --> then blows up ghadab OpenFOAM Running, Solving & CFD 3 October 27, 2013 11:34
Estimation of "inlet solid volume fraction"...? Genanry FLUENT 1 February 15, 2007 11:29


All times are GMT -4. The time now is 12:45.