clarify that rotation
is a circular shift (rename to shift_circ
)
This commit is contained in:
parent
fcd6fc7065
commit
1a754dcbc9
@ -32,7 +32,7 @@ import numpy # type: ignore
|
|||||||
import scipy.sparse as sparse # type: ignore
|
import scipy.sparse as sparse # type: ignore
|
||||||
|
|
||||||
from ..fdmath import vec, dx_lists_t, vfdfield_t
|
from ..fdmath import vec, dx_lists_t, vfdfield_t
|
||||||
from ..fdmath.operators import shift_with_mirror, rotation, curl_forward, curl_back
|
from ..fdmath.operators import shift_with_mirror, shift_circ, curl_forward, curl_back
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Jan Petykiewicz'
|
__author__ = 'Jan Petykiewicz'
|
||||||
@ -316,7 +316,7 @@ def poynting_e_cross(e: vfdfield_t, dxes: dx_lists_t) -> sparse.spmatrix:
|
|||||||
"""
|
"""
|
||||||
shape = [len(dx) for dx in dxes[0]]
|
shape = [len(dx) for dx in dxes[0]]
|
||||||
|
|
||||||
fx, fy, fz = [rotation(i, shape, 1) for i in range(3)]
|
fx, fy, fz = [shift_circ(i, shape, 1) for i in range(3)]
|
||||||
|
|
||||||
dxag = [dx.ravel(order='C') for dx in numpy.meshgrid(*dxes[0], indexing='ij')]
|
dxag = [dx.ravel(order='C') for dx in numpy.meshgrid(*dxes[0], indexing='ij')]
|
||||||
Ex, Ey, Ez = [ei * da for ei, da in zip(numpy.split(e, 3), dxag)]
|
Ex, Ey, Ez = [ei * da for ei, da in zip(numpy.split(e, 3), dxag)]
|
||||||
@ -343,7 +343,7 @@ def poynting_h_cross(h: vfdfield_t, dxes: dx_lists_t) -> sparse.spmatrix:
|
|||||||
"""
|
"""
|
||||||
shape = [len(dx) for dx in dxes[0]]
|
shape = [len(dx) for dx in dxes[0]]
|
||||||
|
|
||||||
fx, fy, fz = [rotation(i, shape, 1) for i in range(3)]
|
fx, fy, fz = [shift_circ(i, shape, 1) for i in range(3)]
|
||||||
|
|
||||||
dxag = [dx.ravel(order='C') for dx in numpy.meshgrid(*dxes[0], indexing='ij')]
|
dxag = [dx.ravel(order='C') for dx in numpy.meshgrid(*dxes[0], indexing='ij')]
|
||||||
dxbg = [dx.ravel(order='C') for dx in numpy.meshgrid(*dxes[1], indexing='ij')]
|
dxbg = [dx.ravel(order='C') for dx in numpy.meshgrid(*dxes[1], indexing='ij')]
|
||||||
@ -417,7 +417,7 @@ def e_boundary_source(mask: vfdfield_t,
|
|||||||
jmask = numpy.zeros_like(mask, dtype=bool)
|
jmask = numpy.zeros_like(mask, dtype=bool)
|
||||||
|
|
||||||
def shift_rot(axis: int, polarity: int) -> sparse.spmatrix:
|
def shift_rot(axis: int, polarity: int) -> sparse.spmatrix:
|
||||||
return rotation(axis=axis, shape=shape, shift_distance=polarity)
|
return shift_circ(axis=axis, shape=shape, shift_distance=polarity)
|
||||||
|
|
||||||
def shift_mir(axis: int, polarity: int) -> sparse.spmatrix:
|
def shift_mir(axis: int, polarity: int) -> sparse.spmatrix:
|
||||||
return shift_with_mirror(axis=axis, shape=shape, shift_distance=polarity)
|
return shift_with_mirror(axis=axis, shape=shape, shift_distance=polarity)
|
||||||
|
@ -10,7 +10,7 @@ import scipy.sparse as sparse # type: ignore
|
|||||||
from .types import vfdfield_t
|
from .types import vfdfield_t
|
||||||
|
|
||||||
|
|
||||||
def rotation(axis: int, shape: Sequence[int], shift_distance: int = 1) -> sparse.spmatrix:
|
def shift_circ(axis: int, shape: Sequence[int], shift_distance: int = 1) -> sparse.spmatrix:
|
||||||
"""
|
"""
|
||||||
Utility operator for performing a circular shift along a specified axis by a
|
Utility operator for performing a circular shift along a specified axis by a
|
||||||
specified number of elements.
|
specified number of elements.
|
||||||
@ -104,7 +104,7 @@ def deriv_forward(dx_e: Sequence[numpy.ndarray]) -> List[sparse.spmatrix]:
|
|||||||
dx_e_expanded = numpy.meshgrid(*dx_e, indexing='ij')
|
dx_e_expanded = numpy.meshgrid(*dx_e, indexing='ij')
|
||||||
|
|
||||||
def deriv(axis: int) -> sparse.spmatrix:
|
def deriv(axis: int) -> sparse.spmatrix:
|
||||||
return rotation(axis, shape, 1) - sparse.eye(n)
|
return shift_circ(axis, shape, 1) - sparse.eye(n)
|
||||||
|
|
||||||
Ds = [sparse.diags(+1 / dx.ravel(order='C')) @ deriv(a)
|
Ds = [sparse.diags(+1 / dx.ravel(order='C')) @ deriv(a)
|
||||||
for a, dx in enumerate(dx_e_expanded)]
|
for a, dx in enumerate(dx_e_expanded)]
|
||||||
@ -129,7 +129,7 @@ def deriv_back(dx_h: Sequence[numpy.ndarray]) -> List[sparse.spmatrix]:
|
|||||||
dx_h_expanded = numpy.meshgrid(*dx_h, indexing='ij')
|
dx_h_expanded = numpy.meshgrid(*dx_h, indexing='ij')
|
||||||
|
|
||||||
def deriv(axis: int) -> sparse.spmatrix:
|
def deriv(axis: int) -> sparse.spmatrix:
|
||||||
return rotation(axis, shape, -1) - sparse.eye(n)
|
return shift_circ(axis, shape, -1) - sparse.eye(n)
|
||||||
|
|
||||||
Ds = [sparse.diags(-1 / dx.ravel(order='C')) @ deriv(a)
|
Ds = [sparse.diags(-1 / dx.ravel(order='C')) @ deriv(a)
|
||||||
for a, dx in enumerate(dx_h_expanded)]
|
for a, dx in enumerate(dx_h_expanded)]
|
||||||
@ -186,7 +186,7 @@ def avg_forward(axis: int, shape: Sequence[int]) -> sparse.spmatrix:
|
|||||||
raise Exception('Invalid shape: {}'.format(shape))
|
raise Exception('Invalid shape: {}'.format(shape))
|
||||||
|
|
||||||
n = numpy.prod(shape)
|
n = numpy.prod(shape)
|
||||||
return 0.5 * (sparse.eye(n) + rotation(axis, shape))
|
return 0.5 * (sparse.eye(n) + shift_circ(axis, shape))
|
||||||
|
|
||||||
|
|
||||||
def avg_back(axis: int, shape: Sequence[int]) -> sparse.spmatrix:
|
def avg_back(axis: int, shape: Sequence[int]) -> sparse.spmatrix:
|
||||||
|
Loading…
Reference in New Issue
Block a user