|
[Sponsors] |
UDF to Define Temperature Dependent Negative Heat Source |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 9, 2019, 14:06 |
UDF to Define Temperature Dependent Negative Heat Source
|
#1 |
New Member
Amitav tikadar
Join Date: Jul 2017
Location: Atlanta
Posts: 14
Rep Power: 9 |
Hi,
I am trying to calculate the average temperature of interface at each iteration (since I am solving steady state problem) and based on the interface temperature I want to update my negative heat source value (Q_Source=(-constant*(T_Interface-T_Constant))/volume). First, I tried UDM to store interface temperature but didn't work. Then I tried to GLOBAL variable to avoid UDM, but again no luck. I am using ANSYS FLUENT 2019 R2. For both cases, I Interpreted the UDF and during the interpretetion, FLUENT didn't show any error. I have attached my written UDF below. Can someone please help me to fix the problem? Thanks in advance. /*********UDF with UDM**********/ #include "udf.h" /*********INTERFACE TEMPERATURE**************/ DEFINE_EXECUTE_AT_END(average_interface_temp_of_wi ndings_air) { Domain *d; face_t f; real temper = 0.0; real A[ND_ND]; real tsavg=0.0; real area = 0.0; real area_tot = 0.0; int ID = 10; /*this is the ID of the interface that I want to get the temperature from*/ Thread *t; d = Get_Domain(1); t = Lookup_Thread(d,ID); /*We are trying to calculate area weighted average temperature of a surface- as per the definition of area weighted average*/ begin_f_loop(f,t) { F_AREA(A,f,t); /*get face area which is a vector*/ area = NV_MAG(A);/*get magnitude of the face area*/ area_tot += area; /*calculate total area*/ temper = F_T(f,t); /*calculate face temperature*/ tsavg += temper*area; } end_f_loop(f,t) tsavg /= area_tot; printf("Average Interface Temperature = %g\n",tsavg); begin_f_loop(f,t) { F_UDMI(f,t,0) = tsavg; /* User Define Memory */ } end_f_loop(f,t) } /**********NEGATIVE HEAT SOURCE***************/ DEFINE_SOURCE(negative_heat_source,c,t,dS,eqn) { real source; face_t f; source = -5000.*(F_UDMI(f,t,0)-290.); /* For the time being, I have assumed an arbitrary constant for hA and T_Sat */ dS[eqn] = 0.; /* Need to double check. It can be -5000. as a resultant of the derivative of source term */ return source; } /******UDF with Global Variable***********/ #include "udf.h" /*********INTERFACE TEMPERATURE**************/ real tsavg=0; /* Defining Global Variable */ DEFINE_EXECUTE_AT_END(average_interface_temp) { Domain *d; face_t f; /*real tsavg=0;*/ real temper = 0.0; real A[ND_ND]; real area = 0.0; real area_tot = 0.0; int ID = 10; /*this is the ID of the interface that I want to get the temperature from*/ Thread *t; d = Get_Domain(1); t = Lookup_Thread(d,ID); /*We are trying to calculate area weighted average temperature of a surface- as per the definition of area weighted average*/ begin_f_loop(f,t) { F_AREA(A,f,t); /*get face area which is a vector*/ area = NV_MAG(A);/*get magnitude of the face area*/ area_tot += area; /*calculate total area*/ temper = F_T(f,t); /*calculate face temperature*/ tsavg += temper*area; } end_f_loop(f,t) tsavg /= area_tot; printf("Average Interface Temperature = %g\n",tsavg); } /**********NEGATIVE HEAT SOURCE***************/ DEFINE_SOURCE(heat_source,c,t,dS,eqn) { real source; source = -5000.*(tsavg-300.); /* For the time being, I have assumed an arbitrary constant for hA and T_Sat */ dS[eqn] = 0.; /* Need to double check. It can be -5000. as a resultant of the derivative of source term */ return source; } |
|
September 23, 2019, 04:52 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
if you are using 2019R2 -> it means you run your code in parallel, but it was not considered
you have to modify your code: Ansys Fluent Customization manual -> Global Reduction Macros other problem Code:
DEFINE_SOURCE(negative_heat_source,c,t,dS,eqn) { real source; face_t f; source = -5000.*(F_UDMI(f,t,0)-290.); /* For the time being, I have assumed an arbitrary constant for hA and T_Sat */ fix these issues first best regards |
|
Tags |
fluent - udf, udf source, udf source energy |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding temperature dependent heat source using fvOptions in chtMultiRegionSimpleFoam | shaileshbg | OpenFOAM Running, Solving & CFD | 14 | January 26, 2024 19:48 |
[Other] Tabulated thermophysicalProperties library | chriss85 | OpenFOAM Community Contributions | 62 | October 2, 2022 04:50 |
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 | ordinary | OpenFOAM Installation | 19 | September 3, 2019 19:13 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 07:42 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |