Logo Studenta

07_Ecuaciones_diferenciales_ordinarias_PVF

¡Este material tiene más páginas!

Vista previa del material en texto

NOTAS DE CLASE
Tema: Ecuaciones diferenciales ordinarias (EDO)
 - Problemas de valores iniciales (PVF)
 
Forma normal de la EDO de orden n
 
 
 
 
 
 
 
Ejemplo:
 
Ejemplo:
 
Ejemplo:
 
 
 
 
Ejemplo:
program diferencias_finitas
use kinds
implicit none
integer (kind=ikind1) :: i,n
real (kind=rkind8), allocatable :: 
diag(:),diag_inf(:),diag_sup(:),b(:),temp(:)
real (kind=rkind8) :: Q
real (kind=rkind8) :: x_min,x_max,h,tempa,tempb
write(*,*)'Enter the number of nodes (boundaries not included)'
read(*,*)n
allocate (diag(n),b(n),temp(n),diag_inf(n-1),diag_sup(n-1))
Q=-0.15_RKIND8 ; x_min=0._RKIND8 ; x_max=10._RKIND8
tempa=240._RKIND8 ; tempb=150._RKIND8
h=(x_max-x_min)/real(n+1)
diag=Q*h**2-2._RKIND8
diag_inf=1._RKIND8
diag_sup=1._RKIND8
b=0._RKIND8 ; b(1)=-tempa ; b(n)=-tempb
call tridia(diag,diag_inf,diag_sup,b,temp,n)
!!!!!!!!!! Writing results !!!!!!!!!!!!!!!
write(*,*) x_min,tempa
do i=1,n
 write(*,*) x_min+h*i,temp(i)
enddo
write(*,*) x_max,tempb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
deallocate (diag,diag_inf,diag_sup,b,temp)
end program diferencias_finitas
 
Ejemplo:
TAREA: analizar el método 
implementado en la
subrutina tridia 
!**************************** T R I D I A *************************** 
subroutine tridia(alpha,beta,gamma,b,y,n) 
! 
! Solution of tridiagonal systems 
! 
! ALPHA: main diagonal (destroyed in TRIDIA). 
! BETA: subdiagonal (first element has index 1). 
! GAMMA: superdiagonal (first element has index 1). 
! B: right-hand side (destroyed in TRIDIA). 
! Y: solution. 
! N: dimension of system. 
! 
use kinds
implicit none
integer (kind=ikind1) :: i,j,n
real(kind=rkind8), dimension(n) :: alpha,b,y 
real(kind=rkind8), dimension(n-1) :: beta,gamma 
real(kind=rkind8) :: rap
DO i=2,n 
 rap = beta(i-1) / alpha(i-1) ; alpha(i) = alpha(i) - rap*gamma(i-1) ; b(i) = b(i) - rap*b(i-1) 
END DO 
y(n) = b(n) / alpha(n) 
DO j=2,n 
 i = n-j+1 ; y(i) = ( b(i) - gamma(i)*y(i+1) ) / alpha(i) 
END DO 
end subroutine tridia
!**************************** T R I D I A *************************** 
 
Ejemplo:
 
A: matriz tridiagonal m-1xm-1
 
FIN NOTAS DE CLASE
Tema: Ecuaciones diferenciales ordinarias (EDO), PVF
	Diapositiva 1
	Diapositiva 2
	Diapositiva 3
	Diapositiva 4
	Diapositiva 5
	Diapositiva 6
	Diapositiva 7
	Diapositiva 8
	Diapositiva 9
	Diapositiva 10
	Diapositiva 11
	Diapositiva 12
	Diapositiva 13
	Diapositiva 14
	Diapositiva 15
	Diapositiva 16
	Diapositiva 17
	Diapositiva 18
	Diapositiva 19

Continuar navegando