|
[Sponsors] |
October 14, 2020, 11:20 |
UDF_ implement under relaxation factor
|
#1 |
New Member
Join Date: Oct 2020
Posts: 5
Rep Power: 6 |
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. |
|
October 19, 2020, 11:15 |
|
#2 | |
New Member
Join Date: Oct 2020
Posts: 5
Rep Power: 6 |
Quote:
|
||
October 19, 2020, 11:50 |
|
#3 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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.
|
|
October 26, 2020, 09:18 |
|
#4 |
New Member
Join Date: Oct 2020
Posts: 5
Rep Power: 6 |
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! |
|
October 26, 2020, 09:43 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
In your initial question, you wrote
Code:
slip = (1-underrelaxfactor) *u[1] + underrelaxfactor * Coeff1[1] * Ls*slip; But in the code, you wrote: Code:
slip = (1-underrelaxfactor) *u[0] + underrelaxfactor * Coeff1[0] * slip; |
|
October 26, 2020, 10:44 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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! |
|
October 26, 2020, 10:54 |
|
#7 |
New Member
Join Date: Oct 2020
Posts: 5
Rep Power: 6 |
Thank you.Pakk.
I want the wall slip velocity to vary with the velocity gradient. |
|
October 26, 2020, 20:42 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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.
|
|
January 9, 2021, 04:15 |
|
#9 |
New Member
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
thanks for your replay。but Low pressure boundary slip only works in 3D. How can I open this button in 2D?
|
|
January 9, 2021, 04:23 |
|
#10 | |
New Member
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
|
||
January 10, 2021, 02:58 |
|
#11 |
New Member
Join Date: Oct 2020
Posts: 5
Rep Power: 6 |
I think our UDFs should be similar, and maybe we can learn from each other and share our UDF.
|
|
January 11, 2021, 01:56 |
|
#12 |
New Member
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
||
January 20, 2021, 05:59 |
|
#13 | |
New Member
zhangdongjie
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
|
||
Tags |
udf, under relaxation factor |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
what is under relaxation factor? | rayy | FLUENT | 30 | September 6, 2020 02:06 |
Question on Convective augmentation factor (UDF) | ASDzxc | FLUENT | 3 | June 5, 2020 13:46 |
How to choose relaxation factor for pressure solver | mushtime | OpenFOAM Running, Solving & CFD | 0 | June 24, 2016 12:51 |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
under relaxation factor | taw | Main CFD Forum | 0 | February 19, 2010 08:08 |