https://github.com/arturgower/tensoralgebra.wl
A Mathematica package to perform tensor algebra, including an advanced tensor expand, and tensor derivative.
https://github.com/arturgower/tensoralgebra.wl
Last synced: about 2 months ago
JSON representation
A Mathematica package to perform tensor algebra, including an advanced tensor expand, and tensor derivative.
- Host: GitHub
- URL: https://github.com/arturgower/tensoralgebra.wl
- Owner: arturgower
- License: mit
- Created: 2023-02-05T14:40:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-06T18:21:10.000Z (over 2 years ago)
- Last Synced: 2025-02-05T09:23:35.952Z (3 months ago)
- Language: Mathematica
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TensorAlgebra.wl
A Mathematica package to perform tensor algebra, including an advanced tensor expand, and tensor derivative.```
<< "/TensorAlgebra.wl";(*Define your tensors*)
matrices = {F, \[Delta]F};
symMatrices = {S, \[Delta]S};
skwMatrices = {W, \[Delta]W};
scalars = {a, a[_]};
$Assumptions = (# \[Element] Reals & /@ scalars);
$Assumptions = $Assumptions~Join~MatrixAssumptions[matrices, symMatrices, skwMatrices];
?"TensorAlgebra`*"(* TensorExpand2 distributes tensor multiplication and terms involving Tr and Det .
Mathematica provides its own function call TensorExpand which is very limited and in first versions had errors*)
scalar = (Tr[(a[1] S).(a[3] F + a[4] δF) . S . S . F + Transpose[S . S . F] + Transpose[F . S . F]] Tr[a[2] F . S . F] + Det[a S.F.MatrixPower[F, -1]])^2;
scalarExpand = TensorExpand@TensorExpand2[scalar];(*To differentiate the scalar (composed of Tr and Det and Dot) in \
terms of S we use *)
DscalarDS = DTensor[scalar, S, \[Delta]S];
(*Where \[Delta]S is just som dummy Tensor. It should have the same \
properties as S (i.e. symmetric and be assumed to be a Tensor). If \
instead of S you give \[Delta]F the result could be different*)```