CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for volume fraction (https://www.cfd-online.com/Forums/fluent-udf/140797-udf-volume-fraction.html)

hossein65 March 1, 2016 08:19

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

hossein65 March 1, 2016 08:37

Quote:

Originally Posted by sirpolar (Post 509256)
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?

ebtedaei October 9, 2017 07:23

The same problem !
 
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 October 9, 2017 07:25

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 October 9, 2017 07:56

The same problem !
 
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 (Post 509256)
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])
}
}


pakk October 9, 2017 08:23

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.

ebtedaei October 9, 2017 09:29

Hi,
What is [**pt] in 6 line and[*] in 7 , 8 lines?

Thanks,
Ali

Quote:

Originally Posted by sirpolar (Post 509256)
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])
}
}


pakk October 9, 2017 09:50

The star indicates that the variable is a pointer.

ebtedaei October 23, 2017 10:21

Add UDF in Fluent's materials section?
 
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

pakk October 24, 2017 04:41

I don't understand what you are asking.

ebtedaei October 24, 2017 15:02

Quote:

Originally Posted by pakk (Post 668968)
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 October 24, 2017 15:05

I have a twophase flow :
Water and a other fluid phase

pakk October 25, 2017 02:38

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...

Sun October 25, 2017 04:26

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

ebtedaei November 4, 2017 00:29

UDF for viscosity
 
3 Attachment(s)
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:

https://www.cfd-online.com/Forums/fl...-fraction.html

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:

Sun November 4, 2017 05:29

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!

ebtedaei November 5, 2017 09:17

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 November 5, 2017 10:16

1 Attachment(s)
What numbers do I enter in this window?

pakk November 6, 2017 04:37

If you want to have one User Defined Memory, change the first zero (0) into a one (1).

ebtedaei November 6, 2017 06:39

1 Attachment(s)
Quote:

Originally Posted by Sun (Post 670371)
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?


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