PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Advection of a magnetic field loop.
5 
6  This problem consists of a weak magnetic field loop being advected in a
7  uniform velocity field. Since the total pressure is dominated by the
8  thermal contribution, the magnetic field is essentially transported as
9  a passive scalar.
10  The preservation of the initial circular shape tests the scheme
11  dissipative properties and the correct discretization balance of
12  multidimensional terms.
13 
14  Following [GS05][MT10][MTB10] (see also references therein),
15  the computational box is defined by \f$ x\in[-1,1],\, y\in[-0.5,0.5] \f$
16  discretized on \f$ 2N_y\times N_y\f$ grid cells (Ny=64).
17  Density and pressure are initially constant and equal to 1.
18  The velocity of the flow is given by
19  \f[
20  \vec{v} = V_0(\cos\alpha, \sin\alpha)
21  \f]
22  with \f$V_0 = \sqrt{5},\,\sin \alpha = 1/\sqrt{5},\, \cos \alpha = 2/\sqrt{5}\f$.
23  The magnetic field is defined through its magnetic vector potential as
24  \f[
25  A_z = \left\{ \begin{array}{ll}
26  A_0(R-r) & \textrm{if} \quad R_1 < r \leq R \,, \\ \noalign{\medskip}
27  0 & \textrm{if} \quad r > R \,,
28  \end{array} \right.
29  \f]
30  with \f$ A_0 = 10^{-3},\, R = 0.3,\, r = \sqrt{x^2+y^2}\f$.
31  A slightly different variant is used for the finite difference schemes
32  as explained in [MTB10]:
33  \f[
34  A_z = \left\{ \begin{array}{ll}
35  a_0 + a_2r^2 & \textrm{if} \quad 0 \leq r \leq R_1 \,, \\ \noalign{\medskip}
36  A_0(R-r) & \textrm{if} \quad R_1 < r \leq R \,, \\ \noalign{\medskip}
37  0 & \textrm{if} \quad r > R \,,
38  \end{array} \right.
39  \f]
40  where \f$R_1=0.2 R,\, a_2 = -0.5A_0/R_1,\, a_0 = A_0(R-R_1) - a_2R_1^2\f$.
41 
42  Double periodic boundary conditions are imposed.
43 
44  A snapshot of the solution on a \c 128x64 grid at t=0.2 is shown below.
45 
46  \image html mhd_fl.03.jpg "Magetic pressure at t=0.2 (configuration #03)."
47 
48  \author A. Mignone (mignone@ph.unito.it)
49  \date Aug 6, 2015
50 
51  \b References
52  - [GS05] "An unsplit Godunov method for ideal MHD via constrained transport",
53  Gardiner \& Stone JCP (2005) 205, 509
54  - [MT10] "A second-order unsplit Godunov scheme for cell-centered MHD:
55  The CTU-GLM scheme", Mignone \& Tzeferacos, JCP (2010) 229, 2117.
56 
57  - [MTB10] "High-order conservative finite difference GLM-MHD schemes for
58  cell-centered MHD", Mignone, Tzeferacos & Bodo, JCP (2010) 229, 5896.
59 */
60 /* ///////////////////////////////////////////////////////////////////// */
61 #include "pluto.h"
62 
63 /* ********************************************************************* */
64 void Init (double *v, double x1, double x2, double x3)
65 /*
66  *
67  *
68  *
69  *********************************************************************** */
70 {
71  double c, s, v0=sqrt(5.0);
72  double A=1.e-3, R=0.3, R1, r, Bphi;
73 
74  r = sqrt(x1*x1 + x2*x2);
75  c = 2.0/sqrt(5.0);
76  s = 1.0/sqrt(5.0);
77 /*
78  c = 1.0/sqrt(2.0);
79  s = 1.0/sqrt(2.0);
80 */
81  v[RHO] = 1.0;
82  v[VX1] = v0*c;
83  v[VX2] = v0*s;
84  v[VX3] = 0.0;
85  v[PRS] = 1.0;
86  v[TRC] = 0.0;
87 
88 #if PHYSICS == MHD || PHYSICS == RMHD
89 
90  v[AX1] = 0.0;
91  v[AX2] = 0.0;
92  v[AX3] = A*(R - r)*(r <= R);
93 
94  #ifdef FINITE_DIFFERENCE
95  R1 = 0.2*R;
96  if (r < R1) {
97  double a0, a2;
98  a2 = -A/(2.0*R1);
99  a0 = A*(R-R1) - a2*R1*R1;
100  v[AX3] = a0 + a2*r*r;
101  A = -2.0*a2*r;
102  } else if (r <= R){
103  v[AX3] = A*(R - r);
104  } else {
105  v[AX3] = 0.0;
106  A = 0.0;
107  }
108  #endif
109 
110  v[BX1] = -A*x2/r*(r <= R); /* = dAz/dy */
111  v[BX2] = A*x1/r*(r <= R); /* = - dAz/dx */
112  v[BX3] = 0.0;
113 
114 #endif
115 }
116 /* ********************************************************************* */
117 void Analysis (const Data *d, Grid *grid)
118 /*
119  *
120  *
121  *********************************************************************** */
122 {
123 
124 }
125 
126 /* ********************************************************************* */
127 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
128 /*
129  *
130  *********************************************************************** */
131 { }
132 
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
#define AX2
Definition: mod_defs.h:86
#define TRC
Definition: pluto.h:581
#define VX1
Definition: mod_defs.h:28
Definition: structs.h:78
#define AX3
Definition: mod_defs.h:87
tuple c
Definition: menu.py:375
#define s
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
Definition: structs.h:30
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define BX2
Definition: mod_defs.h:26
Definition: structs.h:346
void Analysis(const Data *d, Grid *grid)
Definition: init.c:66
void Init(double *v, double x1, double x2, double x3)
Definition: init.c:17