CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS

Fluent UDF for Radial Motion of Pump Geometry

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 7, 2024, 11:10
Default Fluent UDF for Radial Motion of Pump Geometry
  #1
New Member
 
Syaida
Join Date: Jun 2024
Posts: 1
Rep Power: 0
Syaida21 is on a distinguished road
I'm currently working on a 2D simulation in Fluent that requires me to simulate the radial motion of a pump geometry. To achieve this, I've implemented a UDF (User-Defined Function) for grid motion, which aims to change the radius of the pump geometry over time and return it to its original radius after a specified duration (to replicate inflation and deflation of the balloon pump).

I've encountered an issue where the pump geometry shifts laterally (to the right or left) instead of the intended radial motion. Below is the UDF code I'm using for the grid motion:

#include "udf.h"
#include "math.h"

DEFINE_GRID_MOTION(pump_wall_motion, domain, dt, time, dtime)
{
Domain *d;
Thread *t;
face_t f;
Node *node_p;
real current_time = CURRENT_TIME;
real final_radius = 154.94e-3;
real original_radius = 230.74e-3;
real transition_duration = 2.0; // Duration of the transition in seconds
real transition_speed = (final_radius - original_radius) / transition_duration; // Speed of transition
real center_x = 141.05; // X-coordinate of the pump center
real center_y = 5.0; // Y-coordinate of the pump center
int n;

// Calculate the new radius based on the linear transition
real new_radius;
if (current_time < transition_duration) {
new_radius = original_radius + transition_speed * current_time;
} else {
new_radius = final_radius;
}

// Get the domain and thread
d = Get_Domain(1);
t = Lookup_Thread(d, 9);

// Iterate over all faces in the thread
begin_f_loop(f, t)
{
f_node_loop(f, t, n)
{
node_p = F_NODE(f, t, n);
if (NODE_POS_NEED_UPDATE(node_p))
{
NODE_POS_UPDATED(node_p);

// Get current coordinates relative to the center
real x = NODE_X(node_p) - center_x;
real y = NODE_Y(node_p) - center_y;

// Calculate the distance from the center
real distance = sqrt(x * x + y * y);

// Prevent division by zero for nodes exactly at the center
if (distance > 1e-6)
{
// Calculate the scale factor based on the new radius
real scale_factor = new_radius / original_radius;

// Calculate the new position
real new_x = center_x + x * scale_factor;
real new_y = center_y + y * scale_factor;

// Update node positions relative to the center
NODE_X(node_p) = new_x;
NODE_Y(node_p) = new_y;
}
}
}
}
end_f_loop(f, t);
}

I've already tried verifying the centre coordinates, thread selection, boundary conditions, and mesh quality, but the lateral motion issue persists. Any insights or suggestions on resolving this issue would be greatly appreciated. Thank you!
Attached Images
File Type: jpg Fontan with pump.jpg (50.4 KB, 6 views)
File Type: jpg before.jpg (35.5 KB, 6 views)
File Type: jpg after.jpg (33.7 KB, 6 views)
Syaida21 is offline   Reply With Quote

Reply

Tags
pump simulation, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Fluent UDF Mesh Motion Issue: Blade Pitch w/ Respect to Azimuth Angle recmvp Fluent UDF and Scheme Programming 0 July 30, 2023 16:50
Specifying Mesh Deformation & Rigid Body Motion on a Cell Zone Using UDF zx9cp Fluent UDF and Scheme Programming 3 July 11, 2023 06:14
Error: WorkBench Error: Could not handle event: SolutionStatusUpdate Kieyo Fluent Multiphase 0 November 10, 2022 00:58
Define grid motion udf issue: Wing geometry breaks down with time tev_lev Fluent UDF and Scheme Programming 0 June 1, 2022 12:22
Zone motion udf error in Fluent Sigurd Fluent UDF and Scheme Programming 9 November 30, 2020 03:34


All times are GMT -4. The time now is 13:40.