Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Program explicito
  2.  
  3. implicit none
  4.  
  5. real (8):: dt, dx, r,x
  6.  
  7. real(8), allocatable:: a(:,:)
  8.  
  9. real(8), parameter :: k=80.2, c=447000, d=7870, tmax=1E7       ! d es densidad
  10.  
  11. integer, parameter :: p=100 ! Hay que considerar al cero en los intervalos de posición
  12.  
  13. integer:: i, t
  14. !Debo tener en cuenta que t es la CANTIDAD de PASOS TEMPORALES, y NO el tiempo final
  15. !Si me dan un r y un dx, tendré que calcular dt y dividir al tiempo final por dt para sacar la cantidad de pasos t
  16.  
  17. !Ingrese el intervalo de tiempo'
  18.  dt = 220.
  19.  !t = tmax/dt
  20. !Ingrese el intervalo de posición '
  21.  dx = 5E-3
  22.  
  23. ! Si ya me dan r , directamente reemplazo en el valor de r
  24.  !r=0.4
  25.  !dt = r*(c*d*(dx**2))/k
  26.  t = floor(tmax/dt)+1
  27.  r= (k*dt)/(c*d*(dx**2))
  28.  
  29. write(*,*) r, dt, dx!, t
  30.  
  31.  
  32. allocate ( a(p, t))
  33.  
  34. a = matriz(dx,t,r)
  35.  
  36. open (unit=2,file='resultadosExplicito.dat',status='replace')
  37.  
  38. write(*,*) 'La matriz a quedó (i: posición, j: tiempo)'
  39. write(2,*) 'La matriz a quedó (i: posición, j: tiempo)'
  40.  x = 0.
  41.  do i=1,p
  42.   x = x + dx
  43.   !write(*,'(21f8.2)') a(i,:)
  44.   write(2,'(5f8.2)') x, a(i,1), a(i,2), a(i,4), a(i,6)
  45.  end do
  46.  
  47.  
  48. close (2,status='keep')
  49. deallocate (a)
  50. !call system ("gnuplot -persist 'Script.p'")
  51.  
  52. !======================================================================
  53.  
  54.  Contains
  55.  
  56. !======================================================================
  57.  
  58. function matriz(dx,t,r)
  59.  real(8):: a(p,t), dx, x, matriz(p,t),r
  60.  integer :: i,j, t
  61.  
  62. !Armo la matriz con las condiciones iniciales (CI)
  63.  a (1, :)= 273. ! Condición de contorno (CC)
  64.  a( p, :)=473. ! Condición de contorno (CC)
  65.  
  66. !Esto es para cuando hay una distribución inicial!
  67.  
  68. !x=0
  69.  
  70. !i=1
  71.  
  72.  !do while ((0<=x) .and. (x<=1))
  73.  
  74.   ! a(i, 1) = 100*x
  75.    
  76.   ! i=i+1
  77.    
  78.    !x= x + dx
  79.    
  80.  !end do
  81.  
  82.  !do while ((1<=x) .and. (x<=2))
  83.  
  84.  ! a(i, 1)= 100*(2-x)
  85.  
  86.   ! i=i+1
  87.    
  88.    !x=x+dx
  89.    
  90. ! end do
  91.  
  92.  do i=2,p-1
  93.   a(i,1)=473. !Cuando la distribución es uniforme
  94.  end do
  95.  
  96.  do j=2,t
  97.   do i=2,p-1
  98.    a(i,j)= r*(a(i+1, j-1) + a(i-1, j-1))  + (1-2*r)*a (i, j-1)
  99.   end do
  100.   if (a(41,j)<358.) then
  101.    write(*,*) 'En el extremo más próximo al extremo a 0ºC, se tarda ',j*dt,'segundos para llegar a 85ºC'
  102.    read*
  103.   end if
  104.  end do
  105.  matriz = a
  106.  
  107. end function
  108.  
  109. end program explicito
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement