replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Approximating time gradient
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Approximating time gradient

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
pban92



Joined: 23 Nov 2009
Posts: 38

PostPosted: Mon Apr 04, 2011 12:26 pm    Post subject: Approximating time gradient Reply with quote

Hello,

I have a two-column discrete data file with 10,000 rows. The first column is the time (t) and the second is the velocity data (v) where time increment, Delta-T = 0.0001.
I am trying to find the time gradient of the velocity (dv/dt). Can someone help me with the coding below?
Many thanks!

Code:
OPEN (UNIT=100, FILE=data.txt, STATUS='OLD', ACTION='READ', IOSTAT=ierr)
      DO i = 1, size(y)
         READ (3,*,IOSTAT=ierr) xdummy, vel(i) 
         if (ierr /=0) exit
   END DO

    n=i-1

tgrad = 0.

DO i = 1,n
tgrad = tgrad+(vel(i+1)-vel(i))/(0.0001)
if (i>n) exit
ENDDO

write(*,'Time gradient is ') tgrad/n*0.0001

CLOSE(UNIT=100, FILE=data.txt, STATUS='OLD', ACTION='WRITE', IOSTAT=ierr)
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Tue Apr 05, 2011 1:32 pm    Post subject: Reply with quote

Isn't the answer to the second DO loop you have coded simply

tgrad = (vel(n+1)-Vel(1)) / 0.0001

Also, does dv/dt ( = (vel(i)-vel(i-1)) / (xdummy(i)-xdummy(i-1)) ) vary with I ?

Assuming it does, you can use a forward difference calculation, in each time step to calculate an estimate of x(i)

x(i) = x(i-1) + (v(i)+v(i-1))/2 * dt + (a(i)+a(i-1))/4 * dt**2
( x = x0 + vel * dt + acc /2 *dt**2 )

You can vary the calculation, depending on the way you estimate acceleration (tgrad(i)) varying over dt. It's an interesting change to the forward difference equations.

John
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group