-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogkillResistencia.f90
53 lines (51 loc) · 1.66 KB
/
logkillResistencia.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
program logkillResistencia
!Resolucion de la ecuacion diferencial X'(t)=kg*X-kd*X*U(t)*e^(-lambda*t) con runge kutta de orden 2
implicit none
integer, parameter :: dp = 8
real(dp) t0,tmax,dt,x0,k_g,k_d,lambda,u0
real(dp), allocatable, dimension (:) :: t,x,z,u
integer i,j,N
!**********************************************************************
t0 = 0.0_dp
tmax = 50.0_dp
N = 10000
x0 = 30.0_dp
k_g = 0.1_dp
k_d = 0.04_dp
lambda = 0.1_dp
u0 = 0.0_dp
allocate(t(0:N),x(0:N),z(0:N),u(0:N))
!**********************************************************************
dt = (tmax - t0) / dble(N) !llenando vector temporal
do i=0,N
t(i) = t0 + dt * dble(i)
end do
!**********************************************************************
x(0) = x0 !valores iniciales
u(0) = u0
!**********************************************************************
do i=1,N !runge kutta
do j=1,2
if (j.eq.1) then
z(i) = z(i-1) + 1.0_dp * dt
u(i) = 30.0_dp*(sqrt(z(i-1))/(sqrt(10.0_dp)+sqrt(z(i-1))))
x(i) = x(i-1) + ( k_g * x(i-1) - exp(-lambda*z(i-1)) *&
k_d * x(i-1) * u(i) ) * dt
else
z(i) = 0.5_dp * ( z(i-1) + (1.0_dp ) * dt + z(i) )
u(i) = 30.0_dp*(sqrt(z(i-1))/(sqrt(10.0_dp)+sqrt(z(i-1))))
x(i) = 0.5_dp * &
( x(i-1) + ( k_g * x(i-1) - exp(-lambda*z(i-1)) *&
k_d * x(i-1) * u(i) ) * dt + x(i) )
end if
end do
end do
!**********************************************************************
open(1,file='resistencia.dat') !llenando archivo
do i=0,N,1
write(1,*) t(i),x(i),u(i)
end do
close(1)
call system('gnuplot -c resistencia.gplot')
!**********************************************************************
end program logkillResistencia