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

Adding excess stress terms into the momentum equations

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 20, 2024, 10:24
Default Adding excess stress terms into the momentum equations
  #1
New Member
 
Murat Can ONEN
Join Date: Sep 2021
Location: Turkey
Posts: 13
Rep Power: 5
mcanoenen is on a distinguished road
Hello

I am trying to add x and y momentum source terms that include second gradients of the velocity field.



My UDF is as follows but does not compile when I wrote equations as such:

Code:
DEFINE_SOURCE(momentum_x_source, c, t, dS, eqn)
{
    real source;
    real grad_Txx_e[ND_ND];
    real grad_Txy_e[ND_ND];
    real grad_DUDX[ND_ND];
    real grad_DUDY[ND_ND];
    real grad_DVDX[ND_ND];

    /* Calculate the gradients of Txx and DUDX */
        
     grad_Txx_e = C_UDSI_G(c, t, Txx);
     grad_Txy_e = C_UDSI_G(c, t, Txy);
     grad_DUDX = C_DUDX_G(c, t);
     grad_DUDY = C_DUDY_G(c, t);
     grad_DVDX = C_DVDX_G(c, t);

    /* Source term for the x-momentum equation */

    source = grad_Txx_e[0] - 2 * M_Eta_S * grad_DUDX[0] + grad_Txy_e[1]- M_Eta_S * (grad_DUDY [1] + grad_DVDX [0]);
    
    dS[eqn] = 0.0; // Set the derivative of the source term if needed
    return source;
}
Could you give some tips on how to add those second derivative terms into the momentum equations?

Thanks,

mcanoenen
mcanoenen is offline   Reply With Quote

Old   August 22, 2024, 05:25
Default
  #2
New Member
 
Murat Can ONEN
Join Date: Sep 2021
Location: Turkey
Posts: 13
Rep Power: 5
mcanoenen is on a distinguished road
Hello, I want to share an update about my progress

APROACH 1: Deleting second-order velocity gradients from the equations (the basic way)



Based on my understanding, taking the second derivative of the velocity field was not feasible without defining new User-Defined Scalars. Therefore, I reintegrated the viscous terms into the Txx, Txy, and Tyy. This allowed me to incorporate the derivatives of Txx_, Txy_, and Tyy_ into the momentum equations, albeit with a risk to convergence. To ensure convergence, I modified the viscosity using an exponential equation that gradually adjusted the momentum equations, starting from a viscosity of 1 Pa.s and approaching a minimum of 1e-6, as given by exp(-0.01*ITER_N), while maintaining a constant viscosity value within the Txx_, Txy_, and Tyy_ terms. Ultimately, the solution demonstrated satisfactory convergence for both the momentum (velocity residuals) and pressure correction (mass residual) equations.

Code:
DEFINE_SOURCE(momentum_x_source, c, t, dS, eqn)
{
    real source;

    /* Source term for the x-momentum equation */
    source = C_UDSI_G(c, t, Txx)[0] + C_UDSI_G(c, t, Txy)[1]; // x-component of the gradient
    dS[eqn] = 0.0; // Set the derivative of the source term if needed

    return source;
}

DEFINE_SOURCE(momentum_y_source, c, t, dS, eqn)
{
    real source;
 
    /* Source term for the y-momentum equation */
	
    source = C_UDSI_G(c, t, Tyy)[1] + C_UDSI_G(c, t, Txy)[0]; // y-component of the gradient
    dS[eqn] = 0.0; // Set the derivative of the source term if needed
	
    return source;
}
In addition, in the 2D scenario I'm working on, it involves the transport of Txx_, Txy_, and Tyy_ terms. I'm deriving them by defining User-Defined Scalars (UDS) for those three terms. However, in my case the transport equations for these terms do not include diffusion transport, which should be considered zero. Setting it to zero causes the solution to diverge instantly. To ensure convergence, I've adjusted the diffusivity similar to how viscosity is defined in the momentum equation.

Code:
DEFINE_DIFFUSIVITY(artificial_diff, c, t, i)
{
        return fmax(1e-4, pow(2.71, -0.001 * N_ITER));
}

DEFINE_PROPERTY(viscosity, c, t)
{
	return fmax(1e-6, * pow(2.71, -0.001 * N_ITER));
}
mcanoenen.

Last edited by mcanoenen; September 4, 2024 at 07:31.
mcanoenen is offline   Reply With Quote

Old   September 4, 2024, 07:30
Default Second update
  #3
New Member
 
Murat Can ONEN
Join Date: Sep 2021
Location: Turkey
Posts: 13
Rep Power: 5
mcanoenen is on a distinguished road
APPROACH 2) Inclusion of second-order velocity gradient terms with defining new UDSs. (Answer to the query title)

While Approach 1 has given results, I can confirm that the velocity profile lacked the viscous characteristics at the corners of the velocity profile. To avoid this, the second-order terms can be solved with the momentum equation and removed with the source terms as in the original form shared here.

So I have defined the following User Defined Scalars to do this.

Code:
enum                       //defining new UDSs//
{
        DUUDXX,
	DUUDYY,
	DVVDXX,
	DVVDYY
}

DEFINE_EXECUTE_ON_LOADING(define_variables, libname)
{

	Set_User_Scalar_Name(DUUDXX, "DUUDXX");
	Set_User_Scalar_Name(DUUDYY, "DUUDYY");
        Set_User_Scalar_Name(DVVDXX, "DVVDXX");
	Set_User_Scalar_Name(DVVDYY, "DVVDYY");
}
Solve those UDS with 0 flux and 0 diffusivity:

Code:
DEFINE_SOURCE(DUUDYY_source, c, t, dS, eqn)
{
    real source;
    real x[ND_ND];
	
    source = C_UDSI(c, t, DUUDYY) - C_MU_L(c, t) * C_DUDY(c, t);
    dS[eqn] = 1; // Set the derivative of the source term
    return source;
}

DEFINE_SOURCE(DVVDXX_source, c, t, dS, eqn)
{
    real source;
    real x[ND_ND];
	
    source = C_UDSI(c, t, DVVDXX) - C_MU_L(c, t) * C_DVDX(c, t);
    dS[eqn] = 1; // Set the derivative of the source term
    return source;
}

DEFINE_SOURCE(DVVDYY_source, c, t, dS, eqn)
{
    real source;
    real x[ND_ND];
	
    source = C_UDSI(c, t, DVVDYY) - C_MU_L(c, t) * C_DVDY(c, t);
    dS[eqn] = 1; // Set the derivative of the source term
    return source;
}
Add the calculated second-order velocity gradients into the momentum equation:

Code:
DEFINE_SOURCE(momentum_x_source, c, t, dS, eqn)
{
    real source;

    /* Source term for the x-momentum equation */
    source = - C_UDSI_G(c, t, DUUDXX)[0] - C_UDSI_G(c, t, DUUDYY)[1];        // remove second order derivative from x momentum
    dS[eqn] = 0.0; // Set the derivative of the source term if needed

    return source;
}

DEFINE_SOURCE(momentum_y_source, c, t, dS, eqn)
{
    real source;
 
    /* Source term for the y-momentum equation */
	
    source = - C_UDSI_G(c, t, DVVDXX)[0] - C_UDSI_G(c, t, DVVDYY)[1] ;        // remove second order derivative from Y momentum
    dS[eqn] = 0.0; // Set the derivative of the source term if needed
	
    return source;
}
This way I could validate my CFD solution using viscoelastic fluid flow between the parallel plates published in the literature. Hopefully, this might help someone who has been trying to solve viscoelastic flow equations using Fluent software.

Regards,

mcanoenen.
mcanoenen is offline   Reply With Quote

Reply

Tags
fluent, udf, viscoelasticfluid

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
chtMultiRegionFoam solver stops without any error amol_patel OpenFOAM Running, Solving & CFD 4 July 5, 2024 02:41
Modify the momentum equations azizi0407 FLUENT 0 September 12, 2020 03:42
Adding two terms in the momentum equation in in chtMultiRegionSimpleFoam zahraa OpenFOAM Pre-Processing 0 June 13, 2015 13:42
Adding extra terms in governing equations Alek CFX 6 February 10, 2014 13:21
Turbulent terms in the MRF equations Francisco Saldarriaga Main CFD Forum 1 July 22, 1999 17:49


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