|
[Sponsors] |
how to insert a define_property (density)in a define_source |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 17, 2022, 16:44 |
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 |
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 |
|
November 18, 2022, 01:07 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
November 18, 2022, 11:42 |
|
#3 |
New Member
Felipe Benitez Hernandez
Join Date: Oct 2022
Posts: 2
Rep Power: 0 |
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 |
|
November 21, 2022, 00:15 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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; }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
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 |