Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Metrics #13

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
90ed058
added source files
cjayross Jul 4, 2019
f22376a
added .gitignore
cjayross Jul 4, 2019
3dcca53
added myself as an author
cjayross Jul 4, 2019
e495709
reorganized test files
cjayross Jul 4, 2019
4030936
removed metric commutation group, added tox.ini, reformatted
cjayross Jul 4, 2019
d2bf9b1
Revert "added myself as an author"
cjayross Jul 4, 2019
84efb1c
removed ipy_test_environment and added more strict checks in Replacem…
cjayross Jul 4, 2019
a3bd7d9
fixed test cases, loosened comparisons in ReplacementManager
cjayross Jul 5, 2019
5f342a0
reformatted
cjayross Jul 7, 2019
9a77b33
ran isort
cjayross Jul 7, 2019
bc228f5
added source files
cjayross Jul 4, 2019
5c61856
added myself as an author
cjayross Jul 4, 2019
6bd731d
reorganized test files
cjayross Jul 4, 2019
099f048
removed metric commutation group, added tox.ini, reformatted
cjayross Jul 4, 2019
83767bb
Revert "added myself as an author"
cjayross Jul 4, 2019
ac1fd21
removed ipy_test_environment and added more strict checks in Replacem…
cjayross Jul 4, 2019
d2464d8
fixed test cases, loosened comparisons in ReplacementManager
cjayross Jul 5, 2019
7af7f83
reformatted
cjayross Jul 7, 2019
2088f3f
ran isort
cjayross Jul 7, 2019
2bc1ba2
added first metrics
cjayross Jul 7, 2019
2971a0a
added the remaining metrics
cjayross Jul 7, 2019
b8ff53e
added load_metric function
cjayross Jul 7, 2019
e15b2fa
added imports to metric scripts
cjayross Jul 7, 2019
6d6dda1
added load_metric to __init__.py
cjayross Jul 7, 2019
5948c4d
changed order of coordinates in einstein_maxwell
cjayross Jul 7, 2019
992b8e1
added cosh import for de_sitter_1
cjayross Jul 7, 2019
84d8df7
added citations to metrics
cjayross Jul 8, 2019
e5fffcf
added first metrics
cjayross Jul 7, 2019
fb6b2dc
added the remaining metrics
cjayross Jul 7, 2019
e98a5fc
added imports to metric scripts
cjayross Jul 7, 2019
f1a8190
reformatted
cjayross Jul 7, 2019
290c5ed
replaced comments with docstrings
cjayross Jul 8, 2019
28699ba
removed del lines
cjayross Jul 8, 2019
66f1a97
fixed typo in static_spherical_1
cjayross Jul 9, 2019
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pip-wheel-metadata
# VS Code
.vscode

# Emacs - projectile
TAGS

# default pytest cache directory
*/.pytest_cache
.pytest_cache/
Expand Down
177 changes: 177 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/einsteinpy.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/einsteinpy.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/einsteinpy"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/einsteinpy"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
3 changes: 1 addition & 2 deletions src/riccipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
=======
RicciPy
=======

Expand All @@ -8,5 +7,5 @@
"""

__version__ = "0.1.dev0"
from .metric import Metric, SpacetimeMetric
from .metric import Metric, SpacetimeMetric, load_metric
from .tensor import Index, Tensor, expand_tensor, indices
9 changes: 9 additions & 0 deletions src/riccipy/metric.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import namedtuple
from pathlib import Path

from sympy import Array, Pow, Rational, S, ones, tensorproduct, zeros
from sympy.tensor.tensor import TensorIndexType
Expand Down Expand Up @@ -256,3 +257,11 @@ def signature(self):
sig = sign * ones(1, self.dim)
sig[0] *= -1
return tuple(sig)


def load_metric(symbol, name):
base = Path(__file__).parent
var = dict(globals(), **locals())
with open(base / "metrics" / (name + ".py"), "r") as file:
exec(file.read(), var)
return SpacetimeMetric(symbol, var["coords"], var["metric"], timelike=False)
16 changes: 16 additions & 0 deletions src/riccipy/metrics/anti_de_sitter_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Anti-de Sitter space
Hawking and Ellis (5.9) p131
"""
from sympy import cos, diag, sin, sinh, symbols

coords = symbols("t chi theta phi", real=True)
variables = ()
functions = ()
t, ch, th, ph = coords
metric = diag(
-1,
cos(t) ** 2,
cos(t) ** 2 * sinh(ch) ** 2,
cos(t) ** 2 * sinh(ch) ** 2 * sin(th) ** 2,
)
11 changes: 11 additions & 0 deletions src/riccipy/metrics/anti_de_sitter_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Static form of Anti-de Sitter space
Hawking and Ellis (5.9) p131
"""
from sympy import cosh, diag, sin, sinh, symbols

coords = symbols("t r theta phi", real=True)
variables = ()
functions = ()
t, r, th, ph = coords
metric = diag(-cosh(r) ** 2, 1, sinh(r) ** 2, sinh(r) ** 2 * sin(th) ** 2)
18 changes: 18 additions & 0 deletions src/riccipy/metrics/bayin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Bayin's spherically symmetric static perfect fluid solution II
Bayin, Phys. Rev. D, v18, p2745-2751, (1978)
"""
from sympy import Rational, asin, sin, symbols, zeros

coords = symbols("t r theta phi", real=True)
variables = symbols("w_0 C_0 C_1", constant=True)
functions = ()
t, r, th, ph = coords
w0, C0, C1 = variables
metric = zeros(4)
metric[0, 0] = -C0 ** 2 * exp(
-asin((-2 * r ** 2 + C1) / (C1 ** 2 + 4 * w0 ** 2) ** (Rational(1, 2)))
)
metric[1, 1] = w0 ** 2 / (-r ** 4 + C1 * r ** 2 + w0 ** 2)
metric[2, 2] = r ** 2
metric[3, 3] = r ** 2 * sin(th) ** 2
13 changes: 13 additions & 0 deletions src/riccipy/metrics/beckers_sinzinkayo_demaret_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Beckers, Sinzinkayo, and Demaret solution
Beckers et al., Phys. Rev. D, v30, p1846, (1984)
"""
from sympy import diag, symbols

coords = symbols("t x y z", real=True)
variables = symbols("k d m", constant=True)
functions = ()
t, x, y, z = coords
k, d, m = variables
expr = (k * x + d) ** (2 * m)
metric = diag(-expr, expr, expr, expr)
13 changes: 13 additions & 0 deletions src/riccipy/metrics/beckers_sinzinkayo_demaret_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Beckers, Sinzinkayo, and Demaret solution
Beckers et al., Phys. Rev. D, v30, p1846, (1984)
"""
from sympy import diag, symbols

coords = symbols("t x y z", real=True)
variables = symbols("m", constant=True)
functions = ()
t, x, y, z = coords
m = variables
expr = x ** (2 * m)
metric = diag(-expr, expr, expr, expr)
14 changes: 14 additions & 0 deletions src/riccipy/metrics/bertotti_robinson_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
The Bertotti-Robinson solution
Bertotti, Phys. Rev., v116, p1331, (1959)
Bertotti, Commun. Math. Phys., v5, p257, (1967)
Robinson, Commun. Math. Phys., v9, p161, (1968)
Stephani (10.16) p120
"""
from sympy import diag, symbols

coords = symbols("t x y z", real=True)
variables = ()
functions = ()
t, x, y, z = coords
metric = diag(-(1 + z ** 2), 1 - y ** 2, 1 / (1 - y ** 2), 1 / (1 + z ** 2))
15 changes: 15 additions & 0 deletions src/riccipy/metrics/bertotti_robinson_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
The Bertotti-Robinson solution
Bertotti, Phys. Rev., v116, p1331, (1959)
Lovelock, Commun. Math. Phys., v5, p257, (1967)
Dolan, Commun. Math. Phys., v9, p161, (1968)
Stephani (10.18) p121
"""
from sympy import diag, symbols

coords = symbols("t r theta phi", real=True)
variables = symbols("q", constant=True)
functions = ()
t, r, th, ph = coords
q = variables
metric = diag(-q ** 2 / r ** 2, q ** 2 / r ** 2, q ** 2, q ** 2 * sin(th) ** 2)
15 changes: 15 additions & 0 deletions src/riccipy/metrics/bertotti_robinson_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
The Bertotti-Robinson solution
Bertotti, Phys. Rev., v116, p1331, (1959)
Lovelock, Commun. Math. Phys., v5, p257, (1967)
Dolan, Commun. Math. Phys., v9, p161, (1968)
Stephani (10.19) p120
"""
from sympy import diag, sin, sinh, symbols

coords = symbols("t x theta phi", real=True)
variables = symbols("k", constant=True)
functions = ()
t, x, th, ph = coords
k = variables
metric = diag(-k ** 2 * sinh(x) ** 2, k ** 2, k ** 2, k ** 2 * sin(th) ** 2)
15 changes: 15 additions & 0 deletions src/riccipy/metrics/bertotti_robinson_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
The Bertotti-Robinson solution
Bertotti, Phys. Rev., v116, p1331, (1959)
Lovelock, Commun. Math. Phys., v5, p257, (1967)
Dolan, Commun. Math. Phys., v9, p161, (1968)
Stephani (32.95) p372
"""
from sympy import cos, diag, symbols

coords = symbols("t z x y", real=True)
variables = symbols("omega", constant=True)
functions = ()
t, x, y, z = coords
om = variables
metric = diag(-1, 1, cos(om * x) ** 2, cos(om * t) ** 2)
11 changes: 11 additions & 0 deletions src/riccipy/metrics/bianchi_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
General metric from Bianchi II automorphisms
"""
from sympy import Function, diag, exp, symbols

coords = symbols("t x y z", real=True)
variables = ()
functions = symbols("alpha", cls=Function)
t, x, y, z = coords
al = functions
metric = diag(1, exp(-2 * al(t)), exp(al(t)), exp(al(t)))
11 changes: 11 additions & 0 deletions src/riccipy/metrics/bianchi_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
General metric from Bianchi IV automorphisms
"""
from sympy import Function, diag, exp, symbols

coords = symbols("t x y z", real=True)
variables = ()
functions = symbols("alpha beta gamma", cls=Function)
t, x, y, z = coords
al, be, ga = functions
metric = diag(1, exp(al(t)), exp(be(t)), exp(ga(t)))
13 changes: 13 additions & 0 deletions src/riccipy/metrics/bondi_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Spherical Bondi metric in advanced (ingoing) coordinates
Bondi, Proc. Roy. Soc. Lond. A, v282, p303, (1964)
"""
from sympy import Function, diag, sin, symbols

coords = symbols("r v theta phi", real=True)
variables = ()
functions = symbols("C M", cls=Function)
r, v, th, ph = coords
C, M = functions
metric = diag(0, -C(r, v) ** 2 * (1 - 2 * M(r, v) / r), r ** 2, r ** 2 * sin(th) ** 2)
metric[0, 1] = metric[1, 0] = C(r, v)
Loading