CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Programming a duty cycle in CFX (https://www.cfd-online.com/Forums/cfx/124351-programming-duty-cycle-cfx.html)

merper October 2, 2013 17:17

Programming a duty cycle in CFX
 
Ok, I'm guessing this is probably a simple thing to implement, but I've spent all morning searching and can only jury rig a solution so far. How do I use a loop or create and expression to turn a boundary condition on and off for 10, 20, 30...% of the time.

Right now, I'm using a simple if statement to create the cycle:

.6253 [V] - if(atstep >(DutyCyclePercentage*.8[s]/10)/TimestepSize, .6253 [V], 0 [V]) +if(atstep > 8[s]/TimestepSize,.6253[V],0[V])- if(atstep >(8[s]+DutyCyclePercentage*.8[s]/10)/TimestepSize, .6253 [V], 0 [V]) + if(atstep >16[s]/TimestepSize,.6253[V],0[V])-.....


but I basically have to repeat this over and over for the length of my simulation. How do I simplify this with a loop? I can't find the syntax.

ghorrocks October 2, 2013 18:10

Use the mod function to work out where in the current cycle you are. Then do a single if statement on that value to get a repeating duty cycle signal.

merper October 2, 2013 18:34

Ah, so simple. Yeah thanks.

if(mod(atstep,cyclelength),true,false)


All times are GMT -4. The time now is 18:02.