PLUTO  4.4-patch2
Functions
particles_lp_dsa.c File Reference

Shock-related function for LP spectra update. More...

#include "pluto.h"

Functions

static int locate_spec (double *, double, int, int, int)
 
static double RegridSpec (double *, double *, double, double, int, int)
 
void Particles_LP_SampleShock (Particle *pl, particleProbe *probe, Grid *grid)
 
double Particles_LP_GetEmaxAtShock (Particle *pl, particleProbe *probe, double AccEff, Grid *grid)
 
void Particles_LP_ComputeShockNormalSpeed (Particle *pl, double *nhat, double *vshk)
 
void Particles_LP_UpdateUpstreamSpectra (Particle *pl, Grid *grid, double q, double eng_max, long int TotpartSHK, double TotpartE, double TotpartN)
 

Detailed Description

Authors
B. Vaidya (bvaid.nosp@m.ya@i.nosp@m.iti.a.nosp@m.c.in)
A. Mignone (migno.nosp@m.ne@t.nosp@m.o.inf.nosp@m.n.it)
D. Mukherjee (dipan.nosp@m.jan..nosp@m.mukhe.nosp@m.rjee.nosp@m.@unit.nosp@m.o.it)
Date
July 3, 2019

Function Documentation

◆ locate_spec()

int locate_spec ( double *  ar,
double  val,
int  nel,
int  ilg,
int  ihg 
)
static

Search ordered array to locate val in array (spectrum). Returns index i such that: ar[i] <= val < ar[i+1] If val > ar[nlast-1], return i = nel If val < ar[0], return i = -1

Parameters
[in]arPointer to input array
[in]valValue to search
[in]nelLength of array
[in]ilgGuess value of lower bound. Give 0 if not known.
[in]ihgGuess value of upper bound. Give nel-1 if not known. ilg, ihg if given, helps achieve faster convergence.

◆ Particles_LP_ComputeShockNormalSpeed()

void Particles_LP_ComputeShockNormalSpeed ( Particle *  pl,
double *  nhat,
double *  vshk 
)

Compute Shock speed and Normal Unit Vector using the Coplanarity theorem (See. Schwartz 1998 Chapter on Shocks).

Parameters
[in]plPointer to the Particle Structure.
[out]nhat1D Vector for the Shock Normal.
[out]vshkShock Speed.

◆ Particles_LP_GetEmaxAtShock()

double Particles_LP_GetEmaxAtShock ( Particle *  pl,
particleProbe *  probe,
double  AccEff,
Grid grid 
)

Compute the maximum energy of the injected energy spectrum that needs to be updated when the macro-particle crosses the shock. See Mimica 2009 & Fromm 2016.

Parameters
[in]plPointer to the Particle Structure.
[in]AccEffAcceleration Efficiency depends on Free Turbulence Parameter
Returns
Maximum energy [in code units] of the updated spectrum

◆ Particles_LP_SampleShock()

void Particles_LP_SampleShock ( Particle *  pl,
particleProbe *  probe,
Grid grid 
)

Compute upstream and downstream fluid quantites as the particles crosses the shock. The density and velocity values are required for estimating the shock normal and shock speed and finally therefore the compression ratio.

Parameters
[in]dPointer to the data structure.
[in/out]pl Pointer to the Particle structure.
[in]gridPointer to the grid structure.

◆ Particles_LP_UpdateUpstreamSpectra()

void Particles_LP_UpdateUpstreamSpectra ( Particle *  pl,
Grid grid,
double  q,
double  eng_max,
long int  TotpartSHK,
double  TotpartE,
double  TotpartN 
)

Updates the particle spectra as the particle pl passes through the shock. The energy grid is reset and the distribution becomes a predefined power-law. We initialize $ \chi $ to be the volume average:

\[ \chi = CE^{-p}\quad\rightarrow\quad \av{\chi}_i = \frac{C}{\Delta E_i} \int_{E_{i-\HALF}}^{E_{i+\HALF}} E^{-p}\, dE = \left\{\begin{array}{ll} \DS \frac{C}{\Delta E_i} \Big(E^{1-p}_{i+\HALF} - E^{1-p}_{i-\HALF}\Big) & \qquad {\rm for} \quad p \ne 1 \\ \noalign{\medskip} \DS \frac{C}{\Delta E_i} \log\left(\frac{E_{i+\HALF}}{E_{i-\HALF}}\right) & \qquad {\rm for} \quad p = 1 \end{array}\right. \]

The constant $ C $ is chosen so that the total integral is gives the number of microparticles per unit (fluid) density:

\[ \frac{N_{\rm micro}}{\rho} = \int_{E_{\min}}^{E_{\max}} \chi\, dE = \sum_i \Delta E_i\av{\chi}_i = C (E_{\max}^{1-p} - E_{\min}^{1-p}) \quad\rightarrow\quad C = \frac{N_{\rm micro}}{\rho}\frac{1}{E_{\max}^{1-p} - E_{\min}^{1-p}} \]

  • Note: spectra array: (0, nel-1), size: nel energy array : (0, nel), size: nel+1

For locate_spec, if guess value of lower bound is ilg, guess upper bound is ilg+10 or nel, whichever is lower. Locate then searches within (ilg, ilg+10) or (ilg, nel). The choice of 10 cells is arbitrary. Smaller range gives faster convergence for locate. 10 should be sufficient for typical applications.

Parameters
[in]plPointer to the Particle structure.
[in]qElectron spectral momentum index : p^{-q}
[in]eng_maxMaximum energy of the updated spectra.
[in]TotpartSHKTotal number of shocked particles to be updated.
[in]TotpartETotal energy density of unshocked cosmic ray electrons in cell Gives energy density of existing particles.
[in]TotpartNTotal number density of unshocked cosmic ray electrons in cell Gives number density of existing particles.

◆ RegridSpec()

double RegridSpec ( double *  Ein,
double *  inspec,
double  Eout_l,
double  Eout_h,
int  il,
int  ih 
)
static

Re-grid an input spectrum to a new energy bin array, preserving the total norm:

\[ \int \chi_{\rm old} dE = \int_{\rm new} dE \]

TODO: Present implementation equivalent to a FLAT reconstruction. Update to LINEAR or PPM if needed. To Check.

; Config 1: (indxh - indxl >= 1) ; ; indxl indxh ;in: ------—|------—|------—|-------—|-— ;out: ---------—|-----------------—|-----------— ; pout_l pout_h

     Config 2: outspec[i] = inspec[il]*(pout_h - pout_l)

; ; indxl ; indxh ;in: ------—|------—|------—|-------—|-— ;out: -------—|--—|---------------------------— ; pout_l pout_h ; ; Config 3: outspec[i] = inspec[nel1-1]*(pin[nel1] - pout_l) ; ; indxl ; indxh ;in: ------—| ;out: --—|----------—|– ; pout_l pout_h ; ; Config 4: outspec[i] = inspec[0]*(pout_h - pin[0]) ; ; indxl ; indxh ;in: |-------—|-— ;out: -----—|----—|----— ; pout_l pout_h