CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > CFX

Expression =1 every 2 Timesteps

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By ghorrocks

Reply
 
LinkBack Thread Tools Display Modes
Old   April 15, 2014, 14:07
Default Expression =1 every 2 Timesteps
  #1
Member
 
Chris_321's Avatar
 
Christian
Join Date: Sep 2013
Location: Germany
Posts: 77
Rep Power: 3
Chris_321 is on a distinguished road
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?
Chris_321 is offline   Reply With Quote

Old   April 15, 2014, 14:53
Default
  #2
Senior Member
 
Edmund Singer P.E.
Join Date: Aug 2010
Location: Minneapolis, MN
Posts: 494
Rep Power: 10
singer1812 is on a distinguished road
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)
singer1812 is offline   Reply With Quote

Old   April 15, 2014, 18:47
Default
  #3
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 10,824
Rep Power: 85
ghorrocks has a spectacular aura aboutghorrocks has a spectacular aura aboutghorrocks has a spectacular aura about
mod(cstep,2) is simpler and not prone to round off.
mvoss and singer1812 like this.
ghorrocks is offline   Reply With Quote

Old   April 17, 2014, 05:33
Default
  #4
Member
 
Chris_321's Avatar
 
Christian
Join Date: Sep 2013
Location: Germany
Posts: 77
Rep Power: 3
Chris_321 is on a distinguished road
Thank you
Chris_321 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
outputTime in Swak function immortality OpenFOAM Post-Processing 8 June 28, 2015 16:25
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 19:44
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 07:25
Lift, Drag Vs time chart,calculations Jamesd69climber CFX 8 February 17, 2005 18:23


All times are GMT -4. The time now is 03:19.