Package: riccipy
A tensor algebra calculator for General Relativity.UsageRicciPy makes extensive usage ofsympyfor managing tensor products and
contractions. To create a tensor, it is required to construct an array to
represent the components of the tensor. This can be done by using most
nested array types: a nestedlist, asympy.Arrayinstance, asympy.Matrixinstance, or anumpyarray will work.Before beginning any involved application, it is first necessary to define aMetricinstance so that indices can be appropriately raised and lowered
automatically.In the following example, the electromagnetic tensor is defined in a Minkowski
spacetime. To begin, we declare the components of the electromagnetic tensor
using sympy for representing variables:>>>fromsympyimportdiag,symbols>>>fromriccipyimportTensor,Metric,indices,expand_array>>>E1,E2,E3,B1,B2,B3=symbols('E1:4 B1:4')>>>em=[[0,-E1,-E2,-E3],[E1,0,-B3,B2],[E2,B3,0,-B1],[E3,-B2,B1,0]]>>>t,x,y,z=symbols('t x y z')Next, the Minkowski metric is defined along with theTensorobject for the
electromagnetic tensor. Here, thesymmetrykeyword is optional but is used
to declare the electromagnetic tensor as being antisymmetric (refer to sympy’s
documentation for thesympy.tensor.tensormodule).>>>eta=Metric('eta',[t,x,y,z],diag(1,-1,-1,-1))>>>F=Tensor('F',em,eta,symmetry=[[2]])>>>mu,nu=indices('mu nu',eta)muandnuare now variables that can be used to represent the
indices of either the metric,eta, or the tensorF. Negative signs
indicate that the particular index is a subscript (covariant) rather than
a superscript (contravariant).This first calculation demonstrates how contractions are handled: simply
multiply two indexed tensors and matching indices will automatically apply
the Einstein summation convention. Symbolically, indices that are to be
contracted are denoted by the metric those indices belong to (in this caseeta_0andeta_1).To convert a symbolic tensor expression into components, pass the expression
toexpand_array.>>>expr=F(mu,nu)*F(-mu,-nu)>>>exprF(eta_0,eta_1)*F(-eta_0,-eta_1)>>>expand_array(expr)2*B_1**2+2*B_2**2+2*B_3**2-2*E_1**2-2*E_2**2-2*E_3**2This next calculation demonstrates the consequence of having definedFas
being antisymmetric:>>>expr=F(mu,nu)+F(nu,mu)>>>expand_array(expr)0Metrics DatabaseRicciPy comes with over 100 different metrics representing solutions to the
Einstein Field Equations. To search for metrics, you can use thefindfunction:>>>fromriccipy.metricsimportfind>>>find('sitter')['anti-de sitter','de sitter','schwarzschild-de sitter']Theload_metricfunction can be used to automatically return aMetricinstance of the specified metric. For example, to load an Anti de-Sitter
spacetime the call would look like:>>>g,variables,functions=load_metric('g','anti-de sitter')>>>g.as_array()[[-1,0,0,0],[0,cos(t)**2,0,0],[0,0,cos(t)**2*sinh(chi)**2,0],[0,0,0,sin(theta)**2*cos(t)**2*sinh(chi)**2]]InstallationTo install RicciPy the following dependencies are required:Sympy (version >= 1.4)Numpy (version >= 1.15)Installation is handled automatically by using$pipinstallriccipyContributing & QuestionsRicciPy is in it’s early stages of development and thus contributions are
very welcome, yet they will be handled on a person-to-person basis until
sufficient interest accumulates in the project. Feel free to email the primary
author atcalvinjayross@gmail.comif you have any questions or interest in
developing RicciPy.