# UDF for Square Wave

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

 December 8, 2006, 07:57 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) } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 December 9, 2006, 14:49 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

March 13, 2010, 09:36
question
#3
New Member

Join Date: Mar 2010
Posts: 6
Rep Power: 8
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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Shane FLUENT 1 September 3, 2010 02:32 teguhtf FLUENT 1 March 9, 2010 09:04 A8anato_psofimi FLUENT 2 November 10, 2009 15:42 hm FLUENT 0 August 2, 2004 21:45 A8anato_psofimi FLUENT 0 February 9, 2004 05:00

All times are GMT -4. The time now is 03:55.