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

UDF error. Re: varying flow rate based on temperature

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2024, 17:15
Smile UDF error. Re: varying flow rate based on temperature
  #1
New Member
 
VIVEK SAXENA
Join Date: Apr 2024
Posts: 1
Rep Power: 0
vivek1441 is on a distinguished road
Dear community,

I am trying to 3D model a hybrid cooling system based on a liquid-cooled plate consisting of phase change material (PCM). The cold plate has one cooling channel surrounded by PCM. On passing between the PCM domain, the cooling channel divides the PCM region into two domains. A heat flux condition exits on one of the large faces of the cold plate.

I want to write a UDF to control the inlet coolant velocity so that it activates the coolant flow by 0.2m/s only when the average temperature of the PCM domain reaches above 305K, and the flow stops as soon as the average temperature decreases below 305K.


Here is the UDF:


#include "udf.h"


real calculate_average_temp(Domain *domain, int domain_id) {
Thread *t = Lookup_Thread(domain, domain_id);
cell_t c;
real total_temp = 0.0;
int total_cells = 0;


begin_c_loop(c, t) {
total_temp += C_T(c, t);
total_cells++;
} end_c_loop(c, t)

if (total_cells > 0) {
return total_temp / total_cells;
}
}



DEFINE_EXECUTE_AT_END(control_coolant_flow) {
Domain *domain = Get_Domain(58); // Use the correct fluid domain ID if different
Thread *inlet_thread;
face_t f;
real avg_temp1, avg_temp2, overall_avg_temp;


int pcm_domain_id1 = 55; // first PCM domain ID
int pcm_domain_id2 = 56; // second PCM domain ID
int inlet_thread_id = 88; // coolant inlet thread ID


avg_temp1 = calculate_average_temp(domain, pcm_domain_id1);
avg_temp2 = calculate_average_temp(domain, pcm_domain_id2);


overall_avg_temp = (avg_temp1 + avg_temp2) / 2.0;

inlet_thread = Lookup_Thread(domain, inlet_thread_id);


if (overall_avg_temp >= 305.5) {
begin_f_loop(f, inlet_thread) {
F_PROFILE(f, inlet_thread, 0) = 0.2;
} end_f_loop(f, inlet_thread)
} else {
begin_f_loop(f, inlet_thread) {
F_PROFILE(f, inlet_thread, 0) = 0.0;
} end_f_loop(f, inlet_thread)
}
}



As soon as I load the UDF and initialize it, I get a segmentation fault error and fluent crashes. Please suggest how to eliminate the problem.
vivek1441 is offline   Reply With Quote

Reply

Tags
#coldplate, #fluent, #udf, #velocity


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
Decreased Mass Flow Rate for Same Gometry with Increased Temperature? yanqoue CFX 1 November 13, 2019 17:21
Number of particles based on mass flow rate in DPM Saptarshi Fluent Multiphase 1 May 24, 2018 09:49
UDF to return assigned gauge pressure to a BC + mass flow rate Tarantino Fluent UDF and Scheme Programming 1 September 28, 2017 20:06
Please help (an UDF for regulating the mass flow rate) swidi Fluent UDF and Scheme Programming 2 July 30, 2015 13:32
volume flow rate error in udf jjchristophe Fluent UDF and Scheme Programming 1 July 13, 2010 05:23


All times are GMT -4. The time now is 03:58.