Commit 32bcf13e authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

examples and presentation added

parent 59e9086f
%% Cell type:markdown id: tags:
# Instantiating basic tensors:
%% Cell type:code id: tags:
``` python
import tfields
```
%% Cell type:code id: tags:
``` python
scalars = tfields.Tensors([0, 1, 2])
scalars.rank, scalars.dim
```
%%%% Output: execute_result
(0, 1)
%% Cell type:code id: tags:
``` python
vectors = tfields.Tensors([[0, 0, 0],
[0, 0, 1],
[0, -1, 0]])
vectors.rank, vectors.dim
```
%%%% Output: execute_result
(1, 3)
%% Cell type:code id: tags:
``` python
# Levi-Zivita Tensor
matrices = tfields.Tensors([[[0, 0, 0], [0, 0, 1], [0, -1, 0]],
[[0, 0, -1], [0, 0, 0], [1, 0, 0]],
[[0, 1, 0], [-1, 0, 0], [0, 0, 0]]])
matrices.rank, matrices.dim
```
%%%% Output: execute_result
(2, 3)
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -397,6 +397,7 @@ class Tensors(AbstractNdarray):
tensors: np.ndarray or AbstractNdarray subclass
Examples:
>>> import numpy as np
>>> import tfields
Initialize a scalar range
>>> scalars = tfields.Tensors([0, 1, 2])
......@@ -412,9 +413,10 @@ class Tensors(AbstractNdarray):
>>> assert vectors.coord_sys == 'cartesian'
Initialize the Levi-Zivita Tensor
>>> matrices = tfields.Tensors([[[0, 0, 0], [0, 0, 1], [0, -1, 0]],
... [[0, 0, -1], [0, 0, 0], [1, 0, 0]],
... [[0, 1, 0], [-1, 0, 0], [0, 0, 0]]])
>>> matrices = tfields.Tensors(
... [[[0, 0, 0], [0, 0, 1], [0, -1, 0]],
... [[0, 0, -1], [0, 0, 0], [1, 0, 0]],
... [[0, 1, 0], [-1, 0, 0], [0, 0, 0]]])
>>> matrices.shape == (3, 3, 3)
True
>>> matrices.rank == 2
......
......@@ -436,6 +436,7 @@ class Mesh3D(tfields.TensorMaps):
... (-np.pi, np.pi, 5),
... (-np.pi / 2, np.pi / 2, 3),
... coord_sys='spherical')
>>> oktaeder.transform('cartesian')
Cube with edge length of 2 units
>>> cube = tfields.Mesh3D.grid((-1, 1, 2),
......@@ -447,6 +448,7 @@ class Mesh3D(tfields.TensorMaps):
... (-np.pi, np.pi, 12),
... (-5, 3, 12),
... coord_sys='cylinder')
>>> cylinder.transform('cartesian')
"""
if not len(base_vectors) == 3:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment