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

add neutrino cooling routines #628

Merged
merged 30 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c098949
add neutrino cooling routines
zingale Sep 10, 2023
28ea51c
more work
zingale Sep 11, 2023
2fdbc8d
converted version
zingale Sep 11, 2023
fcf8f9a
fix flake8
zingale Sep 11, 2023
8e306ad
more work
zingale Sep 11, 2023
a88b07a
this seems to work now
zingale Sep 11, 2023
cb95754
fix flake8
zingale Sep 11, 2023
f1d4756
add init
zingale Sep 12, 2023
2529a6d
some renaming
zingale Sep 12, 2023
a2b6acd
add the ability to make a plot
zingale Sep 12, 2023
7dc4734
Merge branch 'main' into neutrino_cooling
zingale Sep 12, 2023
dbad6eb
add unit test
zingale Sep 12, 2023
37307b8
Merge branch 'neutrino_cooling' of github.com:zingale/pynucastro into…
zingale Sep 12, 2023
9291f4d
fix pylint
zingale Sep 12, 2023
bdb0111
add docs
zingale Sep 12, 2023
48035f6
Merge branch 'main' into neutrino_cooling
zingale Sep 22, 2023
2d2a267
Merge branch 'main' into neutrino_cooling
zingale Sep 27, 2023
255ae1c
Merge branch 'main' into neutrino_cooling
zingale Oct 18, 2023
5135590
Merge branch 'main' into neutrino_cooling
zingale Oct 19, 2023
a2ce903
Merge branch 'main' into neutrino_cooling
zingale Oct 23, 2023
9b7c10d
Merge branch 'main' into neutrino_cooling
zingale Oct 24, 2023
4b98075
remove unused
zingale Oct 25, 2023
0642a3d
Merge branch 'main' into neutrino_cooling
zingale Oct 25, 2023
77ba4f4
more cleaning
zingale Oct 25, 2023
fb5f621
more unused
zingale Oct 25, 2023
50acf5a
remove unused function
zingale Oct 26, 2023
a98394a
more fixes
zingale Oct 28, 2023
bf976ff
Merge branch 'main' into neutrino_cooling
zingale Nov 1, 2023
5e92cd5
remove more unused vars
zingale Nov 1, 2023
87fa450
Merge branch 'main' into neutrino_cooling
yut23 Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ codes.

.. toctree::
:maxdepth: 1
:caption: Advanced Usage
:caption: Advanced Rate Operations

screening-examples
modify-example.ipynb
approx-rates-examples.ipynb
custom-rates.ipynb
unimportant-rates.ipynb
partition-function
NSE-example.ipynb
julia

.. toctree::
:maxdepth: 1
Expand All @@ -60,6 +58,24 @@ codes.
networks
cxx-networks

.. toctree::
:maxdepth: 1
:caption: Nuclear Statistical Equilibrium

NSE-example.ipynb

.. toctree::
:maxdepth: 1
:caption: Plasma Neutrinos

neutrino-cooling.ipynb

.. toctree::
:maxdepth: 1
:caption: Interfacing With Other Languages

julia

.. toctree::
:maxdepth: 1
:caption: Reference
Expand Down
176 changes: 176 additions & 0 deletions docs/source/neutrino-cooling.ipynb

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pynucastro/neutrino_cooling/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Neutrino cooling routines"""

__all__ = ["neutrino_cooling", "sneut5"]

from .neutrino_cooling import NeutrinoCooling
from .sneut5 import sneut5
46 changes: 46 additions & 0 deletions pynucastro/neutrino_cooling/neutrino_cooling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import matplotlib.pyplot as plt
import numpy as np

from .sneut5 import sneut5


class NeutrinoCooling:
"""A class to provide an interface to explore neutrino cooling.
This calls a specific implementation of the cooling that includes
contributions from pairs, plasma, recombination, bremsstrahlung,
and photoneutrinos."""

def __init__(self, neutrino_function=sneut5):

self.func = neutrino_function

def plot(self, *, Tmin=1.e7, Tmax=1.e10, rhomin=1.e3, rhomax=1.e10,
abar=20, zbar=10, npts_temp=50, npts_rho=50):
"""given a fixed abar/zbar, make a plot of neutrino cooling over
a range of density and temperature"""

Ts = np.logspace(np.log10(Tmin), np.log10(Tmax), npts_temp)
rhos = np.logspace(np.log10(rhomin), np.log10(rhomax), npts_rho)

data = np.zeros((npts_temp, npts_rho))

for i, T in enumerate(Ts):
for j, rho in enumerate(rhos):
data[i, j] = np.log10(self.func(rho, T, abar=abar, zbar=zbar))

fig, ax = plt.subplots()

# by default, imshow puts the first index on the y axis
# and the second on the x axis, so label accordingly

extent = (np.log10(rhomin), np.log10(rhomax),
np.log10(Tmin), np.log10(Tmax))

im = ax.imshow(data, cmap="viridis",
extent=extent, aspect="auto", origin="lower")
fig.colorbar(im, ax=ax)

ax.set_ylabel(r"$\log(T)$ [K]")
ax.set_xlabel(r"$\log(\rho)$ [g/cm$^3$]")

return fig