 module Coef
 
 use variaveis 
 
 implicit none


 contains

	subroutine coeficientes(N, AW, AP, AE, un)

    integer, intent(inout)              :: N
	real*8, dimension(:), intent(inout) :: AW, AP, AE  
	real*8, dimension(:), intent(in) :: un
	
	real*8                              :: x                ! coordenada espacial

	dx = 1.0d0 / (N - 1)

	! contorno esquerdo
    AW(1) = 0.0d0
    AE(1) = 0.0d0
    AP(1) = 1.0d0
    

    ! pontos internos
	do i = 2, N-1

       x = (i-1) * dx

	   AW(i) = 1.0d0 / (dx**2) + (Rey * un(i-1)) / ( dx ) 

       AE(i) = 1.0d0 / (dx**2) 

       AP(i) = 2.0d0 / (dx**2) + (Rey * un(i)) / ( dx )
       
    end do

 	! contorno direito
    AW(N) = 0.0d0
    AE(N) = 0.0d0
    AP(N) = 1.0d0
   
	
  end subroutine coeficientes

subroutine Termofonte(N, SP)

    integer, intent(inout)              :: N
	real*8, dimension(:), intent(inout) :: SP  
		
	real*8                              :: x                ! coordenada espacial

	dx = 1.0d0 / (N - 1)

	! contorno esquerdo
   
    SP(1) = 0.0d0

    ! pontos internos
	do i = 2, N-1

       x = (i-1) * dx

       SP(i) = ((Rey**2.0d0)*(dexp(x*Rey))*(2.0d0*dexp(x*Rey) - dexp(Rey) - 1.0d0)) / &
	   ((dexp(Rey) - 1.0d0 )**2.0d0) 

    end do

 	! contorno direito
    
    SP(N) = 1.0d0
	
  end subroutine Termofonte



end module Coef