|
|
|
|
@ -16,7 +16,7 @@ class Propagator(_ABC, _nn.Module):
|
|
|
|
|
operator_X: оператор отображающий распроcтранение светового поля вдоль оси абсцисс
|
|
|
|
|
operator_Y: оператор отображающий распроcтранение светового поля вдоль оси ординат
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self, operator_X: _torch.Tensor, operator_Y: _torch.Tensor, trainable = False, diagonal = False):
|
|
|
|
|
def __init__(self, operator_X: _torch.Tensor, operator_Y: _torch.Tensor, trainable = False):
|
|
|
|
|
super(Propagator, self).__init__()
|
|
|
|
|
operator_X: _torch.Tensor = _torch.view_as_real(operator_X)
|
|
|
|
|
operator_Y: _torch.Tensor = _torch.view_as_real(operator_Y)
|
|
|
|
|
@ -24,12 +24,10 @@ class Propagator(_ABC, _nn.Module):
|
|
|
|
|
self._operator_X = _nn.Parameter(operator_X)
|
|
|
|
|
self._operator_Y = _nn.Parameter(operator_Y)
|
|
|
|
|
self._trainable = trainable
|
|
|
|
|
self._diagonal = diagonal
|
|
|
|
|
else:
|
|
|
|
|
self.register_buffer('_operator_X', operator_X, persistent=True)
|
|
|
|
|
self.register_buffer('_operator_Y', operator_Y, persistent=True)
|
|
|
|
|
self._trainable = trainable
|
|
|
|
|
self._diagonal = diagonal
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def operator_X(self) -> _torch.Tensor:
|
|
|
|
|
@ -111,13 +109,13 @@ class Propagator(_ABC, _nn.Module):
|
|
|
|
|
Распределение комплексной амплитуды светового поля,
|
|
|
|
|
после распространения.
|
|
|
|
|
"""
|
|
|
|
|
if self._diagonal:
|
|
|
|
|
if self._trainable:
|
|
|
|
|
return _torch.diag_embed(self.operator_Y) @ field @ _torch.diag_embed(self.operator_X)
|
|
|
|
|
else:
|
|
|
|
|
return self.operator_Y @ field @ self.operator_X
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
return f"Diag: {self._diagonal} Trainable: {self._trainable} Y shape: {self.operator_Y.shape}, X shape: {self.operator_X.shape}"
|
|
|
|
|
return f"Trainable: {self._trainable} Y shape: {self.operator_Y.shape}, X shape: {self.operator_X.shape}"
|
|
|
|
|
|
|
|
|
|
class PropagatorLens(Propagator):
|
|
|
|
|
"""
|
|
|
|
|
@ -167,7 +165,8 @@ class PropagatorСylindLens(PropagatorLens):
|
|
|
|
|
представленной тонким оптическим элементом.
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self, plane: _ConfigDesignPlane,
|
|
|
|
|
config: _ConfigOpticBase, trainable = False):
|
|
|
|
|
config: _ConfigOpticBase,
|
|
|
|
|
trainable = False):
|
|
|
|
|
"""
|
|
|
|
|
Конструктор класса цилиндрической линзы.
|
|
|
|
|
|
|
|
|
|
@ -177,10 +176,14 @@ class PropagatorСylindLens(PropagatorLens):
|
|
|
|
|
"""
|
|
|
|
|
operator_X = _torch.exp(-1j * config.K / config.distance * plane.linspace_by_x**2)
|
|
|
|
|
operator_Y = _torch.ones_like(plane.linspace_by_y, dtype=_torch.cfloat)
|
|
|
|
|
if trainable:
|
|
|
|
|
super(PropagatorСylindLens, self).__init__(operator_X,
|
|
|
|
|
operator_Y,
|
|
|
|
|
trainable,
|
|
|
|
|
diagonal=True)
|
|
|
|
|
trainable)
|
|
|
|
|
else:
|
|
|
|
|
super(PropagatorСylindLens, self).__init__(_torch.diag_embed(operator_X),
|
|
|
|
|
_torch.diag_embed(operator_Y),
|
|
|
|
|
trainable)
|
|
|
|
|
|
|
|
|
|
class PropagatorSinc(Propagator):
|
|
|
|
|
"""
|
|
|
|
|
|