-
-
February 18, 2025 at 5:17 am
Sravan B
SubscriberHello
I am doing battery simulation using MSMD NTGK battery model cooled by PCM and liquid cooling. For liquid cooling, delayed inlet boundary conditions supply liquid when a certain amount of PCM is melted down. So I'm using UDf to apply delayed inlet velocity boundary condition. Here is the UDF:
#include "udf.h"
// Parallel-safe UDF for delayed inlet velocity based on PCM liquid fraction
DEFINE_PROFILE(delayed_inlet_velocity, thread, position)
{
Domain *d;
Thread *pcm_thread;
cell_t c;
real liquid_fraction = 0.0;
real sum_liquid_fraction = 0.0;
int cell_count = 0;
// Get the domain
d = Get_Domain(1); // Adjust domain ID if needed
// Identify PCM zone/thread using the correct ID
int pcm_zone_id = 11; // Update with your PCM zone ID
pcm_thread = Lookup_Thread(d, pcm_zone_id);
// Calculate average liquid fraction in the PCM region
begin_c_loop_int(c, pcm_thread)
{
liquid_fraction = C_LIQF(c, pcm_thread); // Get PCM liquid fraction
sum_liquid_fraction += liquid_fraction;
cell_count++;
}
end_c_loop_int(c, pcm_thread)
// Calculate the average liquid fraction
real avg_liquid_fraction = (cell_count > 0) ? (sum_liquid_fraction / cell_count) : 0.0;
// Apply velocity condition based on liquid fraction threshold
face_t f;
begin_f_loop_int(f, thread)
{
if (avg_liquid_fraction >= 0.3)
F_PROFILE(f, thread, position) = 1.0; // Set inlet velocity to 1 m/s
else
F_PROFILE(f, thread, position) = 0.0; // Delay cooling (velocity = 0)
}
end_f_loop_int(f, thread)
Message("Average PCM liquid fraction: %f\n", avg_liquid_fraction);
}
I have attached an error picture that I got when I did hybrid initialization. -
February 18, 2025 at 11:19 am
Rob
Forum ModeratorSIGSEV tends to mean Fluent is expecting a value that isn't passed to it. So, it's likely your UDF is looking for data that doesn't exist.Â
Have a look at Expressions using Reports: that may be an easier option than writing a UDF.Â
-
- You must be logged in to reply to this topic.
-
6520
-
1906
-
1463
-
1310
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.