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

UDF, Breathing Waveform - Repeating Sinewave

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

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 28, 2021, 11:00
Default UDF, Breathing Waveform - Repeating Sinewave
  #1
New Member
 
Bella Barbera
Join Date: Nov 2020
Posts: 6
Rep Power: 3
bazinga22 is on a distinguished road
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!
Attached Files
File Type: c Breathing-Waveform (4).c (434 Bytes, 12 views)
bazinga22 is offline   Reply With Quote

Old   January 29, 2021, 06:29
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,063
Rep Power: 31
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   January 29, 2021, 09:34
Default
  #3
New Member
 
Bella Barbera
Join Date: Nov 2020
Posts: 6
Rep Power: 3
bazinga22 is on a distinguished road
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?
bazinga22 is offline   Reply With Quote

Old   February 1, 2021, 19:45
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,063
Rep Power: 31
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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)
}
tiztaz likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 17, 2021, 05:44
Default
  #5
New Member
 
Tiziano
Join Date: Nov 2021
Posts: 2
Rep Power: 0
tiztaz is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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)
}
Hi everibody, what is the meaning of t%6? I don't understand, thank you
tiztaz is offline   Reply With Quote

Old   November 17, 2021, 21:16
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,063
Rep Power: 31
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Reply

Tags
ansys, fluent, loop, sinewave, 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
UDF for vapor pressure anuarun Fluent UDF and Scheme Programming 12 December 24, 2021 10:12
Save output of udf in another udf! JuanJoMex FLUENT 0 February 8, 2018 12:43
Replicating Scalable Wall Function with a UDF yousefaz FLUENT 0 August 4, 2017 02:30
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 02:11.