Upload
jenny-ramos-lazaro
View
213
Download
0
Embed Size (px)
Citation preview
7/26/2019 Trabajo Finalemnt
1/3
program numero7real :: h,ti,tf,treal :: vt,tend! y2=z y1=v xp=tinteger ::i,minteger, parameter:: n = 2real,dimension(100) :: tpreal, dimension (2) :: y,yireal, dimension (100,100) :: ypprint*, "*********************************************************"print*, " Solucion de sistemas de EDO usando el metodo: runge k
utta "print*, "*********************************************************"print*, "Valores iniciales de las variables dependientes:"read(*,*) (yi(i), i = 1,n)print*," ingrese el tiempo inicial "read(*,*) tiprint*," ingrese el tiempo final "read(*,*) tfprint*," Valor del tamao de paso: "read(*,*) vtt = tim = 1tp(m) = t
do i = 1,nyp(i,m) = yi(i)y(i) = yi(i)
end dodo
tend = t + vtif (tend > tf) then
tend = tfend ifh = vtcall funciones(t,y,h,tend,n)m = m+1tp(m) = t
do i = 1,nyp(i,m) = y(i)end doif(t >= tf) exit
end doprint*, " "print*, " t v z"print*, " "
do i=1,mprint*,tp(i),yp(1,i),yp(2,i)
end do
end program numero7
function dydx1 (t,v,z)real :: t,v,zdydx1 = -16.0*z+0*v+0*t
end function dydx1
function dydx2 (t,v,z)real :: t,v,zdydx2 = v+0*z+0*t
7/26/2019 Trabajo Finalemnt
2/3
end function dydx2
subroutine funciones(t,y,h,tend,n)
real :: t,h,tendreal,dimension (2) :: y, ynewinteger :: n,i
doif (tend - t < h ) then
h = tend -tend ifcall RungeKutta(t,y,h,n,ynew)do i = 1,n
y(i) = ynew(i)end doif (t >= tend) exit
end doend subroutine funciones
subroutine Rungekutta(t,y,h,n,ynew)
real :: t, h real, dimension (2) :: ynew,y
integer:: ninteger:: ireal,dimension(2)::ym,yereal,dimension(2)::k1,k2,k3,k4
interfacefunction dydx1 (x,v,z)
real :: x,v,zend function dydx1
end interface
interfacefunction dydx2 (x,v,z)real :: x,v,z
end function dydx2 end interface
call Desarrollo (t,y,k1)do i=1,n
ym(i)=y(i)+0.5*k1(i)*hend do
call Desarrollo(t+h/2,ym,k2)do i=1,n
ym(i)=y(i)+0.5*k2(i)*hend do
call Desarrollo (t+h/2,ym,k3)do i=1,n
ye(i)=y(i)+k3(i)*hend docall Desarrollo(t+h,ye,k4)
do i=1,n
7/26/2019 Trabajo Finalemnt
3/3
ynew(i)= y(i) + (h/6)*(k1(i)+2*(k2(i)+k3(i))+k4(i))end do
t = t + h
end subroutine RungeKutta
subroutine desarrollo(t,y,dydx)real :: t, v1,v2real,dimension (21) :: y, dydx
interfacefunction dydx1 (t,v,z)
real :: t,v,zend function dydx1
end interface
interfacefunction dydx2 (t,v,z)
real :: t,v,zend function dydx2
end interface
v1 = y(1)v2 = y(2)dydx(1) = dydx1 (t,v1,v2)dydx(2) = dydx2 (t,v1,v2)
end subroutine Desarrollo