# The NRPy_param_funcs module sets up global structures that manage free parameters within NRPy+
import NRPy_param_funcs as par # NRPy+: Parameter interface
# The indexedexp module defines various functions for defining and managing indexed quantities like tensors and pseudotensors
import indexedexp as ixp # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support
# The grid module defines various parameters related to a numerical grid or the dimensionality of indexed expressions
# For example, it declares the parameter DIM, which specifies the dimensionality of the indexed expression
import grid as gri # NRPy+: Functions having to do with numerical grids
from outputC import outputC # NRPy+: Basic C code output functionality
# Set the dimension to 3
par.set_parval_from_str("DIM",3)
# Declare rank-1 contravariant ("U" and "D") vectors
betaU = ixp.declarerank1("betaU")
betaD = ixp.zerorank1()
# Declare h_{ij}=hDD[i][j] and h^{ij}=hUU[i][j]
hDD = ixp.declarerank2("hDD","sym01")
# Get the dimension we just set (should be set to 3).
DIM = par.parval_from_str("DIM")
for i in range(DIM):
for j in range(DIM):
betaD[j] += betaU[i]*hDD[i][j]
outputC(betaD,["betaD0out","betaD1out","betaD2out"])
/* * Original SymPy expressions: * "[betaD0out = betaU0*hDD00 + betaU1*hDD01 + betaU2*hDD02, * betaD1out = betaU0*hDD01 + betaU1*hDD11 + betaU2*hDD12, * betaD2out = betaU0*hDD02 + betaU1*hDD12 + betaU2*hDD22]" */ { betaD0out = betaU0*hDD00 + betaU1*hDD01 + betaU2*hDD02; betaD1out = betaU0*hDD01 + betaU1*hDD11 + betaU2*hDD12; betaD2out = betaU0*hDD02 + betaU1*hDD12 + betaU2*hDD22; }