annotate Lorenz2Langford.diff @ 6:d90925ba642e default tip

add a patch file
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Tue, 23 Jul 2024 02:36:26 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
1 diff -r 925250ea21a4 rk_Lorenz.R
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
2 --- a/rk_Lorenz.R Sun Jul 21 06:20:46 2024 +0900
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
3 +++ b/rk_Lorenz.R Tue Jul 23 02:35:22 2024 +0900
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
4 @@ -1,25 +1,25 @@
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
5 dll <- paste("rksub", .Platform$dynlib.ext, sep="")
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
6 dyn.load(dll)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
7
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
8 -max_i <- as.integer(5000)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
9 +max_i <- as.integer(5000*10)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
10
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
11 r <- .Fortran("rk_sakamoti",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
12 - as.double(c(0.5, 0.5, 0.5)),
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
13 - max_i,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
14 + as.double(c(1.0, 1.0, 1.0)),
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
15 + max_i,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
16 matrix(0, max_i, 4))
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
17 dyn.unload(dll)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
18
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
19 m <- r[[3]]
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
20 colnames(m) <- c("t", "x", "y", "z")
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
21
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
22 -png(filename = "Lorenz system.png",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
23 +png(filename = "Langford.png",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
24 width = 800, height = 600, bg="white", type="cairo")
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
25 library(scatterplot3d)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
26 scatterplot3d(m[,2], m[,3], m[,4],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
27 highlight.3d = FALSE,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
28 col.axis = "blue", col.grid = "lightblue",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
29 type = "l", color = "purple", lwd = 2,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
30 - main = "Lorenz system",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
31 + main = "Langford Attractor",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
32 xlab = colnames(m)[2],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
33 ylab = colnames(m)[3],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
34 zlab = colnames(m)[4],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
35 @@ -27,3 +27,16 @@
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
36 cex.lab = 2)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
37 dev.off()
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
38
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
39 +subplot <- function(m, n){
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
40 + m2 <- m[n, ]
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
41 + scatterplot3d(m2[,2], m2[,3], m2[,4],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
42 + highlight.3d = FALSE,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
43 + col.axis = "blue", col.grid = "lightblue",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
44 + type = "l", color = "purple", lwd = 2,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
45 + main = "Langford Attractor",
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
46 + xlab = colnames(m)[2],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
47 + ylab = colnames(m)[3],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
48 + zlab = colnames(m)[4],
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
49 + cex.main = 3,
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
50 + cex.lab = 2)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
51 +}
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
52 diff -r 925250ea21a4 rkmod.f90
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
53 --- a/rkmod.f90 Sun Jul 21 06:20:46 2024 +0900
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
54 +++ b/rkmod.f90 Tue Jul 23 02:35:22 2024 +0900
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
55 @@ -10,10 +10,15 @@
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
56 real(kind=dpkind) :: time
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
57 real(kind=dpkind),dimension(:) :: wk
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
58 real(kind=dpkind),dimension(size(wk)) :: rhside
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
59 - real(kind=dpkind),parameter :: a=10e0,b=28e0,c=8e0/3e0
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
60 - rhside(1)=a*(wk(2)-wk(1))
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
61 - rhside(2)=b*wk(1)-wk(2)-wk(1)*wk(3)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
62 - rhside(3)=wk(1)*wk(2)-c*wk(3)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
63 +! real(kind=dpkind),parameter :: a=10e0,b=28e0,c=8e0/3e0
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
64 +! rhside(1)=a*(wk(2)-wk(1))
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
65 +! rhside(2)=b*wk(1)-wk(2)-wk(1)*wk(3)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
66 +! rhside(3)=wk(1)*wk(2)-c*wk(3)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
67 + real(kind=dpkind),parameter :: a = 0.6
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
68 + rhside(1) = (wk(3) - 0.7)*wk(1) - 3.5*wk(2)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
69 + rhside(2) = 3.5*wk(1) + (wk(3) - 0.7)*wk(2)
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
70 + rhside(3) = a + wk(3) - wk(3)**3 / 3 - (wk(1)**2 + wk(2)**2)*(1 + 0.25*wk(3))
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
71 +
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
72 end function
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
73 !Rから呼び出すサブルーチン
d90925ba642e add a patch file
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
74 subroutine calc(x, max_i, r)