LightWave2D 0.0.6__tar.gz → 0.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. lightwave2d-0.0.7/LightWave2D/VERSION +1 -0
  2. lightwave2d-0.0.7/LightWave2D/__pycache__/__init__.cpython-311.pyc +0 -0
  3. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/components.cpython-311.pyc +0 -0
  4. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/detector.cpython-311.pyc +0 -0
  5. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/experiment.cpython-311.pyc +0 -0
  6. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/grid.cpython-311.pyc +0 -0
  7. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/physics.cpython-311.pyc +0 -0
  8. lightwave2d-0.0.7/LightWave2D/__pycache__/pml.cpython-311.pyc +0 -0
  9. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/source.cpython-311.pyc +0 -0
  10. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__pycache__/utils.cpython-311.pyc +0 -0
  11. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/components.py +16 -8
  12. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/experiment.py +20 -3
  13. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/grid.py +2 -0
  14. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/pml.py +0 -1
  15. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D.egg-info/PKG-INFO +1 -1
  16. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/PKG-INFO +1 -1
  17. lightwave2d-0.0.6/LightWave2D/VERSION +0 -1
  18. lightwave2d-0.0.6/LightWave2D/__pycache__/__init__.cpython-311.pyc +0 -0
  19. lightwave2d-0.0.6/LightWave2D/__pycache__/pml.cpython-311.pyc +0 -0
  20. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LICENSE +0 -0
  21. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/__init__.py +0 -0
  22. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/detector.py +0 -0
  23. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/directories.py +0 -0
  24. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/physics.py +0 -0
  25. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/source.py +0 -0
  26. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D/utils.py +0 -0
  27. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D.egg-info/SOURCES.txt +0 -0
  28. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D.egg-info/dependency_links.txt +0 -0
  29. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D.egg-info/requires.txt +0 -0
  30. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/LightWave2D.egg-info/top_level.txt +0 -0
  31. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/MANIFEST.in +0 -0
  32. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/README.rst +0 -0
  33. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/developments/testings_0.py +0 -0
  34. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/setup.cfg +0 -0
  35. {lightwave2d-0.0.6 → lightwave2d-0.0.7}/setup.py +0 -0
@@ -0,0 +1 @@
1
+ 0.0.7
@@ -36,12 +36,14 @@ class BaseComponent():
36
36
  edgecolor (str): The color of the component's edge.
37
37
  alpha (float): Transparency level of the component.
38
38
  rotation (float): Rotation angle of the component.
39
+ sigma (float): Conductivity of the component.
39
40
  """
40
41
  grid: Grid
41
42
  facecolor: str = 'lightblue'
42
43
  edgecolor: str = 'blue'
43
44
  alpha: float = 0.3
44
45
  rotation: float = 0
46
+ sigma: float = 0
45
47
 
46
48
  def __post_init__(self):
47
49
  x0, y0 = self.position
@@ -63,14 +65,10 @@ class BaseComponent():
63
65
 
64
66
  self.path = Path(self.polygon.exterior.coords)
65
67
 
66
- x_mesh, y_mesh = numpy.meshgrid(self.grid.x_stamp, self.grid.y_stamp)
67
-
68
- coordinates = numpy.c_[x_mesh.T.flatten(), y_mesh.T.flatten()]
68
+ coordinates = numpy.c_[self.grid.x_mesh.T.flatten(), self.grid.y_mesh.T.flatten()]
69
69
 
70
70
  self.idx = self.path.contains_points(coordinates).astype(bool).reshape(self.epsilon_r_mesh.shape)
71
71
 
72
- self.epsilon_r_mesh[self.idx] = self.epsilon_r
73
-
74
72
  def add_to_ax(self, ax: plt.axis) -> PatchCollection:
75
73
  """
76
74
  Add the component to the provided axis.
@@ -107,14 +105,23 @@ class BaseComponent():
107
105
 
108
106
  plt.show()
109
107
 
110
- def add_to_mesh(self, epsilon_r_mesh: numpy.ndarray) -> NoReturn:
108
+ def add_to_epsilon_r_mesh(self, epsilon_r_mesh: numpy.ndarray) -> NoReturn:
111
109
  """
112
110
  Add the component's permittivity to the provided mesh.
113
111
 
114
112
  Args:
115
113
  epsilon_r_mesh (np.ndarray): The permittivity mesh to be updated.
116
114
  """
117
- epsilon_r_mesh += self.epsilon_r_mesh
115
+ epsilon_r_mesh[self.idx] = self.epsilon_r
116
+
117
+ def add_to_sigma_mesh(self, sigma_mesh: numpy.ndarray) -> NoReturn:
118
+ """
119
+ Add the component's sigma to the provided mesh.
120
+
121
+ Args:
122
+ sigma_mesh (np.ndarray): The permittivity mesh to be updated.
123
+ """
124
+ sigma_mesh[self.idx] = self.sigma
118
125
 
119
126
  def add_non_linear_effect_to_field(self, field: numpy.ndarray) -> NoReturn:
120
127
  """
@@ -123,7 +130,8 @@ class BaseComponent():
123
130
  Args:
124
131
  field (np.ndarray): The field to which non-linear effects will be added.
125
132
  """
126
- chi_2 = 1e10
133
+ return
134
+ chi_2 = 0
127
135
 
128
136
  field += self.idx * self.grid.dt**2 / (self.epsilon_r_mesh * Physics.epsilon_0 * Physics.mu_0) * chi_2 * field ** 2
129
137
 
@@ -211,6 +211,11 @@ class Experiment:
211
211
  sigma_x, sigma_y = self.pml.sigma_x, self.pml.sigma_y
212
212
  else:
213
213
  sigma_x = sigma_y = numpy.zeros(self.grid.shape)
214
+
215
+ for component in self.components:
216
+ component.add_to_sigma_mesh(sigma_x)
217
+ component.add_to_sigma_mesh(sigma_y)
218
+
214
219
  return sigma_x, sigma_y
215
220
 
216
221
  def get_epsilon(self) -> numpy.ndarray:
@@ -222,7 +227,7 @@ class Experiment:
222
227
  """
223
228
  epsilon_r_mesh = numpy.ones(self.grid.shape)
224
229
  for component in self.components:
225
- component.add_to_mesh(epsilon_r_mesh)
230
+ component.add_to_epsilon_r_mesh(epsilon_r_mesh)
226
231
 
227
232
  return epsilon_r_mesh * Physics.epsilon_0
228
233
 
@@ -264,11 +269,15 @@ class Experiment:
264
269
 
265
270
  Ez[1:-1, 1:-1] += eps_factor[1:-1, 1:-1] * (dHy_dx - dHx_dy)
266
271
 
272
+ # Apply absorption (losses) to the electric field Ez
273
+ absorption_factor = 1 - (sigma_x + sigma_y) * eps_factor / 2
274
+ absorption_factor = numpy.clip(absorption_factor, 0, 1) # Absorption cliped to [0, 1] to ensure stability
275
+
276
+ Ez *= absorption_factor
277
+
267
278
  for component in self.components:
268
279
  component.add_non_linear_effect_to_field(Ez)
269
280
 
270
- Ez *= (1 - (sigma_x + sigma_y) * eps_factor / 2)
271
-
272
281
  for source in self.sources:
273
282
  source.add_source_to_field(Ez, time=t)
274
283
 
@@ -342,6 +351,7 @@ class Experiment:
342
351
  frame_number (int): The index of the frame to be saved.
343
352
  filename (str): The file path where the image will be saved.
344
353
  dpi (int): The resolution of the saved image in dots per inch.
354
+ show_intensity (bool): If True, the intensity is shown instead of amplitude
345
355
  colormap (Optional[Union[str, object]]): The colormap used for visualizing the data. Defaults to a predefined blue-black-red colormap.
346
356
 
347
357
  Returns:
@@ -394,6 +404,7 @@ class Experiment:
394
404
  skip_frame: int = 10,
395
405
  scale_max: float = 5,
396
406
  unit_size: int = 6,
407
+ auto_adjust_clim: bool = False,
397
408
  colormap: Optional[Union[str, object]] = colormaps.blue_black_red) -> animation.FuncAnimation:
398
409
  """
399
410
  Renders the propagation of a field as an animation using matplotlib.
@@ -403,6 +414,7 @@ class Experiment:
403
414
 
404
415
  Args:
405
416
  skip_frame (int): The number of time steps to skip between frames in the animation.
417
+ auto_adjust_clim (bool): TODO
406
418
  colormap (Optional[Union[str, object]]): The colormap used for visualizing the data. Defaults to a predefined blue-black-red colormap.
407
419
  unit_size (float): The base unit size for scaling the plot elements.
408
420
 
@@ -437,6 +449,11 @@ class Experiment:
437
449
  """
438
450
  field_t = self.Ez_t[frame].T
439
451
  field_artist.set_array(field_t)
452
+
453
+ if auto_adjust_clim:
454
+ max_amplitude = abs(field_t).max() / scale_max
455
+ field_artist.set_clim(vmin=-max_amplitude, vmax=max_amplitude)
456
+
440
457
  return [artist for artist in artist_list]
441
458
 
442
459
  def init_func():
@@ -52,6 +52,8 @@ class Grid:
52
52
  self.x_stamp = numpy.arange(self.n_x) * self.dx
53
53
  self.y_stamp = numpy.arange(self.n_y) * self.dy
54
54
 
55
+ self.x_mesh, self.y_mesh = numpy.meshgrid(self.x_stamp, self.y_stamp)
56
+
55
57
  self.polygon = geo.Polygon([
56
58
  (self.x_stamp[0], self.y_stamp[0]),
57
59
  (self.x_stamp[0], self.y_stamp[-1]),
@@ -47,7 +47,6 @@ class PML:
47
47
  opposite_width = f"{100 - opposite_width}%"
48
48
  self.width_start = self.grid.get_coordinate(x=self.width, y=self.width)
49
49
  self.width_stop = self.grid.get_coordinate(x=opposite_width, y=opposite_width)
50
- self.width_stop_ = self.grid.get_coordinate(x="100%", y="100%")
51
50
 
52
51
  bottom_boundary = y_mesh < self.width_start.y
53
52
  left_boundary = x_mesh < self.width_start.x
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LightWave2D
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: A package for finite-difference time domain computation for light propagation.
5
5
  Home-page: https://github.com/MartinPdeS/LightWave2D
6
6
  Author: Martin Poinsinet de Sivry
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LightWave2D
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: A package for finite-difference time domain computation for light propagation.
5
5
  Home-page: https://github.com/MartinPdeS/LightWave2D
6
6
  Author: Martin Poinsinet de Sivry
@@ -1 +0,0 @@
1
- 0.0.6
File without changes
File without changes
File without changes
File without changes
File without changes