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

how to insert a define_property (density)in a define_source

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 17, 2022, 16:44
Question how to insert a define_property (density)in a define_source
  #1
New Member
 
Felipe Benitez Hernandez
Join Date: Oct 2022
Posts: 2
Rep Power: 0
felipe2308 is on a distinguished road
Hello everyone.
I am currently working on a porous zone problem. I want to ask for help on how to write a UDF for an energy source term that depends on a density that is also calculated with a UDF.
This depends on a temperature change having a reference temperature of 270 k and using a T (c,t) and the passage of time (t)
The function would look like this:
source=rho*CP* ∆T/∆t

I would greatly appreciate your help. I am new to C programming language and creating UDFs
felipe2308 is offline   Reply With Quote

Old   November 18, 2022, 01:07
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
use both define_property and define_source macros in udf
inside define_property define density dependence
inside define_source use this source=rho*CP* ∆T/∆t
__________________
best regards


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

Old   November 18, 2022, 11:42
Default
  #3
New Member
 
Felipe Benitez Hernandez
Join Date: Oct 2022
Posts: 2
Rep Power: 0
felipe2308 is on a distinguished road
I have this udf but I don't know if it is correctly defined.
I can interpret it but when I solve it i get an error

CODE:
#include "udf.h"

DEFINE_PROPERTY (cell_density,c,t)
{
Thread *t;
cell_t c;
real rho;
real temp = C_T (c,t);
if (temp <=295 && temp>=270)
rho = (-708.84*(temp*temp)) + (9666.4*temp) + 2e+06;
else
rho = (5746.4*(temp*temp)) - (61528*temp) + 1e+06;
return rho;
C_UDMI (c,t,0) = rho;
}

DEFINE_SOURCE (energy_source, c, t, dS, eqn)
{
real source;
real T = CURRENT_TIME;
real tempref = 270;
real temp = C_T (c,t);
source = C_UDMI (c,t,0)*((temp-tempref)/(T));
dS[eqn] = 0;
return source;
}

error:
Error: received a fatal signal (Segmentation fault).
Error Object: #f

Thanks for your help
best regards
felipe2308 is offline   Reply With Quote

Old   November 21, 2022, 00:15
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
For future:
compile code (not interpret) and read log, fix errors

Code:
#include "udf.h" 

DEFINE_PROPERTY(cell_density,c,t)
{
real rho,temp;
temp = C_T(c,t);
if (temp <=295 && temp>=270)
rho = (-708.84*(temp*temp)) + (9666.4*temp) + 2E06;
else
rho = (5746.4*(temp*temp)) - (61528*temp) + 1E06;
return rho;
}

DEFINE_SOURCE(energy_source, c, t, dS, eqn)
{
real source,T,temp,tempref;
T = CURRENT_TIME;
tempref = 270;
temp = C_T (c,t);
source = C_R(c,t)*((temp-tempref)/(T));
dS[eqn] = 0;
return source;
}
felipe2308 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
Insert particle tracking Dshing CFX 2 May 20, 2019 04:57
[Other] How to Create and mesh a pipe with a porous tube insert mizzou OpenFOAM Meshing & Mesh Conversion 0 June 6, 2017 23:38
Insert Points in CFD-Post Supersonic ANSYS 3 August 26, 2016 02:45
3D Insert modelling in Mold Flow Dan Rößler Main CFD Forum 0 December 20, 2005 07:37


All times are GMT -4. The time now is 12:23.