Skip to content

Commit

Permalink
Merge pull request #341 from lukasmerten/Misc
Browse files Browse the repository at this point in the history
Miscellaneous
  • Loading branch information
adundovi committed Jun 8, 2021
2 parents 0a2a294 + d21e493 commit 6887ef9
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 38 deletions.
2 changes: 1 addition & 1 deletion doc/pages/Basic-concepts.md
Expand Up @@ -30,7 +30,7 @@ the parallel sections of the code. If they do, a change by thread A is likely
to mess with the correct calculation in thread B. Most importantly, the
simulation modules which are in the current parallelization layout shared among
the threads cannot store information on the cosmic ray. Instead the information
has be stored on the cosmic ray itself.
has to be stored on the cosmic ray itself.

Program parts in which "thread-safety" cannot be ensured need to be put inside
a "critical region". If a thread reaches a critical region that is occupied by
Expand Down
Expand Up @@ -2038,7 +2038,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
Expand Up @@ -209,7 +209,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
Expand Up @@ -265,7 +265,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
42 changes: 13 additions & 29 deletions doc/pages/example_notebooks/density/densitys_easy_example.ipynb
Expand Up @@ -18,9 +18,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
}
Expand All @@ -40,9 +39,8 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
Expand All @@ -68,9 +66,8 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
Expand Down Expand Up @@ -110,14 +107,13 @@
"metadata": {},
"source": [
"#### The ConstantDensity can be adjusted to new values and the usage of several parts can be chosen.\n",
"For this purpose methodes are available to change and activate (set-function) and methodes to see the actual configuration (getisfor-functions)."
"For this purpose methods are available to change and activate (set-function) and methodes to see the actual configuration (getisfor-functions)."
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
Expand All @@ -130,7 +126,10 @@
"HI: True, HII: True, H2: True, \n",
" \n",
"\n",
"ConstantDensity:HI component is not activ and has a density of 1e+06 cm^-3 HII component is not activ and has a density of 1.5e+06 cm^-3 H2 component is activ and has a density of 1.3e+06 cm^-3\n"
"ConstantDensity:\n",
"HI component is not active and has a density of 1e+06 cm^-3\n",
"HII component is not active and has a density of 1.5e+06 cm^-3\n",
"H2 component is active and has a density of 1.3e+06 cm^-3\n"
]
}
],
Expand Down Expand Up @@ -160,9 +159,8 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
Expand Down Expand Up @@ -206,9 +204,8 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
Expand Down Expand Up @@ -269,9 +266,8 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 7,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
Expand Down Expand Up @@ -314,18 +310,6 @@
"print('H2 density n_H2 = %f' %n_H2)\n",
"print('nucleon density n_nucl = %f' %n_nucl)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
}
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -344,7 +328,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
Expand Up @@ -5,7 +5,7 @@
"metadata": {},
"source": [
"# Galactic trajectories\n",
"The following codes performs a backtracking simulation in the JF2012 Galactic magnetic field model and visualizes the trajectories.\n",
"The following code performs a backtracking simulation in the JF2012 Galactic magnetic field model and visualizes the trajectories.\n",
"A custom simulation module is used for a numbered trajectory output, that simplifies separating the individual trajectories for plotting later on."
]
},
Expand Down Expand Up @@ -153,7 +153,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion doc/pages/example_notebooks/secondaries/photons.v4.ipynb
Expand Up @@ -139,7 +139,7 @@
"source": [
"## Photons from Proton Propagation\n",
"\n",
"The generaton of photons has to be enabled for the individual energy-loss processes in the module chain. Also, separate photon output can be added:"
"The generation of photons has to be enabled for the individual energy-loss processes in the module chain. Also, separate photon output can be added:"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/pages/example_notebooks/sim1D/sim1D.v4.ipynb
Expand Up @@ -13,7 +13,7 @@
"\n",
"To include cosmological effects in this 1D simulation we need two things:\n",
"\n",
"First, the ```Redshift``` module updates the current redshift of the particle in each propagation step. It is best added directly after the propagation module, although the postion shouldn't matter much for the typically small propagation steps.\n",
"First, the ```Redshift``` module updates the current redshift of the particle in each propagation step. It is best added directly after the propagation module, although the position shouldn't matter much for the typically small propagation steps.\n",
"\n",
"Second, we need to set the initial redshift of the particles.\n",
"In 1D simulations the intial redshift is determined by the source distance. To have the source automatically set the redshift we add ```SourceRedshift1D```. **Please note** that it has to be added after the source property that defines the source position.\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/pages/example_notebooks/sim4D/sim4D.v4.ipynb
Expand Up @@ -11,7 +11,7 @@
"**Note:** In CRPropa, time is always expressed in terms of redshift $z$, whereas positions are always expressed in terms of comoving coordinates as Cartesian 3-vectors.\n",
"\n",
"### Simulation setup\n",
"The simulation setup is that of a 3D simulation with a few addition:\n",
"The simulation setup is that of a 3D simulation with a few additions:\n",
"1. We add a source property for the redshift at emission. This can be either ```SourceRedshift```, ```SourceUniformRedshift``` or ```SourceRedshiftEvolution```.\n",
"2. The simulation module ```FutureRedshift``` implements adiabatic energy loss and updates the redshift. In contrast to ```Redshift``` it allows particles to be propagated into the future $z < 0$ which enables faster convergence for finite observation windows.\n",
"3. The observer feature ```ObserverRedshiftWindow``` specifies a time window $z_\\rm{min} < z < z_\\rm{max}$ in which particles are detected if they hit the observer. Note that this can also be done after the simulation by cutting on the redshifts at observation. For this we also output the current redshift at observation.\n",
Expand Down
5 changes: 5 additions & 0 deletions src/module/NuclearDecay.cpp
Expand Up @@ -215,6 +215,8 @@ void NuclearDecay::betaDecay(Candidate *candidate, bool isBetaPlus) const {

// generate cdf of electron energy, neglecting Coulomb correction
// see Basdevant, Fundamentals in Nuclear Physics, eq. (4.92)
// This leads to deviations from theoretical expectations at low
// primary energies.
std::vector<double> energies;
std::vector<double> densities; // cdf(E), unnormalized

Expand All @@ -231,6 +233,9 @@ void NuclearDecay::betaDecay(Candidate *candidate, bool isBetaPlus) const {
}

// draw random electron energy and angle
// assumption of ultra-relativistic particles
// leads to deviations from theoretical predictions
// is not problematic for usual CRPropa energies E>~TeV
Random &random = Random::instance();
double E = interpolate(random.rand() * cdf, densities, energies);
double p = sqrt(E * E - me * me); // p*c
Expand Down

0 comments on commit 6887ef9

Please sign in to comment.