|
[Sponsors] |
July 16, 2008, 17:06 |
Help! Function not LOOPing
|
#1 |
Guest
Posts: n/a
|
Hi, I'm trying to define a loop to generate a recurring capacitor charge-discharge function to be interpreted in FLUENT as an input profile. For some reason, it doesn't seem to be looping at all. I get the first curve, then it stays constant (at 0). There are no errors in interpreting so I'm guessing it is ok syntax wise. All the variables are properly specified. Am I missing something important to make sure it loops?
Here is what it should look like: http://commons.wikimedia.org/wiki/Im...-discharge.svg /* modeled after an RC charging-discharging curve */ /* p = entire period (including resting time) */ /* xp = cross-over point from charging to discharging */ /* pb = period (total charge-discharge time) */ /* a = amplitude*/ p=20; xp=3; pb=5; a=5; flow_time1=0; flow_time3=pb; begin_f_loop(f, thread) {F_CENTROID(x,f,thread); if (flow_time == (flow_time3+p)) { flow_time1=flow_time1+p; flow_time3=flow_time3+p; } if ((flow_time > flow_time1) && (flow_time < flow_time3)) { flow_time2=flow_time - flow_time1; if (flow_time2 <= xp) {F_PROFILE(f,thread,nv) = a*(1-exp(-flow_time2/(pb/6))); } else {F_PROFILE(f,thread,nv) = a*(exp((xp-flow_time2)/(pb/10))); } else { F_PROFILE(f,thread,nv) = 0; } } end_f_loop(f, thread) |
|
July 16, 2008, 17:12 |
Re: Help! Function not LOOPing
|
#2 |
Guest
Posts: n/a
|
I need to add:
the flow_time is obtained from this line outside the loop: real flow_time = RP_Get_Real("flow-time"); |
|
July 17, 2008, 15:44 |
Help! UDF for time-based repeated pressure profile
|
#3 |
Guest
Posts: n/a
|
Hi, I included a different version, which should hopefully be easier to decipher, but with the same idea and problem. This UDF is for a pressure inlet. I can get the first wave, but after that it remains at the constant pressure. Based on my understanding of the code, the wave should be repeated every "p" seconds, but it does not do that. Would totally appreciate it if someone could point out any conceptual or programming errors =)
#include "udf.h" #include "math.h" DEFINE_PROFILE(inlet_pressure,t,nv) { face_t f; real flow_time = RP_Get_Real("flow-time"); real PEEP, p, xp, pb, a, flow_time1, flow_time2, flow_time3, pressure; PEEP=5; pb=5; p=15; xp=3; a=10; flow_time1=0; flow_time3=pb; if (flow_time == (flow_time1+p)) { flow_time1 = flow_time1 + p; flow_time3 = flow_time3 + p; } if ((flow_time > flow_time1) && (flow_time < flow_time3)) { flow_time2 = flow_time - flow_time1; pressure = PEEP + a*(1-exp(-flow_time2/(pb/6))); begin_f_loop(f,t) { F_PROFILE(f,t,nv) = pressure; } end_f_loop(f,t) } else { begin_f_loop(f,t) { F_PROFILE(f,t,nv) = PEEP; } end_f_loop(f,t) } } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
looping | rr123 | FLUENT | 1 | July 8, 2008 17:49 |
Looping in UDF!!! | safa | FLUENT | 0 | December 11, 2007 08:07 |
LOOPING ON NODES | Luca | FLUENT | 0 | January 10, 2005 16:23 |
Looping Problem?? | KKLAU | FLUENT | 1 | June 5, 2004 05:48 |
Looping over cells | Karl | FLUENT | 4 | March 26, 2002 21:18 |