@@ -36,7 +36,7 @@ def __repr__(self):
3636
3737class SuperPosition (ReprBase ):
3838 Description = 'Mode superposition class'
39- ReprVar = ["SuperSet" , " Amplitudes" ]
39+ ReprVar = ["Amplitudes" ]
4040
4141 def __init__ (self , SuperSet , InitialAmplitudes : list ):
4242 self .SuperSet = SuperSet
@@ -45,7 +45,7 @@ def __init__(self, SuperSet, InitialAmplitudes: list):
4545 self ._Amplitudes = None
4646
4747
48- def ComputeAmpltiudes (self ):
48+ def ComputeAmpltiudes (self , rTol = 1e-8 , aTol = 1e-7 , MaxStep = np . inf ):
4949 self .MatrixInterp = interp1d (self .Distance , self .SuperSet .Matrix , axis = - 1 )
5050
5151 def foo (t , y ):
@@ -54,7 +54,10 @@ def foo(t, y):
5454 sol = solve_ivp (foo ,
5555 y0 = self .InitialAmplitudes ,
5656 t_span = [0 , self ._CouplerLength ],
57- method = 'RK45' )
57+ method = 'RK45' ,
58+ rtol = rTol ,
59+ atol = aTol ,
60+ max_step = MaxStep )
5861
5962 self .Amplitudes = sol .y
6063 self .Distances = sol .t
@@ -95,17 +98,49 @@ def PlotAmplitudes(self):
9598 Scene .AddLine (Row = 0 ,
9699 Col = 0 ,
97100 x = z ,
98- y = A ,
101+ y = A .real ,
102+ Fill = False ,
103+ Legend = r"$\Re${A}" ,
104+ xLabel = r'Z-Distance [$\mu m$]' ,
105+ yLabel = r'Mode complex ampltiude [normalized]' )
106+
107+ Scene .AddLine (Row = 0 ,
108+ Col = 0 ,
109+ x = z ,
110+ y = np .abs (A ),
99111 Fill = False ,
100- Legend = None ,
112+ Legend = r"|A|" ,
101113 xLabel = r'Z-Distance [$\mu m$]' ,
102- yLabel = r'Mode complex ampltiude' )
114+ yLabel = r'Mode complex ampltiude [normalized]' )
115+
116+
117+ Scene .SetAxes (0 , 0 , Equal = False , Legend = True )
118+ Scene .Show ()
119+
120+ def PlotField (self , Slice ):
121+ if self ._Amplitudes is None : self .ComputeAmpltiudes ()
122+ Scene = Scene2D (nCols = 1 , nRows = 1 , ColorBar = False )
123+
124+ Field = self .SuperSet [0 ].FullFields [0 ]* 0.
103125
104- Scene .SetAxes (0 , 0 , Equal = False )
126+ for a , mode in zip (self .InitialAmplitudes , self .SuperSet .SuperModes ):
127+ field = np .real (a )* mode .FullFields [Slice ]
128+ Field += field
129+
130+
131+ Scene .AddMesh (Row = 0 ,
132+ Col = 0 ,
133+ x = self .SuperSet [0 ].FullxAxis ,
134+ y = self .SuperSet [0 ].FullyAxis ,
135+ Scalar = Field .T .real ,
136+ xLabel = r'X-Direction [$\mu m$]' ,
137+ yLabel = r'Y-direction [$\mu m$]' )
138+
139+ Scene .SetAxes (Row = 0 , Col = 0 , Equal = True , Legend = False )
105140 Scene .Show ()
106141
107142
108- def PlotFields (self ):
143+ def PlotPropagation (self ):
109144 if self ._Amplitudes is None : self .ComputeAmpltiudes ()
110145
111146 y = self .AmplitudeInterpolation (self .Distance )
@@ -115,16 +150,16 @@ def PlotFields(self):
115150 Field = self .SuperSet [0 ].FullFields .astype (complex )* 0.
116151
117152 for mode , _ in enumerate (self .InitialAmplitudes ):
118- a = y [0 ].astype (complex )
119- field = self .SuperSet [0 ].FullFields .astype (complex )
153+ a = y [mode ].astype (complex )
154+ field = self .SuperSet [mode ].FullFields .astype (complex )
120155 Field += np .einsum ('i, ijk->ijk' , a , field )
121156
122157 surface = mlab .surf ( np .abs ( Field [0 ] ) , warp_scale = "auto" )
123158
124159 @mlab .animate (delay = 100 )
125160 def anim_loc ():
126161 for n , _ in enumerate (self .Distance ):
127- surface .mlab_source .scalars = np .abs ( Field [n ] )
162+ surface .mlab_source .scalars = np .abs (np . abs ( Field [n ] ) )
128163
129164 yield
130165
@@ -143,7 +178,7 @@ class SuperSet(SetProperties, SetPlottings, ReprBase):
143178 "Size" ,
144179 "Geometry" ]
145180
146- Methods = [ "Propagate " ]
181+ Methods = ["GetSuperposition" , "Matrix " ]
147182
148183 def __init__ (self , ParentSolver ):
149184 self .ParentSolver = ParentSolver
0 commit comments