devsim 2.10.0__cp39-abi3-win_amd64.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.
- devsim/__init__.py +17 -0
- devsim/devsim_py3.pyd +0 -0
- devsim/python_packages/Klaassen.py +336 -0
- devsim/python_packages/__init__.py +0 -0
- devsim/python_packages/fermi_physics.py +31 -0
- devsim/python_packages/model_create.py +262 -0
- devsim/python_packages/mos_physics.py +170 -0
- devsim/python_packages/pythonmesh.py +131 -0
- devsim/python_packages/ramp.py +101 -0
- devsim/python_packages/simple_dd.py +75 -0
- devsim/python_packages/simple_physics.py +463 -0
- devsim/umfpack/umfpack_lgpl.dll +0 -0
- devsim/umfpack/umfpack_loader.py +517 -0
- devsim/umfpack/umfshim.py +116 -0
- devsim-2.10.0.data/data/devsim_data/BUILD.md +94 -0
- devsim-2.10.0.data/data/devsim_data/CHANGES.md +773 -0
- devsim-2.10.0.data/data/devsim_data/CITATION.md +23 -0
- devsim-2.10.0.data/data/devsim_data/CODE_OF_CONDUCT.md +74 -0
- devsim-2.10.0.data/data/devsim_data/CONTRIBUTING.md +43 -0
- devsim-2.10.0.data/data/devsim_data/HOWTO.md +27 -0
- devsim-2.10.0.data/data/devsim_data/INSTALL.md +65 -0
- devsim-2.10.0.data/data/devsim_data/README.md +97 -0
- devsim-2.10.0.data/data/devsim_data/TEST.md +13 -0
- devsim-2.10.0.data/data/devsim_data/doc/devsim.pdf +0 -0
- devsim-2.10.0.data/data/devsim_data/doc/symdiff.pdf +0 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/Ve0.jpg +0 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/Ve0_3d.jpg +0 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/Ve7.jpg +0 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/Ve7_3d.jpg +0 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/bioapp1_2d.py +85 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/bioapp1_3d.py +85 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/bioapp1_common.py +399 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/disk_2d.geo +62 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/disk_2d.msh +65606 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/disk_3d.geo +183 -0
- devsim-2.10.0.data/data/devsim_data/examples/bioapp1/disk_3d.msh +25808 -0
- devsim-2.10.0.data/data/devsim_data/examples/capacitance/cap.lay +1587 -0
- devsim-2.10.0.data/data/devsim_data/examples/capacitance/cap1d.py +155 -0
- devsim-2.10.0.data/data/devsim_data/examples/capacitance/cap2d.py +200 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/3dblock.geo +48 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_1d.py +94 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_1d_custom.py +159 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_2d.py +68 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_common.py +253 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_current.lay +3271 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_density.lay +3271 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/diode_potential.lay +3272 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/gmsh_diode2d.msh +1477 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/gmsh_diode2d.py +55 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/gmsh_diode3d.msh +8557 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/gmsh_diode3d.py +74 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/gmsh_diode3d_equil.py +43 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/gmsh_diode3d_float128.py +85 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/laux2d.py +43 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/laux3d.py +54 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/laux_common.py +503 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/pythonmesh3d.py +61 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/ssac_diode.py +57 -0
- devsim-2.10.0.data/data/devsim_data/examples/diode/tran_diode.py +63 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/gmsh_mos2d.geo +160 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/gmsh_mos2d.msh +8599 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/gmsh_mos2d.py +96 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/gmsh_mos2d_create.py +174 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/gmsh_mos2d_kla.py +162 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/logElectrons.lay +1327 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/pythonmesh2d.py +100 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/test.lay +3385 -0
- devsim-2.10.0.data/data/devsim_data/examples/mobility/times.txt +34 -0
- devsim-2.10.0.data/data/devsim_data/examples/plotting/visualization.ipynb +160 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/arrhenius.py +24 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/deftest.py +48 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/modellist1.py +9 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/models1.py +41 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/ordered.py +9 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/parsetest.py +107 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/remove1.py +8 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/subexpression1.py +10 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/table.py +7 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/undefined1.py +10 -0
- devsim-2.10.0.data/data/devsim_data/examples/symdiff/utf8.py +10 -0
- devsim-2.10.0.data/data/devsim_data/examples/vectorpotential/twowire.geo +34 -0
- devsim-2.10.0.data/data/devsim_data/examples/vectorpotential/twowire.lay +1469 -0
- devsim-2.10.0.data/data/devsim_data/examples/vectorpotential/twowire.msh +13596 -0
- devsim-2.10.0.data/data/devsim_data/examples/vectorpotential/twowire.py +177 -0
- devsim-2.10.0.data/data/devsim_data/setup.cfg +23 -0
- devsim-2.10.0.data/data/devsim_data/setup.py +58 -0
- devsim-2.10.0.data/data/devsim_data/testing/3dtetmesh.msh +281 -0
- devsim-2.10.0.data/data/devsim_data/testing/CMakeLists.txt +175 -0
- devsim-2.10.0.data/data/devsim_data/testing/Fermi1.py +59 -0
- devsim-2.10.0.data/data/devsim_data/testing/Fermi1_float128.py +18 -0
- devsim-2.10.0.data/data/devsim_data/testing/GaussFermi.py +38 -0
- devsim-2.10.0.data/data/devsim_data/testing/GaussFermi_float128.py +18 -0
- devsim-2.10.0.data/data/devsim_data/testing/cap2.py +439 -0
- devsim-2.10.0.data/data/devsim_data/testing/cap_mesh.py +33 -0
- devsim-2.10.0.data/data/devsim_data/testing/circ1.py +79 -0
- devsim-2.10.0.data/data/devsim_data/testing/circ2.py +79 -0
- devsim-2.10.0.data/data/devsim_data/testing/circ3.py +18 -0
- devsim-2.10.0.data/data/devsim_data/testing/circ4.py +105 -0
- devsim-2.10.0.data/data/devsim_data/testing/dio2_element_2d.py +136 -0
- devsim-2.10.0.data/data/devsim_data/testing/dio2_element_physics.py +302 -0
- devsim-2.10.0.data/data/devsim_data/testing/equation1.py +68 -0
- devsim-2.10.0.data/data/devsim_data/testing/erf1.py +52 -0
- devsim-2.10.0.data/data/devsim_data/testing/erf2.py +34 -0
- devsim-2.10.0.data/data/devsim_data/testing/fpetest1.py +21 -0
- devsim-2.10.0.data/data/devsim_data/testing/fpetest2.py +25 -0
- devsim-2.10.0.data/data/devsim_data/testing/gmsh_mos3d.geo +272 -0
- devsim-2.10.0.data/data/devsim_data/testing/info.py +11 -0
- devsim-2.10.0.data/data/devsim_data/testing/kahan.py +24 -0
- devsim-2.10.0.data/data/devsim_data/testing/kahan_float128.py +18 -0
- devsim-2.10.0.data/data/devsim_data/testing/laux1.py +232 -0
- devsim-2.10.0.data/data/devsim_data/testing/mctest.mc +30 -0
- devsim-2.10.0.data/data/devsim_data/testing/mctest_user.mc +33 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh1.msh +52 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh1.py +121 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh2.msh +70 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh2.py +210 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh2d.py +105 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh3.py +8 -0
- devsim-2.10.0.data/data/devsim_data/testing/mesh4.py +8 -0
- devsim-2.10.0.data/data/devsim_data/testing/mos_2d.py +111 -0
- devsim-2.10.0.data/data/devsim_data/testing/mos_2d_create.py +207 -0
- devsim-2.10.0.data/data/devsim_data/testing/mos_2d_restart.py +69 -0
- devsim-2.10.0.data/data/devsim_data/testing/mos_2d_restart2.py +24 -0
- devsim-2.10.0.data/data/devsim_data/testing/noise_res.py +51 -0
- devsim-2.10.0.data/data/devsim_data/testing/noise_res_2d.py +101 -0
- devsim-2.10.0.data/data/devsim_data/testing/ptest1.py +53 -0
- devsim-2.10.0.data/data/devsim_data/testing/ptest2.py +110 -0
- devsim-2.10.0.data/data/devsim_data/testing/pythonmesh1d.py +202 -0
- devsim-2.10.0.data/data/devsim_data/testing/res1.py +65 -0
- devsim-2.10.0.data/data/devsim_data/testing/res2.py +65 -0
- devsim-2.10.0.data/data/devsim_data/testing/res3.py +59 -0
- devsim-2.10.0.data/data/devsim_data/testing/rundifftest.py +62 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_cap.py +145 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_cap_2d_edge.py +199 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_cap_2d_element.py +214 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_cap_3d_edge.py +148 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_cap_3d_element.py +167 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_circ.py +18 -0
- devsim-2.10.0.data/data/devsim_data/testing/ssac_res.py +30 -0
- devsim-2.10.0.data/data/devsim_data/testing/symdiff1.py +54 -0
- devsim-2.10.0.data/data/devsim_data/testing/test_common.py +435 -0
- devsim-2.10.0.data/data/devsim_data/testing/testfunc.py +65 -0
- devsim-2.10.0.data/data/devsim_data/testing/testfunc_extended.py +8 -0
- devsim-2.10.0.data/data/devsim_data/testing/transient_circ.py +67 -0
- devsim-2.10.0.data/data/devsim_data/testing/transient_circ2.py +67 -0
- devsim-2.10.0.data/data/devsim_data/testing/transient_circ3.py +125 -0
- devsim-2.10.0.data/data/devsim_data/testing/transient_rc.py +157 -0
- devsim-2.10.0.data/data/devsim_data/testing/trimesh1.msh +47 -0
- devsim-2.10.0.data/data/devsim_data/testing/trimesh1.py +114 -0
- devsim-2.10.0.data/data/devsim_data/testing/trimesh2.py +114 -0
- devsim-2.10.0.data/data/devsim_data/testing/utf8_2.py +126 -0
- devsim-2.10.0.dist-info/METADATA +121 -0
- devsim-2.10.0.dist-info/RECORD +157 -0
- devsim-2.10.0.dist-info/WHEEL +5 -0
- devsim-2.10.0.dist-info/licenses/LICENSE +202 -0
- devsim-2.10.0.dist-info/licenses/NOTICE +241 -0
- devsim-2.10.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
from ctypes import *
|
|
2
|
+
import platform
|
|
3
|
+
import array
|
|
4
|
+
|
|
5
|
+
def debug_print(arg):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
#/* used in all UMFPACK_report_* routines: */
|
|
9
|
+
UMFPACK_PRL = 0 # /* print level */
|
|
10
|
+
|
|
11
|
+
#/* used in UMFPACK_*symbolic only: */
|
|
12
|
+
UMFPACK_DENSE_ROW = 1 #/* dense row parameter */
|
|
13
|
+
UMFPACK_DENSE_COL = 2 #/* dense col parameter */
|
|
14
|
+
UMFPACK_BLOCK_SIZE = 4 #/* BLAS-3 block size */
|
|
15
|
+
UMFPACK_STRATEGY = 5 #/* auto, symmetric, unsym., or 2by2 */
|
|
16
|
+
UMFPACK_2BY2_TOLERANCE = 12 #/* 2-by-2 pivot tolerance */
|
|
17
|
+
UMFPACK_FIXQ = 13 #/* -1: no fixQ, 0: default, 1: fixQ */
|
|
18
|
+
UMFPACK_AMD_DENSE = 14 #/* for AMD ordering */
|
|
19
|
+
UMFPACK_AGGRESSIVE = 19 #/* whether or not to use aggressive
|
|
20
|
+
|
|
21
|
+
#/* default values of Control may change in future versions of UMFPACK. */
|
|
22
|
+
|
|
23
|
+
#/* -------------------------------------------------------------------------- */
|
|
24
|
+
#/* status codes */
|
|
25
|
+
#/* -------------------------------------------------------------------------- */
|
|
26
|
+
#
|
|
27
|
+
UMFPACK_OK = 0
|
|
28
|
+
#
|
|
29
|
+
#/* status > 0 means a warning, but the method was successful anyway. */
|
|
30
|
+
#/* A Symbolic or Numeric object was still created. */
|
|
31
|
+
##define UMFPACK_WARNING_singular_matrix (1)
|
|
32
|
+
#
|
|
33
|
+
#/* The following warnings were added in umfpack_*_get_determinant */
|
|
34
|
+
##define UMFPACK_WARNING_determinant_underflow (2)
|
|
35
|
+
##define UMFPACK_WARNING_determinant_overflow (3)
|
|
36
|
+
#
|
|
37
|
+
#/* status < 0 means an error, and the method was not successful. */
|
|
38
|
+
#/* No Symbolic of Numeric object was created. */
|
|
39
|
+
##define UMFPACK_ERROR_out_of_memory (-1)
|
|
40
|
+
##define UMFPACK_ERROR_invalid_Numeric_object (-3)
|
|
41
|
+
##define UMFPACK_ERROR_invalid_Symbolic_object (-4)
|
|
42
|
+
##define UMFPACK_ERROR_argument_missing (-5)
|
|
43
|
+
##define UMFPACK_ERROR_n_nonpositive (-6)
|
|
44
|
+
##define UMFPACK_ERROR_invalid_matrix (-8)
|
|
45
|
+
##define UMFPACK_ERROR_different_pattern (-11)
|
|
46
|
+
##define UMFPACK_ERROR_invalid_system (-13)
|
|
47
|
+
##define UMFPACK_ERROR_invalid_permutation (-15)
|
|
48
|
+
##define UMFPACK_ERROR_internal_error (-911) /* yes, call me if you get this! */
|
|
49
|
+
##define UMFPACK_ERROR_file_IO (-17)
|
|
50
|
+
|
|
51
|
+
#/* -------------------------------------------------------------------------- */
|
|
52
|
+
#/* solve codes */
|
|
53
|
+
#/* -------------------------------------------------------------------------- */
|
|
54
|
+
#
|
|
55
|
+
#/* Solve the system ( )x=b, where ( ) is defined below. "t" refers to the */
|
|
56
|
+
#/* linear algebraic transpose (complex conjugate if A is complex), or the (') */
|
|
57
|
+
#/* operator in MATLAB. "at" refers to the array transpose, or the (.') */
|
|
58
|
+
#/* operator in MATLAB. */
|
|
59
|
+
#
|
|
60
|
+
UMFPACK_A = (0) # /* Ax=b */
|
|
61
|
+
UMFPACK_At = (1) # /* A'x=b */
|
|
62
|
+
UMFPACK_Aat = (2) # /* A.'x=b */
|
|
63
|
+
#
|
|
64
|
+
UMFPACK_Pt_L = (3) # /* P'Lx=b */
|
|
65
|
+
##define UMFPACK_L (4) /* Lx=b */
|
|
66
|
+
##define UMFPACK_Lt_P (5) /* L'Px=b */
|
|
67
|
+
##define UMFPACK_Lat_P (6) /* L.'Px=b */
|
|
68
|
+
##define UMFPACK_Lt (7) /* L'x=b */
|
|
69
|
+
##define UMFPACK_Lat (8) /* L.'x=b */
|
|
70
|
+
#
|
|
71
|
+
UMFPACK_U_Qt = (9) # /* UQ'x=b */
|
|
72
|
+
##define UMFPACK_U (10) /* Ux=b */
|
|
73
|
+
##define UMFPACK_Q_Ut (11) /* QU'x=b */
|
|
74
|
+
##define UMFPACK_Q_Uat (12) /* QU.'x=b */
|
|
75
|
+
##define UMFPACK_Ut (13) /* U'x=b */
|
|
76
|
+
##define UMFPACK_Uat (14) /* U.'x=b */
|
|
77
|
+
#
|
|
78
|
+
#/* -------------------------------------------------------------------------- */
|
|
79
|
+
#
|
|
80
|
+
#/* Integer constants are used for status and solve codes instead of enum */
|
|
81
|
+
#/* to make it easier for a Fortran code to call UMFPACK. */
|
|
82
|
+
|
|
83
|
+
# /* -------------------------------------------------------------------------- */
|
|
84
|
+
# /* size of Info and Control arrays */
|
|
85
|
+
# /* -------------------------------------------------------------------------- */
|
|
86
|
+
#
|
|
87
|
+
# /* These might be larger in future versions, since there are only 3 unused
|
|
88
|
+
# * entries in Info, and no unused entries in Control. */
|
|
89
|
+
|
|
90
|
+
UMFPACK_INFO = 90
|
|
91
|
+
UMFPACK_CONTROL = 20
|
|
92
|
+
|
|
93
|
+
def get_transpose(x):
|
|
94
|
+
if x:
|
|
95
|
+
return UMFPACK_Aat
|
|
96
|
+
else:
|
|
97
|
+
return UMFPACK_A
|
|
98
|
+
|
|
99
|
+
def get_dll_naming():
|
|
100
|
+
systems = {
|
|
101
|
+
'Linux' : {"prefix" : "lib", "suffix" : ".so"},
|
|
102
|
+
'Darwin' : {"prefix" : "lib", "suffix" : ".dylib"},
|
|
103
|
+
'Windows' : {"prefix" : "", "suffix" : ".dll"},
|
|
104
|
+
}
|
|
105
|
+
return systems[platform.system()]
|
|
106
|
+
|
|
107
|
+
def get_umfpack_name():
|
|
108
|
+
return "./%(prefix)sumfpack_lgpl%(suffix)s" % get_dll_naming()
|
|
109
|
+
|
|
110
|
+
def load_umfpack_dll(dllname):
|
|
111
|
+
dll = cdll.LoadLibrary(dllname)
|
|
112
|
+
if not dll:
|
|
113
|
+
raise RuntimeError("Cannot find UMFPACK dll")
|
|
114
|
+
return dll
|
|
115
|
+
|
|
116
|
+
def get_blas_name():
|
|
117
|
+
if platform.system() == "Windows":
|
|
118
|
+
return "mkl_rt.1.dll"
|
|
119
|
+
else:
|
|
120
|
+
return "%(prefix)sopenblas%(suffix)s" % get_dll_naming()
|
|
121
|
+
|
|
122
|
+
def load_blas_dll(gdata, blaslib = None, noexcept = False):
|
|
123
|
+
#print(dll.blasw_load_dll)
|
|
124
|
+
if blaslib:
|
|
125
|
+
dllname = blaslib
|
|
126
|
+
else:
|
|
127
|
+
dllname = get_blas_name()
|
|
128
|
+
libname = c_char_p(dllname.encode('utf-8'))
|
|
129
|
+
#libname = c_char_p(b'mkl_rt.2.dll')
|
|
130
|
+
msg = c_char_p()
|
|
131
|
+
#dll.blasw_load_dll.argtypes = [c_char_p, c_void_p]
|
|
132
|
+
#dll.blasw_load_dll.restype = c_void_p
|
|
133
|
+
#h = dll.blasw_load_dll(libname, byref(msg))
|
|
134
|
+
h = cdll.LoadLibrary(dllname)
|
|
135
|
+
#if not h or msg:
|
|
136
|
+
# if msg:
|
|
137
|
+
# print(string_at(msg))
|
|
138
|
+
# if not noexcept:
|
|
139
|
+
# raise RuntimeError("NO BLAS DLL LOADED")
|
|
140
|
+
if not h or msg:
|
|
141
|
+
if not noexcept:
|
|
142
|
+
raise RuntimeError("NO BLAS DLL LOADED")
|
|
143
|
+
else:
|
|
144
|
+
gdata.blaslibs.append((dllname, h))
|
|
145
|
+
#print(h)
|
|
146
|
+
return h
|
|
147
|
+
|
|
148
|
+
def load_blas_functions(gdata, h):
|
|
149
|
+
gdata.dll.blasw_load_functions.restype = c_int
|
|
150
|
+
gdata.dll.blasw_load_functions.argtypes = [c_void_p]
|
|
151
|
+
i = gdata.dll.blasw_load_functions(h._handle)
|
|
152
|
+
return i
|
|
153
|
+
|
|
154
|
+
def myprintcb(msg):
|
|
155
|
+
pmsg = msg.decode("utf-8")
|
|
156
|
+
pmsg = pmsg.replace("\n", "\nUMF: ")
|
|
157
|
+
print(pmsg, end="")
|
|
158
|
+
|
|
159
|
+
def set_python_print_callback(gdata):
|
|
160
|
+
CALLBACK = CFUNCTYPE(None, c_char_p)
|
|
161
|
+
gdata.dll.blasw_set_printer_callback.argtypes = [CALLBACK]
|
|
162
|
+
gdata.dll.blasw_set_printer_callback.restype = None
|
|
163
|
+
dcb = CALLBACK(myprintcb)
|
|
164
|
+
gdata.dll.blasw_set_printer_callback(dcb)
|
|
165
|
+
gdata.printcb = dcb
|
|
166
|
+
return dcb
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
#TODO: handle same symbolic
|
|
170
|
+
class di_symbolic:
|
|
171
|
+
def __init__(self, uc):
|
|
172
|
+
self.Symbolic = c_void_p()
|
|
173
|
+
self.umf_control = uc
|
|
174
|
+
|
|
175
|
+
def __del__(self):
|
|
176
|
+
if self.umf_control.is_complex:
|
|
177
|
+
if self.Symbolic:
|
|
178
|
+
debug_print('umfpack_zi_free_symbolic 176')
|
|
179
|
+
self.umf_control.gdata.dll.umfpack_zi_free_symbolic (byref(self.Symbolic))
|
|
180
|
+
else:
|
|
181
|
+
if self.Symbolic:
|
|
182
|
+
debug_print('umfpack_di_free_symbolic 180')
|
|
183
|
+
self.umf_control.gdata.dll.umfpack_di_free_symbolic (byref(self.Symbolic))
|
|
184
|
+
self.umf_control = None
|
|
185
|
+
|
|
186
|
+
def factor_symbolic(self, matrix):
|
|
187
|
+
if self.umf_control.is_complex:
|
|
188
|
+
if self.Symbolic:
|
|
189
|
+
debug_print('umfpack_zi_free_symbolic 187')
|
|
190
|
+
self.umf_control.gdata.dll.umfpack_zi_free_symbolic (byref(self.Symbolic))
|
|
191
|
+
NULL = c_void_p()
|
|
192
|
+
debug_print('umfpack_zi_symbolic 190/u')
|
|
193
|
+
self.status = self.umf_control.gdata.dll.umfpack_zi_symbolic (matrix.n, matrix.n, matrix.AP, matrix.AI, matrix.AX, NULL, byref(self.Symbolic), self.umf_control.Control, self.umf_control.Info)
|
|
194
|
+
else:
|
|
195
|
+
if self.Symbolic:
|
|
196
|
+
debug_print('umfpack_di_free_symbolic 194')
|
|
197
|
+
self.umf_control.gdata.dll.umfpack_di_free_symbolic (byref(self.Symbolic))
|
|
198
|
+
debug_print('umfpack_di_symbolic 196')
|
|
199
|
+
self.status = self.umf_control.gdata.dll.umfpack_di_symbolic (matrix.n, matrix.n, matrix.AP, matrix.AI, matrix.AX, byref(self.Symbolic), self.umf_control.Control, self.umf_control.Info)
|
|
200
|
+
return self.status
|
|
201
|
+
|
|
202
|
+
class di_numeric:
|
|
203
|
+
def __init__(self, uc):
|
|
204
|
+
self.Numeric = c_void_p()
|
|
205
|
+
self.umf_control = uc
|
|
206
|
+
|
|
207
|
+
def __del__(self):
|
|
208
|
+
if self.umf_control.is_complex:
|
|
209
|
+
if self.Numeric:
|
|
210
|
+
debug_print('umfpack_zi_free_numeric 209')
|
|
211
|
+
self.umf_control.gdata.dll.umfpack_zi_free_numeric (byref(self.Numeric))
|
|
212
|
+
else:
|
|
213
|
+
if self.Numeric:
|
|
214
|
+
debug_print('umfpack_di_free_numeric 213')
|
|
215
|
+
self.umf_control.gdata.dll.umfpack_di_free_numeric (byref(self.Numeric))
|
|
216
|
+
|
|
217
|
+
def factor_numeric(self, matrix, Symbolic):
|
|
218
|
+
if self.umf_control.is_complex:
|
|
219
|
+
if self.Numeric:
|
|
220
|
+
debug_print('umfpack_zi_free_numeric 219')
|
|
221
|
+
self.umf_control.gdata.dll.umfpack_zi_free_numeric (byref(self.Numeric))
|
|
222
|
+
NULL = c_void_p()
|
|
223
|
+
debug_print('umfpack_zi_numeric 222')
|
|
224
|
+
self.status = self.umf_control.gdata.dll.umfpack_zi_numeric (matrix.AP, matrix.AI, matrix.AX, NULL, Symbolic.Symbolic, byref(self.Numeric), self.umf_control.Control, self.umf_control.Info)
|
|
225
|
+
else:
|
|
226
|
+
if self.Numeric:
|
|
227
|
+
debug_print('umfpack_di_free_numeric 226')
|
|
228
|
+
self.umf_control.gdata.dll.umfpack_di_free_numeric (byref(self.Numeric))
|
|
229
|
+
debug_print('umfpack_di_numeric 228')
|
|
230
|
+
self.status = self.umf_control.gdata.dll.umfpack_di_numeric (matrix.AP, matrix.AI, matrix.AX, Symbolic.Symbolic, byref(self.Numeric), self.umf_control.Control, self.umf_control.Info)
|
|
231
|
+
return self.status
|
|
232
|
+
|
|
233
|
+
def solve(self, matrix, x, b, transpose):
|
|
234
|
+
X = c_void_p(x.buffer_info()[0])
|
|
235
|
+
B = c_void_p(b.buffer_info()[0])
|
|
236
|
+
if self.umf_control.is_complex:
|
|
237
|
+
NULL = c_void_p()
|
|
238
|
+
self.status = self.umf_control.gdata.dll.umfpack_zi_solve (get_transpose(transpose), matrix.AP, matrix.AI, matrix.AX, NULL, X, NULL, B, NULL, self.Numeric, self.umf_control.Control, self.umf_control.Info)
|
|
239
|
+
else:
|
|
240
|
+
self.status = self.umf_control.gdata.dll.umfpack_di_solve (get_transpose(transpose), matrix.AP, matrix.AI, matrix.AX, X, B, self.Numeric, self.umf_control.Control, self.umf_control.Info)
|
|
241
|
+
return self.status
|
|
242
|
+
|
|
243
|
+
def determinant(self, x, r):
|
|
244
|
+
X = c_void_p(x.buffer_info()[0])
|
|
245
|
+
R = c_void_p(r.buffer_info()[0])
|
|
246
|
+
if self.umf_control.is_complex:
|
|
247
|
+
NULL = c_void_p()
|
|
248
|
+
self.status = self.umf_control.gdata.dll.umfpack_zi_get_determinant (X, NULL, R, NULL, self.Numeric, self.umf_control.Info)
|
|
249
|
+
else:
|
|
250
|
+
self.status = self.umf_control.gdata.dll.umfpack_di_get_determinant (X, R, self.Numeric, self.umf_control.Info)
|
|
251
|
+
return self.status
|
|
252
|
+
|
|
253
|
+
class di_triplet:
|
|
254
|
+
def __init__(self, uc, Arow, Acol, Aval):
|
|
255
|
+
self.umf_control = uc
|
|
256
|
+
self.n = max(Arow) + 1
|
|
257
|
+
self.nz = len(Arow)
|
|
258
|
+
self.Arow = Arow
|
|
259
|
+
self.Acol = Acol
|
|
260
|
+
self.Aval = Aval
|
|
261
|
+
self.Ar = c_void_p(Arow.buffer_info()[0])
|
|
262
|
+
self.Ac = c_void_p(Acol.buffer_info()[0])
|
|
263
|
+
self.Av = c_void_p(Aval.buffer_info()[0])
|
|
264
|
+
|
|
265
|
+
def __del__(self):
|
|
266
|
+
pass
|
|
267
|
+
|
|
268
|
+
class matrix:
|
|
269
|
+
def __init__(self, uc, Ap, Ai, Ax):
|
|
270
|
+
self.umf_control = uc
|
|
271
|
+
self.n = len(Ap)-1
|
|
272
|
+
self.Ap = Ap
|
|
273
|
+
self.Ai = Ai
|
|
274
|
+
self.Ax = Ax
|
|
275
|
+
self.AP = c_void_p(Ap.buffer_info()[0])
|
|
276
|
+
self.AI = c_void_p(Ai.buffer_info()[0])
|
|
277
|
+
self.AX = c_void_p(Ax.buffer_info()[0])
|
|
278
|
+
|
|
279
|
+
def __del__(self):
|
|
280
|
+
pass
|
|
281
|
+
|
|
282
|
+
class global_data:
|
|
283
|
+
def __init__(self):
|
|
284
|
+
self.printcb = None
|
|
285
|
+
self.blaslibs = []
|
|
286
|
+
self.dll = None
|
|
287
|
+
|
|
288
|
+
def __del__(self):
|
|
289
|
+
self.printcb = None
|
|
290
|
+
self.blaslibs = None
|
|
291
|
+
self.dll = None
|
|
292
|
+
|
|
293
|
+
class umf_control:
|
|
294
|
+
def __init__(self, gdata, matrix_type):
|
|
295
|
+
self.timer = None
|
|
296
|
+
self.gdata = gdata
|
|
297
|
+
self.Control = None
|
|
298
|
+
self.Info = None
|
|
299
|
+
# expected attributes
|
|
300
|
+
self.matrix_format = "csc"
|
|
301
|
+
self.matrix_type = "real"
|
|
302
|
+
if matrix_type == "real":
|
|
303
|
+
self.is_complex = False
|
|
304
|
+
elif matrix_type == "complex":
|
|
305
|
+
self.is_complex = True
|
|
306
|
+
else:
|
|
307
|
+
raise RuntimeError("Unknown matrix_type real/complex")
|
|
308
|
+
self.set_defaults()
|
|
309
|
+
|
|
310
|
+
def __del__(self):
|
|
311
|
+
# having a destructor is preventing segmentation fault
|
|
312
|
+
self.gdata = None
|
|
313
|
+
self.Info = None
|
|
314
|
+
self.Control = None
|
|
315
|
+
|
|
316
|
+
def tic(self):
|
|
317
|
+
self.timer = (c_double * 2)()
|
|
318
|
+
self.gdata.dll.umfpack_tic(byref(self.timer))
|
|
319
|
+
|
|
320
|
+
def toc(self):
|
|
321
|
+
self.gdata.dll.umfpack_toc (self.timer)
|
|
322
|
+
print ("\numfpack complete.\nTotal time: %5.2f seconds (CPU time), %5.2f seconds (wallclock time)\n" % ( self.timer [1], self.timer [0]))
|
|
323
|
+
|
|
324
|
+
def set_defaults(self):
|
|
325
|
+
self.Control = (c_double * UMFPACK_CONTROL)()
|
|
326
|
+
if self.is_complex:
|
|
327
|
+
self.gdata.dll.umfpack_zi_defaults(self.Control)
|
|
328
|
+
else:
|
|
329
|
+
self.gdata.dll.umfpack_di_defaults(self.Control)
|
|
330
|
+
self.Info = (c_double * UMFPACK_INFO)()
|
|
331
|
+
|
|
332
|
+
def init_verbose(self):
|
|
333
|
+
# /* change the default print level for this demo */
|
|
334
|
+
# /* (otherwise, nothing will print) */
|
|
335
|
+
self.Control [UMFPACK_PRL] = 6
|
|
336
|
+
# /* print the license agreement */
|
|
337
|
+
if self.is_complex:
|
|
338
|
+
self.gdata.dll.umfpack_zi_report_status (self.Control, UMFPACK_OK)
|
|
339
|
+
else:
|
|
340
|
+
self.gdata.dll.umfpack_di_report_status (self.Control, UMFPACK_OK)
|
|
341
|
+
self.Control [UMFPACK_PRL] = 5
|
|
342
|
+
#
|
|
343
|
+
# /* print the control parameters */
|
|
344
|
+
if self.is_complex:
|
|
345
|
+
self.gdata.dll.umfpack_zi_report_control(self.Control)
|
|
346
|
+
else:
|
|
347
|
+
self.gdata.dll.umfpack_di_report_control(self.Control)
|
|
348
|
+
|
|
349
|
+
def print_vector(self, b, label):
|
|
350
|
+
# /* print the right-hand-side */
|
|
351
|
+
print ("\n%s: " % (label,), flush=True, end="")
|
|
352
|
+
if self.is_complex:
|
|
353
|
+
NULL = (c_void_p)()
|
|
354
|
+
self.gdata.dll.umfpack_zi_report_vector.argtypes = [c_int, c_void_p, c_void_p, c_void_p]
|
|
355
|
+
self.gdata.dll.umfpack_zi_report_vector.restype = None
|
|
356
|
+
self.gdata.dll.umfpack_zi_report_vector (len(b)//2, b.buffer_info()[0], NULL, self.Control)
|
|
357
|
+
else:
|
|
358
|
+
self.gdata.dll.umfpack_di_report_vector.argtypes = [c_int, c_void_p, c_void_p]
|
|
359
|
+
self.gdata.dll.umfpack_di_report_vector.restype = None
|
|
360
|
+
self.gdata.dll.umfpack_di_report_vector (len(b), b.buffer_info()[0], self.Control)
|
|
361
|
+
|
|
362
|
+
def print_triplet(self, tm):
|
|
363
|
+
print ("\nA: ")
|
|
364
|
+
if self.is_complex:
|
|
365
|
+
NULL = (c_void_p)()
|
|
366
|
+
self.gdata.dll.umfpack_zi_report_triplet(tm.n, tm.n, tm.nz, tm.Ar, tm.Ac, tm.Av, NULL, self.Control)
|
|
367
|
+
else:
|
|
368
|
+
self.gdata.dll.umfpack_di_report_triplet(tm.n, tm.n, tm.nz, tm.Ar, tm.Ac, tm.Av, self.Control)
|
|
369
|
+
|
|
370
|
+
def triplet_to_col(self, tm):
|
|
371
|
+
n = tm.n
|
|
372
|
+
nz = tm.nz
|
|
373
|
+
NULL = (c_void_p)()
|
|
374
|
+
nz1 = max(nz,1) #; /* ensure arrays are not of size zero. */
|
|
375
|
+
Ap = array.array('i', [0] * (n+1))
|
|
376
|
+
Ai = array.array('i', [0] * (nz1))
|
|
377
|
+
if self.is_complex:
|
|
378
|
+
Ax = array.array('d', [0] * (2*nz1))
|
|
379
|
+
matrix = di_matrix(self, Ap, Ai, Ax)
|
|
380
|
+
self.status = self.gdata.dll.umfpack_zi_triplet_to_col (n, n, nz, tm.Ar, tm.Ac, tm.Av, NULL, matrix.AP, matrix.AI, matrix.AX, NULL, NULL)
|
|
381
|
+
else:
|
|
382
|
+
Ax = array.array('d', [0] * (nz1))
|
|
383
|
+
matrix = di_matrix(self, Ap, Ai, Ax)
|
|
384
|
+
self.status = self.gdata.dll.umfpack_di_triplet_to_col (n, n, nz, tm.Ar, tm.Ac, tm.Av, matrix.AP, matrix.AI, matrix.AX, NULL)
|
|
385
|
+
|
|
386
|
+
if self.status < 0:
|
|
387
|
+
self.gdata.dll.umfpack_di_report_status (self.Control, self.status)
|
|
388
|
+
raise RuntimeError("umfpack triplet_to_col failed")
|
|
389
|
+
|
|
390
|
+
return matrix
|
|
391
|
+
|
|
392
|
+
def print_matrix(self, matrix):
|
|
393
|
+
print("\nA: ")
|
|
394
|
+
if self.is_complex:
|
|
395
|
+
NULL = (c_void_p)()
|
|
396
|
+
self.gdata.dll.umfpack_zi_report_matrix (matrix.n, matrix.n, matrix.AP, matrix.AI, matrix.AX, NULL, 1, self.Control)
|
|
397
|
+
else:
|
|
398
|
+
self.gdata.dll.umfpack_di_report_matrix (matrix.n, matrix.n, matrix.AP, matrix.AI, matrix.AX, 1, self.Control)
|
|
399
|
+
|
|
400
|
+
def print_info(self):
|
|
401
|
+
if self.is_complex:
|
|
402
|
+
self.gdata.dll.umfpack_zi_report_info (self.Control, self.Info)
|
|
403
|
+
else:
|
|
404
|
+
self.gdata.dll.umfpack_di_report_info (self.Control, self.Info)
|
|
405
|
+
|
|
406
|
+
def print_status(self):
|
|
407
|
+
if self.is_complex:
|
|
408
|
+
self.gdata.dll.umfpack_zi_report_status (self.Control, self.status)
|
|
409
|
+
else:
|
|
410
|
+
self.gdata.dll.umfpack_di_report_status (self.Control, self.status)
|
|
411
|
+
|
|
412
|
+
def error_on_result(self, msg):
|
|
413
|
+
if self.status != 0:
|
|
414
|
+
self.print_info()
|
|
415
|
+
self.print_status()
|
|
416
|
+
raise RuntimeError("%s failed" % (msg,))
|
|
417
|
+
|
|
418
|
+
def symbolic(self, matrix):
|
|
419
|
+
Symbolic = di_symbolic(self)
|
|
420
|
+
self.status = Symbolic.factor_symbolic(matrix)
|
|
421
|
+
self.error_on_result("umfpack symbolic")
|
|
422
|
+
return Symbolic
|
|
423
|
+
|
|
424
|
+
def print_symbolic(self, Symbolic):
|
|
425
|
+
print("\nSymbolic factorization of A: ")
|
|
426
|
+
if self.is_complex:
|
|
427
|
+
self.gdata.dll.umfpack_zi_report_symbolic(Symbolic.Symbolic, self.Control)
|
|
428
|
+
else:
|
|
429
|
+
self.gdata.dll.umfpack_di_report_symbolic(Symbolic.Symbolic, self.Control)
|
|
430
|
+
|
|
431
|
+
def numeric(self, matrix, Symbolic):
|
|
432
|
+
Numeric = di_numeric(self)
|
|
433
|
+
self.status = Numeric.factor_numeric(matrix, Symbolic)
|
|
434
|
+
self.error_on_result("umfpack numeric")
|
|
435
|
+
return Numeric
|
|
436
|
+
|
|
437
|
+
def print_numeric(self, Numeric):
|
|
438
|
+
print ("\nNumeric factorization of A: ")
|
|
439
|
+
if self.is_complex:
|
|
440
|
+
self.gdata.dll.umfpack_zi_report_numeric (Numeric.Numeric, self.Control)
|
|
441
|
+
else:
|
|
442
|
+
self.gdata.dll.umfpack_di_report_numeric (Numeric.Numeric, self.Control)
|
|
443
|
+
|
|
444
|
+
def solve(self, matrix, x, b, Numeric, transpose):
|
|
445
|
+
if self.is_complex:
|
|
446
|
+
self.status = Numeric.solve(matrix, x, b, transpose)
|
|
447
|
+
else:
|
|
448
|
+
self.status = Numeric.solve(matrix, x, b, transpose)
|
|
449
|
+
self.error_on_result("umfpack solve")
|
|
450
|
+
|
|
451
|
+
def determinant(self, x, r, Numeric):
|
|
452
|
+
self.status = Numeric.determinant(x, r)
|
|
453
|
+
self.error_on_result("umfpack get_determinant")
|
|
454
|
+
return self.status
|
|
455
|
+
|
|
456
|
+
def print_determinant(self, x, r):
|
|
457
|
+
print("determinant: (%g" % x [0], end="")
|
|
458
|
+
print(") * 10^(%g)\n"% r [0])
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
#/* -------------------------------------------------------------------------- */
|
|
462
|
+
#/* resid: compute the residual, r = Ax-b or r = A'x=b and return maxnorm (r) */
|
|
463
|
+
#/* -------------------------------------------------------------------------- */
|
|
464
|
+
def real_resid ( transpose, matrix, x, r, b):
|
|
465
|
+
Ap = matrix.Ap
|
|
466
|
+
Ai = matrix.Ai
|
|
467
|
+
Ax = matrix.Ax
|
|
468
|
+
n = len(b)
|
|
469
|
+
for i in range(n):
|
|
470
|
+
r[i] = -b[i]
|
|
471
|
+
if (transpose):
|
|
472
|
+
for j in range(n):
|
|
473
|
+
for p in range(Ap[j], Ap[j+1]):
|
|
474
|
+
i = Ai [p]
|
|
475
|
+
r [j] += Ax [p] * x [i]
|
|
476
|
+
else:
|
|
477
|
+
for j in range(n):
|
|
478
|
+
for p in range(Ap[j], Ap[j+1]):
|
|
479
|
+
i = Ai [p]
|
|
480
|
+
r [i] += Ax [p] * x [j]
|
|
481
|
+
norm = 0.0
|
|
482
|
+
print(len(r))
|
|
483
|
+
for i in range(n):
|
|
484
|
+
if abs(r[i]) > norm:
|
|
485
|
+
norm = abs(r[i])
|
|
486
|
+
return norm
|
|
487
|
+
|
|
488
|
+
def complex_resid ( transpose, matrix, x, r, b):
|
|
489
|
+
Ap = matrix.Ap
|
|
490
|
+
Ai = matrix.Ai
|
|
491
|
+
Ax = matrix.Ax
|
|
492
|
+
f = 2
|
|
493
|
+
n = len(b)//f
|
|
494
|
+
for i in range(n):
|
|
495
|
+
r[f*i] = -b[f*i]
|
|
496
|
+
if (transpose):
|
|
497
|
+
for j in range(n):
|
|
498
|
+
for p in range(Ap[j], Ap[j+1]):
|
|
499
|
+
i = Ai [p]
|
|
500
|
+
r [f*j] += Ax [f*p] * x [f*i]
|
|
501
|
+
else:
|
|
502
|
+
for j in range(n):
|
|
503
|
+
for p in range(Ap[j], Ap[j+1]):
|
|
504
|
+
i = Ai [p]
|
|
505
|
+
r [f*i] += Ax [f*p] * x [f*j]
|
|
506
|
+
norm = 0.0
|
|
507
|
+
print(len(r))
|
|
508
|
+
for i in range(n):
|
|
509
|
+
if abs(r[2*i]) > norm:
|
|
510
|
+
norm = abs(r[2*i])
|
|
511
|
+
return norm
|
|
512
|
+
|
|
513
|
+
def resid ( transpose, is_complex, matrix, x, r, b):
|
|
514
|
+
if is_complex:
|
|
515
|
+
return complex_resid(transpose, matrix, x, r, b)
|
|
516
|
+
else:
|
|
517
|
+
return real_resid(transpose, matrix, x, r, b)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import devsim
|
|
2
|
+
from . import umfpack_loader as umf
|
|
3
|
+
import sys
|
|
4
|
+
import os
|
|
5
|
+
import array
|
|
6
|
+
|
|
7
|
+
class dsobject:
|
|
8
|
+
def __init__(self, n, transpose):
|
|
9
|
+
self.n = n
|
|
10
|
+
self.transpose = transpose
|
|
11
|
+
self.status = True
|
|
12
|
+
self.message = None
|
|
13
|
+
# this may not be needed to save
|
|
14
|
+
self.matrix = None
|
|
15
|
+
self.gdata = None
|
|
16
|
+
self.initialize_umfpack()
|
|
17
|
+
self.umf_control = None
|
|
18
|
+
self.x = None
|
|
19
|
+
|
|
20
|
+
def __del__(self):
|
|
21
|
+
self.matrix=None
|
|
22
|
+
self.umf_control = None
|
|
23
|
+
self.gdata=None
|
|
24
|
+
|
|
25
|
+
def initialize_umfpack(self):
|
|
26
|
+
self.gdata = umf.global_data()
|
|
27
|
+
self.gdata.dll = umf.load_umfpack_dll(os.path.join(os.path.dirname(__file__), umf.get_umfpack_name()))
|
|
28
|
+
for b in devsim.get_parameter(name='info')['math_libraries']:
|
|
29
|
+
h = umf.load_blas_dll(self.gdata, blaslib=b, noexcept=True)
|
|
30
|
+
if h:
|
|
31
|
+
mcount = umf.load_blas_functions(self.gdata, h)
|
|
32
|
+
if mcount == 0:
|
|
33
|
+
break
|
|
34
|
+
if mcount != 0:
|
|
35
|
+
raise RuntimeError('Missing %d math functions' % mcount)
|
|
36
|
+
|
|
37
|
+
def factor(self, **kwargs):
|
|
38
|
+
self.status = False
|
|
39
|
+
self.message = ''
|
|
40
|
+
is_complex = kwargs['is_complex']
|
|
41
|
+
if not self.umf_control:
|
|
42
|
+
if is_complex:
|
|
43
|
+
self.umf_control = umf.umf_control(self.gdata, 'complex')
|
|
44
|
+
else:
|
|
45
|
+
self.umf_control = umf.umf_control(self.gdata, 'real')
|
|
46
|
+
#self.umf_control.init_verbose()
|
|
47
|
+
# test same symbolic
|
|
48
|
+
self.matrix = umf.matrix(uc=self.umf_control, Ap=kwargs['Ap'], Ai=kwargs["Ai"], Ax=kwargs["Ax"])
|
|
49
|
+
if not kwargs['is_same_symbolic']:
|
|
50
|
+
self.symbolic = self.umf_control.symbolic(matrix=self.matrix)
|
|
51
|
+
self.numeric = self.umf_control.numeric(matrix=self.matrix, Symbolic=self.symbolic)
|
|
52
|
+
self.status = True
|
|
53
|
+
self.message = ''
|
|
54
|
+
|
|
55
|
+
def solve(self, **kwargs):
|
|
56
|
+
self.status = False
|
|
57
|
+
self.message = ''
|
|
58
|
+
if self.umf_control.is_complex:
|
|
59
|
+
#print(kwargs.keys())
|
|
60
|
+
#raise RuntimeError("COMPLEX!")
|
|
61
|
+
self.x = array.array('d', [0.0])*len(kwargs['b'])
|
|
62
|
+
self.umf_control.solve(matrix=self.matrix, Numeric=self.numeric, b=kwargs['b'], transpose=self.transpose, x=self.x)
|
|
63
|
+
else:
|
|
64
|
+
self.x = array.array('d', kwargs['b'])
|
|
65
|
+
self.umf_control.solve(matrix=self.matrix, Numeric=self.numeric, b=kwargs['b'], transpose=self.transpose, x=self.x)
|
|
66
|
+
self.status = True
|
|
67
|
+
|
|
68
|
+
def local_solver_callback(**kwargs):
|
|
69
|
+
#print(kwargs['action'])
|
|
70
|
+
if (kwargs['action'] == 'init'):
|
|
71
|
+
so = dsobject(
|
|
72
|
+
n=kwargs['n'],
|
|
73
|
+
transpose=kwargs['transpose']
|
|
74
|
+
)
|
|
75
|
+
return {
|
|
76
|
+
'solver_object' : so,
|
|
77
|
+
'matrix_format' : "csc",
|
|
78
|
+
'status' : so.status,
|
|
79
|
+
'message' : so.message,
|
|
80
|
+
}
|
|
81
|
+
elif kwargs['action'] == 'factor':
|
|
82
|
+
so = kwargs['solver_object']
|
|
83
|
+
so.factor(**kwargs)
|
|
84
|
+
return {
|
|
85
|
+
'status' : so.status,
|
|
86
|
+
'message' : so.message,
|
|
87
|
+
}
|
|
88
|
+
elif kwargs['action'] == 'solve':
|
|
89
|
+
so = kwargs['solver_object']
|
|
90
|
+
so.solve(**kwargs)
|
|
91
|
+
if kwargs['is_complex']:
|
|
92
|
+
return {
|
|
93
|
+
'status' : so.status,
|
|
94
|
+
'message' : so.message,
|
|
95
|
+
'x' : so.x,
|
|
96
|
+
}
|
|
97
|
+
else:
|
|
98
|
+
return {
|
|
99
|
+
'status' : so.status,
|
|
100
|
+
'message' : so.message,
|
|
101
|
+
'x' : so.x,
|
|
102
|
+
}
|
|
103
|
+
else:
|
|
104
|
+
raise RuntimeError('Unsupported action, ' + kwargs['action'])
|
|
105
|
+
return False
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
devsim.set_parameter(name="direct_solver", value="custom")
|
|
109
|
+
devsim.set_parameter(name="solver_callback", value=local_solver_callback)
|
|
110
|
+
#print(devsim.get_parameter(name="info"))
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
#print(sys.argv)
|
|
114
|
+
sys.argv = sys.argv[1:]
|
|
115
|
+
sys.path.append(os.path.dirname(sys.argv[0]))
|
|
116
|
+
exec(compile(open(sys.argv[0], "rb").read(), sys.argv[0], 'exec'))
|