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

UDF_ implement under relaxation factor

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 14, 2020, 10:20
Talking UDF_ implement under relaxation factor
  #1
New Member
 
Join Date: Oct 2020
Posts: 5
Rep Power: 5
LEE CHENG is on a distinguished road
Hello, everyone.
The UDF is used to calculate the slip velocity. In order to make the case easier to converge, the under relaxation factor is added to the UDF code.
The code before adding the under relaxation factor is:
slip = Coeff1[1] * Ls*slip;
The code after adding the relaxation factor is:
slip = (1-underrelaxfactor) *u[1] + underrelaxfactor * Coeff1[1] * Ls*slip;
underrelaxfactor=0.01.
Before I changed the code, changing the value of Ls gave me a different result, but after I changed the code, changing the value of Ls seemed to have no effect on the result of the calculation.
Do I need to add any other Settings in FLUENT or code?I hope the experts can give me some advice. Thank you.
LEE CHENG is offline   Reply With Quote

Old   October 19, 2020, 10:15
Default
  #2
New Member
 
Join Date: Oct 2020
Posts: 5
Rep Power: 5
LEE CHENG is on a distinguished road
Quote:
Originally Posted by LEE CHENG View Post
Hello, everyone.
The UDF is used to calculate the slip velocity. In order to make the case easier to converge, the under relaxation factor is added to the UDF code.
The code before adding the under relaxation factor is:
slip = Coeff1[1] * Ls*slip;
The code after adding the relaxation factor is:
slip = (1-underrelaxfactor) *u[1] + underrelaxfactor * Coeff1[1] * Ls*slip;
underrelaxfactor=0.01.
Before I changed the code, changing the value of Ls gave me a different result, but after I changed the code, changing the value of Ls seemed to have no effect on the result of the calculation.
Do I need to add any other Settings in FLUENT or code?I hope the experts can give me some advice. Thank you.
Thank you in advance for your help
LEE CHENG is offline   Reply With Quote

Old   October 19, 2020, 10:50
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I can not really follow what you are doing, or trying to ask. You also only put one line of code, where is the rest of the UDF? How do you attach it? Why don't you just use the built-in slip? Too many questions.
pakk is offline   Reply With Quote

Old   October 26, 2020, 08:18
Default
  #4
New Member
 
Join Date: Oct 2020
Posts: 5
Rep Power: 5
LEE CHENG is on a distinguished road
I want to calculate the wall slip velocity according to the wall velocity gradient and return it to FLUENT.But if I change the value of Ls it doesn't seem to change.Here's my code:
#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "math.h"
void coord_coeff(Thread *f_thread)
{
face_t face;
cell_t cell;
Thread *c_thread;
real y[ND_ND];
real u[ND_ND], a;
real B[ND_ND], b;
real A[ND_ND];
real dr0[ND_ND], es[ND_ND], ds, A_by_es;
begin_f_loop(face, f_thread)
{
F_CENTROID(y, face, f_thread);
cell = F_C0(face, f_thread);
c_thread = THREAD_T0(f_thread);

BOUNDARY_FACE_GEOMETRY(face, f_thread, A, ds, es, A_by_es, dr0);
ND_SET(u[0], u[1], u[2], C_U(cell, c_thread), C_V(cell, c_thread), C_W(cell, c_thread));
a = NV_MAG(u);
NV_CROSS(B, u, A);
b = NV_MAG(B);
ND_SET(F_UDMI(face, f_thread, 0), F_UDMI(face, f_thread, 1), F_UDMI(face, f_thread, 2), NVD_DOT(u, 1, 0, 0) / a, NVD_DOT(u, 0, 1, 0) / a, NVD_DOT(u, 0, 0, 1) / a);
ND_SET(F_UDMI(face, f_thread, 3), F_UDMI(face, f_thread, 4), F_UDMI(face, f_thread, 5), NVD_DOT(A, 1, 0, 0) / A_by_es, NVD_DOT(A, 0, 1, 0) / A_by_es, NVD_DOT(A, 0, 0, 1) / A_by_es);
ND_SET(F_UDMI(face, f_thread, 6), F_UDMI(face, f_thread, 7), F_UDMI(face, f_thread, 8), NVD_DOT(B, 1, 0, 0) / b, NVD_DOT(B, 0, 1, 0) / b, NVD_DOT(B, 0, 0, 1) / b);
}
end_f_loop(face, f_thread)
}
DEFINE_PROFILE(slip_velocity_x, f_thread, index)
{
face_t face;
cell_t cell;
Thread *c_thread;
real normal_slip, tangential_slip,k_slip;
real slip;
real Ls=0.00005;
real underrelaxfactor=0.01;
real Coeff1[ND_ND], Coeff2[ND_ND], Coeff3[ND_ND];
real u[ND_ND];

coord_coeff(f_thread);

if (Data_Valid_P())
{
begin_f_loop(face, f_thread)
{
cell = F_C0(face, f_thread);
c_thread = THREAD_T0(f_thread);
ND_SET(u[0], u[1], u[2], F_U(face, c_thread), F_V(face, c_thread), F_W(face, c_thread));
ND_SET(Coeff1[0], Coeff1[1], Coeff1[2], F_UDMI(face, f_thread, 0), F_UDMI(face, f_thread, 1), F_UDMI(face, f_thread, 2));
ND_SET(Coeff2[0], Coeff2[1], Coeff2[2], F_UDMI(face, f_thread, 3), F_UDMI(face, f_thread, 4), F_UDMI(face, f_thread, 5));
ND_SET(Coeff3[0], Coeff3[1], Coeff3[2], F_UDMI(face, f_thread, 6), F_UDMI(face, f_thread, 7), F_UDMI(face, f_thread, 8));
normal_slip = -1*NVD_DOT(Coeff1, NV_DOT(Coeff2, C_U_G(cell, c_thread)), NV_DOT(Coeff2, C_V_G(cell, c_thread)), NV_DOT(Coeff2, C_W_G(cell, c_thread)));
tangential_slip= NVD_DOT(Coeff1, NV_DOT(Coeff1, C_U_G(cell, c_thread)), NV_DOT(Coeff1, C_V_G(cell, c_thread)), NV_DOT(Coeff1, C_W_G(cell, c_thread)));
k_slip= NVD_DOT(Coeff1, NV_DOT(Coeff3, C_U_G(cell, c_thread)), NV_DOT(Coeff3, C_V_G(cell, c_thread)), NV_DOT(Coeff3, C_W_G(cell, c_thread)));
slip = Ls*normal_slip;
slip = (1-underrelaxfactor) *u[0] + underrelaxfactor * Coeff1[0] * slip;

F_PROFILE(face, f_thread, index) = slip;
}
end_f_loop(face, f_thread)
}
Before I add this line of code(slip = (1-underrelaxfactor) *u[0] + underrelaxfactor * Coeff1[0] * slip, it's going to change with Ls.
Please take a look. Is there any problem in my code that I have ignored?Thank you very much!
LEE CHENG is offline   Reply With Quote

Old   October 26, 2020, 08:43
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
In your initial question, you wrote
Code:
slip = (1-underrelaxfactor) *u[1] + underrelaxfactor * Coeff1[1] * Ls*slip;
As far as I see, this should just work.
But in the code, you wrote:
Code:
slip = (1-underrelaxfactor) *u[0] + underrelaxfactor * Coeff1[0] * slip;
This is not the same. There is no "Ls" anymore in this line, so that is why your results don't depend on it anymore.
pakk is offline   Reply With Quote

Old   October 26, 2020, 09:44
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Still, I hope you are aware that Fluent already has built-in slip. If you just want to add to slip to your model, you don't need UDFs, just select the option.

If you are already aware, I put it here for other people who just want to use slip: don't use any UDF, just select the low-pressure boundary slip!
pakk is offline   Reply With Quote

Old   October 26, 2020, 09:54
Default
  #7
New Member
 
Join Date: Oct 2020
Posts: 5
Rep Power: 5
LEE CHENG is on a distinguished road
Thank you.Pakk.
I want the wall slip velocity to vary with the velocity gradient.
LEE CHENG is offline   Reply With Quote

Old   October 26, 2020, 19:42
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Then I repeat again: Fluent has a built-in functionality for slip. Search for "low-pressure boundary slip". It might just do exactly what you want, no UDF required.
pakk is offline   Reply With Quote

Old   January 9, 2021, 03:15
Default
  #9
New Member
 
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5
zhangdongjie is on a distinguished road
Quote:
Originally Posted by pakk View Post
Then I repeat again: Fluent has a built-in functionality for slip. Search for "low-pressure boundary slip". It might just do exactly what you want, no UDF required.
thanks for your replay。but Low pressure boundary slip only works in 3D. How can I open this button in 2D?
zhangdongjie is offline   Reply With Quote

Old   January 9, 2021, 03:23
Default
  #10
New Member
 
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5
zhangdongjie is on a distinguished road
Quote:
Originally Posted by LEE CHENG View Post
Hello, everyone.
The UDF is used to calculate the slip velocity. In order to make the case easier to converge, the under relaxation factor is added to the UDF code.
The code before adding the under relaxation factor is:
slip = Coeff1[1] * Ls*slip;
The code after adding the relaxation factor is:
slip = (1-underrelaxfactor) *u[1] + underrelaxfactor * Coeff1[1] * Ls*slip;
underrelaxfactor=0.01.
Before I changed the code, changing the value of Ls gave me a different result, but after I changed the code, changing the value of Ls seemed to have no effect on the result of the calculation.
Do I need to add any other Settings in FLUENT or code?I hope the experts can give me some advice. Thank you.
I'm simulating a nozzle with rarefied gas. Its kn number is very large. First order slip and temperature jump must be added. I use Maxwell slip equation to write UDF, but I don't know where UDF should be loaded. I look up the data. The sliding speed can be loaded into the shear stress, so where is the temperature jump loaded? Is it loaded directly into the wall temperature?
zhangdongjie is offline   Reply With Quote

Old   January 10, 2021, 01:58
Default
  #11
New Member
 
Join Date: Oct 2020
Posts: 5
Rep Power: 5
LEE CHENG is on a distinguished road
I think our UDFs should be similar, and maybe we can learn from each other and share our UDF.
LEE CHENG is offline   Reply With Quote

Old   January 11, 2021, 00:56
Default
  #12
New Member
 
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5
zhangdongjie is on a distinguished road
Quote:
Originally Posted by LEE CHENG View Post
I think our UDFs should be similar, and maybe we can learn from each other and share our UDF.
haode,xiongdi,wodeQQ1248385182
zhangdongjie is offline   Reply With Quote

Old   January 20, 2021, 04:59
Default
  #13
New Member
 
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5
zhangdongjie is on a distinguished road
Quote:
Originally Posted by LEE CHENG View Post
I think our UDFs should be similar, and maybe we can learn from each other and share our UDF.
Hello, can you talk to each other? 1248385182@qq.com
zhangdongjie is offline   Reply With Quote

Reply

Tags
udf, under relaxation factor


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
what is under relaxation factor? rayy FLUENT 30 September 6, 2020 01:06
Question on Convective augmentation factor (UDF) ASDzxc FLUENT 3 June 5, 2020 12:46
How to choose relaxation factor for pressure solver mushtime OpenFOAM Running, Solving & CFD 0 June 24, 2016 11:51
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 07:26
under relaxation factor taw Main CFD Forum 0 February 19, 2010 07:08


All times are GMT -4. The time now is 09:57.