On Saturday, January 11, 2014 3:30:40 PM UTC-5, Comer wrote:
>
>
>
> On Saturday, January 11, 2014 2:04:23 PM UTC-5, F. B. wrote:
>>
>>
>>
>> On Saturday, January 11, 2014 7:26:51 PM UTC+1, Comer wrote:
>>>
>>>
>>> I do have another question or two...
>>>
>>> I see the .data method. What is really needed is the ability to create
>>> data arrays constructed from symbols, indeed functions of various local
>>> coordinates. So far I have only seen numerical entries in the data... Can
>>> one put instead something like what symarray provides in place of the
>>> Minkowski metric?
>>>
>>>
>> Yes, of course. I just notice there's no symbolic example in the
>> docstrings. Take a look at this test:
>>
>>
>> https://github.com/sympy/sympy/blob/master/sympy/tensor/tests/test_tensor.py#L1235
>>
>> This is a 4-momentum-like assignment of sympy Symbols. Nested lists or a
>> generating function are accepted. I don't remember if it also accepts a
>> numpy ndarray, if it doesn't, that' a bug.
>>
>
> Ok, thanks. I will give it a try.
>
> Comer
>
>>
>>
>
Now I am trying to create the Weyl tensor. Here is what I do and the
response:
W = tensorhead('W',[Lorentz]*4,[[2, 2]])
terma = tensor_mul(Rational(1,2)*g(-a,-c)*Ric(-d,-b))
print terma.args
terma = TensMul(*terma.args)
termb = tensor_mul(Rational(1,2)*g(-a,-d)*Ric(-c,-b))
print termb.args
termb = TensMul(*termb.args)
termc = tensor_mul(Rational(1,2)*g(-b,-c)*Ric(-d,-a))
print termc.args
termc = TensMul(*termc.args)
termd = tensor_mul(Rational(1,2)*g(-b,-d)*Ric(-c,-a))
print termd.args
termd= TensMul(*termd.args)
terme = tensor_mul(Rational(1,3)*R*g(-a,-c)*g(-d,-b))
print terme.args
terme = TensMul(*terme.args)
termf = tensor_mul(Rational(1,3)*R*g(-a,-d)*g(-c,-b))
print termf.args
termf = TensMul(*termf.args)
W = Riem -terma + termb + termc - termd + terme -termf
Response:
ValueError Traceback (most recent call last)
/Users/comerduncan/ipython/IPython/utils/py3compat.pyc in execfile(fname,
*where)
* 217* else:
* 218* filename = fname
--> 219 builtin_mod.execfile(filename, *where)
* 220*
* 221* # Parts below taken from six:
/Users/comerduncan/sympytensor/RiemRicREinstein.py in <module>()
* 86* termf = TensMul(*termf.args)
* 87*
---> 88 W = Riem -terma + termb + termc - termd + terme -termf
* 89*
/Users/comerduncan/Sandbox/sympy/sympy/tensor/tensor.pyc in __rsub__(self,
other)
* 2758*
* 2759* def __rsub__(self, other):
-> 2760 return TensAdd(other, -self)
* 2761*
* 2762* def __mul__(self, other):
/Users/comerduncan/Sandbox/sympy/sympy/tensor/tensor.pyc in __new__(cls,
*args, **kw_args)
* 2052*
* 2053* # now check that all addends have the same indices:
-> 2054 TensAdd._tensAdd_check(args)
* 2055* args = Tuple(*args)
* 2056*
/Users/comerduncan/Sandbox/sympy/sympy/tensor/tensor.pyc in _tensAdd_check
(args)
* 2174* list_indices = [set([y[0] for y in x.free]) for x in args[
1:]]
* 2175* if not all(x == indices0 for x in list_indices):
-> 2176 raise ValueError('all tensors must have the same
indices')
* 2177*
* 2178* @staticmethod
ValueError: all tensors must have the same indices.
So, I believe all terms have the same indices, just in different orders. By
construction the overall quantity should have the same symmetries in its 4
indices as the Riemann tensor. When I print the terms individually they all
look as intended, but it chokes when I try to construct W using them. What
am I doing wrong?
Comer
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.