-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathadiabatic.py
More file actions
75 lines (59 loc) · 2.36 KB
/
adiabatic.py
File metadata and controls
75 lines (59 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SuPyMode.supermode import SuperMode
import numpy
from SuPyMode.representation.base import InheritFromSuperMode, BaseMultiModePlot
import matplotlib.pyplot as plt
class Adiabatic(InheritFromSuperMode, BaseMultiModePlot):
"""
Represents the adiabatic criterion between modes of different supermodes in optical fiber simulations.
This class extends from `InheritFromSuperMode` for accessing supermode-related data and from `BaseMultiModePlot`
for plotting functionalities tailored to visualize adiabatic transition measurements.
Attributes
----------
parent_supermode : SuperMode
The parent supermode object that provides the base mode data.
"""
def __init__(self, parent_supermode: SuperMode):
"""
Initialize an Adiabatic object with a reference to a parent supermode.
Parameters
----------
parent_supermode : SuperMode
The parent supermode object that provides the base mode data.
"""
self.parent_supermode = parent_supermode
def get_values(self, other_supermode: SuperMode) -> numpy.ndarray:
"""
Calculate the adiabatic transition measure between the parent supermode and another specified supermode.
Parameters
----------
other_supermode : SuperMode
The supermode with which to compare the parent supermode.
Returns
-------
numpy.ndarray
An array of adiabatic transition measures calculated between the two supermodes, adjusted as needed for
computational compatibility.
"""
output = self.parent_supermode.binding.get_adiabatic_with_mode(other_supermode.binding)
if not self.parent_supermode.is_computation_compatible(other_supermode):
output *= numpy.inf
return abs(output)
def _dress_ax(self, ax: plt.Axes) -> None:
"""
Set axis labels for the adiabatic criterion plot.
Parameters
----------
ax : matplotlib.axes.Axes
The axis object on which to set the labels.
"""
ax.set(
xlabel='Inverse taper ratio',
ylabel=r'Adiabatic criterion [$\mu$m$^{-1}$]',
ylim=[1e-5, 1],
)
# -