annotate rkmain.f90 @ 0:5bd0f2a15d2a

import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Tue, 23 Jul 2024 02:30:57 +0900
parents
children 954faa9f6837
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
1 program rkmain
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
2 use rungekutta !ルンゲクッタ解法をまとめたモジュール
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
3 implicit none
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
4 real(kind=dpkind),dimension(3) :: x !状態変数
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
5 type(rk) :: rktype !ルンゲクッタ法ソルバに関連する型
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
6
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
7 !微分方程式の右辺を計算する関数、解法、時間刻みの指定
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
8 call rktype%setup(rhside,"rk4",1d-5)
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
9 !初期値の指定
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
10 x=[0.5e0,0.5e0,0.5e0]
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
11 !時刻0?50秒まで、0.01秒毎に標準出力へ書き出し。
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
12 !ただし、内部的には刻み幅1e-5秒としている。
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
13 do
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
14 if(rktype%time>5e1)exit
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
15 call rktype%solver(rktype%time+1e-2,x) !積分実行
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
16 print*,rktype%time,x
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
17 enddo
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
18 !========================================
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
19 contains
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
20 !微分方程式の右辺を定義
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
21 function rhside(self,time,wk)
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
22 class(rk),intent(inout) :: self !parameter
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
23 real(kind=dpkind) :: time
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
24 real(kind=dpkind),dimension(:) :: wk
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
25 real(kind=dpkind),dimension(size(wk)) :: rhside
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
26 real(kind=dpkind),parameter :: a=10e0,b=28e0,c=8e0/3e0
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
27 rhside(1)=a*(wk(2)-wk(1))
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
28 rhside(2)=b*wk(1)-wk(2)-wk(1)*wk(3)
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
29 rhside(3)=wk(1)*wk(2)-c*wk(3)
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
30 end function
5bd0f2a15d2a import from https://qiita.com/sakamoti/items/de851e0d07aeef5be310
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
31 end program