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

UDF for Square Wave

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 8, 2006, 07:57
Default UDF for Square Wave
  #1
Emmanuel
Guest
 
Posts: n/a
Hi,

How can I write a simple UDF for a square wave.

Frequency is 220hz

Mean value is 15.59psi

Amplitude is 0.89psi

I want to compare a square wave with my sinusoidal wave.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#include "udf.h"

DEFINE_PROFILE(unsteady_pressure, thread, position) {

float t, pressure; face_t f;

t = RP_Get_Real("flow-time");

pressure = (15.59+(0.89*sin(220*6.283185307*t)))*6894.757;

begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = pressure; } end_f_loop(f, thread)

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  Reply With Quote

Old   December 9, 2006, 14:49
Default Re: UDF for Square Wave
  #2
Phil
Guest
 
Posts: n/a
I did this at one time. I used a cycle fraction to define when to switch from the positive side of the cycle to negative side.
Calculate cycle fraction as cycle fraction = t/T
where t= flow time and T=time period (1/220)
then use this simple code in place of your last line.


CODE:

begin_f_loop (f, thread)
{
if (cyc_frac < 0.5)
{
F_PROFILE(f,thread,position) = 16.48;
}
else
{
F_PROFILE (f,thread,position) = 14.7;
}
}
end_f_loop (f, thread)


Hope this helps,
Phil
  Reply With Quote

Old   March 13, 2010, 09:36
Default question
  #3
New Member
 
Join Date: Mar 2010
Posts: 5
Rep Power: 7
mahbube is on a distinguished road
Quote:
Originally Posted by Emmanuel
;137486
Hi,

How can I write a simple UDF for a square wave.

Frequency is 220hz

Mean value is 15.59psi

Amplitude is 0.89psi

I want to compare a square wave with my sinusoidal wave.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#include "udf.h"

DEFINE_PROFILE(unsteady_pressure, thread, position) {

float t, pressure; face_t f;

t = RP_Get_Real("flow-time");

pressure = (15.59+(0.89*sin(220*6.283185307*t)))*6894.757;

begin_f_loop(f, thread) { F_PROFILE(f, thread, position) = pressure; } end_f_loop(f, thread)

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hi,
would you please say me how you write pressure equation for sinusoidal wave?could you send/give or/and even introduce me some references
mahbube is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Compiled UDF problem 4 Wave tank tutorial Shane FLUENT 1 September 3, 2010 02:32
asking about UDF wave tank teguhtf FLUENT 1 March 9, 2010 09:04
HELP! UDF sinusoidal wave, VOF model, porous face! A8anato_psofimi FLUENT 2 November 10, 2009 15:42
Boundary condition, UDF, Wave simulation hm FLUENT 0 August 2, 2004 21:45
UDF for sine wave in tank & cell count questions! A8anato_psofimi FLUENT 0 February 9, 2004 05:00


All times are GMT -4. The time now is 04:41.