Advertisement
Thomas_Lillieskold

Subroutine Euler_Method_Stiff

Mar 25th, 2023 (edited)
1,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE Euler_Metodo
  2. USE DATOS, ONLY:t_min,t_max,phi_1,phi_2,phi_3,phi_4,neq,dim  
  3. USE FUNCTIONS
  4. USE CHECK_K
  5. PRIVATE
  6.  
  7. PUBLIC::Euler_exp
  8.  
  9. contains
  10. SUBROUTINE Euler_exp(Vn,Inc)
  11.  
  12.         REAL(8),DIMENSION(:,:),POINTER,INTENT(IN) :: Vn
  13.         REAL(8),DIMENSION(dim,neq)::Vn2
  14.         REAL(8)Inc
  15.         REAL(8),DIMENSION(neq)::f
  16.         REAL(8),DIMENSION(neq)::f2
  17.         REAL(8) t_i,t_2
  18.         INTEGER i,j, iter,q
  19.         CHARACTER(8):: Est
  20.        
  21.         vn(1,1)=phi_1
  22.         vn(1,2)=phi_2
  23.         vn(1,3)=phi_3
  24.         vn(1,4)=phi_4
  25.        
  26.         vn2(1,1)=phi_1
  27.         vn2(1,2)=phi_2
  28.         vn2(1,3)=phi_3
  29.         vn2(1,4)=phi_4
  30.        
  31.         q=1
  32.         i=1
  33.         t_i=t_min
  34.         t_2=t_min
  35.    
  36.     OPEN(10,FILE="write_outs")
  37.  
  38.     DO WHILE (t_i .le. t_max)
  39.    
  40.     Iter = i
  41.    
  42.     print*, "Iter",iter,"i",i
  43.     PRINT*, "t_i",t_i,"inc",inc
  44.    
  45.    
  46.    
  47.     CALL Fun(Vn(i,:),t_i, f) !Asignacion temporal de valores a vn
  48.    
  49.     Vn(i+1,:)= Vn(i,:) + Inc * f
  50.    
  51.     t_i = t_i + Inc
  52.    
  53.     i = i + 1
  54.    
  55.     DO J=1,2,1
  56.    
  57.         CALL Fun(Vn2(q,:),t_2,f2) !Asignacion temporal de valores a vn2
  58.        
  59.         Vn2(q+1,:)= Vn2(q,:) + (Inc/2.d0) * f2
  60.        
  61.         t2= t2 + Inc/2.d0
  62.        
  63.         q = q + 1
  64.        
  65.     END DO
  66.    
  67.     CALL Check(Vn(i,:),Vn2(q,:), Est)
  68.    
  69.     CALL Control(Est, t_i, Inc, i, q)
  70.    
  71.    
  72.     !IF (i /= Iter) THEN !Se acepto la aproximacion
  73.        
  74.     Write(10,*) t_i,Vn(i,1),Vn(i,2),Vn(i,3),Vn(i,4)
  75.    
  76.     !END IF
  77.    
  78.     END DO
  79. END SUBROUTINE Euler_exp
  80.    
  81. END MODULE Euler_Metodo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement