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

UDF for volume fraction

Register Blogs Community New Posts Updated Threads Search

Like Tree12Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2016, 09:19
Default
  #21
Member
 
Hossein
Join Date: Oct 2010
Location: Greensboro, NC, USA
Posts: 30
Rep Power: 16
hossein65 is on a distinguished road
I compiled your code, but I am trying to use it for DEFINE_PROPERTY. For the error you get, I put mixture_domain=Get_Domain(1). It compiles and runs well
__________________
Hossein Amini
PhD student in Biochemical Engineering; Computational Science and Engineering department;
North Carolina Agricultural and Technical State University
hossein65 is offline   Reply With Quote

Old   March 1, 2016, 09:37
Default
  #22
Member
 
Hossein
Join Date: Oct 2010
Location: Greensboro, NC, USA
Posts: 30
Rep Power: 16
hossein65 is on a distinguished road
Quote:
Originally Posted by sirpolar View Post
Dear sun the other friends
I have written the UDF as follows, when I interpreted it to the fluent it is ok
But when I want to run (after initialization) the fluent gives this error:
FLUENT received fatal signal (ACCESS_VIOLATION)
I was wondering if you know what is wrong with it?

#include "udf.h"
DEFINE_ADJUST(viscouse_function, d)
{
real visc;
cell_t cell;
Thread **pt;
Thread *cell_threads;
Domain *mixture_domain;
mp_thread_loop_c(cell_threads, mixture_domain, pt)
{
begin_c_loop(cell,pt[1])
{
visc = 1- ((0.95-(C_VOF(cell,pt[1])))-0.25);
}
end_c_loop(cell,pt[1])
}
}
I put mixture_domain=Get_Domain(1) to initialize the domain, and it perfectly compiles and runs with DEFINE_PROPERTY macro that I am using. But the problem is that I get ridiculous constant VOF values which do not match the actual VOF values for my model. I have a two phase Eulerian mixture (Water+Carbon (as fluid)) and cannot get the real carbon VOF values. The funny thing is that when I comment out the line containing the visc function (1-((0.95-(C_VOF(cell,pt[1])))-0.25)) and put a constant number (say 1.0), I get the water VOF !! which doesn't make sense because I am removing the C_VOF (cell,pt[1]) variable. I mean when I say visc=1.0, I get the water VOF. However, I cannot define any functions based on these values unless, and only can multiply the returned value by some numbers and get the result. When I do subtract, add or something else, it doesn't work. Any ideas?
__________________
Hossein Amini
PhD student in Biochemical Engineering; Computational Science and Engineering department;
North Carolina Agricultural and Technical State University
hossein65 is offline   Reply With Quote

Old   October 9, 2017, 08:23
Default The same problem !
  #23
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Dear Ebrahim,

I have a same problem like your case and just my viscosity function is different. Did you solve your UDF's problem?
I would be appreciated if you could help me on this.

Thanks in advance,
Ali
ebtedaei is offline   Reply With Quote

Old   October 9, 2017, 08:25
Default
  #24
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Dear Ebrahim,

I have a same problem like your case and just my viscosity function is different. Did you solve your UDF's problem?
I would be appreciated if you could help me on this.

Thanks in advance,
Ali
ebtedaei is offline   Reply With Quote

Old   October 9, 2017, 08:56
Default The same problem !
  #25
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Dear Ebrahim,
I have a same problem with you problem. Just my viscosity function is different.
Did you solve the UDF's problem(viscous function vs volume of fraction)?

I would be appreciated if you could help me on this.

Thanks in advance,
Ali

Quote:
Originally Posted by sirpolar View Post
Dear sun the other friends
I have written the UDF as follows, when I interpreted it to the fluent it is ok
But when I want to run (after initialization) the fluent gives this error:
FLUENT received fatal signal (ACCESS_VIOLATION)
I was wondering if you know what is wrong with it?

#include "udf.h"
DEFINE_ADJUST(viscouse_function, d)
{
real visc;
cell_t cell;
Thread **pt;
Thread *cell_threads;
Domain *mixture_domain;
mp_thread_loop_c(cell_threads, mixture_domain, pt)
{
begin_c_loop(cell,pt[1])
{
visc = 1- ((0.95-(C_VOF(cell,pt[1])))-0.25);
}
end_c_loop(cell,pt[1])
}
}
ebtedaei is offline   Reply With Quote

Old   October 9, 2017, 09:23
Default
  #26
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The solution was already given by Hossein Amini, just above your message.

If you are interested in what was the reason for the error message: the variable "mixture_domain" is defined, but never given a value. You ask the computer to say something about a mixture domain, but you don't tell him which mixture domain (even though you probably only have one), so Fluent is confused.
pakk is offline   Reply With Quote

Old   October 9, 2017, 10:29
Default
  #27
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Hi,
What is [**pt] in 6 line and[*] in 7 , 8 lines?

Thanks,
Ali

Quote:
Originally Posted by sirpolar View Post
Dear sun the other friends
I have written the UDF as follows, when I interpreted it to the fluent it is ok
But when I want to run (after initialization) the fluent gives this error:
FLUENT received fatal signal (ACCESS_VIOLATION)
I was wondering if you know what is wrong with it?

#include "udf.h"
DEFINE_ADJUST(viscouse_function, d)
{
real visc;
cell_t cell;
Thread **pt;
Thread *cell_threads;
Domain *mixture_domain;
mp_thread_loop_c(cell_threads, mixture_domain, pt)
{
begin_c_loop(cell,pt[1])
{
visc = 1- ((0.95-(C_VOF(cell,pt[1])))-0.25);
}
end_c_loop(cell,pt[1])
}
}
ebtedaei is offline   Reply With Quote

Old   October 9, 2017, 10:50
Default
  #28
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The star indicates that the variable is a pointer.
pakk is offline   Reply With Quote

Old   October 23, 2017, 11:21
Default Add UDF in Fluent's materials section?
  #29
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Hi All,
I wrote UDF code in Fluent and I added it instead of the constant amount of water viscosity, but I have not answered so far! Should special settings be made?

Thanks,
Ali
ebtedaei is offline   Reply With Quote

Old   October 24, 2017, 05:41
Default
  #30
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I don't understand what you are asking.
pakk is offline   Reply With Quote

Old   October 24, 2017, 16:02
Default
  #31
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Quote:
Originally Posted by pakk View Post
I don't understand what you are asking.
I want to write a UDF for Viscosity function of mixture phase vs. Volume of fraction of second phase.
ebtedaei is offline   Reply With Quote

Old   October 24, 2017, 16:05
Default
  #32
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
I have a twophase flow :
Water and a other fluid phase
ebtedaei is offline   Reply With Quote

Old   October 25, 2017, 03:38
Default
  #33
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
And you already wrote a UDF or not?

What is your problem? Do you not know how to write it? Or do you get errors? Or do you get unexpected results?

If you want help, don't let us guess at what you are doing...
pakk is offline   Reply With Quote

Old   October 25, 2017, 05:26
Default
  #34
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 16
Sun is on a distinguished road
Hi ali, as pakk said your question is bit unclear.
Please share your UDF, or maybe the function you are trying to code for the viscosity. In case you are getting unexpected results, please share the results and tell us why you think they are wrong. So, everyone will have a better understanding of the problem.
cheers
Sun is offline   Reply With Quote

Old   November 4, 2017, 01:29
Default UDF for viscosity
  #35
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Thank you for your reply.
I use a mix model that the water and the other phase (X) are mixed, which phase water and phase X have individual properties (density and viscosity).
In the Inlet Boundary Condition, the phase X with a certain amount of volume of fraction (alphaX) is mixed with the water phase However, in different points of the domain and at different times, the volume of fraction of the X phase changes, and subsequently the viscosity of the mixed phase (m) also changes according to the formula:

Viscosity (m) = 3.8 * viscosity (water) * (1-(alphaX/0.62))^(-1.55)

Where, the viscosity function of the mixture phase (m) varies according to the volume of fraction (alpha X) of the phase X, and also the μc is the constant value of the viscosity of water.

A very similar example to my problem that I found on the cfd-online site is as follows:

UDF for volume fraction

It is important that based on a study on related articles, I have to replace the UDF file on the constant amount of water viscosity in the Materials substitute of fluent to vary the viscosity of the mix phase at different points and at different times in the domain.

Of course, I have already written three UDF codes, but I have not responded to any of these.
Thank you in advance for your commenting on any of these fallowing codes:
Attached Files
File Type: c Viscosity_1.c (357 Bytes, 15 views)
File Type: c Viscosity_2.c (564 Bytes, 9 views)
File Type: c Viscosity_3.c (376 Bytes, 9 views)
ebtedaei is offline   Reply With Quote

Old   November 4, 2017, 06:29
Default
  #36
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 16
Sun is on a distinguished road
Hi,
Maybe you can use both
Code:
DEFINE_ADJUST
and
Code:
DEFINE_PROPERTY
. Here is an example, you might need to modify it based on your needs:
Code:
DEFINE_PROPERTY(viscosity_mix,c,t)
{
	real viscosity;
    
    viscosity = C_UDMI(c,t,1);
    
    return viscosity;		
}

DEFINE_ADJUST(my_adjust,mixture_domain)
{
	Thread *t;
	cell_t c;
	Thread **pt;
		
	real mu_water = 0.00103;

	mp_thread_loop_c(t,mixture_domain,pt)
	{
	   begin_c_loop(c,t)
	   {
		
		C_UDMI(c,t,1) = 3.8*mu_water*(pow((1.0 - C_VOF(c,pt[1])/0.62), -1.55));
		
	   }
        end_c_loop(c,t)	   
	}
}
Please remember to define a user define memory before compiling, because the values are stored in an UDM.

hope it helps
cheers!
Sun is offline   Reply With Quote

Old   November 5, 2017, 10:17
Default
  #37
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Thanks for your reply.

What do you mean by last statement:

"Please remember to define a user define memory before compiling, because the values are stored in an UDM."

How can I define a user define memory before compiling?

I isn't professional in writing UDF!!!
ebtedaei is offline   Reply With Quote

Old   November 5, 2017, 11:16
Default
  #38
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
What numbers do I enter in this window?
Attached Images
File Type: jpg User-Defined-Memory.jpg (129.6 KB, 16 views)
ebtedaei is offline   Reply With Quote

Old   November 6, 2017, 05:37
Default
  #39
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
If you want to have one User Defined Memory, change the first zero (0) into a one (1).
pakk is offline   Reply With Quote

Old   November 6, 2017, 07:39
Default
  #40
Senior Member
 
ali
Join Date: Jul 2016
Posts: 147
Rep Power: 10
ebtedaei is on a distinguished road
Quote:
Originally Posted by Sun View Post
Hi,
Maybe you can use both
Code:
DEFINE_ADJUST
and
Code:
DEFINE_PROPERTY
. Here is an example, you might need to modify it based on your needs:
Code:
DEFINE_PROPERTY(viscosity_mix,c,t)
{
	real viscosity;
    
    viscosity = C_UDMI(c,t,1);
    
    return viscosity;		
}

DEFINE_ADJUST(my_adjust,mixture_domain)
{
	Thread *t;
	cell_t c;
	Thread **pt;
		
	real mu_water = 0.00103;

	mp_thread_loop_c(t,mixture_domain,pt)
	{
	   begin_c_loop(c,t)
	   {
		
		C_UDMI(c,t,1) = 3.8*mu_water*(pow((1.0 - C_VOF(c,pt[1])/0.62), -1.55));
		
	   }
        end_c_loop(c,t)	   
	}
}
Please remember to define a user define memory before compiling, because the values are stored in an UDM.

hope it helps
cheers!
Hi,
As you see, In my case two fluids are mixed together: water and another fluid called ferrosilicon (Other than Air).
In udf code that you wrote, how do I understand the software that the volume fraction (vof) is related to the ferrosilicon fluid?
Attached Images
File Type: jpg fluids.jpg (130.6 KB, 13 views)
ebtedaei 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
udf: volume fraction gradient in eulerian model jwwang FLUENT 22 April 15, 2015 07:27
Conversion of mass fraction to mole fraction in FLUENT prince_pahariaa FLUENT 0 August 26, 2014 09:08
interDyMFoam - change in volume fraction gopala OpenFOAM Running, Solving & CFD 0 April 27, 2009 11:46
UDF for Species mass fraction daniel FLUENT 3 June 22, 2005 09:40
Species Mass Fraction inside UDF using PDF? Daniel Schneider FLUENT 0 September 20, 2000 07:34


All times are GMT -4. The time now is 13:39.