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

UDF for pulsatile flow

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2019, 07:56
Post UDF for pulsatile flow
  #1
New Member
 
Cristian Schwatz
Join Date: Mar 2019
Posts: 8
Rep Power: 7
Cschwatz is on a distinguished road
Hello CFD wizards,

I've been trying for the past days to develop an UDF that provides a pulsatile behaviour for an inlet flow. This pulsatile behaviour tries to simulate the same behaviour seen in a heartbeat, which is a flow rate/velocity that varies over time due to contractions and relaxations of the heart over a cardiac cycle.
Basically, what I've done is a regression of the data that I've obtained from an article and separated them in a few polynomial functions, since it would've been quite complicated to get the pulsatile behaviour in just a single polynomial function.

When I compile the UDF, the velocity presents a constant behaviour, not following what is expected.
Also, is there any way that I could make a loop for this UDF, so I just update the time and pull a specific function for that time? Given that these functions will repeat themselves every cardiac cycle.

Thanks in advance!

The UDF that I have, so far, is as follows:

#include "udf.h"
DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
real t = CURRENT_TIMESTEP;

begin_f_loop(f, thread)
{


if (t>=0.0 && t<= 0.128)
{
F_PROFILE(f, thread, position) = -122.25*pow(t, 3) + 25.689*pow(t, 2) - 0.1683*t + 0.0701;
}

else if (t> 0.128 && t<= 0.186)

{
F_PROFILE(f, thread, position) = 170.88*pow(t, 3) - 74.116*pow(t, 2) + 10.038*t - 0.2159;
}

else if (t> 0.186 && t<0.261)

{
F_PROFILE(f, thread, position) = -10.052*pow(t, 3) + 5.9452*pow(t, 2) - 0.09495*t + 0.2198;
}

else if (t >= 0.261 && t<0.388)

{
F_PROFILE(f, thread, position) = 41.661*pow(t, 3) - 43.059*pow(t, 2) + 14.028*t - 1.2703;
}

else if (t >= 0.388 && t < 0.468)

{
F_PROFILE(f, thread, position) = -59.067*pow(t, 3) + 77.805*pow(t, 2) - 33.944*t + 5.0295;
}

else if (t >= 0.468 && t < 0.687)

{
F_PROFILE(f, thread, position) = 6.8298*pow(t, 3) - 12.125*pow(t, 2) + 6.8967*t - 1.1411;
}

else if (t>=0.687 && t<1.0)

{
F_PROFILE(f, thread, position) = 1.8829*pow(t, 3) - 5.1168*pow(t, 2) + 4.523*t - 1.2208;
}

}
end_f_loop(f, thread)
}
Cschwatz is offline   Reply With Quote

Old   March 28, 2019, 20:48
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"
DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
real t;
t = RP_Get_Real("flow-time");

begin_f_loop(f, thread)
{

t =  fmod(t, 1.0);

if (t>=0.0 && t<= 0.128)
{	
F_PROFILE(f, thread, position) = -122.25*pow(t, 3) + 25.689*pow(t, 2) - 0.1683*t + 0.0701;
}

else if (t> 0.128 && t<= 0.186)

{	
F_PROFILE(f, thread, position) = 170.88*pow(t, 3) - 74.116*pow(t, 2) + 10.038*t - 0.2159;
}

else if (t> 0.186 && t<0.261)

{ 
F_PROFILE(f, thread, position) = -10.052*pow(t, 3) + 5.9452*pow(t, 2) - 0.09495*t + 0.2198;
}

else if (t >= 0.261 && t<0.388)

{ 
F_PROFILE(f, thread, position) = 41.661*pow(t, 3) - 43.059*pow(t, 2) + 14.028*t - 1.2703;
}

else if (t >= 0.388 && t < 0.468)

{
F_PROFILE(f, thread, position) = -59.067*pow(t, 3) + 77.805*pow(t, 2) - 33.944*t + 5.0295;
}

else if (t >= 0.468 && t < 0.687)

{
F_PROFILE(f, thread, position) = 6.8298*pow(t, 3) - 12.125*pow(t, 2) + 6.8967*t - 1.1411;
}

else if (t>=0.687 && t<1.0)

{ 
F_PROFILE(f, thread, position) = 1.8829*pow(t, 3) - 5.1168*pow(t, 2) + 4.523*t - 1.2208;
}

}
end_f_loop(f, thread)
}
best regards
AlexanderZ is offline   Reply With Quote

Old   April 1, 2019, 08:41
Default
  #3
New Member
 
Cristian Schwatz
Join Date: Mar 2019
Posts: 8
Rep Power: 7
Cschwatz is on a distinguished road
Thanks for the reply Alexander!

However, I'm still encountering the same problem as before. When I run a simulation with this udf, the velocity remains constant throughout the entire simulation. For some reason, the functions that I've written in the code are "not being used" by fluent. Is there a way to check where the problem could be in the code?

Thanks again!
Cschwatz is offline   Reply With Quote

Old   April 2, 2019, 01:54
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
code is correct

did you apply this profile to your boundary?

best regards
AlexanderZ is offline   Reply With Quote

Old   April 3, 2019, 08:46
Default
  #5
New Member
 
Cristian Schwatz
Join Date: Mar 2019
Posts: 8
Rep Power: 7
Cschwatz is on a distinguished road
Yes, I used it as an inlet boundary condition. However, for some odd reason, when I plot the velocity profile via fluent monitors, it just plots a straight line, like if it was ignoring all the polinomial functions I've written in the code. I've also tried to run the UDF by compiling it and by interpreting it, but there was no difference.

Thanks once again!
Cschwatz is offline   Reply With Quote

Old   April 3, 2019, 22:31
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile code I've sent before.
I've applied it as temperature BC and it works, it should works as velocity BC as well.

best regards
AlexanderZ is offline   Reply With Quote

Old   April 5, 2019, 15:38
Default
  #7
New Member
 
Cristian Schwatz
Join Date: Mar 2019
Posts: 8
Rep Power: 7
Cschwatz is on a distinguished road
I've compiled the code as you said and I still got the same problem...
I've attached 2 screenshots of the fluent window to show you the output the udf is giving. As you can see, instead of plotting a profile (as expected), it just plots a straight line, as if the velocity was constant throughout the entire simulation. Not sure if I'm doing something wrong in the C# script, since I just copied and pasted the code you've sent me before.

Thanks again


https://imgur.com/a/bUtXjxq
Cschwatz is offline   Reply With Quote

Reply


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
UDF to measure Mass Flow Rate a.lynchy Fluent UDF and Scheme Programming 31 October 4, 2018 15:10
volume flow rate for outlet boundry condition and dfine udf for it raminostadi FLUENT 0 December 24, 2016 02:52
UDF for 3D turbulent fully developed flow howhs Fluent UDF and Scheme Programming 0 August 1, 2013 12:47
UDF for time-dependent flow borhan_sd@yahoo.com Fluent UDF and Scheme Programming 2 May 30, 2013 03:59
UDF for transient pressure inlet, mass flow check at nozzle exit and volumetric heat kokoory FLUENT 0 August 17, 2011 03:07


All times are GMT -4. The time now is 19:06.