From dcc9e7c2ad7ff8f4fa1b9fc5f9c7aa4debc5dbdf Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 6 Jan 2020 00:08:08 -0800 Subject: [PATCH] Update some type info --- meanas/fdmath/__init__.py | 8 ++++---- meanas/fdmath/types.py | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/meanas/fdmath/__init__.py b/meanas/fdmath/__init__.py index 0e165e2..0803099 100644 --- a/meanas/fdmath/__init__.py +++ b/meanas/fdmath/__init__.py @@ -8,20 +8,20 @@ Fields, Functions, and Operators Discrete fields are stored in one of two forms: -- The `field_t` form is a multidimensional `numpy.ndarray` +- The `fdfield_t` form is a multidimensional `numpy.ndarray` + For a scalar field, this is just `U[m, n, p]`, where `m`, `n`, and `p` are discrete indices referring to positions on the x, y, and z axes respectively. + For a vector field, the first index specifies which vector component is accessed: `E[:, m, n, p] = [Ex[m, n, p], Ey[m, n, p], Ez[m, n, p]]`. -- The `vfield_t` form is simply a vectorzied (i.e. 1D) version of the `field_t`, +- The `vfdfield_t` form is simply a vectorzied (i.e. 1D) version of the `field_t`, as obtained by `meanas.fdmath.vectorization.vec` (effectively just `numpy.ravel`) Operators which act on fields also come in two forms: + Python functions, created by the functions in `meanas.fdmath.functional`. - The generated functions act on fields in the `field_t` form. + The generated functions act on fields in the `fdfield_t` form. + Linear operators, usually 2D sparse matrices using `scipy.sparse`, created by `meanas.fdmath.operators`. These operators act on vectorized fields in the - `vfield_t` form. + `vfdfield_t` form. The operations performed should be equivalent: `functional.op(*args)(E)` should be equivalent to `unvec(operators.op(*args) @ vec(E), E.shape[1:])`. diff --git a/meanas/fdmath/types.py b/meanas/fdmath/types.py index 6e2fd63..f8719d1 100644 --- a/meanas/fdmath/types.py +++ b/meanas/fdmath/types.py @@ -29,12 +29,15 @@ dx_lists_t = List[List[numpy.ndarray]] ''' 'dxes' datastructure which contains grid cell width information in the following format: - [[[dx_e_0, dx_e_1, ...], [dy_e_0, ...], [dz_e_0, ...]], - [[dx_h_0, dx_h_1, ...], [dy_h_0, ...], [dz_h_0, ...]]] + [[[dx_e[0], dx_e[1], ...], [dy_e[0], ...], [dz_e[0], ...]], + [[dx_h[0], dx_h[1], ...], [dy_h[0], ...], [dz_h[0], ...]]] - where `dx_e_0` is the x-width of the `x=0` cells, as used when calculating dE/dx, - and `dy_h_0` is the y-width of the `y=0` cells, as used when calculating dH/dy, etc. + where `dx_e[0]` is the x-width of the `x=0` cells, as used when calculating dE/dx, + and `dy_h[0]` is the y-width of the `y=0` cells, as used when calculating dH/dy, etc. ''' fdfield_updater_t = Callable[[fdfield_t], fdfield_t] +''' + Convenience type for functions which take and return an fdfield_t +'''