PLUTO
init.c File Reference

Advection of a magnetic field loop. More...

#include "pluto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

void Init (double *v, double x1, double x2, double x3)
 
void Analysis (const Data *d, Grid *grid)
 
void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

Advection of a magnetic field loop.

This problem consists of a weak magnetic field loop being advected in a uniform velocity field. Since the total pressure is dominated by the thermal contribution, the magnetic field is essentially transported as a passive scalar. The preservation of the initial circular shape tests the scheme dissipative properties and the correct discretization balance of multidimensional terms.

Following [GS05][MT10][MTB10] (see also references therein), the computational box is defined by $ x\in[-1,1],\, y\in[-0.5,0.5] $ discretized on $ 2N_y\times N_y$ grid cells (Ny=64). Density and pressure are initially constant and equal to 1. The velocity of the flow is given by

\[ \vec{v} = V_0(\cos\alpha, \sin\alpha) \]

with $V_0 = \sqrt{5},\,\sin \alpha = 1/\sqrt{5},\, \cos \alpha = 2/\sqrt{5}$. The magnetic field is defined through its magnetic vector potential as

\[ A_z = \left\{ \begin{array}{ll} A_0(R-r) & \textrm{if} \quad R_1 < r \leq R \,, \\ \noalign{\medskip} 0 & \textrm{if} \quad r > R \,, \end{array} \right. \]

with $ A_0 = 10^{-3},\, R = 0.3,\, r = \sqrt{x^2+y^2}$. A slightly different variant is used for the finite difference schemes as explained in [MTB10]:

\[ A_z = \left\{ \begin{array}{ll} a_0 + a_2r^2 & \textrm{if} \quad 0 \leq r \leq R_1 \,, \\ \noalign{\medskip} A_0(R-r) & \textrm{if} \quad R_1 < r \leq R \,, \\ \noalign{\medskip} 0 & \textrm{if} \quad r > R \,, \end{array} \right. \]

where $R_1=0.2 R,\, a_2 = -0.5A_0/R_1,\, a_0 = A_0(R-R_1) - a_2R_1^2$.

Double periodic boundary conditions are imposed.

A snapshot of the solution on a 128x64 grid at t=0.2 is shown below.

mhd_fl.03.jpg
Magetic pressure at t=0.2 (configuration #03).
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 6, 2015

References

  • [GS05] "An unsplit Godunov method for ideal MHD via constrained transport", Gardiner & Stone JCP (2005) 205, 509
  • [MT10] "A second-order unsplit Godunov scheme for cell-centered MHD: The CTU-GLM scheme", Mignone & Tzeferacos, JCP (2010) 229, 2117.
  • [MTB10] "High-order conservative finite difference GLM-MHD schemes for cell-centered MHD", Mignone, Tzeferacos & Bodo, JCP (2010) 229, 5896.

Definition in file init.c.

Function Documentation

void Analysis ( const Data d,
Grid grid 
)

Perform runtime data analysis.

Parameters
[in]dthe PLUTO Data structure
[in]gridpointer to array of Grid structures

Definition at line 117 of file init.c.

122 {
123 
124 }
void Init ( double *  v,
double  x1,
double  x2,
double  x3 
)

The Init() function can be used to assign initial conditions as as a function of spatial position.

Parameters
[out]va pointer to a vector of primitive variables
[in]x1coordinate point in the 1st dimension
[in]x2coordinate point in the 2nd dimension
[in]x3coordinate point in the 3rdt dimension

The meaning of x1, x2 and x3 depends on the geometry:

\[ \begin{array}{cccl} x_1 & x_2 & x_3 & \mathrm{Geometry} \\ \noalign{\medskip} \hline x & y & z & \mathrm{Cartesian} \\ \noalign{\medskip} R & z & - & \mathrm{cylindrical} \\ \noalign{\medskip} R & \phi & z & \mathrm{polar} \\ \noalign{\medskip} r & \theta & \phi & \mathrm{spherical} \end{array} \]

Variable names are accessed by means of an index v[nv], where nv = RHO is density, nv = PRS is pressure, nv = (VX1, VX2, VX3) are the three components of velocity, and so forth.

Definition at line 64 of file init.c.

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 }
#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
#define AX3
Definition: mod_defs.h:87
tuple c
Definition: menu.py:375
#define s
#define BX3
Definition: mod_defs.h:27
#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
double * A
Right interface area, A[i] = .
Definition: structs.h:87
void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Assign user-defined boundary conditions.

Parameters
[in,out]dpointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies the boundary side where ghost zones need to be filled. It can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Assign user-defined boundary conditions in the lower boundary ghost zones. The profile is top-hat:

\[ V_{ij} = \left\{\begin{array}{ll} V_{\rm jet} & \quad\mathrm{for}\quad r_i < 1 \\ \noalign{\medskip} \mathrm{Reflect}(V) & \quad\mathrm{otherwise} \end{array}\right. \]

where $ V_{\rm jet} = (\rho,v,p)_{\rm jet} = (1,M,1/\Gamma)$ and M is the flow Mach number (the unit velocity is the jet sound speed, so $ v = M$).

Assign user-defined boundary conditions:

  • left side (x beg): constant shocked values
  • bottom side (y beg): constant shocked values for x < 1/6 and reflective boundary otherwise.
  • top side (y end): time-dependent boundary: for $ x < x_s(t) = 10 t/\sin\alpha + 1/6 + 1.0/\tan\alpha $ we use fixed (post-shock) values. Unperturbed values otherwise.

Assign user-defined boundary conditions at inner and outer radial boundaries. Reflective conditions are applied except for the azimuthal velocity which is fixed.

Assign user-defined boundary conditions.

Parameters
[in/out]d pointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies on which side boundary conditions need to be assigned. side can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Definition at line 127 of file init.c.

131 { }