emerge 0.6.0__py3-none-any.whl → 0.6.2__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/cs.py +15 -6
- emerge/_emerge/geo/__init__.py +2 -2
- emerge/_emerge/geo/pcb.py +2 -2
- emerge/_emerge/geo/pipes.py +62 -0
- emerge/_emerge/geo/polybased.py +298 -59
- emerge/_emerge/geo/shapes.py +25 -0
- emerge/_emerge/geometry.py +4 -0
- emerge/_emerge/mesh3d.py +5 -4
- emerge/_emerge/mth/optimized.py +0 -31
- emerge/_emerge/physics/microwave/assembly/curlcurl.py +3 -8
- emerge/_emerge/physics/microwave/assembly/generalized_eigen.py +3 -8
- emerge/_emerge/physics/microwave/assembly/generalized_eigen_hb.py +3 -8
- emerge/_emerge/physics/microwave/microwave_data.py +76 -24
- emerge/_emerge/physics/microwave/sc.py +10 -15
- emerge/_emerge/plot/simple_plots.py +0 -2
- emerge/_emerge/simmodel.py +1 -1
- emerge/lib.py +161 -160
- {emerge-0.6.0.dist-info → emerge-0.6.2.dist-info}/METADATA +2 -3
- {emerge-0.6.0.dist-info → emerge-0.6.2.dist-info}/RECORD +23 -22
- {emerge-0.6.0.dist-info → emerge-0.6.2.dist-info}/WHEEL +0 -0
- {emerge-0.6.0.dist-info → emerge-0.6.2.dist-info}/entry_points.txt +0 -0
- {emerge-0.6.0.dist-info → emerge-0.6.2.dist-info}/licenses/LICENSE +0 -0
emerge/_emerge/mth/optimized.py
CHANGED
|
@@ -358,37 +358,6 @@ def local_mapping(vertex_ids, triangle_ids):
|
|
|
358
358
|
|
|
359
359
|
return out
|
|
360
360
|
|
|
361
|
-
@njit(f8[:,:](f8[:], f8[:], f8[:]), cache=True, nogil=True)
|
|
362
|
-
def orthonormal_basis(xs: np.ndarray, ys: np.ndarray, zs: np.ndarray):
|
|
363
|
-
"""
|
|
364
|
-
Returns an orthonormal basis for the tetrahedron defined by the points
|
|
365
|
-
xs, ys, zs. The basis is given as a 3x3 matrix with the first column being
|
|
366
|
-
the normal vector of the face opposite to the first vertex.
|
|
367
|
-
"""
|
|
368
|
-
x1, x2, x3 = xs
|
|
369
|
-
y1, y2, y3 = ys
|
|
370
|
-
z1, z2, z3 = zs
|
|
371
|
-
e1x, e1y, e1z = x2-x1, y2-y1, z2-z1
|
|
372
|
-
e2x, e2y, e2z = x3-x1, y3-y1, z3-z1
|
|
373
|
-
|
|
374
|
-
nn = np.array([e2y*e1z - e2z*e1y,
|
|
375
|
-
e2z*e1x - e2x*e1z,
|
|
376
|
-
e2y*e1x - e2x*e1y])
|
|
377
|
-
|
|
378
|
-
nn = nn/np.sqrt(nn[0]**2 + nn[1]**2 + nn[2]**2)
|
|
379
|
-
n2 = np.array([e1x, e1y, e1z])/np.sqrt(e1x**2 + e1y**2 + e1z**2)
|
|
380
|
-
n1 = np.array([n2[1]*nn[2] - n2[2]*nn[1],
|
|
381
|
-
n2[2]*nn[0] - n2[0]*nn[2],
|
|
382
|
-
n2[0]*nn[1] - n2[1]*nn[0]])
|
|
383
|
-
|
|
384
|
-
if dot(n1, cross(n2, nn)) < 0:
|
|
385
|
-
n1 = -n1
|
|
386
|
-
|
|
387
|
-
B = np.zeros((3,3), dtype=np.float64)
|
|
388
|
-
B[:,0] = n1
|
|
389
|
-
B[:,1] = n2
|
|
390
|
-
B[:,2] = nn
|
|
391
|
-
return B
|
|
392
361
|
|
|
393
362
|
@njit(f8[:,:](f8[:], f8[:], f8[:]), cache=True, nogil=True, fastmath=True)
|
|
394
363
|
def compute_distances(xs: np.ndarray, ys: np.ndarray, zs: np.ndarray) -> np.ndarray:
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
from ....elements import Nedelec2
|
|
20
20
|
from scipy.sparse import csr_matrix, coo_matrix
|
|
21
|
-
from numba_progress import ProgressBar, ProgressBarType
|
|
22
21
|
from ....mth.optimized import local_mapping, matinv, dot_c, cross_c, compute_distances
|
|
23
22
|
from numba import c16, types, f8, i8, njit, prange
|
|
24
23
|
|
|
@@ -167,8 +166,7 @@ def tet_mass_stiffness_matrices(field: Nedelec2,
|
|
|
167
166
|
nE = edges.shape[1]
|
|
168
167
|
nTri = tris.shape[1]
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
dataE, dataB, rows, cols = _matrix_builder(nodes, tets, tris, edges, field.mesh.edge_lengths, tet_to_field, tet_to_edge, ur, er, pgb)
|
|
169
|
+
dataE, dataB, rows, cols = _matrix_builder(nodes, tets, tris, edges, field.mesh.edge_lengths, tet_to_field, tet_to_edge, ur, er)
|
|
172
170
|
|
|
173
171
|
E = coo_matrix((dataE, (rows, cols)), shape=(nE*2 + nTri*2, nE*2 + nTri*2)).tocsr()
|
|
174
172
|
B = coo_matrix((dataB, (rows, cols)), shape=(nE*2 + nTri*2, nE*2 + nTri*2)).tocsr()
|
|
@@ -426,9 +424,8 @@ def ned2_tet_stiff_mass(tet_vertices, edge_lengths, local_edge_map, local_tri_ma
|
|
|
426
424
|
i8[:,:],
|
|
427
425
|
i8[:,:],
|
|
428
426
|
c16[:,:,:],
|
|
429
|
-
c16[:,:,:],
|
|
430
|
-
|
|
431
|
-
def _matrix_builder(nodes, tets, tris, edges, all_edge_lengths, tet_to_field, tet_to_edge, ur, er, pgb: ProgressBar):
|
|
427
|
+
c16[:,:,:]), cache=True, nogil=True, parallel=True)
|
|
428
|
+
def _matrix_builder(nodes, tets, tris, edges, all_edge_lengths, tet_to_field, tet_to_edge, ur, er):
|
|
432
429
|
nT = tets.shape[1]
|
|
433
430
|
nedges = edges.shape[1]
|
|
434
431
|
|
|
@@ -442,8 +439,6 @@ def _matrix_builder(nodes, tets, tris, edges, all_edge_lengths, tet_to_field, te
|
|
|
442
439
|
|
|
443
440
|
for itet in prange(nT): # ty: ignore
|
|
444
441
|
p = itet*400
|
|
445
|
-
if np.mod(itet,10)==0:
|
|
446
|
-
pgb.update(10)
|
|
447
442
|
urt = ur[:,:,itet]
|
|
448
443
|
ert = er[:,:,itet]
|
|
449
444
|
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
from ....elements.nedleg2 import NedelecLegrange2
|
|
20
20
|
from scipy.sparse import csr_matrix
|
|
21
|
-
from numba_progress import ProgressBar, ProgressBarType
|
|
22
21
|
from ....mth.optimized import local_mapping, matinv, compute_distances, gaus_quad_tri
|
|
23
22
|
from numba import c16, types, f8, i8, njit, prange
|
|
24
23
|
|
|
@@ -54,8 +53,7 @@ def generelized_eigenvalue_matrix(field: NedelecLegrange2,
|
|
|
54
53
|
|
|
55
54
|
nodes = field.local_nodes
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
dataE, dataB, rows, cols = _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0, pgb)
|
|
56
|
+
dataE, dataB, rows, cols = _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0)
|
|
59
57
|
|
|
60
58
|
nfield = field.n_field
|
|
61
59
|
|
|
@@ -427,9 +425,8 @@ def generalized_matrix_GQ(tri_vertices, local_edge_map, Ms, Mm, k0):
|
|
|
427
425
|
i8[:,:],
|
|
428
426
|
c16[:,:,:],
|
|
429
427
|
c16[:,:,:],
|
|
430
|
-
f8,
|
|
431
|
-
|
|
432
|
-
def _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0, pgb: ProgressBar):
|
|
428
|
+
f8), cache=True, nogil=True, parallel=True)
|
|
429
|
+
def _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0):
|
|
433
430
|
|
|
434
431
|
ntritot = tris.shape[1]
|
|
435
432
|
nnz = ntritot*196
|
|
@@ -443,8 +440,6 @@ def _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0, pgb: ProgressB
|
|
|
443
440
|
|
|
444
441
|
for itri in prange(ntritot): # type: ignore
|
|
445
442
|
p = itri*196
|
|
446
|
-
if np.mod(itri,10)==0:
|
|
447
|
-
pgb.update(10)
|
|
448
443
|
urt = ur[:,:,itri]
|
|
449
444
|
ert = er[:,:,itri]
|
|
450
445
|
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
from ....elements.nedleg2 import NedelecLegrange2
|
|
20
20
|
from scipy.sparse import csr_matrix
|
|
21
|
-
from numba_progress import ProgressBar, ProgressBarType
|
|
22
21
|
from ....mth.optimized import local_mapping, matinv, compute_distances, gaus_quad_tri
|
|
23
22
|
from numba import c16, types, f8, i8, njit, prange
|
|
24
23
|
|
|
@@ -54,8 +53,7 @@ def generelized_eigenvalue_matrix(field: NedelecLegrange2,
|
|
|
54
53
|
|
|
55
54
|
nodes = field.local_nodes
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
dataE, dataB, rows, cols = _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0, pgb)
|
|
56
|
+
dataE, dataB, rows, cols = _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0)
|
|
59
57
|
|
|
60
58
|
nfield = field.n_field
|
|
61
59
|
|
|
@@ -427,9 +425,8 @@ def generalized_matrix_GQ(tri_vertices, local_edge_map, Ms, Mm, k0):
|
|
|
427
425
|
i8[:,:],
|
|
428
426
|
c16[:,:,:],
|
|
429
427
|
c16[:,:,:],
|
|
430
|
-
f8,
|
|
431
|
-
|
|
432
|
-
def _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0, pgb: ProgressBar):
|
|
428
|
+
f8), cache=True, nogil=True, parallel=True)
|
|
429
|
+
def _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0):
|
|
433
430
|
|
|
434
431
|
ntritot = tris.shape[1]
|
|
435
432
|
nnz = ntritot*196
|
|
@@ -443,8 +440,6 @@ def _matrix_builder(nodes, tris, edges, tri_to_field, ur, er, k0, pgb: ProgressB
|
|
|
443
440
|
|
|
444
441
|
for itri in prange(ntritot): # type: ignore
|
|
445
442
|
p = itri*196
|
|
446
|
-
if np.mod(itri,10)==0:
|
|
447
|
-
pgb.update(10)
|
|
448
443
|
urt = ur[:,:,itri]
|
|
449
444
|
ert = er[:,:,itri]
|
|
450
445
|
|
|
@@ -254,9 +254,72 @@ class FarfieldData:
|
|
|
254
254
|
H: np.ndarray
|
|
255
255
|
theta: np.ndarray
|
|
256
256
|
phi: np.ndarray
|
|
257
|
+
ang: np.ndarray | None = None
|
|
257
258
|
|
|
259
|
+
@property
|
|
260
|
+
def Ex(self) -> np.ndarray:
|
|
261
|
+
return self.E[0,:]
|
|
262
|
+
|
|
263
|
+
@property
|
|
264
|
+
def Ey(self) -> np.ndarray:
|
|
265
|
+
return self.E[1,:]
|
|
266
|
+
|
|
267
|
+
@property
|
|
268
|
+
def Ez(self) -> np.ndarray:
|
|
269
|
+
return self.E[2,:]
|
|
270
|
+
|
|
271
|
+
@property
|
|
272
|
+
def Hx(self) -> np.ndarray:
|
|
273
|
+
return self.H[0,:]
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def Hy(self) -> np.ndarray:
|
|
277
|
+
return self.H[1,:]
|
|
278
|
+
|
|
279
|
+
@property
|
|
280
|
+
def Hz(self) -> np.ndarray:
|
|
281
|
+
return self.H[2,:]
|
|
282
|
+
|
|
283
|
+
@property
|
|
284
|
+
def Etheta(self) -> np.ndarray:
|
|
285
|
+
thx = -np.cos(self.theta)*np.cos(self.phi)
|
|
286
|
+
thy = -np.cos(self.theta)*np.sin(self.phi)
|
|
287
|
+
thz = np.sin(self.theta)
|
|
288
|
+
return thx*self.E[0,:] + thy*self.E[1,:] + thz*self.E[2,:]
|
|
289
|
+
|
|
290
|
+
@property
|
|
291
|
+
def Ephi(self) -> np.ndarray:
|
|
292
|
+
phx = -np.sin(self.phi)
|
|
293
|
+
phy = np.cos(self.phi)
|
|
294
|
+
phz = np.zeros_like(self.theta)
|
|
295
|
+
return phx*self.E[0,:] + phy*self.E[1,:] + phz*self.E[2,:]
|
|
296
|
+
|
|
297
|
+
@property
|
|
298
|
+
def Erhcp(self) -> np.ndarray:
|
|
299
|
+
return (self.Etheta - 1j*self.Ephi)/np.sqrt(2)
|
|
300
|
+
|
|
301
|
+
@property
|
|
302
|
+
def Elhcp(self) -> np.ndarray:
|
|
303
|
+
return (self.Etheta + 1j*self.Ephi)/np.sqrt(2)
|
|
304
|
+
|
|
305
|
+
@property
|
|
306
|
+
def AR(self) -> np.ndarray:
|
|
307
|
+
R = np.abs(self.Erhcp)
|
|
308
|
+
L = np.abs(self.Elhcp)
|
|
309
|
+
return (R+L)/(R-L)
|
|
310
|
+
|
|
311
|
+
@property
|
|
312
|
+
def normE(self) -> np.ndarray:
|
|
313
|
+
return np.sqrt(np.abs(self.E[0,:])**2 + np.abs(self.E[1,:])**2 + np.abs(self.E[2,:])**2)
|
|
314
|
+
|
|
315
|
+
@property
|
|
316
|
+
def normH(self) -> np.ndarray:
|
|
317
|
+
return np.sqrt(np.abs(self.H[0,:])**2 + np.abs(self.H[1,:])**2 + np.abs(self.H[2,:])**2)
|
|
318
|
+
|
|
319
|
+
|
|
258
320
|
def surfplot(self,
|
|
259
|
-
polarization: Literal['Ex','Ey','Ez','Etheta','Ephi','normE'],
|
|
321
|
+
polarization: Literal['Ex','Ey','Ez','Etheta','Ephi','normE','Erhcp','Elhcp','AR'],
|
|
322
|
+
quantity: Literal['abs','real','imag','angle'] = 'abs',
|
|
260
323
|
isotropic: bool = True, dB: bool = False, dBfloor: float = -30, rmax: float | None = None,
|
|
261
324
|
offset: tuple[float, float, float] = (0,0,0)) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
|
|
262
325
|
"""Returns the parameters to be used as positional arguments for the display.add_surf() function.
|
|
@@ -273,27 +336,16 @@ class FarfieldData:
|
|
|
273
336
|
Returns:
|
|
274
337
|
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: The X, Y, Z, F values
|
|
275
338
|
"""
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
thy = -np.cos(self.theta)*np.sin(self.phi)
|
|
287
|
-
thz = np.sin(self.theta)
|
|
288
|
-
F = np.abs(thx*self.E[0,:] + thy*self.E[1,:] + thz*self.E[2,:])
|
|
289
|
-
elif polarization == "Ephi":
|
|
290
|
-
phx = -np.sin(self.phi)
|
|
291
|
-
phy = np.cos(self.phi)
|
|
292
|
-
phz = np.zeros_like(self.theta)
|
|
293
|
-
F = np.abs(phx*self.E[0,:] + phy*self.E[1,:] + phz*self.E[2,:])
|
|
294
|
-
else:
|
|
295
|
-
logger.warning('Defaulting to normE')
|
|
296
|
-
F = np.sqrt(np.abs(self.E[0,:])**2 + np.abs(self.E[1,:])**2 + np.abs(self.E[2,:])**2)
|
|
339
|
+
fmap = {
|
|
340
|
+
'abs': np.abs,
|
|
341
|
+
'real': np.real,
|
|
342
|
+
'imag': np.imag,
|
|
343
|
+
'angle': np.angle,
|
|
344
|
+
}
|
|
345
|
+
mapping = fmap.get(quantity.lower(),np.abs)
|
|
346
|
+
|
|
347
|
+
F = mapping(self.__dict__.get(polarization, self.normE))
|
|
348
|
+
|
|
297
349
|
if isotropic:
|
|
298
350
|
F = F/np.sqrt(Z0/(2*np.pi))
|
|
299
351
|
if dB:
|
|
@@ -764,7 +816,7 @@ class MWField:
|
|
|
764
816
|
ang_range: tuple[float, float] = (-180, 180),
|
|
765
817
|
Npoints: int = 201,
|
|
766
818
|
origin: tuple[float, float, float] | None = None,
|
|
767
|
-
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
819
|
+
syms: list[Literal['Ex','Ey','Ez', 'Hx','Hy','Hz']] | None = None) -> FarfieldData:#tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
768
820
|
"""Compute the farfield electric and magnetic field defined by a circle.
|
|
769
821
|
|
|
770
822
|
Args:
|
|
@@ -784,7 +836,7 @@ class MWField:
|
|
|
784
836
|
theta, phi = arc_on_plane(refdir, plane_normal_parsed, ang_range, Npoints)
|
|
785
837
|
E,H = self.farfield(theta, phi, faces, origin, syms = syms)
|
|
786
838
|
angs = np.linspace(*ang_range, Npoints)*np.pi/180
|
|
787
|
-
return
|
|
839
|
+
return FarfieldData(E, H, theta, phi, ang=angs)
|
|
788
840
|
|
|
789
841
|
def farfield_3d(self,
|
|
790
842
|
faces: FaceSelection | GeoSurface,
|
|
@@ -15,13 +15,11 @@
|
|
|
15
15
|
# along with this program; if not, see
|
|
16
16
|
# <https://www.gnu.org/licenses/>.
|
|
17
17
|
|
|
18
|
-
from numba_progress import ProgressBar
|
|
19
18
|
from ...mesh3d import SurfaceMesh
|
|
20
19
|
import numpy as np
|
|
21
20
|
from loguru import logger
|
|
22
21
|
from numba import c16, njit, prange, f8
|
|
23
22
|
from numba.types import Tuple as TupleType # ty: ignore
|
|
24
|
-
from numba_progress.progress import ProgressBarType
|
|
25
23
|
from ...const import Z0
|
|
26
24
|
|
|
27
25
|
LR = 0.001
|
|
@@ -34,14 +32,13 @@ LR = 0.001
|
|
|
34
32
|
f8[:, :],
|
|
35
33
|
f8[:, :],
|
|
36
34
|
f8,
|
|
37
|
-
ProgressBarType,
|
|
38
35
|
),
|
|
39
36
|
parallel=True,
|
|
40
37
|
fastmath=True,
|
|
41
38
|
cache=True,
|
|
42
39
|
nogil=True,
|
|
43
40
|
)
|
|
44
|
-
def stratton_chu_ff(Ein, Hin, vis, wns, tpout, k0
|
|
41
|
+
def stratton_chu_ff(Ein, Hin, vis, wns, tpout, k0):
|
|
45
42
|
|
|
46
43
|
Ex = Ein[0, :].flatten()
|
|
47
44
|
Ey = Ein[1, :].flatten()
|
|
@@ -125,7 +122,6 @@ def stratton_chu_ff(Ein, Hin, vis, wns, tpout, k0, pgb):
|
|
|
125
122
|
Eoutz += Q * (rx * ie1y - ry * ie1x)
|
|
126
123
|
|
|
127
124
|
# ii += iadd
|
|
128
|
-
pgb.update(1)
|
|
129
125
|
Eout[0, :] = Eoutx
|
|
130
126
|
Eout[1, :] = Eouty
|
|
131
127
|
Eout[2, :] = Eoutz
|
|
@@ -162,14 +158,13 @@ def stratton_chu(Ein, Hin, mesh: SurfaceMesh, theta: np.ndarray, phi: np.ndarray
|
|
|
162
158
|
Eout = None
|
|
163
159
|
Hout = None
|
|
164
160
|
tpout = np.array([theta, phi])
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
161
|
+
|
|
162
|
+
Eout, Hout = stratton_chu_ff(
|
|
163
|
+
Ein.astype(np.complex128),
|
|
164
|
+
Hin.astype(np.complex128),
|
|
165
|
+
vis.astype(np.float64),
|
|
166
|
+
wns.astype(np.float64),
|
|
167
|
+
tpout.astype(np.float64),
|
|
168
|
+
np.float64(k0),
|
|
169
|
+
)
|
|
175
170
|
return Eout.astype(np.complex128), Hout.astype(np.complex128)
|
emerge/_emerge/simmodel.py
CHANGED
|
@@ -62,7 +62,7 @@ class Simulation:
|
|
|
62
62
|
|
|
63
63
|
def __init__(self,
|
|
64
64
|
modelname: str,
|
|
65
|
-
loglevel: Literal['DEBUG','INFO','WARNING','ERROR'] = 'INFO',
|
|
65
|
+
loglevel: Literal['TRACE','DEBUG','INFO','WARNING','ERROR'] = 'INFO',
|
|
66
66
|
load_file: bool = False,
|
|
67
67
|
save_file: bool = False,
|
|
68
68
|
logfile: bool = False,
|