```python
import sys
import sympy
from sympy import *
from sympy import Rational as frac
from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead
init_printing()

# Various scalars
vartheta, varphi = sympy.symbols('vartheta, varphi', real=True)
v, M, nu, delta, R_L = sympy.symbols('v, M, nu, delta, R_L', real=True)
Sigma_n, Sigma_ell, Sigma_lambda = sympy.symbols('Sigma_n, Sigma_ell, Sigma_lambda', real=True)
S_n, S_ell, S_lambda = sympy.symbols('S_n, S_ell, S_lambda', real=True)

# Tell sympy we're just doing Euclidean stuff
Euclidean = TensorIndexType('Euclidean', dummy_fmt='E')
Euclidean.data = [1,1,1]
g = Euclidean.metric
i0,i1,i2,i3 = tensor_indices('i0:4', Euclidean)

# Basis vectors of the source system
nHat, lambdaHat, ellHat = tensorhead(r'\hat{n}, \hat{\lambda}, \hat{\ell}', [Euclidean], [[1]])
nHat.data = [1,0,0]
lambdaHat.data = [0,1,0]
ellHat.data = [0,0,1]

# Spin vectors of the source system
Sigma,S = tensorhead(r'\vec{\Sigma}, \vec{S}', [Euclidean], [[1]])
Sigma.data = [Sigma_n, Sigma_lambda, Sigma_ell]
S.data = [S_n, S_lambda, S_ell]

# Basis vectors of the detector
NHat, PHat, QHat = tensorhead(r'\hat{N}, \hat{P}, \hat{Q}', [Euclidean], [[1]])
NHat.data = [sin(vartheta)*cos(varphi), sin(vartheta)*sin(varphi), cos(vartheta)]
PHat.data = [sin(varphi), -cos(varphi), 0]
QHat.data = [cos(vartheta)*cos(varphi), cos(vartheta)*sin(varphi), -sin(vartheta)]

# This projects the strain field onto the detector
D_jk = ( (PHat(i0)*PHat(i1) - QHat(i0)*QHat(i1)) - sympy.I*(PHat(i0)*QHat(i1) + QHat(i0)*PHat(i1)) )/2;
def complex_h_from_tensor(h_jk):
    return sympy.simplify((h_jk(i0,i1) * D_jk(i2,i3) * g(-i0,-i2) * g(-i1,-i3)).contract_metric(g))
    #return sympy.simplify(h_jk(i0,i1) * D_jk(-i0,-i1))

```


```python
h_jk = 4*(M/R_L)*nu*v**2*(lambdaHat(i0)*lambdaHat(i1) - nHat(i0)*nHat(i1))
```


```python
h_jk(i0,i1).data
```




    array([[-4*M*nu*v**2/R_L, 0, 0],
           [0, 4*M*nu*v**2/R_L, 0],
           [0, 0, 0]], dtype=object)




```python
h = complex_h_from_tensor(h_jk)
```

ed15cc9c463eca3ad8ce1b1114075a2e0849596f
ipynb
Jupyter Notebook
Waveforms/ComplexStrainFromPolarizations.ipynb
keefemitman/PostNewtonian
853d6577cb0002da5eebe1cb55f0c28fbc114324
MIT
2015-03-26T01:04:36.000Z
2022-02-01T19:26:21.000Z
Waveforms/ComplexStrainFromPolarizations.ipynb
keefemitman/PostNewtonian
853d6577cb0002da5eebe1cb55f0c28fbc114324
MIT
2015-01-08T23:46:29.000Z
2017-09-20T19:13:51.000Z
Waveforms/ComplexStrainFromPolarizations.ipynb
keefemitman/PostNewtonian
853d6577cb0002da5eebe1cb55f0c28fbc114324
MIT
2016-05-13T02:36:14.000Z
2021-11-23T21:36:32.000Z
Qwen/Qwen-72B
1. YES
2. YES