emerge 0.6.2__py3-none-any.whl → 0.6.5__py3-none-any.whl
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.
Potentially problematic release.
This version of emerge might be problematic. Click here for more details.
- emerge/__init__.py +1 -1
- emerge/_emerge/geo/polybased.py +118 -24
- emerge/_emerge/physics/microwave/microwave_3d.py +1 -1
- emerge/_emerge/physics/microwave/microwave_data.py +61 -8
- emerge/_emerge/simmodel.py +26 -1
- {emerge-0.6.2.dist-info → emerge-0.6.5.dist-info}/METADATA +1 -1
- {emerge-0.6.2.dist-info → emerge-0.6.5.dist-info}/RECORD +10 -11
- emerge/_emerge/geo/pipes.py +0 -62
- {emerge-0.6.2.dist-info → emerge-0.6.5.dist-info}/WHEEL +0 -0
- {emerge-0.6.2.dist-info → emerge-0.6.5.dist-info}/entry_points.txt +0 -0
- {emerge-0.6.2.dist-info → emerge-0.6.5.dist-info}/licenses/LICENSE +0 -0
emerge/__init__.py
CHANGED
emerge/_emerge/geo/polybased.py
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# <https://www.gnu.org/licenses/>.
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
import numpy as np
|
|
19
|
-
from ..cs import CoordinateSystem, GCS, Axis
|
|
19
|
+
from ..cs import CoordinateSystem, GCS, Axis, _parse_axis
|
|
20
20
|
from ..geometry import GeoVolume, GeoPolygon, GeoEdge, GeoSurface
|
|
21
21
|
from .shapes import Alignment
|
|
22
22
|
import gmsh
|
|
@@ -158,7 +158,35 @@ def rotate_point(point: tuple[float, float, float],
|
|
|
158
158
|
rotated += o
|
|
159
159
|
return tuple(rotated)
|
|
160
160
|
|
|
161
|
+
def _dist(p1: tuple[float, float], p2: tuple[float, float]) -> float:
|
|
162
|
+
return ((p2[0]-p1[0])**2 + (p2[1]-p1[1])**2)**(0.5)
|
|
161
163
|
|
|
164
|
+
def _pair_points(x1: np.ndarray,
|
|
165
|
+
y1: np.ndarray,
|
|
166
|
+
x2: np.ndarray,
|
|
167
|
+
y2: np.ndarray) -> list[tuple[int,int]]:
|
|
168
|
+
if x1.shape[0]==x2.shape[0]:
|
|
169
|
+
return [(i,i) for i in range(x1.shape[0])]
|
|
170
|
+
|
|
171
|
+
#create point tuples
|
|
172
|
+
p1s = [(x,y) for x,y in zip(x1, y1)]
|
|
173
|
+
p2s = [(x,y) for x,y in zip(x2, y2)]
|
|
174
|
+
|
|
175
|
+
pairs = []
|
|
176
|
+
for i, p1 in enumerate(p1s):
|
|
177
|
+
d1 = _dist(p1, p2s[i-1])
|
|
178
|
+
d2 = _dist(p1, p2s[i])
|
|
179
|
+
d3 = _dist(p1, p2s[i+1])
|
|
180
|
+
mind = min([d1, d2, d3])
|
|
181
|
+
if mind==d1:
|
|
182
|
+
pairs.append((i,i-1))
|
|
183
|
+
continue
|
|
184
|
+
elif mind==d2:
|
|
185
|
+
pairs.append((i,i))
|
|
186
|
+
else:
|
|
187
|
+
pairs.append((i,i+1))
|
|
188
|
+
return pairs
|
|
189
|
+
|
|
162
190
|
def orthonormalize(axis: np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
163
191
|
"""Generates a set of orthonormal vectors given an input vector X
|
|
164
192
|
|
|
@@ -233,8 +261,9 @@ class XYPolygon:
|
|
|
233
261
|
"""This class generalizes a polygon in an un-embedded XY space that can be embedded in 3D space.
|
|
234
262
|
"""
|
|
235
263
|
def __init__(self,
|
|
236
|
-
xs: np.ndarray | list | tuple = None,
|
|
237
|
-
ys: np.ndarray | list | tuple = None
|
|
264
|
+
xs: np.ndarray | list | tuple | None = None,
|
|
265
|
+
ys: np.ndarray | list | tuple | None = None,
|
|
266
|
+
cs: CoordinateSystem | None = None):
|
|
238
267
|
"""Constructs an XY-plane placed polygon.
|
|
239
268
|
|
|
240
269
|
Args:
|
|
@@ -250,7 +279,13 @@ class XYPolygon:
|
|
|
250
279
|
self.y: np.ndarray = np.asarray(ys)
|
|
251
280
|
|
|
252
281
|
self.fillets: list[tuple[float, int]] = []
|
|
282
|
+
|
|
283
|
+
self._cs: CoordinateSystem = cs
|
|
253
284
|
|
|
285
|
+
@property
|
|
286
|
+
def center(self) -> tuple[float, float]:
|
|
287
|
+
return np.mean(self.x), np.mean(self.y)
|
|
288
|
+
|
|
254
289
|
@property
|
|
255
290
|
def length(self):
|
|
256
291
|
return sum([((self.x[i2]-self.x[i1])**2 + (self.y[i2]-self.y[i1])**2)**0.5 for i1, i2 in zip(range(self.N-1),range(1, self.N))])
|
|
@@ -282,6 +317,10 @@ class XYPolygon:
|
|
|
282
317
|
"""
|
|
283
318
|
return 0.5*np.abs(np.dot(self.x,np.roll(self.y,1))-np.dot(self.y,np.roll(self.x,1)))
|
|
284
319
|
|
|
320
|
+
def incs(self, cs: CoordinateSystem) -> XYPolygon:
|
|
321
|
+
self._cs = cs
|
|
322
|
+
return self
|
|
323
|
+
|
|
285
324
|
def extend(self, xpts: list[float], ypts: list[float]) -> XYPolygon:
|
|
286
325
|
"""Adds a series for x and y coordinates to the existing polygon.
|
|
287
326
|
|
|
@@ -301,7 +340,7 @@ class XYPolygon:
|
|
|
301
340
|
for i in range(self.N):
|
|
302
341
|
yield (self.x[i], self.y[i])
|
|
303
342
|
|
|
304
|
-
def fillet(self, radius: float, *indices: int) ->
|
|
343
|
+
def fillet(self, radius: float, *indices: int) -> XYPolygon:
|
|
305
344
|
"""Add a fillet rounding with a given radius to the provided nodes.
|
|
306
345
|
|
|
307
346
|
Example:
|
|
@@ -313,8 +352,9 @@ class XYPolygon:
|
|
|
313
352
|
"""
|
|
314
353
|
for i in indices:
|
|
315
354
|
self.fillets.append((radius, i))
|
|
355
|
+
return self
|
|
316
356
|
|
|
317
|
-
def
|
|
357
|
+
def _make_wire(self, cs: CoordinateSystem) -> tuple[list[int], list[int], int]:
|
|
318
358
|
"""Turns the XYPolygon object into a GeoPolygon that is embedded in 3D space.
|
|
319
359
|
|
|
320
360
|
The polygon will be placed in the XY-plane of the provided coordinate center.
|
|
@@ -340,13 +380,27 @@ class XYPolygon:
|
|
|
340
380
|
|
|
341
381
|
add = 0
|
|
342
382
|
for radius, index in self.fillets:
|
|
343
|
-
t1 = lines[index + add]
|
|
344
|
-
t2 = lines[
|
|
383
|
+
t1 = lines[(index + add-1) % len(lines)]
|
|
384
|
+
t2 = lines[index + add]
|
|
345
385
|
tag = gmsh.model.occ.fillet2_d(t1, t2, radius)
|
|
346
386
|
lines.insert(index, tag)
|
|
347
387
|
add += 1
|
|
348
388
|
|
|
349
389
|
wiretag = gmsh.model.occ.add_wire(lines)
|
|
390
|
+
return ptags, lines, wiretag
|
|
391
|
+
|
|
392
|
+
def _finalize(self, cs: CoordinateSystem) -> GeoPolygon:
|
|
393
|
+
"""Turns the XYPolygon object into a GeoPolygon that is embedded in 3D space.
|
|
394
|
+
|
|
395
|
+
The polygon will be placed in the XY-plane of the provided coordinate center.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
cs (CoordinateSystem, optional): The coordinate system in which to put the polygon. Defaults to None.
|
|
399
|
+
|
|
400
|
+
Returns:
|
|
401
|
+
GeoPolygon: The resultant 3D GeoPolygon object.
|
|
402
|
+
"""
|
|
403
|
+
ptags, lines, wiretag = self._make_wire(cs)
|
|
350
404
|
surftag = gmsh.model.occ.add_plane_surface([wiretag,])
|
|
351
405
|
poly = GeoPolygon([surftag,])
|
|
352
406
|
poly.points = ptags
|
|
@@ -384,6 +438,8 @@ class XYPolygon:
|
|
|
384
438
|
Returns:
|
|
385
439
|
GeoPolygon: The resultant object.
|
|
386
440
|
"""
|
|
441
|
+
if self._cs is not None:
|
|
442
|
+
return self._finalize(self._cs)
|
|
387
443
|
if cs is None:
|
|
388
444
|
cs = GCS
|
|
389
445
|
return self._finalize(cs)
|
|
@@ -500,7 +556,34 @@ class XYPolygon:
|
|
|
500
556
|
self.extend(xs, ys)
|
|
501
557
|
return self
|
|
502
558
|
|
|
559
|
+
def connect(self, other: XYPolygon) -> GeoVolume:
|
|
560
|
+
"""Connect two XYPolygons with a defined coordinate system
|
|
503
561
|
|
|
562
|
+
The coordinate system must be defined before this function can be used. To add a coordinate systme without
|
|
563
|
+
rendering the Polygon to a GeoVolume, use:
|
|
564
|
+
>>> polygon.incs(my_cs_obj)
|
|
565
|
+
|
|
566
|
+
Args:
|
|
567
|
+
other (XYPolygon): _descrThe otheiption_
|
|
568
|
+
|
|
569
|
+
Returns:
|
|
570
|
+
GeoVolume: The resultant volume object
|
|
571
|
+
"""
|
|
572
|
+
if self._cs is None:
|
|
573
|
+
raise RuntimeError('Cannot connect XYPolygons without a defined coordinate system. Set this first using .incs()')
|
|
574
|
+
if other._cs is None:
|
|
575
|
+
raise RuntimeError('Cannot connect XYPolygons without a defined coordinate system. Set this first using .incs()')
|
|
576
|
+
p1, l1, w1 = self._make_wire(self._cs)
|
|
577
|
+
p2, l2, w2 = other._make_wire(other._cs)
|
|
578
|
+
o1 = np.array(self._cs.in_global_cs(*self.center, 0)).flatten()
|
|
579
|
+
o2 = np.array(other._cs.in_global_cs(*other.center, 0)).flatten()
|
|
580
|
+
dts = gmsh.model.occ.addThruSections([w1, w2], True, parametrization="IsoParametric")
|
|
581
|
+
vol = GeoVolume([t for d,t in dts if d==3])
|
|
582
|
+
|
|
583
|
+
vol._add_face_pointer('front',o1, self._cs.zax.np)
|
|
584
|
+
vol._add_face_pointer('back', o2, other._cs.zax.np)
|
|
585
|
+
return vol
|
|
586
|
+
|
|
504
587
|
class Disc(GeoSurface):
|
|
505
588
|
|
|
506
589
|
def __init__(self, origin: tuple[float, float, float],
|
|
@@ -525,8 +608,7 @@ class Curve(GeoEdge):
|
|
|
525
608
|
degree: int = 3,
|
|
526
609
|
weights: list[float] | None = None,
|
|
527
610
|
knots: list[float] | None = None,
|
|
528
|
-
ctype: Literal['Spline','BSpline','Bezier'] = '
|
|
529
|
-
dstart: tuple[float, float, float] | None = None):
|
|
611
|
+
ctype: Literal['Spline','BSpline','Bezier'] = 'Spline'):
|
|
530
612
|
"""Generate a Spline/Bspline or Bezier curve based on a series of points
|
|
531
613
|
|
|
532
614
|
This calls the different curve features in OpenCASCADE.
|
|
@@ -547,11 +629,6 @@ class Curve(GeoEdge):
|
|
|
547
629
|
self.xpts: np.ndarray = xpts
|
|
548
630
|
self.ypts: np.ndarray = ypts
|
|
549
631
|
self.zpts: np.ndarray = zpts
|
|
550
|
-
|
|
551
|
-
if dstart is None:
|
|
552
|
-
dstart = (xpts[1]-xpts[0], ypts[1]-ypts[0], zpts[1]-zpts[0])
|
|
553
|
-
|
|
554
|
-
self.dstart: tuple[float, float, float] = dstart
|
|
555
632
|
|
|
556
633
|
points = [gmsh.model.occ.add_point(x,y,z) for x,y,z in zip(xpts, ypts, zpts)]
|
|
557
634
|
|
|
@@ -571,6 +648,14 @@ class Curve(GeoEdge):
|
|
|
571
648
|
gmsh.model.occ.remove([(0,tag) for tag in points])
|
|
572
649
|
super().__init__(tags)
|
|
573
650
|
|
|
651
|
+
gmsh.model.occ.synchronize()
|
|
652
|
+
p1 = gmsh.model.getValue(self.dim, self.tags[0], [0,])
|
|
653
|
+
p2 = gmsh.model.getValue(self.dim, self.tags[0], [1e-6])
|
|
654
|
+
self.dstart: tuple[float, float, float] = (p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
574
659
|
@property
|
|
575
660
|
def p0(self) -> tuple[float, float, float]:
|
|
576
661
|
"""The start coordinate
|
|
@@ -653,7 +738,7 @@ class Curve(GeoEdge):
|
|
|
653
738
|
zp[2] += d/2*dz
|
|
654
739
|
dp = tuple(Z)
|
|
655
740
|
|
|
656
|
-
return Curve(xp, yp, zp, ctype='Spline'
|
|
741
|
+
return Curve(xp, yp, zp, ctype='Spline')
|
|
657
742
|
|
|
658
743
|
@staticmethod
|
|
659
744
|
def helix_lh(pstart: tuple[float, float, float],
|
|
@@ -731,9 +816,12 @@ class Curve(GeoEdge):
|
|
|
731
816
|
zp[2] += d/2*dz
|
|
732
817
|
dp = tuple(Z)
|
|
733
818
|
|
|
734
|
-
return Curve(xp, yp, zp, ctype='Spline'
|
|
819
|
+
return Curve(xp, yp, zp, ctype='Spline')
|
|
735
820
|
|
|
736
|
-
def pipe(self, crossection: GeoSurface | XYPolygon,
|
|
821
|
+
def pipe(self, crossection: GeoSurface | XYPolygon,
|
|
822
|
+
max_mesh_size: float | None = None,
|
|
823
|
+
start_tangent: Axis | tuple[float, float, float] | np.ndarray | None = None,
|
|
824
|
+
x_axis: Axis | tuple[float, float, float] | np.ndarray | None = None) -> GeoVolume:
|
|
737
825
|
"""Extrudes a surface or XYPolygon object along the given curve
|
|
738
826
|
|
|
739
827
|
If a GeoSurface object is used, make sure it starts at the center of the curve. This property
|
|
@@ -744,25 +832,31 @@ class Curve(GeoEdge):
|
|
|
744
832
|
Args:
|
|
745
833
|
crossection (GeoSurface | XYPolygon): The cross section definition to be used
|
|
746
834
|
max_mesh_size (float, optional): The maximum mesh size. Defaults to None
|
|
835
|
+
start_tangent (Axis, tuple, ndarray, optional): The input polygon plane normal direction. Defaults to None
|
|
836
|
+
x_axis (Axis, tuple, ndarray optional): The reference X-axis to align the input polygon. Defaults to None
|
|
747
837
|
Returns:
|
|
748
838
|
GeoVolume: The resultant volume object
|
|
749
839
|
"""
|
|
750
840
|
if isinstance(crossection, XYPolygon):
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
841
|
+
if start_tangent is None:
|
|
842
|
+
start_tangent = self.dstart
|
|
843
|
+
if x_axis is not None:
|
|
844
|
+
xax = _parse_axis(x_axis)
|
|
845
|
+
zax = _parse_axis(self.dstart)
|
|
846
|
+
yax = zax.cross(xax)
|
|
847
|
+
cs = CoordinateSystem(xax, yax, zax, self.p0)
|
|
848
|
+
else:
|
|
849
|
+
zax = self.dstart
|
|
850
|
+
cs = Axis(np.array(zax)).construct_cs(self.p0)
|
|
851
|
+
surf = crossection.geo(cs)
|
|
754
852
|
else:
|
|
755
853
|
surf = crossection
|
|
756
854
|
x1, y1, z1, x2, y2, z2 = gmsh.model.occ.getBoundingBox(*surf.dimtags[0])
|
|
757
855
|
diag = ((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2)**(0.5)
|
|
758
|
-
|
|
759
856
|
pipetag = gmsh.model.occ.addPipe(surf.dimtags, self.tags[0], 'GuidePlan')
|
|
760
|
-
|
|
761
857
|
self.remove()
|
|
762
858
|
surf.remove()
|
|
763
|
-
|
|
764
859
|
volume = GeoVolume(pipetag[0][1])
|
|
765
|
-
|
|
766
860
|
volume.max_meshsize = diag/2
|
|
767
861
|
return volume
|
|
768
862
|
|
|
@@ -249,7 +249,7 @@ class MWData:
|
|
|
249
249
|
self.sim.new(**vars)['report'] = report
|
|
250
250
|
|
|
251
251
|
@dataclass
|
|
252
|
-
class
|
|
252
|
+
class FarFieldData:
|
|
253
253
|
E: np.ndarray
|
|
254
254
|
H: np.ndarray
|
|
255
255
|
theta: np.ndarray
|
|
@@ -816,7 +816,7 @@ class MWField:
|
|
|
816
816
|
ang_range: tuple[float, float] = (-180, 180),
|
|
817
817
|
Npoints: int = 201,
|
|
818
818
|
origin: tuple[float, float, float] | None = None,
|
|
819
|
-
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) ->
|
|
819
|
+
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) -> FarFieldData:#tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
820
820
|
"""Compute the farfield electric and magnetic field defined by a circle.
|
|
821
821
|
|
|
822
822
|
Args:
|
|
@@ -836,14 +836,14 @@ class MWField:
|
|
|
836
836
|
theta, phi = arc_on_plane(refdir, plane_normal_parsed, ang_range, Npoints)
|
|
837
837
|
E,H = self.farfield(theta, phi, faces, origin, syms = syms)
|
|
838
838
|
angs = np.linspace(*ang_range, Npoints)*np.pi/180
|
|
839
|
-
return
|
|
839
|
+
return FarFieldData(E, H, theta, phi, ang=angs)
|
|
840
840
|
|
|
841
841
|
def farfield_3d(self,
|
|
842
842
|
faces: FaceSelection | GeoSurface,
|
|
843
843
|
thetas: np.ndarray | None = None,
|
|
844
844
|
phis: np.ndarray | None = None,
|
|
845
845
|
origin: tuple[float, float, float] | None = None,
|
|
846
|
-
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) ->
|
|
846
|
+
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) -> FarFieldData:
|
|
847
847
|
"""Compute the farfield in a 3D angular grid
|
|
848
848
|
|
|
849
849
|
If thetas and phis are not provided, they default to a sample space of 2 degrees.
|
|
@@ -868,7 +868,7 @@ class MWField:
|
|
|
868
868
|
E = E.reshape((3, ) + T.shape)
|
|
869
869
|
H = H.reshape((3, ) + T.shape)
|
|
870
870
|
|
|
871
|
-
return
|
|
871
|
+
return FarFieldData(E, H, T, P)
|
|
872
872
|
|
|
873
873
|
def farfield(self, theta: np.ndarray,
|
|
874
874
|
phi: np.ndarray,
|
|
@@ -924,7 +924,7 @@ class MWField:
|
|
|
924
924
|
|
|
925
925
|
return Eff, Hff
|
|
926
926
|
|
|
927
|
-
def
|
|
927
|
+
def optycal_surface(self, faces: FaceSelection | GeoSurface | None = None) -> tuple:
|
|
928
928
|
"""Export this models exterior to an Optical acceptable dataset
|
|
929
929
|
|
|
930
930
|
Args:
|
|
@@ -948,7 +948,24 @@ class MWField:
|
|
|
948
948
|
H = field.H
|
|
949
949
|
k0 = self.k0
|
|
950
950
|
return vertices, triangles, E, H, origin, k0
|
|
951
|
-
|
|
951
|
+
|
|
952
|
+
def optycal_antenna(self, faces: FaceSelection | GeoSurface | None = None,
|
|
953
|
+
origin: tuple[float, float, float] | None = None,
|
|
954
|
+
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) -> dict:
|
|
955
|
+
"""Export this models exterior to an Optical acceptable dataset
|
|
956
|
+
|
|
957
|
+
Args:
|
|
958
|
+
faces (FaceSelection | GeoSurface): The faces to export. Defaults to None
|
|
959
|
+
|
|
960
|
+
Returns:
|
|
961
|
+
tuple: _description_
|
|
962
|
+
"""
|
|
963
|
+
freq = self.freq
|
|
964
|
+
def function(theta: np.ndarray, phi: np.ndarray, k0: float):
|
|
965
|
+
E, H = self.farfield(theta, phi, faces, origin, syms)
|
|
966
|
+
return E[0,:], E[1,:], E[2,:], H[0,:], H[1,:], H[2,:]
|
|
967
|
+
|
|
968
|
+
return dict(freq=freq, ff_function=function)
|
|
952
969
|
|
|
953
970
|
class MWScalar:
|
|
954
971
|
"""The MWDataSet class stores solution data of FEM Time Harmonic simulations.
|
|
@@ -1027,6 +1044,42 @@ class MWScalarNdim:
|
|
|
1027
1044
|
def S(self, i1: int, i2: int) -> np.ndarray:
|
|
1028
1045
|
return self.Sp[...,self._portmap[i1], self._portmap[i2]]
|
|
1029
1046
|
|
|
1047
|
+
@property
|
|
1048
|
+
def Smat(self) -> np.ndarray:
|
|
1049
|
+
"""Returns the full S-matrix
|
|
1050
|
+
|
|
1051
|
+
Returns:
|
|
1052
|
+
np.ndarray: The S-matrix with shape (nF, nP, nP)
|
|
1053
|
+
"""
|
|
1054
|
+
Nports = len(self._portmap)
|
|
1055
|
+
nfreq = self.freq.shape[0]
|
|
1056
|
+
|
|
1057
|
+
Smat = np.zeros((nfreq,Nports,Nports), dtype=np.complex128)
|
|
1058
|
+
|
|
1059
|
+
for i in self._portnumbers:
|
|
1060
|
+
for j in self._portnumbers:
|
|
1061
|
+
Smat[:,i-1,j-1] = self.S(i,j)
|
|
1062
|
+
|
|
1063
|
+
return Smat
|
|
1064
|
+
|
|
1065
|
+
def emmodel(self, f_sample: np.ndarray | None = None) -> tuple[np.ndarray, np.ndarray]:
|
|
1066
|
+
"""Returns the required date for a Heavi S-parameter component
|
|
1067
|
+
|
|
1068
|
+
Returns:
|
|
1069
|
+
tuple[np.ndarray, np.ndarray]: Heavi data
|
|
1070
|
+
"""
|
|
1071
|
+
|
|
1072
|
+
if f_sample is not None:
|
|
1073
|
+
f = f_sample
|
|
1074
|
+
S = self.model_Smat(f_sample)
|
|
1075
|
+
else:
|
|
1076
|
+
f = self.freq
|
|
1077
|
+
S = self.Smat
|
|
1078
|
+
|
|
1079
|
+
Z0s = self.Z0
|
|
1080
|
+
S = renormalise_s(S, Z0s, 50.0)
|
|
1081
|
+
return f, S
|
|
1082
|
+
|
|
1030
1083
|
def model_S(self, i: int, j: int,
|
|
1031
1084
|
freq: np.ndarray,
|
|
1032
1085
|
Npoles: int | Literal['auto'] = 'auto',
|
|
@@ -1062,7 +1115,7 @@ class MWScalarNdim:
|
|
|
1062
1115
|
Returns:
|
|
1063
1116
|
np.ndarray: The (Nf,Np,Np) S-parameter matrix
|
|
1064
1117
|
"""
|
|
1065
|
-
Nports = len(self.
|
|
1118
|
+
Nports = len(self._portmap)
|
|
1066
1119
|
nfreq = frequencies.shape[0]
|
|
1067
1120
|
|
|
1068
1121
|
Smat = np.zeros((nfreq,Nports,Nports), dtype=np.complex128)
|
emerge/_emerge/simmodel.py
CHANGED
|
@@ -37,7 +37,7 @@ import inspect
|
|
|
37
37
|
from pathlib import Path
|
|
38
38
|
from atexit import register
|
|
39
39
|
import signal
|
|
40
|
-
|
|
40
|
+
from .. import __version__
|
|
41
41
|
|
|
42
42
|
############################################################
|
|
43
43
|
# EXCEPTION DEFINITIONS #
|
|
@@ -54,6 +54,9 @@ Known problems/solutions:
|
|
|
54
54
|
class SimulationError(Exception):
|
|
55
55
|
pass
|
|
56
56
|
|
|
57
|
+
class VersionError(Exception):
|
|
58
|
+
pass
|
|
59
|
+
|
|
57
60
|
############################################################
|
|
58
61
|
# BASE 3D SIMULATION MODEL #
|
|
59
62
|
############################################################
|
|
@@ -228,6 +231,28 @@ class Simulation:
|
|
|
228
231
|
# PUBLIC FUNCTIONS #
|
|
229
232
|
############################################################
|
|
230
233
|
|
|
234
|
+
def check_version(self, version: str) -> None:
|
|
235
|
+
"""Compares the provided version number with the version number of EMerge that is running the script.
|
|
236
|
+
|
|
237
|
+
You may remove any call to check_version to suppress VersionErrors and warnings.
|
|
238
|
+
|
|
239
|
+
Args:
|
|
240
|
+
version (str): The EMerge version you intend to write this code for.
|
|
241
|
+
|
|
242
|
+
Raises:
|
|
243
|
+
VersionError: A potential version error if incompatibility is possible
|
|
244
|
+
"""
|
|
245
|
+
vM, vm, vp = [float(x) for x in version.split('.')]
|
|
246
|
+
cM, cm, cp = [float(x) for x in __version__.split('.')]
|
|
247
|
+
if vM != cM:
|
|
248
|
+
raise VersionError(f"You are running a script designed for version {version} with a possibly incompatible version of EMerge {__version__}")
|
|
249
|
+
if vm != cm:
|
|
250
|
+
raise VersionError(f"You are running a script designed for version {version} with a possibly incompatible version of EMerge {__version__}")
|
|
251
|
+
if vp != cp:
|
|
252
|
+
logger.warning(f"You are running a script designed for version {version} with a possibly incompatible version of EMerge {__version__}")
|
|
253
|
+
logger.warning("You may suppress this error by removing the call to .check_version().")
|
|
254
|
+
input('Press enter to proceed...')
|
|
255
|
+
|
|
231
256
|
def save(self) -> None:
|
|
232
257
|
"""Saves the current model in the provided project directory."""
|
|
233
258
|
# Ensure directory exists
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
emerge/__init__.py,sha256=
|
|
1
|
+
emerge/__init__.py,sha256=NGSPQ4EPfFHaKDQJrKTqMiBfEdvgxZhsgNxt4SoubIw,2605
|
|
2
2
|
emerge/__main__.py,sha256=WVf16sfrOI910QWohrQDaChZdRifMNoS6VKzCT6f3ZA,92
|
|
3
3
|
emerge/cli.py,sha256=NU1uhwuZ6i50680v3_I4kDZPTHqz74gOYK71UBhb8oE,666
|
|
4
4
|
emerge/ext.py,sha256=IBoHH5PQFj5pYMfp6r-uMpNNgbSe8c0g9x8qjBzzVmU,223
|
|
@@ -22,7 +22,7 @@ emerge/_emerge/mesher.py,sha256=fKgPb6oZe_bqp0XYfZ6UNgBfRaAS3-tjUtZX8NalJe8,1319
|
|
|
22
22
|
emerge/_emerge/periodic.py,sha256=xfdKKq3qX7iBBestnRizOzJNfXlpr9lCPkiYhfrRIR8,12013
|
|
23
23
|
emerge/_emerge/plot.py,sha256=cf1I9mj7EIUJcq8vmANlUkqoV6QqVaJaP-zlC-T9E18,8041
|
|
24
24
|
emerge/_emerge/selection.py,sha256=6UizuWC01sUGjFodrGTy8N1J1832vfOWA4u5paNupw4,21297
|
|
25
|
-
emerge/_emerge/simmodel.py,sha256=
|
|
25
|
+
emerge/_emerge/simmodel.py,sha256=guiNnSSxdc6qABHr78LAdp9U1dVxb-SPWBgaKTxFzgw,19535
|
|
26
26
|
emerge/_emerge/simulation_data.py,sha256=r9-9lpLeA1Z5HU3jDVOXV1H80GVawnXL5K81_dvmlE4,14506
|
|
27
27
|
emerge/_emerge/solver.py,sha256=PGPI2LuF4XhfyS8KfC-49X9M1mtYUadgHyqopYfPj58,48542
|
|
28
28
|
emerge/_emerge/system.py,sha256=p4HNz7d_LMRNE9Gk75vVdFecDH2iN_groAM9u-yQTpk,1618
|
|
@@ -37,9 +37,8 @@ emerge/_emerge/geo/horn.py,sha256=h4GzGzEkXgWaQgoBMvhFgGsqOrNRB3CJg3RBKXigCz0,41
|
|
|
37
37
|
emerge/_emerge/geo/modeler.py,sha256=gbxmwXAdR7kKW_EFbkd1QPVqJWKJpnTufI7lxaqPyjU,15573
|
|
38
38
|
emerge/_emerge/geo/operations.py,sha256=LKA7_BU4iw6-i6KOUyuL6l10QjXSwnXsixOaTw-M6Vk,9697
|
|
39
39
|
emerge/_emerge/geo/pcb.py,sha256=b4FZAwZaO8X2NMnRkYYDUTa8w9ZdN2XfZdmyHhZZaGY,52213
|
|
40
|
-
emerge/_emerge/geo/pipes.py,sha256=l1Vm5lpbxMwHQqffZWLTKQU_xNnsXvHq0XNDNCpQKXY,2054
|
|
41
40
|
emerge/_emerge/geo/pmlbox.py,sha256=TNjuyPtuqrAU5Yl8GrLlievuwYf3hUKJaCEz0cXKSzo,7922
|
|
42
|
-
emerge/_emerge/geo/polybased.py,sha256=
|
|
41
|
+
emerge/_emerge/geo/polybased.py,sha256=loVJRBjYCTUlti5tHwfH8iU-Inb6n2sOS2Cw4gVKid4,31917
|
|
43
42
|
emerge/_emerge/geo/shapes.py,sha256=7biZx_5s3sWKgJq6U_rqOBHyMZ3Nt6kHWj7tYsHPkt8,19289
|
|
44
43
|
emerge/_emerge/geo/step.py,sha256=XcAiEN8W4umNmZdYmrGHX_aJUuiMgc6vgT-UIk8Gbqc,2689
|
|
45
44
|
emerge/_emerge/geo/pcb_tools/calculator.py,sha256=eGYUXdXmHUJCPlfJyY96S87wjeAVFG-e4sPOwbYj0eA,832
|
|
@@ -51,9 +50,9 @@ emerge/_emerge/mth/pairing.py,sha256=i8bBvTeMmzgF0JdiDNJiTXxx913x4f10777pzD6FJo0
|
|
|
51
50
|
emerge/_emerge/physics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
51
|
emerge/_emerge/physics/microwave/__init__.py,sha256=QHeILGYWmvbfLl1o9wrTiWLm0evfXDgS0JiikUoMTts,28
|
|
53
52
|
emerge/_emerge/physics/microwave/adaptive_freq.py,sha256=aWhijhCVAbnuwkru-I1AaRdY20uyozf6OWRIh9r2ijg,9786
|
|
54
|
-
emerge/_emerge/physics/microwave/microwave_3d.py,sha256=
|
|
53
|
+
emerge/_emerge/physics/microwave/microwave_3d.py,sha256=5P8yyr6e6hFHBS1JAFHq8gsU1CxFG1LTelKVggv7AjY,42007
|
|
55
54
|
emerge/_emerge/physics/microwave/microwave_bc.py,sha256=-fxeZREL42snL4XvXuUqo4QJh24o8lHJ_IcWxkt5yAU,42484
|
|
56
|
-
emerge/_emerge/physics/microwave/microwave_data.py,sha256=
|
|
55
|
+
emerge/_emerge/physics/microwave/microwave_data.py,sha256=rIxHAaVFhKgedeEdEGqEd-2zXT0ZRUtL588NCA_d4XQ,46722
|
|
57
56
|
emerge/_emerge/physics/microwave/periodic.py,sha256=wYSUgLFVtCLqSG3EDKoCDRU93iPUzBdXzVRdHTRmbpI,3000
|
|
58
57
|
emerge/_emerge/physics/microwave/port_functions.py,sha256=aVU__AkVk8b1kH2J_oDLF5iNReCxC9nzCtesFSSSSQo,2112
|
|
59
58
|
emerge/_emerge/physics/microwave/sc.py,sha256=WZvoPhmHkfEv619RhmN09sXDBV0ryTqybwErA8Rc7lU,4735
|
|
@@ -79,8 +78,8 @@ emerge/_emerge/projects/_load_base.txt,sha256=94o0eSWoDKlNR336EmhpG_S5syQHIUPHQx
|
|
|
79
78
|
emerge/_emerge/projects/generate_project.py,sha256=TNw-0SpLc82MBq0bd9hB_yqvBZCgmuPonCBsHTp91uk,1450
|
|
80
79
|
emerge/_emerge/solve_interfaces/cudss_interface.py,sha256=-SjiTNIyE7iJ8Bm14Cva5e2lpJDgfiS2Mvz1Bgy-UL4,9688
|
|
81
80
|
emerge/_emerge/solve_interfaces/pardiso_interface.py,sha256=iVFxToMmIzhj3hcAP-O_MDHKz82ePFIHY1us11kzUBU,15305
|
|
82
|
-
emerge-0.6.
|
|
83
|
-
emerge-0.6.
|
|
84
|
-
emerge-0.6.
|
|
85
|
-
emerge-0.6.
|
|
86
|
-
emerge-0.6.
|
|
81
|
+
emerge-0.6.5.dist-info/METADATA,sha256=Kf2Xyi7EWIR34D7554jWXG0-HscLA6PR3MdQ9r-TjhM,3304
|
|
82
|
+
emerge-0.6.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
83
|
+
emerge-0.6.5.dist-info/entry_points.txt,sha256=8rFvAXticpKg4OTC8JEvAksnduW72KIEskCGG9XnFf8,43
|
|
84
|
+
emerge-0.6.5.dist-info/licenses/LICENSE,sha256=SuHm9Fw32RI6tylP2YCyTPITMwpueazVUZwUMFRE_zk,17856
|
|
85
|
+
emerge-0.6.5.dist-info/RECORD,,
|
emerge/_emerge/geo/pipes.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# EMerge is an open source Python based FEM EM simulation module.
|
|
2
|
-
# Copyright (C) 2025 Robert Fennis.
|
|
3
|
-
|
|
4
|
-
# This program is free software; you can redistribute it and/or
|
|
5
|
-
# modify it under the terms of the GNU General Public License
|
|
6
|
-
# as published by the Free Software Foundation; either version 2
|
|
7
|
-
# of the License, or (at your option) any later version.
|
|
8
|
-
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
|
|
14
|
-
# You should have received a copy of the GNU General Public License
|
|
15
|
-
# along with this program; if not, see
|
|
16
|
-
# <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
from __future__ import annotations
|
|
19
|
-
import gmsh
|
|
20
|
-
import numpy as np
|
|
21
|
-
from typing import Literal, Callable
|
|
22
|
-
from ..geometry import GeoEdge, GeoSurface, GeoVolume
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class Curve(GeoEdge):
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def __init__(self, xpts: np.ndarray, ypts: np.ndarray, zpts: np.ndarray,
|
|
30
|
-
degree: int = 3,
|
|
31
|
-
weights: list[float] | None = None,
|
|
32
|
-
knots: list[float] | None = None,
|
|
33
|
-
ctype: Literal['Spline','BSpline','Bezier'] = 'Bezier'):
|
|
34
|
-
self.xpts: np.ndarray = xpts
|
|
35
|
-
self.ypts: np.ndarray = ypts
|
|
36
|
-
self.zpts: np.ndarray = zpts
|
|
37
|
-
|
|
38
|
-
points = [gmsh.model.occ.add_point(x,y,z) for x,y,z in zip(xpts, ypts, zpts)]
|
|
39
|
-
|
|
40
|
-
if ctype.lower()=='spline':
|
|
41
|
-
tags = gmsh.model.occ.addSpline(points)
|
|
42
|
-
|
|
43
|
-
elif ctype.lower()=='bspline':
|
|
44
|
-
if weights is None:
|
|
45
|
-
weights = []
|
|
46
|
-
if knots is None:
|
|
47
|
-
knots = []
|
|
48
|
-
tags = gmsh.model.occ.addBSpline(points, degree=degree, weights=weights, knots=knots)
|
|
49
|
-
else:
|
|
50
|
-
tags = gmsh.model.occ.addBezier(points)
|
|
51
|
-
|
|
52
|
-
tags = gmsh.model.occ.addWire([tags,])
|
|
53
|
-
gmsh.model.occ.remove([(0,tag) for tag in points])
|
|
54
|
-
super().__init__(tags)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class Helix(GeoVolume):
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|