#!/usr/bin/env python # coding: utf-8 # # # # # The NRPy+ code required to generate the needed C code for the lowering operator: $g_{ij} \beta^i$, with the result set to C variables "`betaD0out`", "`betaD1out`", and "`betaD2out`" # # ## *Courtesy Zach Etienne* # In[1]: # 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"])