https://github.com/tianyikillua/tensorconvert
Easy-to-use Python package for the conversion between various matrix representations of second-order and fourth-order tensors
https://github.com/tianyikillua/tensorconvert
mandel matrix numerical-methods scientific-computing sympy tensor voigt
Last synced: 5 months ago
JSON representation
Easy-to-use Python package for the conversion between various matrix representations of second-order and fourth-order tensors
- Host: GitHub
- URL: https://github.com/tianyikillua/tensorconvert
- Owner: tianyikillua
- License: mit
- Created: 2023-07-29T14:14:23.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-08-22T13:26:28.000Z (10 months ago)
- Last Synced: 2025-08-22T15:36:02.336Z (10 months ago)
- Topics: mandel, matrix, numerical-methods, scientific-computing, sympy, tensor, voigt
- Language: Python
- Homepage: https://tensorconvert.readthedocs.io
- Size: 925 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Conversion between tensor representations
[](https://www.repostatus.org/#active)
[](https://github.com/tianyikillua/tensorconvert/blob/master/LICENSE.txt)
[](https://github.com/psf/black)
[](https://tensorconvert.readthedocs.io/en/latest/)
This package provides an easy-to-use API to represent **symbolic** second-order and fourth-order tensors. Various representations frequently used in physics are provided and conversion between them can be obtained.
Compared to [mechkit](https://github.com/JulianKarlBauer/mechkit), the scope of this package is not limited to continuum mechanics since these representations can be used for other domains.
The API is inspired from [scipy.spatial.transform.Rotation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html):
- Representing an existing tensor is performed by `as_...` methods.
- Initializing from a representation uses `from_...` methods.
Thanks to the [Fluent API](https://en.wikipedia.org/wiki/Fluent_interface#Python), `as_...` methods can be applied directly after `from_...` methods. For example, to convert a fourth-order tensor represented by Mandel notation to Voigt notation, we can do
```python
FourthOrderTensor(...).from_mandel(...).to_voigt()
```
## Installation
[sympy](https://www.sympy.org/) is a strong dependency of this package since all tensor representations are `sympy` objects.
The package is still being developed. You can use `pip` to install the current `main` version.
```sh
pip install -U git+https://github.com/tianyikillua/tensorconvert.git@main
```
## Documentation
Refer to the [documentation](https://tensorconvert.readthedocs.io/en/latest/) for the API and the examples using `tensorconvert`.