UDF for Square Wave
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) } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
Re: UDF for Square Wave
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 |
question
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 |
All times are GMT -4. The time now is 03:10. |