|
[Sponsors] |
Error while trying to run a UDF for drag coefficient |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Join Date: Jun 2024
Posts: 2
Rep Power: 0 ![]() |
Hello,
I'm a new user in ANSYS-FLUENT and I'm working in a quite simple Eulerian Multiphase model with liquid as the primary phase and vapour as the secondary dispersed one. I'm trying to implement an UDF in order to model drag coefficient using the AIAD model, for which I need to acces to the Liquid Volume Fraction Gradient. The error I am getting is attached below. As I understand this error means there is a segmentation fault, and it may be caused because I am trying to access gradient of volume fraction, but I am not really sure. Some help with this will be greatly appreciated. The UDF Script is written as follows: #include"udf.h" #include"sg_mphase.h" #defineALPHA_B_LIM0.3 /* Bubble limit volume fraction */ #defineALPHA_D_LIM0.3 /* Droplet limit volume fraction */ #defineCD_BUBBLE0.44 /* Drag coefficient for bubble regime */ #defineCD_DROPLET0.44 /* Drag coefficient for droplet regime */ #definea_B70.0 /* Blending function coefficient */ #definea_D70.0 /* Blending function coefficient */ #defined_B0.0001 /* Bubble diameter (m) */ #defined_D0.0001 /* Droplet diameter (m) */ DEFINE_EXCHANGE_PROPERTY(aiad_drag_force, cell, mix_thread, second_column_phase_index, first_column_phase_index) { Thread *prim_th, *sec_th; real drag_force=0.0; real alpha_prim, alpha_sec; real A_B, A_D, A_fs; real f_b, f_d, f_fs; real C_D, C_Dfs, A; real rho_prim, rho_sec, rho_iv; real mu_prim, mu_sec; real u_prim, u_sec, v_prim, v_sec, w_prim, w_sec; real rel_vel_mag; real tau_prim, tau_sec; real grad_alphal_x, grad_alphal_y, grad_alphal_z; real grad_alphav_x, grad_alphav_y, grad_alphav_z; prim_th =THREAD_SUB_THREAD(mix_thread, first_column_phase_index); sec_th =THREAD_SUB_THREAD(mix_thread, second_column_phase_index); alpha_prim=C_VOF(cell, prim_th); alpha_sec=C_VOF(cell, sec_th); rho_prim=C_R(cell, prim_th); rho_sec=C_R(cell, sec_th); rho_iv=alpha_prim*rho_prim+alpha_sec*rho_sec; mu_prim=C_MU_L(cell, prim_th); mu_sec=C_MU_L(cell, sec_th); u_prim=C_U(cell, prim_th); v_prim=C_V(cell, prim_th); w_prim=C_W(cell, prim_th); u_sec=C_U(cell, sec_th); v_sec=C_V(cell, sec_th); w_sec=C_W(cell, sec_th); rel_vel_mag=sqrt(pow(u_prim-u_sec, 2) + pow(v_prim-v_sec, 2) + pow(w_prim-w_sec, 2)); A_B=6.0*alpha_sec/d_B; A_D=6.0*alpha_prim/d_D; f_b=1.0/ (1.0+exp(a_B* (alpha_sec-ALPHA_B_LIM))); f_d=1.0/ (1.0+exp(a_D* (alpha_prim-ALPHA_D_LIM))); f_fs=1.0-f_b-f_d; grad_alphav_x=C_VOF_G(cell, sec_th)[0]; grad_alphav_y=C_VOF_G(cell, sec_th)[1]; grad_alphav_z=C_VOF_G(cell, sec_th)[2]; grad_alphal_x=-grad_alphav_x; grad_alphal_y=-grad_alphav_y; grad_alphal_z=-grad_alphav_z; A_fs=sqrt(grad_alphal_x*grad_alphal_x+ grad_alphal_y*grad_alphal_y+ grad_alphal_z*grad_alphal_z); if (A_fs<1e-10) A_fs=1e-10; tau_prim=mu_prim*sqrt(pow(C_DUDX(cell, prim_th)*grad_alphal_x/A_fs, 2) + pow(C_DVDY(cell, prim_th)*grad_alphal_y/A_fs, 2) + pow(C_DWDZ(cell, prim_th)*grad_alphal_z/A_fs, 2)); tau_sec=mu_sec*sqrt(pow(C_DUDX(cell, sec_th)*grad_alphav_x/A_fs, 2) + pow(C_DVDY(cell, sec_th)*grad_alphav_y/A_fs, 2) + pow(C_DWDZ(cell, sec_th)*grad_alphav_z/A_fs, 2)); if (rel_vel_mag<1e-10) rel_vel_mag=1e-10; /* avoid division by zero */ C_Dfs=2.0* (alpha_prim*tau_prim+alpha_sec*tau_sec) / (rho_iv*rel_vel_mag*rel_vel_mag); /* Combined drag coefficient */ C_D=f_fs*C_Dfs+f_b*CD_BUBBLE+f_d*CD_DROPLET; return C_D; } |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to run a simple Fluent UDF | Rcfd1 | Fluent UDF and Scheme Programming | 5 | March 7, 2025 04:39 |
The UDF of Heat Transfer Coefficient In TFM | Dinghc | Fluent UDF and Scheme Programming | 0 | August 14, 2023 21:51 |
How to find heat transfer coefficient using UDF in internal turbulent flow | YHH0123 | Fluent UDF and Scheme Programming | 0 | December 5, 2022 00:35 |
UDF : Lift coefficient time history and Data sampling | Bibill | Fluent UDF and Scheme Programming | 9 | June 5, 2020 06:31 |
Lift coefficient UDF | peaker007 | Fluent UDF and Scheme Programming | 0 | November 24, 2011 22:10 |