# Expression =1 every 2 Timesteps

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 15, 2014, 14:07 Expression =1 every 2 Timesteps #1 Member     Christian Join Date: Sep 2013 Location: Germany Posts: 88 Rep Power: 5 Sponsored Links Hello, 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?

 April 15, 2014, 14:53 #2 Senior Member   Edmund Singer P.E. Join Date: Aug 2010 Location: Minneapolis, MN Posts: 512 Rep Power: 14 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: step(cos(ctstep*pi)-0.9)

 April 15, 2014, 18:47 #3 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 13,724 Rep Power: 106 mod(cstep,2) is simpler and not prone to round off. mvoss and singer1812 like this.

 April 17, 2014, 05:33 #4 Member     Christian Join Date: Sep 2013 Location: Germany Posts: 88 Rep Power: 5 Thank you

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post immortality OpenFOAM Post-Processing 16 February 14, 2016 17:02 immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16 lzgwhy Main CFD Forum 1 January 11, 2011 19:44 manaliac Main CFD Forum 2 November 29, 2010 07:25 Jamesd69climber CFX 8 February 17, 2005 18:23