MPI-AMRVAC  3.0
The MPI - Adaptive Mesh Refinement - Versatile Advection Code
mod_dipole.t
Go to the documentation of this file.
1 !> sets up a magnetic dipole in a 3D cartesian box
2 ! parameters for dipole moment:
3 ! strength mu_dipole (factor 4pi included)
4 ! polar angle in degrees theta_dipole [0 to 90]
5 ! azimuthal angle in degrees phi_dipole [0 to 360]
6 ! center of dipole at x1_dip, x2_dip, x3_dip
7 module mod_dipole
8  implicit none
10  double precision :: mx, my, mz
11 
12 contains
13 
14 {^ifthreed
15  subroutine dipole(ixI^L,ixO^L,x,B)
17 
18  integer, intent(in) :: ixI^L, ixO^L
19  double precision, intent(in) :: x(ixI^S,1:ndim)
20  double precision, intent(inout) :: B(ixI^S,1:ndir)
21 
22  double precision :: xsincos(ixI^S),xsinsin(ixI^S),xcos(ixI^S)
23  double precision :: rr0(ixI^S),mdotr(ixI^S)
24 
25  b=0.0d0
26  mx=mu_dipole*dsin(theta_dipole*dpi/180.0d0)*dcos(phi_dipole*dpi/180.d0)
27  my=mu_dipole*dsin(theta_dipole*dpi/180.0d0)*dsin(phi_dipole*dpi/180.0d0)
28  mz=mu_dipole*dcos(theta_dipole*dpi/180.0d0)
29  rr0(ixo^s)=dsqrt((x(ixo^s,1)-x1_dip)**2 &
30  +(x(ixo^s,2)-x2_dip)**2 &
31  +(x(ixo^s,3)-x3_dip)**2)
32  if(any(rr0(ixo^s)<smalldouble)) call mpistop("dipole center at cell center")
33  !where(rr0(ixO^S)<smalldouble)
34  ! rr0(ixO^S)=bigdouble
35  !endwhere
36  xsincos(ixo^s)=(x(ixo^s,1)-x1_dip)/rr0(ixo^s)
37  xsinsin(ixo^s)=(x(ixo^s,2)-x2_dip)/rr0(ixo^s)
38  xcos(ixo^s) =(x(ixo^s,3)-x3_dip)/rr0(ixo^s)
39  mdotr(ixo^s)=mx*xsincos(ixo^s)+my*xsinsin(ixo^s)+mz*xcos(ixo^s)
40  b(ixo^s,1)=(3.0d0*xsincos(ixo^s)*mdotr(ixo^s)-mx)/rr0(ixo^s)**3
41  b(ixo^s,2)=(3.0d0*xsinsin(ixo^s)*mdotr(ixo^s)-my)/rr0(ixo^s)**3
42  b(ixo^s,3)=(3.0d0*xcos(ixo^s) *mdotr(ixo^s)-mz)/rr0(ixo^s)**3
43 
44  end subroutine dipole
45 }
46 end module mod_dipole
subroutine mpistop(message)
Exit MPI-AMRVAC with an error message.
Definition: comm_lib.t:194
sets up a magnetic dipole in a 3D cartesian box
Definition: mod_dipole.t:7
double precision x1_dip
Definition: mod_dipole.t:9
double precision mz
Definition: mod_dipole.t:10
double precision x3_dip
Definition: mod_dipole.t:9
double precision my
Definition: mod_dipole.t:10
double precision mx
Definition: mod_dipole.t:10
double precision phi_dipole
Definition: mod_dipole.t:9
double precision mu_dipole
Definition: mod_dipole.t:9
double precision x2_dip
Definition: mod_dipole.t:9
subroutine dipole(ixIL, ixOL, x, B)
Definition: mod_dipole.t:16
double precision theta_dipole
Definition: mod_dipole.t:9
This module contains definitions of global parameters and variables and some generic functions/subrou...