|
[Sponsors] |
January 28, 2021, 12:00 |
UDF, Breathing Waveform - Repeating Sinewave
|
#1 |
New Member
Bella Barbera
Join Date: Nov 2020
Posts: 6
Rep Power: 6 |
Hello all,
I am working to create a UDF that represents a breathing pattern for a 3D transient simulation. The UDF is set for the massflow rate of the persons nostril. The pattern lasts 6 seconds is pretty much just a sine-wave when t<5, but from t=5 to t=6 the person is resting and the breathing mass flow rate is 0 as seen in the screen shot attached. However I cannot figure out how to loop this to continue "infinitely" as right now the breathing waveform runs once through from 0-6 seconds and I would like it to continue/restart the same pattern 6-12 s, 12-18 s and so on.... Can anyone help me with fixing my code to do so? Thank you! |
|
January 29, 2021, 07:29 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
/************************* transient.c UDF for specifying a transient boudnary condition ******************************/ #include "udf.h" DEFINE_PROFILE(transient_massflowrate,thread,position) { face_t f; real t = CURRENT_TIME; begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = .000125*sin((2*M_PI*(t%5))/5); } end_f_loop(f, thread) }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 29, 2021, 10:34 |
|
#3 |
New Member
Bella Barbera
Join Date: Nov 2020
Posts: 6
Rep Power: 6 |
Hi thank you, this doesn't work I don't believe, because I need the 1s of rest from 5 to 6 seconds of 0 flow rate. Your reply will just loop the sine function every 5 seconds.
Any other thoughts? |
|
February 1, 2021, 20:45 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
lol
Code:
/************************* transient.c UDF for specifying a transient boudnary condition ******************************/ #include "udf.h" DEFINE_PROFILE(transient_massflowrate,thread,position) { face_t f; real t = CURRENT_TIME; begin_f_loop(f, thread) { if (t%6 == 0) F_PROFILE(f, thread, position) = 0.0; else F_PROFILE(f, thread, position) = .000125*sin((2*M_PI*(t%6))/5); } end_f_loop(f, thread) }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 17, 2021, 06:44 |
|
#5 | |
New Member
Tiziano
Join Date: Nov 2021
Posts: 2
Rep Power: 0 |
Quote:
|
||
November 17, 2021, 22:16 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
its a check if number is divisible by 6 without remainder
google operator % for C language
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
ansys, fluent, loop, sinewave, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for vapor pressure | anuarun | Fluent UDF and Scheme Programming | 13 | June 23, 2024 14:12 |
Save output of udf in another udf! | JuanJoMex | FLUENT | 0 | February 8, 2018 13:43 |
Replicating Scalable Wall Function with a UDF | yousefaz | FLUENT | 0 | August 4, 2017 03:30 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |