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

Use DEFINE_PROPERTY for non reversible temperature density change

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 17, 2022, 08:33
Question Use DEFINE_PROPERTY for non reversible temperature density change
  #1
New Member
 
Join Date: Oct 2022
Posts: 12
Rep Power: 3
cfd_Matrix is on a distinguished road
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;
}
cfd_Matrix is offline   Reply With Quote

Old   October 18, 2022, 03:13
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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;
}
cfd_Matrix likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 19, 2022, 08:02
Default
  #3
New Member
 
Join Date: Oct 2022
Posts: 12
Rep Power: 3
cfd_Matrix is on a distinguished road
thank you very much for help !
cfd_Matrix is offline   Reply With Quote

Old   October 19, 2022, 08:30
Default Vof gradient udf
  #4
New Member
 
Join Date: Oct 2022
Posts: 12
Rep Power: 3
cfd_Matrix is on a distinguished road
Quote:
Originally Posted by cfd_Matrix View Post
thank you very much for help !

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);
}
cfd_Matrix is offline   Reply With Quote

Old   October 20, 2022, 00:01
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile code
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 9, 2022, 05:38
Default
  #6
New Member
 
Join Date: Oct 2022
Posts: 12
Rep Power: 3
cfd_Matrix is on a distinguished road
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.
cfd_Matrix is offline   Reply With Quote

Old   November 9, 2022, 05:40
Default
  #7
New Member
 
Join Date: Oct 2022
Posts: 12
Rep Power: 3
cfd_Matrix is on a distinguished road
Quote:
Originally Posted by cfd_Matrix View Post
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.
#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;
}
cfd_Matrix is offline   Reply With Quote

Reply


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
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


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