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

UDF value different when computed from results variable

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 23, 2020, 23:42
Default UDF value different when computed from results variable
  #1
New Member
 
Yoshi Toshi
Join Date: Mar 2016
Posts: 29
Rep Power: 10
wiggles8x0 is on a distinguished road
Hi,
I have a velocity inlet BC which I am tweaking to get a Reynolds number of say 100. I made a UDF for it such as 1.225*U/eff-viscosity and monitored this value as i changed the inlet BC value. The case in constant density.

Once I converged the case I got the individual values for U and eff-viscosity and am finding that when I plug this into the Reynolds number equation, it doesn't equal the UDF that is defined exactly the same way. The only difference I can imagine being is that somehow the value of eff-viscosity being used in the UDF and results-variable of eff-viscosity are different since the velocity remain the same but I don't get how or why. Or how I can make them equal.

Any help would be appreciated, thanks.
wiggles8x0 is offline   Reply With Quote

Old   April 24, 2020, 02:15
Default
  #2
Senior Member
 
duri
Join Date: May 2010
Posts: 245
Rep Power: 17
duri is on a distinguished road
Quote:
Originally Posted by wiggles8x0 View Post
Hi,
The only difference I can imagine being is that somehow the value of eff-viscosity being used in the UDF and results-variable of eff-viscosity are different since the velocity remain the same but I don't get how or why. Or how I can make them equal.

Effective viscosity could be a post processing variable which may not be updated each iteration. Check by printing turbulent viscosity and molecular viscosity and the sum of this should equal to effective viscosity on a given cell.
duri is offline   Reply With Quote

Old   April 24, 2020, 04:54
Default Reynolds Number
  #3
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Reynolds number is never defined using effective viscosity. Effective viscosity is a sum of molecular viscosity, which is property of fluid, and turbulent viscosity, which is a property of flow and not fluid. If you have constant property fluid, then Re of 100 implies a constant velocity, which you can easily calculate and apply directly. No UDF is needed for that.

However, if you really want to use the definition using effective viscosity, then the first thing you need to include in your definition is a length scale, which is missing. Secondly, as I mentioned earlier, turbulent viscosity is a flow property, so, until and unless flow is converged, you will not have a fixed value for effective viscosity; this will change every iteration. However, you might be applying certain value of Turbulent quantities at the inlet. Just use those to determine effective viscosity, calculate viscosity for Re of 100, and apply that velocity. You don't need a UDF in any case.
__________________
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   April 24, 2020, 08:54
Default
  #4
New Member
 
Yoshi Toshi
Join Date: Mar 2016
Posts: 29
Rep Power: 10
wiggles8x0 is on a distinguished road
Thanks for the input!

So first off I believe I have a well enough converged case where values aren't changing too much iteration to iteration.

I also attached a few images as yes I forgot to mention that I am multiplying by a length term (0.5m). So my confusion comes from that when I post process these variables in Fluent, they still end up giving different values if you calculate Re manually which doesn't make too much sense to me.

Yes I know i don't need a udf but I was getting some weird results before and so I just wanted this monitor variable do double check that things are going how I want them to.


EDIT: I confirmed the non-varying results by making report definitions for both the velocity and eff-viscosity term and neither change with iterations.
Attached Images
File Type: jpg results.JPG (31.7 KB, 6 views)
File Type: jpg udf.JPG (15.3 KB, 5 views)
File Type: jpg udff.JPG (43.3 KB, 5 views)
File Type: jpg residuals.JPG (50.4 KB, 4 views)
wiggles8x0 is offline   Reply With Quote

Old   April 24, 2020, 09:13
Default Averaging
  #5
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Density and length scale, as well as, molecular viscosity are constant. However, velocity and turbulent viscosity change from face to face over the inlet. So, for Re that you calculated using Custom Field Function, the equation is

\frac{\sum A_i Re_i}{\sum Ai}
Re_i = \frac{0.5\rho U_i}{\mu_{effi}}

while when you are calculating it yourself, then you are using averaged values, so, the equation becomes

0.5\rho\frac{\sum A_i U_i}{A\mu + \sum A_i \mu_{ti}}

Until and unless all A_i are equal, the values may not match.
__________________
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   April 24, 2020, 09:28
Default
  #6
New Member
 
Yoshi Toshi
Join Date: Mar 2016
Posts: 29
Rep Power: 10
wiggles8x0 is on a distinguished road
ah okay thank you for going into the details for me.
So I guess my next question would have to be why is it that the solver is changing the area when the inlet has a fixed value of 0.5m? I don't necessarily understand how or why that value would change relative to what variable I want.
wiggles8x0 is offline   Reply With Quote

Old   April 24, 2020, 09:39
Default Area
  #7
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Solver is not changing the area. However, if you look at the inlet, you will observe that it is made up of many mesh faces. Area of each face is used to determine area-weighted average. And then there is total area, which is sum of all these area values.
__________________
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   April 24, 2020, 09:50
Default
  #8
New Member
 
Yoshi Toshi
Join Date: Mar 2016
Posts: 29
Rep Power: 10
wiggles8x0 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Area of each face is used to determine area-weighted average. And then there is total area, which is sum of all these area values.
I'm not sure I fully understand what you are trying to convey. Would you mind maybe explaining it a different way in how this would explain why the area term might not be the same in all the places it is being employed?

Are you perhaps saying that the area term would be constant for all variables only across all cell faces only if all the cells have exactly the same size? And if that is the case, then wouldn't that mean that this error in values would apply everywhere in the domain when post-processing? How does one even resolve this discrepancy?

Also, how exactly would the solver calculate {\sum A_i Re_i} if not by doing 0.5\rho\frac{\sum A_i U_i}{A\mu + \sum A_i \mu_{ti}} ?
wiggles8x0 is offline   Reply With Quote

Old   April 24, 2020, 09:57
Default Averaging
  #9
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
When Re is defined as a CFF, then Re is calculated for each face and then its area-weighted average is calculated. For CFF, Re is calculated at the cell-centers adjacent to the inlet boundary. Then, these values are interpolated to inlet face centers. And then, the average is calculated.

The other way you are doing is calculating area-weighted average for velocity and turbulent viscosity and then determining the Re. In this case, values for the velocity magnitude and effective viscosity are interpolated to the inlet and then averaged. You use these averaged values to determine Re.

Both could lead to different results. There is no discrepancy here. These are two different methods. Ideally, the values should be rather close to each other. It is quite possible that the reason I have given is not enough to explain the discrepancy. You can try to export face area, velocity, and effective viscosity for inlet into a text file via File > Export > Solution. This will give you raw data for each face. Then you can determine it yourself.
__________________
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

Tags
fluent, 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
UDF print results into .dat file more than once per time step? how to fix it? xuwenhua625 Fluent UDF and Scheme Programming 5 May 15, 2019 06:33
Evaluating UDF variable to change boundary conditions saml FLUENT 0 July 12, 2016 09:22
Using a calculated variable in another UDF hwet Fluent UDF and Scheme Programming 12 November 26, 2015 04:36
changing scheme variable with UDF? Wagemakers FLUENT 17 September 30, 2015 15:34
UDF: exporting a variable between two DEFINE function Carlo FLUENT 3 August 19, 2009 13:21


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