
[Sponsors] 
Adding excess stress terms into the momentum equations 

LinkBack  Thread Tools  Search this Thread  Display Modes 
August 20, 2024, 10:24 
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 
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 xmomentum 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; } Thanks, mcanoenen 

August 22, 2024, 05:25 

#2 
New Member
Murat Can ONEN
Join Date: Sep 2021
Location: Turkey
Posts: 13
Rep Power: 5 
Hello, I want to share an update about my progress
APROACH 1: Deleting secondorder 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 UserDefined 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 1e6, 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 xmomentum equation */ source = C_UDSI_G(c, t, Txx)[0] + C_UDSI_G(c, t, Txy)[1]; // xcomponent 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 ymomentum equation */ source = C_UDSI_G(c, t, Tyy)[1] + C_UDSI_G(c, t, Txy)[0]; // ycomponent of the gradient dS[eqn] = 0.0; // Set the derivative of the source term if needed return source; } Code:
DEFINE_DIFFUSIVITY(artificial_diff, c, t, i) { return fmax(1e4, pow(2.71, 0.001 * N_ITER)); } DEFINE_PROPERTY(viscosity, c, t) { return fmax(1e6, * pow(2.71, 0.001 * N_ITER)); } Last edited by mcanoenen; September 4, 2024 at 07:31. 

September 4, 2024, 07:30 
Second update

#3 
New Member
Murat Can ONEN
Join Date: Sep 2021
Location: Turkey
Posts: 13
Rep Power: 5 
APPROACH 2) Inclusion of secondorder 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 secondorder 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"); } 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; } Code:
DEFINE_SOURCE(momentum_x_source, c, t, dS, eqn) { real source; /* Source term for the xmomentum 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 ymomentum 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; } Regards, mcanoenen. 

Tags 
fluent, udf, viscoelasticfluid 
Thread Tools  Search this Thread 
Display Modes  


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