|
[Sponsors] |
Use DEFINE_PROPERTY for non reversible temperature density change |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 17, 2022, 08:33 |
Use DEFINE_PROPERTY for non reversible temperature density change
|
#1 |
New Member
Join Date: Oct 2022
Posts: 12
Rep Power: 3 |
hi everyone,
i have to write UDF (unsteady model) for non-reversible changes in material density with temperature using DEFIN_PROPERTIES : If T< Tcr (critical temperature), rho = 5.0 Kg/m3 else If T>= Tcr , rho = 20 Kg/m3 and it keep this values even if the temperatures return below Tcr. what change to make to take into account the non reversible change Thanks in advance DEFINE_PROPERTY(density, c, t) { real rho; real temp; temp = C_T(c, t); C_CENTROID(r,c,t); if(temp<600) { rho=5.0; } else { rho=20.0; } return rho; } |
|
October 18, 2022, 03:13 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
#include "udf.h" DEFINE_INIT(my_init_func,d) { cell_t c; Thread *t; thread_loop_c(t,d) { begin_c_loop_all(c,t) { C_UDMI(c,t,0) = 0; } end_c_loop_all(c,t) } } DEFINE_PROPERTY(density, c, t) { real rho; real temp; temp = C_T(c, t); if (temp<600) && (C_UDMI(c,t,0) < 1) { rho = 5.0; } else { rho = 20.0; C_UDMI(c,t,0) = 1; } return rho; }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 19, 2022, 08:02 |
|
#3 |
New Member
Join Date: Oct 2022
Posts: 12
Rep Power: 3 |
thank you very much for help !
|
|
October 19, 2022, 08:30 |
Vof gradient udf
|
#4 |
New Member
Join Date: Oct 2022
Posts: 12
Rep Power: 3 |
Dear sir, i hope this mail find you good , I am working on a two-phase (gas-liquid) flow problem using the VOF method. I need to calculate the vof gardient (both magnitude and three componants vector) to use them in define source terms, i'm using DEFINE_ADJUST to store vof gradient in UDMIS, but I get errors when interpreting th UDF , : Scalar_Reconstruction undeclared variable; DEFINE_ADJUST(adjust_gradient_heat, domain) { Thread *t; Thread **pt; cell_t c; int phase_domain_index = 1.0; Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index); { Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL); Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL); Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate); } mp_thread_loop_c(t,domain,pt) if (FLUID_THREAD_P(t)) { Thread *ppt = pt[phase_domain_index]; begin_c_loop (c,t) { C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0]; C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1]; C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2]; C_UDMI(c,t,3) = sqrt(C_UDMI(c,t,0)*C_UDMI(c,t,0) + C_UDMI(c,t,1)*C_UDMI(c,t,1) + C_UDMI(c,t,2)*C_UDMI(c,t,2)); // magnitude of gradient of volume fraction C_UDMI(c,t,4) = C_UDMI(c,t,0)/C_UDMI(c,t,3); // nx -> x gradient of volume fraction divided by magnitude of gradient of volume fraction C_UDMI(c,t,5) = C_UDMI(c,t,1)/C_UDMI(c,t,3); // ny -> y gradient of volume fraction divided by magnitude of gradient of volume fraction C_UDMI(c,t,6) = C_UDMI(c,t,2)/C_UDMI(c,t,3); // nz -> z gradient of volume fraction divided by magnitude of gradient of volume fraction } end_c_loop (c,t) } Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL); } |
|
October 20, 2022, 00:01 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
compile code
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 9, 2022, 05:38 |
|
#6 |
New Member
Join Date: Oct 2022
Posts: 12
Rep Power: 3 |
Dear friend, i have quastion , What change i have to make to the UDF if it is a 2 phases VOF problem with air as primary phase and the second material (that undergoes non reversible density change) is the secondary phase. The non reversible change muste ocuure to the seonde phase only not air. thanks in advance.
|
|
November 9, 2022, 05:40 |
|
#7 | |
New Member
Join Date: Oct 2022
Posts: 12
Rep Power: 3 |
Quote:
DEFINE_INIT(my_init_func,d) { cell_t c; Thread *t; thread_loop_c(t,d) { begin_c_loop_all(c,t) { C_UDMI(c,t,0) = 0; } end_c_loop_all(c,t) } } DEFINE_PROPERTY(density, c, t) { real rho; real temp; temp = C_T(c, t); if (temp<600) && (C_UDMI(c,t,0) < 1) { rho = 5.0; } else { rho = 20.0; C_UDMI(c,t,0) = 1; } return rho; } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Averaging over iterations for steady-state simulation | CFD student | Fluent UDF and Scheme Programming | 8 | September 22, 2022 03:39 |
[blockMesh] Unable to change mesh density in blocks | jtipton2 | OpenFOAM Meshing & Mesh Conversion | 4 | July 19, 2019 09:28 |
Change Temperature boundary by a solver (rhoPimpleFoam) | fredo490 | OpenFOAM Programming & Development | 7 | May 15, 2013 11:11 |
density of water as some function of temperature | danish | CFX | 1 | June 24, 2008 12:10 |
Mixing = density change | Paul | Main CFD Forum | 0 | March 1, 2005 07:48 |