forked from AstroSnow/PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathionrectest.f90
158 lines (139 loc) · 4.87 KB
/
ionrectest.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
subroutine ionrectest
use parameters,only:pi
use globalvar,only:ix,jx,kx,U_h,U_m,flag_bnd,col,beta,flag_b_stg,dtout,&
flag_mhd,flag_mpi,my_rank,flag_pip,gm,beta,tend,&
x,y,z,dx,dy,dz,n_fraction,debug_direction,debug_option,gra,flag_grav,total_prc,&
margin,dxc,s_order,mpi_siz,mpi_pos, flag_IR, T0
use scheme_rot,only:pv2cq_mhd,pv2cq_hd
use model_rot, only:set_coordinate,setcq
use procedures
implicit none
double precision :: ro_h(1:ix,1:jx,1:kx),ro_m(1:ix,1:jx,1:kx)
double precision :: vx_h(1:ix,1:jx,1:kx),vx_m(1:ix,1:jx,1:kx)
double precision :: vy_h(1:ix,1:jx,1:kx),vy_m(1:ix,1:jx,1:kx)
double precision :: vz_h(1:ix,1:jx,1:kx),vz_m(1:ix,1:jx,1:kx)
double precision :: P_h (1:ix,1:jx,1:kx),P_m (1:ix,1:jx,1:kx)
double precision :: B_x (1:ix,1:jx,1:kx)
double precision :: B_y (1:ix,1:jx,1:kx)
double precision :: B_z (1:ix,1:jx,1:kx)
double precision :: temperature(1:ix+1),energy(1:ix+1),rho(1:ix+1)
double precision :: mask(ix,jx,kx)
double precision :: v_para(ix,jx,kx),v_perp(ix,jx,kx)
double precision :: b_para(ix,jx,kx),b_perp(ix,jx,kx)
double precision :: v_b_para(ix,jx,kx),b_b_para(ix,jx,kx)
double precision :: v_theta(ix,jx,kx),v_phi(ix,jx,kx)
double precision :: b_theta(ix,jx,kx),b_phi(ix,jx,kx)
double precision :: f_n,f_p,f_p_n,f_p_p,start(3),end(3),B0,P_tot,P_top,P_base
double precision :: lambda
integer i,j,k
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(debug_direction.eq.1) then
! 0D problem
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!set ionization fraction-----------------
if ((flag_pip.eq.0) .OR. (flag_IR.eq.0)) then
print*,'=== flag_PIP and flag_IR should be 1 ==='
stop
else
f_n=n_fraction
f_p=1.0d0-n_fraction
f_p_n=f_n/(f_n+2.0d0*f_p)
f_p_p=2.0d0*f_p/(f_n+2.0d0*f_p)
endif
!----------------------------------------
!Set coordinate (uniform grid)--------------------------
!!set lower and upper coordinate
start(1)=0.0d0 ;end(1)=1.0d0 !400.0d0/f_p
start(2)=-1.0d0 ;end(2)=1.0d0
start(3)=-1.0d0 ;end(3)=1.0d0
call set_coordinate(start,end)
!---------------------------------------
!initialise arrays
do k=1,kx;do j=1,jx;do i=1,ix
ro_h(i,j,k)=1.0d0*f_n
ro_m(i,j,k)=1.0d0*f_p
p_h(i,j,k)=2.0d0*f_p_n/gm
p_m(i,j,k)=2.0d0*f_p_p/gm
vx_h(i,j,k)=0.0d0
vx_m(i,j,k)=0.0d0
vy_h(i,j,k)=0.0d0
vy_m(i,j,k)=0.0d0
vz_h(i,j,k)=0.0d0
vz_m(i,j,k)=0.0d0
b_x(i,j,k)=0.0d0
b_y(i,j,k)=0.0d0
b_z(i,j,k)=0.0d0
enddo;enddo;enddo
!!set boundary condition----------------------
flag_bnd(1)=1
flag_bnd(2)=1
flag_bnd(3)=1
flag_bnd(4)=1
flag_bnd(5)=1
flag_bnd(6)=1
!-------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
elseif(debug_direction.eq.2) then
! Leake 2012/2013 reconnection paper
! TO DO!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lambda=0.5 !/L0?
!set ionization fraction-----------------
if ((flag_pip.eq.0) .OR. (flag_IR.eq.0)) then
print*,'=== flag_PIP and flag_IR should be 1 ==='
stop
else
f_n=n_fraction
f_p=1.0d0-n_fraction
f_p_n=f_n/(f_n+2.0d0*f_p)
f_p_p=2.0d0*f_p/(f_n+2.0d0*f_p)
endif
!----------------------------------------
!Set coordinate (uniform grid)--------------------------
!!set lower and upper coordinate
start(1)=0.0d0 ;end(1)=1.0d0 !400.0d0/f_p
start(2)=-1.0d0 ;end(2)=1.0d0
start(3)=-1.0d0 ;end(3)=1.0d0
call set_coordinate(start,end)
!---------------------------------------
!initialise arrays
do k=1,kx;do j=1,jx;do i=1,ix
ro_h(i,j,k)=1.0d0*f_n
ro_m(i,j,k)=1.0d0*f_p
p_h(i,j,k)=2.0d0*f_p_n/gm
p_m(i,j,k)=2.0d0*f_p_p/gm
vx_h(i,j,k)=0.0d0
vx_m(i,j,k)=0.0d0
vy_h(i,j,k)=0.0d0
vy_m(i,j,k)=0.0d0
vz_h(i,j,k)=0.0d0
vz_m(i,j,k)=0.0d0
b_x(i,j,k)=-B0*sinh(y(j)/lambda)
b_y(i,j,k)=0.0d0
b_z(i,j,k)=0.0d0
enddo;enddo;enddo
!!set boundary condition----------------------
flag_bnd(1)=1
flag_bnd(2)=1
flag_bnd(3)=1
flag_bnd(4)=1
flag_bnd(5)=1
flag_bnd(6)=1
!-------------------------------------------------
endif
!convert PV2cq and set that value to global variable 'U_h' and/or 'U_m'
call setcq(ro_m,vx_m,vy_m,vz_m,p_m,B_x,B_y,B_z, &
ro_h,vx_h,vy_h,vz_h,p_h)
!---------------------------------------------------------------------
!set default output period and time duration--------------------------
if(tend.lt.0.0) then
tend=0.4d0
dtout=tend/10.0
if(flag_mpi.eq.0 .or.my_rank.eq.0) print *,"TEND",dtout,tend
endif
!---------------------------------------------------------------------
end subroutine ionrectest