New programming languages

Moderators: None (Apply to moderate this forum)
Number of threads: 111
Number of posts: 329

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
people can this be solved NUMERICALLY on FORTRAN? Posted by lapachacha on 21 May 2011 at 2:27 PM
hello people...i have beeen given this projectile problem to be solved numerically in FORTRAN..i have coded it using runge0kutta 4th order ......now the thing is that i have not been given the end points of time,,;ie. the range.. and i am asked to

a)the maximum height attained by the projectile

what is to b added to the existing code to achive this?

b)the time required to reach the maximum height

what is to b added to the existing code to achive this?

c)the time required to return to the original elevation..

what is to b added to the existing code to achive this?

i did fortran 4 years ago...havent beeen in practice..this was the lone effort i cud recall...please help...


i have attached the question and the code..

heres the code
CODE


!************************************************* *********************
! *
! projectile question *
! *
!************************************************* **********************


DATA M,G,C/10.0,9.80665,0.1/

!FIRST i HAVE REDUCED THE GIVEN EQUATION IN TWO LINEAR 1ST-ORDER EQUATIONS
!FOR THE SOLUTION TO PROCEED


F1(T,U1,Y2) = U1
F2(T,U1,Y2) = (-M*G-C*U1**2)/M


!ASSIGNMENT OF VALUES TO CONSTANTS



WRITE(*,*) 'Input left and right endpoints separated by'
WRITE(*,*) 'blank'
WRITE(*,*) ' '
READ(*,*) A, B

WRITE(*,*) 'Input the two initial conditions.'
WRITE(*,*) ' '
READ(*,*) ALPHA1, ALPHA2

WRITE(6,*) 'Input a positive integer for the number'
WRITE(6,*) 'of subintervals '
WRITE(6,*) ' '
READ(5,*) N


WRITE(*,6)
6 FORMAT(12X,'t(i)',11X,'w1(i)',11X,'w2(i)')

H=(B-A)/N
T=A


! the initiaal conditions
W1=ALPHA1
W2=ALPHA2

WRITE(*,1) T,W1,W2

!RK PARAMETER EVALUATIONS HERE

DO 110 I=1,N

X11=H*F1(T,W1,W2)
X12=H*F2(T,W1,W2)

X21=H*F1(T+H/2,W1+X11/2,W2+X12/2)
X22=H*F2(T+H/2,W1+X11/2,W2+X12/2)

X31=H*F1(T+H/2,W1+X21/2,W2+X22/2)
X32=H*F2(T+H/2,W1+X21/2,W2+X22/2)

X41=H*F1(T+H,W1+X31,W2+X32)
X42=H*F2(T+H,W1+X31,W2+X32)

W1=W1+(X11+2*X21+2*X31+X41)/6
W2=W2+(X12+2*X22+2*X32+X42)/6

T=A+I*H

WRITE(*,1) T,W1,W2
110 CONTINUE


STOP
1 FORMAT(3(1X,E15.8))
END
Attachment: projectile question.png (43057 Bytes | downloaded 161 times)
Report
Re: people can this be solved NUMERICALLY on FORTRAN? Posted by quikcarl on 24 May 2011 at 6:27 PM
Of course, it can be solved, but I don't know the theory or the finite steps that need to be taken to get there. 1st, your function statements have 3 variables, but you're only using one (U1).
 F1(T,U1,Y2) = U1
 F2(T,U1,Y2) = (-M*G-C*U1**2)/M

2nd, all of the other FORTRAN looks correct, but I suggest another computer language to solve the problem, if you know any, like, C, MatLab, or Pascal.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.