PLUTO
4.4-patch2
|
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) |
|
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
[in] | ar | Pointer to input array |
[in] | val | Value to search |
[in] | nel | Length of array |
[in] | ilg | Guess value of lower bound. Give 0 if not known. |
[in] | ihg | Guess value of upper bound. Give nel-1 if not known. ilg, ihg if given, helps achieve faster convergence. |
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).
[in] | pl | Pointer to the Particle Structure. |
[out] | nhat | 1D Vector for the Shock Normal. |
[out] | vshk | Shock Speed. |
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.
[in] | pl | Pointer to the Particle Structure. |
[in] | AccEff | Acceleration Efficiency depends on Free Turbulence Parameter |
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.
[in] | d | Pointer to the data structure. |
[in/out] | pl Pointer to the Particle structure. | |
[in] | grid | Pointer to the grid structure. |
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 to be the volume average:
The constant is chosen so that the total integral is gives the number of microparticles per unit (fluid) density:
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.
[in] | pl | Pointer to the Particle structure. |
[in] | q | Electron spectral momentum index : p^{-q} |
[in] | eng_max | Maximum energy of the updated spectra. |
[in] | TotpartSHK | Total number of shocked particles to be updated. |
[in] | TotpartE | Total energy density of unshocked cosmic ray electrons in cell Gives energy density of existing particles. |
[in] | TotpartN | Total number density of unshocked cosmic ray electrons in cell Gives number density of existing particles. |
|
static |
Re-grid an input spectrum to a new energy bin array, preserving the total norm:
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