emerge 0.5.1__py3-none-any.whl → 0.5.3__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/_emerge/bc.py +14 -20
- emerge/_emerge/const.py +5 -0
- emerge/_emerge/cs.py +2 -2
- emerge/_emerge/elements/femdata.py +14 -14
- emerge/_emerge/elements/index_interp.py +1 -1
- emerge/_emerge/elements/ned2_interp.py +1 -1
- emerge/_emerge/elements/nedelec2.py +4 -4
- emerge/_emerge/elements/nedleg2.py +10 -10
- emerge/_emerge/geo/horn.py +1 -1
- emerge/_emerge/geo/modeler.py +18 -19
- emerge/_emerge/geo/operations.py +13 -10
- emerge/_emerge/geo/pcb.py +180 -82
- emerge/_emerge/geo/pcb_tools/calculator.py +2 -2
- emerge/_emerge/geo/pcb_tools/macro.py +14 -13
- emerge/_emerge/geo/pmlbox.py +1 -1
- emerge/_emerge/geometry.py +47 -33
- emerge/_emerge/logsettings.py +15 -16
- emerge/_emerge/material.py +15 -11
- emerge/_emerge/mesh3d.py +81 -59
- emerge/_emerge/mesher.py +26 -21
- emerge/_emerge/mth/integrals.py +1 -1
- emerge/_emerge/mth/pairing.py +2 -2
- emerge/_emerge/periodic.py +34 -31
- emerge/_emerge/physics/microwave/adaptive_freq.py +15 -16
- emerge/_emerge/physics/microwave/assembly/assembler.py +120 -93
- emerge/_emerge/physics/microwave/assembly/curlcurl.py +1 -8
- emerge/_emerge/physics/microwave/assembly/generalized_eigen.py +43 -8
- emerge/_emerge/physics/microwave/assembly/robinbc.py +5 -5
- emerge/_emerge/physics/microwave/microwave_3d.py +71 -44
- emerge/_emerge/physics/microwave/microwave_bc.py +206 -117
- emerge/_emerge/physics/microwave/microwave_data.py +36 -38
- emerge/_emerge/physics/microwave/sc.py +26 -26
- emerge/_emerge/physics/microwave/simjob.py +20 -15
- emerge/_emerge/physics/microwave/sparam.py +12 -12
- emerge/_emerge/physics/microwave/touchstone.py +1 -1
- emerge/_emerge/plot/display.py +12 -6
- emerge/_emerge/plot/pyvista/display.py +44 -39
- emerge/_emerge/plot/pyvista/display_settings.py +1 -1
- emerge/_emerge/plot/simple_plots.py +15 -15
- emerge/_emerge/selection.py +35 -39
- emerge/_emerge/simmodel.py +41 -47
- emerge/_emerge/simulation_data.py +24 -15
- emerge/_emerge/solve_interfaces/cudss_interface.py +238 -0
- emerge/_emerge/solve_interfaces/pardiso_interface.py +24 -18
- emerge/_emerge/solver.py +314 -136
- emerge/cli.py +1 -1
- emerge/lib.py +245 -248
- {emerge-0.5.1.dist-info → emerge-0.5.3.dist-info}/METADATA +5 -1
- emerge-0.5.3.dist-info/RECORD +83 -0
- emerge/_emerge/plot/grapher.py +0 -93
- emerge-0.5.1.dist-info/RECORD +0 -82
- {emerge-0.5.1.dist-info → emerge-0.5.3.dist-info}/WHEEL +0 -0
- {emerge-0.5.1.dist-info → emerge-0.5.3.dist-info}/entry_points.txt +0 -0
- {emerge-0.5.1.dist-info → emerge-0.5.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -24,7 +24,7 @@ import site
|
|
|
24
24
|
from ctypes.util import find_library
|
|
25
25
|
from enum import Enum
|
|
26
26
|
import numpy as np
|
|
27
|
-
from scipy import sparse
|
|
27
|
+
from scipy import sparse # type: ignore
|
|
28
28
|
from pathlib import Path
|
|
29
29
|
from typing import Iterable, Iterator
|
|
30
30
|
import pickle
|
|
@@ -60,7 +60,8 @@ PARDISO_ERROR_CODES = {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
#: Environment variable that overrides automatic searching
|
|
63
|
-
|
|
63
|
+
|
|
64
|
+
ENV_VAR = "EMERGE_PARDISO_PATH"
|
|
64
65
|
|
|
65
66
|
|
|
66
67
|
def _candidate_dirs() -> Iterable[Path]:
|
|
@@ -71,7 +72,7 @@ def _candidate_dirs() -> Iterable[Path]:
|
|
|
71
72
|
for p in ( # likely “local” env first
|
|
72
73
|
Path(sys.prefix),
|
|
73
74
|
Path(getattr(sys, "base_prefix", sys.prefix)),
|
|
74
|
-
Path(site.USER_BASE),
|
|
75
|
+
Path(str(site.USER_BASE)),
|
|
75
76
|
*(Path(x) for x in os.getenv("LD_LIBRARY_PATH", "").split(":") if x),
|
|
76
77
|
):
|
|
77
78
|
if p not in seen:
|
|
@@ -93,7 +94,7 @@ def _search_mkl() -> Iterator[Path]:
|
|
|
93
94
|
if regex.match(path.name):
|
|
94
95
|
yield path
|
|
95
96
|
|
|
96
|
-
def cache_path_result(tag: str, compute_fn, force: bool = False):
|
|
97
|
+
def cache_path_result(tag: str, compute_fn, force: bool = False) -> str:
|
|
97
98
|
"""
|
|
98
99
|
Retrieve a cached Path object or compute it and store it.
|
|
99
100
|
|
|
@@ -113,13 +114,13 @@ def cache_path_result(tag: str, compute_fn, force: bool = False):
|
|
|
113
114
|
if not force and cache_file.exists():
|
|
114
115
|
with open(cache_file, "rb") as f:
|
|
115
116
|
filename = pickle.load(f)
|
|
116
|
-
|
|
117
|
-
return filename
|
|
117
|
+
logger.debug(f"Using cached MKL file: {filename}")
|
|
118
|
+
return str(filename)
|
|
118
119
|
|
|
119
120
|
result = compute_fn()
|
|
120
121
|
with open(cache_file, "wb") as f:
|
|
121
122
|
pickle.dump(result, f)
|
|
122
|
-
return result
|
|
123
|
+
return str(result)
|
|
123
124
|
|
|
124
125
|
def search_mkl() -> str:
|
|
125
126
|
"""Searches for the file path of the PARDISO MKL executable
|
|
@@ -130,11 +131,11 @@ def search_mkl() -> str:
|
|
|
130
131
|
logger.debug('Searching for MKL executable...')
|
|
131
132
|
for candidate in _search_mkl():
|
|
132
133
|
try:
|
|
133
|
-
ctypes.CDLL(candidate)
|
|
134
|
+
ctypes.CDLL(str(candidate))
|
|
134
135
|
except OSError:
|
|
135
136
|
continue # try the next one
|
|
136
137
|
logger.debug(f'Executable found: {candidate}')
|
|
137
|
-
return candidate
|
|
138
|
+
return str(candidate)
|
|
138
139
|
|
|
139
140
|
def load_mkl() -> ctypes.CDLL:
|
|
140
141
|
"""Locate and load **mkl_rt**; raise ImportError on failure."""
|
|
@@ -200,6 +201,9 @@ CFLOAT32_P = ctypes.POINTER(CFLOAT32)
|
|
|
200
201
|
CFLOAT64_P = ctypes.POINTER(CFLOAT64)
|
|
201
202
|
VOID_SIZE = ctypes.sizeof(ctypes.c_void_p)
|
|
202
203
|
|
|
204
|
+
PT_A: type = CINT32
|
|
205
|
+
PT_B: type = np.int32
|
|
206
|
+
|
|
203
207
|
if VOID_SIZE == 8:
|
|
204
208
|
PT_A = CINT64
|
|
205
209
|
PT_B = np.int64
|
|
@@ -210,7 +214,7 @@ elif VOID_SIZE == 4:
|
|
|
210
214
|
def c_int(value: int):
|
|
211
215
|
return ctypes.byref(ctypes.c_int32(value))
|
|
212
216
|
|
|
213
|
-
PARDISO_ARG_TYPES = (ctypes.POINTER(PT_A),CINT32_P,CINT32_P,
|
|
217
|
+
PARDISO_ARG_TYPES: tuple = (ctypes.POINTER(PT_A),CINT32_P,CINT32_P,
|
|
214
218
|
CINT32_P,CINT32_P,CINT32_P,CNONE_P,CINT32_P,CINT32_P,
|
|
215
219
|
CINT32_P,CINT32_P,CINT32_P,CINT32_P,CNONE_P,CNONE_P,CINT32_P,
|
|
216
220
|
)
|
|
@@ -314,7 +318,7 @@ class PardisoInterface:
|
|
|
314
318
|
self.MATRIX_TYPE = PARDISOMType.REAL_SYM_STRUCT
|
|
315
319
|
self.complex = False
|
|
316
320
|
|
|
317
|
-
def _prepare_B(self, b: np.ndarray) -> np.ndarray:
|
|
321
|
+
def _prepare_B(self, b: np.ndarray | sparse.sparray) -> np.ndarray:
|
|
318
322
|
"""Fixes the forcing-vector for the solution process
|
|
319
323
|
|
|
320
324
|
Args:
|
|
@@ -324,7 +328,8 @@ class PardisoInterface:
|
|
|
324
328
|
np.ndarray: The prepared forcing-vector
|
|
325
329
|
"""
|
|
326
330
|
if sparse.issparse(b):
|
|
327
|
-
b = b.todense()
|
|
331
|
+
b = b.todense() # type: ignore
|
|
332
|
+
|
|
328
333
|
if np.iscomplexobj(b):
|
|
329
334
|
b = b.astype(np.complex128)
|
|
330
335
|
else:
|
|
@@ -337,7 +342,7 @@ class PardisoInterface:
|
|
|
337
342
|
Returns:
|
|
338
343
|
int: The error code
|
|
339
344
|
"""
|
|
340
|
-
|
|
345
|
+
|
|
341
346
|
self._configure(A)
|
|
342
347
|
zerovec = np.zeros_like((A.shape[0], 1), dtype=A.dtype)
|
|
343
348
|
_, error = self._call_solver(A, zerovec, phase=PARDISOPhase.SYMBOLIC_FACTOR)
|
|
@@ -349,7 +354,7 @@ class PardisoInterface:
|
|
|
349
354
|
Returns:
|
|
350
355
|
int: The error code
|
|
351
356
|
"""
|
|
352
|
-
|
|
357
|
+
|
|
353
358
|
self._configure(A)
|
|
354
359
|
zerovec = np.zeros_like((A.shape[0], 1), dtype=A.dtype)
|
|
355
360
|
_, error = self._call_solver(A, zerovec, phase=PARDISOPhase.NUMERIC_FACTOR)
|
|
@@ -372,7 +377,7 @@ class PardisoInterface:
|
|
|
372
377
|
|
|
373
378
|
def configure_solver(self,
|
|
374
379
|
perm_algo: int = 3,
|
|
375
|
-
nthreads: int = None,
|
|
380
|
+
nthreads: int | None = None,
|
|
376
381
|
user_perm: int = 0,
|
|
377
382
|
n_refine_steps: int = 0,
|
|
378
383
|
pivot_pert: int = 13,
|
|
@@ -388,7 +393,7 @@ class PardisoInterface:
|
|
|
388
393
|
weighted_matching (int, optional): weighted matching mode. Defaults to 2.
|
|
389
394
|
"""
|
|
390
395
|
if nthreads is None:
|
|
391
|
-
nthreads = int(os.environ.get('OMP_NUM_THREADS'))
|
|
396
|
+
nthreads = int(os.environ.get('OMP_NUM_THREADS', default="4"))
|
|
392
397
|
|
|
393
398
|
self.IPARM[1] = perm_algo
|
|
394
399
|
self.IPARM[2] = nthreads
|
|
@@ -418,14 +423,15 @@ class PardisoInterface:
|
|
|
418
423
|
A_indices = A.indices + 1
|
|
419
424
|
|
|
420
425
|
# Define the appropriate data type (complex vs real)
|
|
426
|
+
|
|
421
427
|
if self.complex:
|
|
422
428
|
VALUE_P = A.data.ctypes.data_as(CPX16_P)
|
|
423
429
|
RHS_P = b.ctypes.data_as(CPX16_P)
|
|
424
430
|
X_P = x.ctypes.data_as(CPX16_P)
|
|
425
431
|
else:
|
|
426
432
|
VALUE_P = A.data.ctypes.data_as(CFLOAT64_P)
|
|
427
|
-
RHS_P = b.ctypes.data_as(CFLOAT64_P)
|
|
428
|
-
X_P = x.ctypes.data_as(CFLOAT64_P)
|
|
433
|
+
RHS_P = b.ctypes.data_as(CFLOAT64_P) # type: ignore
|
|
434
|
+
X_P = x.ctypes.data_as(CFLOAT64_P) # type: ignore
|
|
429
435
|
|
|
430
436
|
# Calls the pardiso function
|
|
431
437
|
self._pardiso_interface(
|