Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formal integral documentation #1921

Merged
merged 13 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/physics/est_and_conv/estimators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"\n",
"</div>\n",
"\n",
"These estimators allow us to calculate the [radiative temperature](../setup/model.ipynb#Radiative-Temperature) $T_\\mathrm{rad}$ and [dilution factor](../setup/model.ipynb#Dilution-Factor) $W$ in each shell using\n",
"These estimators allow us to calculate the [radiative temperature](../setup/model.ipynb#Temperatures) $T_\\mathrm{rad}$ and [dilution factor](../setup/model.ipynb#Dilution-Factor) $W$ in each shell using\n",
"\n",
"$$T_{\\mathrm{rad}} = \\frac{h}{k_{\\mathrm{B}}} \\frac{\\pi^4}{360 \\zeta(5)} \\frac{\\bar \\nu}{J}$$\n",
"\n",
Expand Down Expand Up @@ -86,7 +86,7 @@
"\n",
"</div>\n",
"\n",
"If set to detailed mode (see [plasma configuration](../../io/configuration/components/plasma.rst)), the `J_blue` plasma property will will be replaced with the value of the $J^b_{lu}$ estimator (the raw estimator times the factor of $\\frac{ct_\\mathrm{explosion}}{4\\pi V \\Delta t}$). Otherwise, the `J_blue` in the plasma are calculated as they typically are in the plasma calculations, and the $J^b_{lu}$ estimator is only used for the [formal integral](../spectrum/sourceintegration.rst)."
"If set to detailed mode (see [plasma configuration](../../io/configuration/components/plasma.rst)), the `J_blue` plasma property will will be replaced with the value of the $J^b_{lu}$ estimator (the raw estimator times the factor of $\\frac{ct_\\mathrm{explosion}}{4\\pi V \\Delta t}$). Otherwise, the `J_blue` in the plasma are calculated as they typically are in the plasma calculations, and the $J^b_{lu}$ estimator is only used for the [formal integral](../spectrum/formal_integral.rst)."
]
},
{
Expand Down
Binary file added docs/physics/images/formal_integral_2d.ggb
Binary file not shown.
Binary file added docs/physics/images/formal_integral_2d_above.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/physics/images/formal_integral_2d_below.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/physics/images/formal_integral_sphere.ggb
Binary file not shown.
Binary file added docs/physics/images/formal_integral_sphere.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/physics/montecarlo/propagation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ When a packet is moved into a new cell, as mentioned before, it is moved to the
boundary, the plasma properties are recalculated, and the propagation direction of the packet is updated (using
:math:`\mu_f = \frac{l + r_i \mu_i}{r_f}`).

.. _physical-interactions:

Physical Interactions
---------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/physics/spectrum/basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
"source": [
"You may notice that the bins are not uniformly spaced with respect to wavelength. This is because we use the same bins for both wavelength and frequency, and thus the bins which are uniformly spaced with respect to frequency are not uniformly spaced with respect to wavelength. This is okay though, since luminosity density allows us to alter the bins without significantly altering the graph!\n",
"\n",
"Another thing you may notice in these graphs is the lack of a smooth curve. This is due to **noise**: the effects of the random nature of Monte Carlo simulations. This makes it very difficult to get a precise spectrum without drastically increasing the number of Monte Carlo packets. To solve this problem, TARDIS uses [virtual packets](virtualpackets.rst) and [the formal integral method](sourceintegration.rst) to generate a spectrum with less noise."
"Another thing you may notice in these graphs is the lack of a smooth curve. This is due to **noise**: the effects of the random nature of Monte Carlo simulations. This makes it very difficult to get a precise spectrum without drastically increasing the number of Monte Carlo packets. To solve this problem, TARDIS uses [virtual packets](virtualpackets.rst) and [the formal integral method](formal_integral.rst) to generate a spectrum with less noise."
]
}
],
Expand Down
150 changes: 150 additions & 0 deletions docs/physics/spectrum/formal_integral.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/physics/spectrum/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ below.
.. toctree::
basic
virtualpackets
sourceintegration
formal_integral
191 changes: 0 additions & 191 deletions docs/physics/spectrum/sourceintegration.rst

This file was deleted.

31 changes: 17 additions & 14 deletions tardis/montecarlo/montecarlo_numba/formal_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
NumbaModel,
NumbaPlasma,
)
from tardis.montecarlo.montecarlo_numba.formal_integral_cuda import CudaFormalIntegrator
from tardis.montecarlo.montecarlo_numba.formal_integral_cuda import (
CudaFormalIntegrator,
)

from tardis.montecarlo.spectrum import TARDISSpectrum

Expand Down Expand Up @@ -49,6 +51,7 @@ def numba_formal_integral(
"""
model, plasma, and estimator are the numba variants
"""

# todo: add all the original todos
# Initialize the output which is shared among threads
L = np.zeros(inu_size, dtype=np.float64)
Expand Down Expand Up @@ -194,14 +197,14 @@ def numba_formal_integral(
return L


#integrator_spec = [
# integrator_spec = [
# ("model", NumbaModel.class_type.instance_type),
# ("plasma", NumbaPlasma.class_type.instance_type),
# ("points", int64),
#]
# ]


#@jitclass(integrator_spec)
# @jitclass(integrator_spec)
class NumbaFormalIntegrator(object):
"""
Helper class for performing the formal integral
Expand Down Expand Up @@ -246,15 +249,15 @@ def formal_integral(

class FormalIntegrator(object):
"""
Class containing the formal integrator.
If there is a NVIDIA CUDA GPU available,
the formal integral will automatically run
on it. If multiple GPUs are available, it will
choose the first one that it sees. You can
read more about selecting different GPUs on
Class containing the formal integrator.

If there is a NVIDIA CUDA GPU available,
the formal integral will automatically run
on it. If multiple GPUs are available, it will
choose the first one that it sees. You can
read more about selecting different GPUs on
Numba's CUDA documentation.

Parameters
----------
model : tardis.model.Radial1DModel
Expand Down Expand Up @@ -383,9 +386,9 @@ def make_source_function(self):
model = self.model
runner = self.runner

#macro_ref = self.atomic_data.macro_atom_references
# macro_ref = self.atomic_data.macro_atom_references
macro_ref = self.atomic_data.macro_atom_references
#macro_data = self.atomic_data.macro_atom_data
# macro_data = self.atomic_data.macro_atom_data
macro_data = self.original_plasma.macro_atom_data

no_lvls = len(self.levels_index)
Expand Down