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

Defining a source term

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 21, 2018, 07:27
Exclamation Source term for axisymmetric problems
  #1
Member
 
Saurabh Das
Join Date: Jul 2018
Posts: 43
Rep Power: 7
Sorabh is on a distinguished road
Hello, I am solving a 2D-axisymmetrical laser heating problem.



The laser radius is 0.4mm and it has a profile I = I0*exp(-del*x), where x is the x co-ordinate of the cell and del is the absorptivity coefficient in m^-1 . I wrote the following macro for heat source:

Code:
DEFINE_SOURCE(top_hat,c,t,dS,eqn)
{
    real x[ND_ND],time;
    real x0,y0,source;
        real I0 = 1e5;
        real del = 1;
    time=RP_Get_Real("flow-time");
    C_CENTROID(x,c,t);
    x0 = x[0];
    y0 = x[1];
    if (y0 > 0 && y0 < 0.4e-3)
    {
        source = I0*exp(-del*x);
        dS[eqn] = 0;
    }    
    else
    {
        source = 0;
        dS[eqn] = 0;
    }
    
    return source;
}
However results are not what is expected. I expected a parabolic profile of temperature, but I get the following.



Is the source term macro correctly defined?

Thanks

Last edited by Sorabh; November 21, 2018 at 22:50.
Sorabh is offline   Reply With Quote

Old   November 22, 2018, 20:01
Default
  #2
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by Sorabh View Post
Hello, I am solving a 2D-axisymmetrical laser heating problem.



The laser radius is 0.4mm and it has a profile I = I0*exp(-del*x), where x is the x co-ordinate of the cell and del is the absorptivity coefficient in m^-1 . I wrote the following macro for heat source:

Code:
DEFINE_SOURCE(top_hat,c,t,dS,eqn)
{
    real x[ND_ND],time;
    real x0,y0,source;
        real I0 = 1e5;
        real del = 1;
    time=RP_Get_Real("flow-time");
    C_CENTROID(x,c,t);
    x0 = x[0];
    y0 = x[1];
    if (y0 > 0 && y0 < 0.4e-3)
    {
        source = I0*exp(-del*x);
        dS[eqn] = 0;
    }    
    else
    {
        source = 0;
        dS[eqn] = 0;
    }
    
    return source;
}
However results are not what is expected. I expected a parabolic profile of temperature, but I get the following.



Is the source term macro correctly defined?

Thanks
DEFINE_SOURCE will apply to all cells in the domain. So your condition y0 > 0 && y0 < 0.4e-3 will apply to all the cells whose y coordinate <0.4e-3.
You should add additional condition to specify only the first column cells near the left wall. Or another method, do not use DEFINE_SOURCE, just use DEFINE_PROFILE to specify the heat flux on left wall.
gearboy is offline   Reply With Quote

Old   November 23, 2018, 22:56
Default
  #3
Member
 
Saurabh Das
Join Date: Jul 2018
Posts: 43
Rep Power: 7
Sorabh is on a distinguished road
Quote:
Originally Posted by gearboy View Post
DEFINE_SOURCE will apply to all cells in the domain. So your condition y0 > 0 && y0 < 0.4e-3 will apply to all the cells whose y coordinate <0.4e-3.
You should add additional condition to specify only the first column cells near the left wall. Or another method, do not use DEFINE_SOURCE, just use DEFINE_PROFILE to specify the heat flux on left wall.
Thanks... but I have defined a condition 'I = I0*exp(-alpha*x)' where alpha = 1.
Will that not be enough to constraint along x axis?
I also considered using the DEFINE_PROFILE to specify heat flux on the wall.. but it is supposed to be a volumetric heat source, hence both x and y (not just y) co-ordinates should be involved.
Sorabh is offline   Reply With Quote

Old   November 24, 2018, 06:03
Default
  #4
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Sorabh,

Here are a few thoughts:


++ It is a mistake to write "exp(-del*x)", since x is an array. A helpful compiler would have issued a warning about this. Instead, try "exp(-del*x0)".


++ If you make this correction, the source looks correctly defined. The test for "if(y>0)" is pointless (since y<0, and on this occasion even y==0 are impossible).

++ I do not remember the details of source terms in 2D-axisymmetric simulations, but I do remember that you need to check the details. Is the source really "per m3", or is it in fact "per angle of rotation" (hence missing a factor of 2*M_PI)? You need to check this -- and I would not trust my understanding of the manuals (and I would not assume that UDFs and GUI-defined values use the same rules), so you need to check this in a test model. I cannot stress this too much. If you do not do this check, you should regard your results as doubtful to within a factor of 2*M_PI.


++ If your model's extent in the x-direction is small compared to the lengthscale "(1./del)", then the rate of source will be approximately constant in the x-direction. In that sense, I do not see your results as obviously wrong.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   November 28, 2018, 09:58
Default
  #5
Member
 
Saurabh Das
Join Date: Jul 2018
Posts: 43
Rep Power: 7
Sorabh is on a distinguished road
Yeah, I did what you said.. the 'x' in the equation was actually x[0], and the heat generation is defined in W/m^3, so that is sorted out.

I noticed that whenever the point of heat generation is at one of the boundaries, the solution is borked.. but it works when the heat is generated 'within' the doman...
Sorabh is offline   Reply With Quote

Reply

Tags
laser-heating, source term


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
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 18:13
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 03:04
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 15:14
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18


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