CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   Expression =1 every 2 Timesteps (

Chris_321 April 15, 2014 14:07

Expression =1 every 2 Timesteps

im looking for an expression that is 1 every 2 timesteps.

I tried to build the expression with a sin function but somehow it does not work propably.

(abs(sin(Time*1[rad/s])) =1)

is there a easier way?

singer1812 April 15, 2014 14:53

Your way is close but you have the expression slightly wrong. And are you interested in every 2 "timesteps" or do you want this as a function of time?

For timesteps your variable needs to be ctstep not Time.

Also, your sin function would need to be

cos(ctstep*pi) in order to get it to "1" on every even step.

But I would be afraid of roundoff error on this and wouldnt trust it to return true using a boolean to evaluate it, so I would switch to a step function. Perhaps:


ghorrocks April 15, 2014 18:47

mod(cstep,2) is simpler and not prone to round off.

Chris_321 April 17, 2014 05:33

Thank you :)

All times are GMT -4. The time now is 08:38.