Skip to content

Commit

Permalink
Added optika.materials.AbstractLayer.interface property. (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie committed Jun 10, 2024
1 parent 6489cb6 commit 843a843
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
21 changes: 16 additions & 5 deletions optika/materials/_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def thickness(self) -> u.Quantity | na.AbstractScalar:
def _thickness_plot(self) -> u.Quantity | na.AbstractScalar:
"""The thickness of the layer when plotted."""

@property
@abc.abstractmethod
def interface(self) -> None | optika.materials.profiles.AbstractInterfaceProfile:
"""
The interface profile on the left side of this layer.
"""

@property
@abc.abstractmethod
def layer_sequence(self) -> LayerSequence:
Expand Down Expand Up @@ -161,11 +168,7 @@ class Layer(

interface: None | optika.materials.profiles.AbstractInterfaceProfile = None
"""
The interface profile for the right side of this layer.
While it might be more natural to want to specify the interface profile for
the left side of the layer, specifying the right side was chosen so that
there would not be any coupling between subsequent layers.
The interface profile on the left side of this layer.
"""

kwargs_plot: None | dict = None
Expand Down Expand Up @@ -415,6 +418,10 @@ def thickness(self) -> u.Quantity | na.AbstractScalar:
def _thickness_plot(self) -> u.Quantity | na.AbstractScalar:
return self.thickness

@property
def interface(self) -> None | optika.materials.profiles.AbstractInterfaceProfile:
return self.layers[0].interface

def __getitem__(self, item: int | slice) -> LayerSequence:
if isinstance(item, int):
return self.layers[item]
Expand Down Expand Up @@ -542,6 +549,10 @@ def thickness(self) -> u.Quantity | na.AbstractScalar:
def _thickness_plot(self) -> u.Quantity | na.AbstractScalar:
return LayerSequence(self.layers).thickness

@property
def interface(self) -> None | optika.materials.profiles.AbstractInterfaceProfile:
return self.layers[0].interface

@property
def layer_sequence(self) -> LayerSequence:
return LayerSequence(self.layers * self.num_periods)
Expand Down
10 changes: 10 additions & 0 deletions optika/materials/_tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ def test_thickness(
result = a.thickness
assert np.all(result >= 0 * u.nm)

def test_interface(
self,
a: optika.materials.AbstractLayer,
):
result = a.interface
if result is not None:
assert isinstance(
result, optika.materials.profiles.AbstractInterfaceProfile
)

def test_layer_sequence(
self,
a: optika.materials.AbstractLayer,
Expand Down

0 comments on commit 843a843

Please sign in to comment.