|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
zhiyonggao
Join Date: Nov 2025
Posts: 1
Rep Power: 0 ![]() |
I am debugging the DEFIN_DPM_LAW and DEFINE_DPM_SWITCH in the DPM model of Fluent 2022R1. In the DPM model settings, the initial injection temperature of the particles is 310 K. The UDF attached is as follows:
#include "udf.h" #include "dpm.h" #include "math.h" #include "dpm_injections.h" real rho_B(real T_p ) { real Rho_B = 2340.; return Rho_B; } real rho_B2O3(real T_p ) { real Rho_B2O3 = 1850.0; return Rho_B2O3; } DEFINE_DPM_INJECTION_INIT(boron_particle_init, I) { Injection *Ilist = I; Particle *p; loop(p, Ilist->p_init) { real dp0 = TP_DIAM(p); real rho_B_init = rho_B(700.); real rho_B2O3_init = rho_B2O3(700.); real x0 = 2.0e-8; real V_core = M_PI/6.0 * pow(dp0,3.0); real V_oxide = M_PI * dp0 * dp0 * x0; real m_pS0 = rho_B_init * V_core; real m_pD0 = rho_B2O3_init * V_oxide; TP_USER_REAL(p,0) = m_pS0; TP_USER_REAL(p,1) = 0.0; TP_USER_REAL(p,2) = m_pD0; TP_USER_REAL(p,3) = x0; Message("Injection Init: dp=%g, m_pS=%g, m_pD=%g\n", dp0, m_pS0, m_pD0); } } DEFINE_DPM_LAW(B_Law, tp, coupled) { int Law = 0, re = 0; real m_total = 0., dm_ps = 0.,dx_xp = 0.; real m_ps = TP_USER_REAL(tp,0); real m_pl = TP_USER_REAL(tp,1); real m_pd = TP_USER_REAL(tp,2); real x_p = TP_USER_REAL(tp,3); int current_law = TP_CURRENT_LAW(tp); Message("B_Law: T_p=%g, current_law=%d\n", TP_T(tp), current_law); dm_ps = 0.01 * m_ps, dx_xp = 0.01 * x_p; m_ps -= dm_ps, x_p -= dx_xp; m_total = m_ps + m_pl + m_pd; TP_MASS(tp) = m_ps + m_pl + m_pd; TP_T(tp) = TP_T(tp) + 10.; TP_USER_REAL(tp,0) = m_ps; TP_USER_REAL(tp,1) = m_pl; TP_USER_REAL(tp,2) = m_pd; TP_USER_REAL(tp,3) = x_p; TP_USER_REAL(tp,4) = m_total; TP_USER_REAL(tp,5) = TP_MASS(tp); TP_USER_REAL(tp,6) = current_law; } DEFINE_DPM_LAW(B_Law_high, tp, coupled) { int current_law = TP_CURRENT_LAW(tp); Message("B_Law: T_p=%g, current_law=%d\n", TP_T(tp), current_law); real m_total = 0., dm_ps = 0., dx_xp = 0.; real m_ps = TP_USER_REAL(tp,0); real m_pl = TP_USER_REAL(tp,1); real m_pd = TP_USER_REAL(tp,2); real x_p = TP_USER_REAL(tp,3); dm_ps = 0.02 * m_ps; dx_xp = 0.02 * x_p; m_ps -= dm_ps; x_p -= dx_xp; m_total = m_ps + m_pl + m_pd; TP_MASS(tp) = m_total; TP_T(tp) = TP_T(tp) + 15.; TP_USER_REAL(tp,0) = m_ps; TP_USER_REAL(tp,1) = m_pl; TP_USER_REAL(tp,2) = m_pd; TP_USER_REAL(tp,3) = x_p; } DEFINE_DPM_SWITCH(dpm_switch, tp, coupled) { Material *m_p = TP_MATERIAL(tp); real T_p = TP_T(tp); int currentlaw = TP_CURRENT_LAW(tp); Message("dpm_switch:T_p=%g, current_law=%d\n", TP_T(tp), currentlaw); if (T_p >= 600. && T_p < 1000.) { Message("Switching to law 9\n"); return 9; } else { Message("Switching to law 8\n"); return 8; } } DEFINE_DPM_PROPERTY(Density_B, c, t, tp, T) { real T_p = TP_T(tp); return rho_B(T_p); } DEFINE_DPM_PROPERTY(SpecificHeat_particle, c, t, tp, T) { real T_p = TP_T(tp); return cp_B(T_p); } I want to use DEFINE_DPM_LAW(B_Law, tp, coupled) to increase the particle temperature by 10 K each time. Using DEFINE_DPM_LAW(B_Law_high, tp, coupled) to increase the particle temperature by 15 K each time. I also hope to achieve switching between DEFINE_DPM_LAW(B_Law, tp, coupled) and DEFINE_DPM_LAW(B_Law_high, tp, coupled) through the DEFINE_DPM_SWITCH(dpm_switch, tp, coupled) function. However, in the calculation, Fluent console outputs the following information: “Injecting 1 particle parcels with mass 1e-16 dpm_switch:T_p=650, current_law=8 Switching to law 9 B_Law: T_p=650, current_law=8 dpm_switch:T_p=640, current_law=8 Switching to law 9 B_Law: T_p=640, current_law=8” According to the Fluent console output, it seems that when using DEFINE_DPM_LAW, the default TP_CURRENT_LAW=8, and DEFINE_DPM_SWITCH cannot achieve switching between DEFINE_DPM_LAWs. Could anyone please tell me how to implement switching between different custom laws if I want to attach multiple DEFINE_DPM_LAWs at the same time? |
|
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|