|
[Sponsors] |
December 8, 2006, 07:57 |
UDF for Square Wave
|
#1 |
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 |
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: 16 |
Quote:
would you please say me how you write pressure equation for sinusoidal wave?could you send/give or/and even introduce me some references |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help! Compiled UDF problem 4 Wave tank tutorial | Shane | FLUENT | 1 | September 3, 2010 03: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 22:45 |
UDF for sine wave in tank & cell count questions! | A8anato_psofimi | FLUENT | 0 | February 9, 2004 05:00 |