@@ -148,19 +148,20 @@ def test_dipole():
148
148
_ = td .PointDipole (size = (1 , 1 , 1 ), source_time = g , center = (1 , 2 , 3 ), polarization = "Ex" )
149
149
150
150
151
- def test_FieldSource ():
151
+ @pytest .mark .parametrize ("swap_axes" , [True , False ])
152
+ def test_FieldSource (swap_axes ):
152
153
g = td .GaussianPulse (freq0 = 1e12 , fwidth = 0.1e12 )
153
154
mode_spec = td .ModeSpec (num_modes = 2 )
154
155
155
156
# test we can make planewave
156
- _ = td .PlaneWave (size = (0 , td .inf , td .inf ), source_time = g , pol_angle = np .pi / 2 , direction = "+" )
157
- # s.plot(y=0)
158
- # plt.close()
157
+ s = td .PlaneWave (size = (0 , td .inf , td .inf ), source_time = g , pol_angle = np .pi / 2 , direction = "+" )
158
+ s .plot (y = 0 , swap_axes = swap_axes )
159
+ plt .close ()
159
160
160
161
# test we can make gaussian beam
161
- _ = td .GaussianBeam (size = (0 , 1 , 1 ), source_time = g , pol_angle = np .pi / 2 , direction = "+" )
162
- # s.plot(y=0)
163
- # plt.close()
162
+ s = td .GaussianBeam (size = (0 , 1 , 1 ), source_time = g , pol_angle = np .pi / 2 , direction = "+" )
163
+ s .plot (y = 0 , swap_axes = swap_axes )
164
+ plt .close ()
164
165
165
166
# test we can make an astigmatic gaussian beam
166
167
_ = td .AstigmaticGaussianBeam (
@@ -173,11 +174,11 @@ def test_FieldSource():
173
174
)
174
175
175
176
# test we can make mode source
176
- _ = td .ModeSource (
177
+ s = td .ModeSource (
177
178
size = (0 , 1 , 1 ), direction = "+" , source_time = g , mode_spec = mode_spec , mode_index = 0
178
179
)
179
- # s.plot(y=0)
180
- # plt.close()
180
+ s .plot (y = 0 , swap_axes = swap_axes )
181
+ plt .close ()
181
182
182
183
# test that non-planar geometry crashes plane wave and gaussian beams
183
184
with pytest .raises (pydantic .ValidationError ):
@@ -203,10 +204,25 @@ def test_FieldSource():
203
204
with pytest .raises (pydantic .ValidationError ):
204
205
_ = td .TFSF (size = (1 , 1 , 0 ), direction = "+" , source_time = g , injection_axis = 2 )
205
206
206
- # s.plot(z=0)
207
+ # s.plot(z=0, swap_axes=swap_axes )
207
208
# plt.close()
208
209
209
210
211
+ @pytest .mark .parametrize ("swap_axes" , [True , False ])
212
+ def test_current_source (swap_axes ):
213
+ L : float = 5.0
214
+ source = td .UniformCurrentSource (
215
+ center = (0 , - L / 3 , 0 ),
216
+ size = (L , 0 , L / 2 ),
217
+ polarization = "Ex" ,
218
+ source_time = td .GaussianPulse (
219
+ freq0 = 100e14 ,
220
+ fwidth = 10e14 ,
221
+ ),
222
+ )
223
+ source .plot (z = 0 , swap_axes = swap_axes )
224
+
225
+
210
226
def test_pol_arrow ():
211
227
g = td .GaussianPulse (freq0 = 1e12 , fwidth = 0.1e12 )
212
228
0 commit comments