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

Interfacial species transport UDF in Eulerian model

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By richard222

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2016, 10:32
Default Interfacial species transport UDF in Eulerian model
  #1
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
I am simulating species transport in a 2 phase vapor-liquid bubble column using the Eulerian framework. This UDF is designed to calculate the mass transfer rate of one species from the primary phase (liquid) to the secondary phase (gas).

The UDF compiles and hooks successfully in fluent, but no mass transfer occurs when the simulation is run. I wasn't sure whether it is necessary to introduce a the "thread_loop_c" loop over all cells (see code below), but when I tried excluding the loop it would produce an error during initialization. Any thoughts on why the UDF does not work? Thank you in advance

#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "flow.h"
#include "metric.h"

DEFINE_MASS_TRANSFER(source,cell,thread,from_index ,from_species_index,to_index,to_species_index)
{

Domain *mixture_domain=Get_Domain(1);

thread_loop_c(thread, mixture_domain)
{
if( THREAD_ID(thread) == 1)
{
begin_c_loop(cell, thread)
{
real m_lg;
Thread *liq=THREAD_SUB_THREAD(thread,from_index);
Thread *gas=THREAD_SUB_THREAD(thread,to_index);
m_lg=0.3*pow(10,-7)*C_R(cell,liq);
return (m_lg);
}
end_c_loop(cell, thread)
}
}
}

Notes:

- getDomain(1) is the mixture domain (containing both liquid and gas phases).

- THREAD_ID(thread)= 1 is the interior zone of the fluid, from define-> boundary conditions .

- I have been running serial (not parallel) simulations, and have tried both compiling and interpreting the UDF (results are the same).
yifang likes this.
richard222 is offline   Reply With Quote

Old   May 19, 2016, 06:11
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
- THREAD_ID(thread)= 1 is the interior zone of the fluid, from define-> boundary conditions .
shouldn't this be the cell zone (cell zone condition) rather than the interior boundary?
Bruno Machado is offline   Reply With Quote

Old   May 19, 2016, 08:00
Default
  #3
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
Hi Bruno. Yes it looks like you are correct according to the UDF manual. So, I changed it to THREAD_ID(thread)= 2 as the cell zone ID number of the fluid is 2. But this still didn't fix the problem. I also tried removing the IF statement entirely from the code but there was no difference
richard222 is offline   Reply With Quote

Old   May 19, 2016, 08:12
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by richard222 View Post
Hi Bruno. Yes it looks like you are correct according to the UDF manual. So, I changed it to THREAD_ID(thread)= 2 as the cell zone ID number of the fluid is 2. But this still didn't fix the problem. I also tried removing the IF statement entirely from the code but there was no difference
return (m_lg);

this should be your last line, before closing the DEFINE_MASS_TRANSFER macro. try to change it and see if it works. and according to the manual, there is no need to loop over the cells.
Bruno Machado is offline   Reply With Quote

Old   May 20, 2016, 07:18
Default
  #5
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
I tried changing the position of return (m_lg) but it didnt work.
I also tried no loop at all but it didnt work. Without a loop it returns a cortex error at initialisation
richard222 is offline   Reply With Quote

Old   May 20, 2016, 18:24
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The DEFINE_MASS_TRANSFER macro is called for each cell and includes arguments with the cell index and its mixture-level thread. You've then looped over all cells within this thread and since you're always exiting the macro on the first loop, the m_lg of the first cell (index of 0) is returned. Remove the cell loop and check the UDF manual for an example.
`e` is offline   Reply With Quote

Old   May 23, 2016, 04:38
Default
  #7
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
I've noticed something strange that I hadn't realised before. When trying to compile the UDF, it builds and loads without any errors. However, when I try to hook the UDF in the phase interactions panel, it says "no UDF has been loaded" and I am unable to hook the UDF there. But if I set the phase interactions panel to the "species mass transfer" option, and then try to hook the compiled UDF to the mass transfer coefficient panel, it DOES work. When I interpret the same UDF, it works fine, and there is no problem hooking it to either the mass transfer coefficient panel or the phase interactions panel. This makes me think that there is something wrong with the way my UDF is being compiled . I am launching fluent (ver 16.1) using the Microsoft VS2015 x64 command prompt, with the case files inside the same directory as the UDF file, and when I compile the UDF it seems to load the library without any problems, so I am not sure where the problem lies. Is it completely necessary to compile rather than interpret this type of UDF? Thanks for your help

Last edited by richard222; May 23, 2016 at 05:57.
richard222 is offline   Reply With Quote

Old   May 23, 2016, 05:45
Default
  #8
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
Quote:
Originally Posted by `e` View Post
The DEFINE_MASS_TRANSFER macro is called for each cell and includes arguments with the cell index and its mixture-level thread. You've then looped over all cells within this thread and since you're always exiting the macro on the first loop, the m_lg of the first cell (index of 0) is returned. Remove the cell loop and check the UDF manual for an example.
Yes, this definitely makes sense. I'd expect the code without the loop to work, which is why i am beginning to think the problem is due to a problem with compilation.
richard222 is offline   Reply With Quote

Old   May 23, 2016, 05:56
Default
  #9
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
To summarise:

In interpreted mode: Interprets UDF fine, but produces a segmentation error when I try to initialise.

In compiled mode: Builds and loads fine, but isnt visible on phase interactions panel to hook (is only visible in mass transfer coefficient panel, if "species mass transfer" model is enabled).
richard222 is offline   Reply With Quote

Old   May 23, 2016, 08:56
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
There's no specific instruction to compile DEFINE_MASS_TRANSFER macros in the UDF manual but it's generally best to compile all UDFs to avoid potential issues. Are there any errors or warnings when you're compiling? And check my compiling process for Fluent UDFs with an existing library loaded.
`e` is offline   Reply With Quote

Old   May 23, 2016, 09:05
Default
  #11
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I guess what you want to have is this:

Code:
#include "udf.h"

DEFINE_MASS_TRANSFER(source,cell,thread,from_index,
from_species_index,to_index,to_species_index)
{
Thread *liq=THREAD_SUB_THREAD(thread,from_index);
real m_lg=0.3*pow(10,-7)*C_R(cell,liq);
return (m_lg);
}
At least that is what you get when you remove all unnecessary loops and variables from your code.
pakk is offline   Reply With Quote

Old   May 23, 2016, 09:35
Default
  #12
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
I tried using the simplified code that you suggested, Pak. There are no error messages during building or loading the UDF, until I select "user defined" option from the phase interactions panel and then I get "Error: No user-defined functions have been loaded". I checked to see if I could unload any previous libraries (there weren't any though) before loading the new one and I compiled the UDF library using the recommended steps.I have attached a screenshot of the fluent command prompt.
Attached Images
File Type: png commandprompt.png (18.4 KB, 52 views)
richard222 is offline   Reply With Quote

Old   May 23, 2016, 09:38
Default
  #13
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
From the manual:
Quote:
"In order to hook a DEFINE_MASS_TRANSFER UDF to Fluent, you must first issue the TUI command solve/set/expert and enter no at the Linearized Mass Transfer UDF? prompt."
Did you do that?
pakk is offline   Reply With Quote

Old   May 23, 2016, 11:52
Default
  #14
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
Thanks pak. That solved the problem of allowing me to hook the compiled UDF to the phase interactions panel. But, when I run the compiled UDF, there is no mass transfer occurring (it appears that ml_g=0). I can't figure out why this is the case
richard222 is offline   Reply With Quote

Old   May 23, 2016, 12:04
Default
  #15
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
And if you print the mass transfer in this way:
Code:
#include "udf.h"

DEFINE_MASS_TRANSFER(source,cell,thread,from_index,
from_species_index,to_index,to_species_index)
{
Thread *liq=THREAD_SUB_THREAD(thread,from_index);
real m_lg=0.3*pow(10,-7)*C_R(cell,liq);
Message("m_lg=%e\n",m_lg);
return (m_lg);
}
Warning: this prints one line per face, so only run this for one time step.

Do you see "m_lg=0" many times?

Or do you see small but positive values? If it is the latter, then Fluent is exactly calculation what you want, but the mass flow is just too small to notice...
pakk is offline   Reply With Quote

Old   May 23, 2016, 12:25
Default
  #16
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
I get very small values of ml_g being repeated many times. Yes it seems that the UDF is working. It is strange though that I am not observing any transfer from the liquid to the gas phase (it is a bubbly flow column). Normally in CFD-post when viewing the mass fraction profile in the liquid phase of the specie being transferred the scalebar of the y axis can deal with a very large number of decimal points
richard222 is offline   Reply With Quote

Old   May 24, 2016, 13:40
Default
  #17
New Member
 
Richard
Join Date: May 2016
Posts: 16
Rep Power: 10
richard222 is on a distinguished road
Thank you for your help. The problem has been solved. It appears that the mass transfer rate was so small that the simulation needed to be run for an extremely long time to achieve a measurable level of mass transfer
richard222 is offline   Reply With Quote

Reply

Tags
define_mass_transfer, species transport, user defined functions


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
Fluent species transport model lakshmi.bala FLUENT 23 November 2, 2022 02:42
Diff in Combustion Modelling By Species Transport Model & Non-Premixed Combustion bhanuday.sharma FLUENT 0 June 23, 2015 03:50
Divergence problem for species transport model MY FLUENT 3 January 11, 2014 05:46
Eulerian Model, UDF Programming hjel0743 Fluent UDF and Scheme Programming 0 October 16, 2012 17:51
Species Transport Model Sam FLUENT 0 November 12, 2005 22:42


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