iam-git / WellMet (public) (License: MIT) (since 2021-08-31) (hash sha1)
WellMet is pure Python framework for spatial structural reliability analysis. Or, more specifically, for "failure probability estimation and detection of failure surfaces by adaptive sequential decomposition of the design domain".
List of commits:
Subject Hash Author Date (UTC)
simplex: implement FullCubatureIntegration 072927115a8a641f89b39265085eb6cac27aa492 I am 2023-01-04 16:27:39
dicebox.circumtri: use mixed facet outside nodes as candidates only. 03c1c974dafa8ff041f032c89149da7fc5b90b39 I am 2023-01-03 15:55:57
shell: use query() method of the convex hull 321a3fab33684cb9bef3c2344200c6519b595bb0 I am 2023-01-03 15:54:45
convex_hull.QHull: implement query() method. Use myshovskych sheme as fallback bc79a6fbee4d488211bf55c88702f39a0126be1b I am 2023-01-03 15:53:00
dicebox.circumtri: handle singular matrix error of CircumCenter 8207789777268039e7a866a594191063c6429c04 I am 2023-01-02 23:56:40
simplex.CubatureIntegration: check for non-finite simplex volumes 3a1473c7452c7dc3a9299ed88520412eb31924c1 I am 2023-01-02 22:51:14
dicebox.circumtri: return to psi potential 9db1f5b0e412ae871ae5f5fbb5ff214a8ddd7f45 I am 2023-01-02 22:20:28
dicebox.circumtri: bughunting 5f9d2b9e4d8077c9e4552d47bf1da789d8cfbcf8 I am 2022-12-29 15:02:14
dicebox.circumtri: process filtered integration nodes as candidates too 315e2f9700d93f1379985dafa818b44df53422a2 I am 2022-12-29 13:51:52
dicebox.circumtri: return back weighted entropy 0424243e29a600ecb1d046631badbc9797e11369 I am 2022-12-28 19:11:30
qt_gui.qt_graph_widgets: reflect renewed simplex estimators 90c83c7c7e6e58d6b9044db1a5e55f9a8a7dd7cd I am 2022-12-28 16:15:40
dicebox: rework CircumTri e360b2f092c11a42b5ac1081061f2891bff3d8de I am 2022-12-28 15:52:28
simplex: make _Triangulation more clean; rework CubatureIntegration fb7dd9fef8592944fbd93a3f07b44c2355d45e20 I am 2022-12-28 15:48:20
introduce shell module, clean version of ghull b13e9b2b15d109770e0c3fbdd5bb7b2a3b5bf5fc I am 2022-12-28 15:45:27
qt_gui.qt_plot.CandidatesWidget: regression fix a75874b5a53e7b420672b582f3ff415b17a32e9b I am 2022-12-23 12:19:51
qt_gui.qt_pairwise.ContactWidget: add mask function 6f88fec7db92e5cd21826a06f42a609a3e03cb6b I am 2022-12-21 15:20:01
qt_gui.qt_pairwise.ContactWidget: add option for mixed pairs only adjacency search. 2f87e8a18908de607b8abc0779448ca3095c134c I am 2022-12-21 14:30:23
qt_gui.qt_dicebox: reflect changes in CircumTri class 9821d389240a383f0b13b7dd92cd501e1c40c537 I am 2022-12-15 09:36:16
dicebox.circumtri: employ _Exploration class. Keep naive CircumTri class in renamed module b8605fb24d55b3296ceac34afba541a5b7ee3070 I am 2022-12-15 09:33:59
convex_hull.QHull.get_exploration_vector: self -> hull fix dae47ef37b5871a98d2ea274cc35aeb2a4eebe1c I am 2022-12-15 09:30:31
Commit 072927115a8a641f89b39265085eb6cac27aa492 - simplex: implement FullCubatureIntegration
Author: I am
Author date (UTC): 2023-01-04 16:27
Committer name: I am
Committer date (UTC): 2023-01-04 16:27
Parent(s): 03c1c974dafa8ff041f032c89149da7fc5b90b39
Signer:
Signing key:
Signing status: N
Tree: 98b91411d30ff74759a8f1a627a59e5b417e86e1
File Lines added Lines deleted
wellmet/simplex.py 130 41
File wellmet/simplex.py changed (mode: 100644) (index b46897b..4f90d6d)
... ... class JustCubatureTriangulation(_FastTriangulation, _CubatureTriangulation):
1036 1036
1037 1037
1038 1038
1039 FastCubatureEstimation = namedtuple('FastCubatureEstimation', (
1039 CubatureEstimation = namedtuple('CubatureEstimation', (
1040 1040 'nvar', 'nvar',
1041 1041 'nsim', 'nsim',
1042 'success',
1042 1043 'failure', 'failure',
1043 1044 'mix', 'mix',
1044 1045 'vertex_ratio_estimation', 'vertex_ratio_estimation',
 
... ... FastCubatureEstimation = namedtuple('FastCubatureEstimation', (
1054 1055 'ncoplanar' 'ncoplanar'
1055 1056 )) ))
1056 1057
1057 #č zadavame v každem integračním bodě očekavaní pravděpodobnosti poruchy
1058 # p_f + p_s = 1
1059 #č jednou z cest integrace je rovnou vynasobit p_f hustoty pravděpodobnosti f(x)
1060 # f_f(x) = f(x) * p_f(x)
1061 #č f_f(x) integrujeme kubaturou. Tím jakoby integrujeme červenou část simplexu.
1062 # Pf_simplex = sum(f_f * w) = sum(f * p_f * w), kde
1063 # sum(w) = 1 #č vahy kubatur
1064 #č Nebo můžem kubaturou prointegrovat přímo p_f(x),
1065 #č čímž dostaneme míru "poruchovosti" simplexu.
1066 #č Houby, výsledek je jiný.
1067 #č A je stejně nekorektní jak odhad vzalenosti přes průměrnou rychlost
1068 # pf_simplex = sum(p_f * w)
1069 # P_simplex = sum(f * w)
1070 # Pf_simplex = pf_simplex * P_simplex = sum(p_f * w) * sum(f * w)
1071 # (p_f1 * w1 + p_f2*w2 + p_f3*w3) * (f1 * w1 + f2*w2 + f3*w3)
1072 class CubatureIntegration(_Triangulation):
1058
1059
1060 class FullCubatureIntegration(_Triangulation):
1073 1061 def __init__(sx, sample_box, tn_scheme, tri_space='Rn', incremental=True, def __init__(sx, sample_box, tn_scheme, tri_space='Rn', incremental=True,
1074 1062 on_failure_added=lambda *__: None, on_mixed_added=lambda *__: None, on_failure_added=lambda *__: None, on_mixed_added=lambda *__: None,
1075 on_delete_simplex=lambda __: None):
1063 on_safe_added=lambda *__: None, on_delete_simplex=lambda __: None):
1076 1064
1077 1065 sx.tri_setup(sample_box, tri_space=tri_space, incremental=incremental) sx.tri_setup(sample_box, tri_space=tri_space, incremental=incremental)
1078 1066
 
... ... class CubatureIntegration(_Triangulation):
1086 1074 sx.failsi = sample_box.failsi sx.failsi = sample_box.failsi
1087 1075
1088 1076 #č kolbeky #č kolbeky
1077 sx.on_safe_added = on_safe_added
1089 1078 sx.on_failure_added = on_failure_added sx.on_failure_added = on_failure_added
1090 1079 sx.on_mixed_added = on_mixed_added sx.on_mixed_added = on_mixed_added
1091 1080 sx.on_delete_simplex = on_delete_simplex sx.on_delete_simplex = on_delete_simplex
1092 1081
1093 1082 #оӵ кылсузъет кылдытом #оӵ кылсузъет кылдытом
1083 sx.safe_simplices = dict()
1094 1084 sx.failure_simplices = dict() sx.failure_simplices = dict()
1095 1085 sx.mixed_simplices = dict() sx.mixed_simplices = dict()
1096 1086
 
... ... class CubatureIntegration(_Triangulation):
1100 1090 in_failure = np.isin(simplices, sx.sample_box.failure_points) in_failure = np.isin(simplices, sx.sample_box.failure_points)
1101 1091
1102 1092 has_failure = in_failure.any(axis=1) has_failure = in_failure.any(axis=1)
1103 simplices = simplices[has_failure]
1104 in_failure = in_failure[has_failure]
1105
1106 1093 all_failure = in_failure.all(axis=1) all_failure = in_failure.all(axis=1)
1094
1107 1095 for indices in simplices[all_failure]: for indices in simplices[all_failure]:
1108 1096 simplex = tuple(indices) simplex = tuple(indices)
1109 1097 #č ty množiny jsou super #č ty množiny jsou super
1110 1098 sx.simplices_set.add(simplex) sx.simplices_set.add(simplex)
1111 1099 sx._integrate_red_simplex(simplex, indices) sx._integrate_red_simplex(simplex, indices)
1112 1100
1113 simplices = simplices[~all_failure]
1114 in_failure = in_failure[~all_failure]
1101 for indices in simplices[~has_failure]:
1102 simplex = tuple(indices)
1103 #č ty množiny jsou super
1104 sx.simplices_set.add(simplex)
1105 sx._integrate_safe_simplex(simplex, indices)
1106
1107 mixed_mask = np.logical_and(has_failure, ~all_failure)
1108 simplices = simplices[mixed_mask]
1109 in_failure = in_failure[mixed_mask]
1115 1110
1116 1111 frs = np.sum(in_failure, axis=1) / (sx.sample_box.nvar + 1) frs = np.sum(in_failure, axis=1) / (sx.sample_box.nvar + 1)
1117 1112 pdfs = sx.PDF[simplices] pdfs = sx.PDF[simplices]
 
... ... class CubatureIntegration(_Triangulation):
1138 1133 for simplex in simplices_set_to_delete: for simplex in simplices_set_to_delete:
1139 1134 sx.failure_simplices.pop(simplex, None) sx.failure_simplices.pop(simplex, None)
1140 1135 sx.mixed_simplices.pop(simplex, None) sx.mixed_simplices.pop(simplex, None)
1136 sx.safe_simplices.pop(simplex, None)
1141 1137
1142 1138 #č Bacha, teď posíláme tuple. #č Bacha, teď posíláme tuple.
1143 1139 #č Kód na té straně úplně stejně bude vyhazovat #č Kód na té straně úplně stejně bude vyhazovat
 
... ... class CubatureIntegration(_Triangulation):
1178 1174 wfr = fpdf / np.sum(pdf) wfr = fpdf / np.sum(pdf)
1179 1175 mfpdf = fpdf / max_fp mfpdf = fpdf / max_fp
1180 1176 sx._integrate_mixed_simplex(simplex, indices, fr, wfr, mfpdf) sx._integrate_mixed_simplex(simplex, indices, fr, wfr, mfpdf)
1177 else:
1178 sx._integrate_safe_simplex(simplex, indices)
1181 1179
1182 1180
1183 1181
 
... ... class CubatureIntegration(_Triangulation):
1288 1286
1289 1287 if p_failure < 0: if p_failure < 0:
1290 1288 print("Negative measure has occured in simplex %s" % indices) print("Negative measure has occured in simplex %s" % indices)
1291 print("Rozbíla se nám integrace, integráční schema je na houby.")
1289 #print("Rozbíla se nám integrace, integráční schema je na houby.")
1292 1290 p_failure = 0 p_failure = 0
1293 1291
1294 1292 assert p_failure >= 0 assert p_failure >= 0
 
... ... class CubatureIntegration(_Triangulation):
1297 1295 #č odhady jsou ve slovníku, posíláme jen to, co tam není #č odhady jsou ve slovníku, posíláme jen to, co tam není
1298 1296 sx.on_failure_added(simplex, indices, vertices_model, nodes, vol) sx.on_failure_added(simplex, indices, vertices_model, nodes, vol)
1299 1297
1298
1299 def _integrate_safe_simplex(sx, simplex, indices):
1300
1301 vertices_model = sx.tri.points[indices]
1302
1303 x = quadpy.tn.transform(sx.tn_scheme.points, vertices_model.T)
1304 vol = quadpy.tn.get_vol(vertices_model)
1305
1306 if not np.isfinite(vol):
1307 print("Incorrect volume has occured in simplex %s" % indices)
1308 vol = 0
1309
1310 nodes = sx.f.new_sample(x.T, sx.tri_space)
1311 fx = nodes.pdf(sx.tri_space)
1312
1313 p_safe = vol * np.dot(fx, sx.tn_scheme.weights)
1314
1315
1316 if p_safe < 0:
1317 print("Negative measure has occured in simplex %s" % indices)
1318 p_safe = 0
1319
1320 assert p_safe >= 0
1321
1322 sx.safe_simplices[simplex] = p_safe
1323 #č odhady jsou ve slovníku, posíláme jen to, co tam není
1324 sx.on_safe_added(simplex, indices, vertices_model, nodes, vol)
1300 1325
1301 1326
1302 1327 def get_pf_estimation(sx): def get_pf_estimation(sx):
 
... ... class CubatureIntegration(_Triangulation):
1313 1338 for failure_simplex in sx.failure_simplices.values(): for failure_simplex in sx.failure_simplices.values():
1314 1339 p_failure += failure_simplex p_failure += failure_simplex
1315 1340
1341 p_success = 0
1342 for safe_simplex in sx.safe_simplices.values():
1343 p_success += safe_simplex
1316 1344
1317 1345 p_mixed, pfv, pfw, pf = simplex_estimations p_mixed, pfv, pfw, pf = simplex_estimations
1318 1346 nsim, nvar = sx.tri.points.shape nsim, nvar = sx.tri.points.shape
1319 return FastCubatureEstimation(
1320 nvar,
1321 nsim,
1322 p_failure,
1323 p_mixed,
1324 pfv + p_failure,
1325 pf + p_failure,
1326 pfw + p_failure,
1327 sx.tri.nsimplex,
1328 #sx.tn_scheme.name,
1329 sx.tn_scheme.points.shape[1],
1330 sx.newly_invalidated,
1331 sx.newly_estimated,
1332 len(sx.failure_simplices),
1333 len(sx.mixed_simplices),
1334 len(sx.tri.coplanar)
1335 )
1347 return CubatureEstimation(
1348 nvar,
1349 nsim,
1350 p_success,
1351 p_failure,
1352 p_mixed,
1353 pfv + p_failure,
1354 pf + p_failure,
1355 pfw + p_failure,
1356 sx.tri.nsimplex,
1357 #sx.tn_scheme.name,
1358 sx.tn_scheme.points.shape[1],
1359 sx.newly_invalidated,
1360 sx.newly_estimated,
1361 len(sx.failure_simplices),
1362 len(sx.mixed_simplices),
1363 len(sx.tri.coplanar)
1364 )
1365
1366
1367
1368
1369
1370 #č zadavame v každem integračním bodě očekavaní pravděpodobnosti poruchy
1371 # p_f + p_s = 1
1372 #č jednou z cest integrace je rovnou vynasobit p_f hustoty pravděpodobnosti f(x)
1373 # f_f(x) = f(x) * p_f(x)
1374 #č f_f(x) integrujeme kubaturou. Tím jakoby integrujeme červenou část simplexu.
1375 # Pf_simplex = sum(f_f * w) = sum(f * p_f * w), kde
1376 # sum(w) = 1 #č vahy kubatur
1377 #č Nebo můžem kubaturou prointegrovat přímo p_f(x),
1378 #č čímž dostaneme míru "poruchovosti" simplexu.
1379 #č Houby, výsledek je jiný.
1380 #č A je stejně nekorektní jak odhad vzalenosti přes průměrnou rychlost
1381 # pf_simplex = sum(p_f * w)
1382 # P_simplex = sum(f * w)
1383 # Pf_simplex = pf_simplex * P_simplex = sum(p_f * w) * sum(f * w)
1384 # (p_f1 * w1 + p_f2*w2 + p_f3*w3) * (f1 * w1 + f2*w2 + f3*w3)
1385 class FastCubatureIntegration(FullCubatureIntegration):
1386
1387 def integrate(sx):
1388 simplices = sx.tri.simplices
1389 in_failure = np.isin(simplices, sx.sample_box.failure_points)
1390
1391 has_failure = in_failure.any(axis=1)
1392 simplices = simplices[has_failure]
1393 in_failure = in_failure[has_failure]
1394
1395 all_failure = in_failure.all(axis=1)
1396 for indices in simplices[all_failure]:
1397 simplex = tuple(indices)
1398 #č ty množiny jsou super
1399 sx.simplices_set.add(simplex)
1400 sx._integrate_red_simplex(simplex, indices)
1401
1402 simplices = simplices[~all_failure]
1403 in_failure = in_failure[~all_failure]
1404
1405 frs = np.sum(in_failure, axis=1) / (sx.sample_box.nvar + 1)
1406 pdfs = sx.PDF[simplices]
1407 fpdfs = np.sum(pdfs * in_failure, axis=1)
1408 wfrs = fpdfs / np.sum(pdfs, axis=1)
1409 mfpdfs = fpdfs / (sx.sample_box.nvar + 1)
1410
1411 for indices, fr, wfr, mfpdf in zip(simplices, frs, wfrs, mfpdfs):
1412 #č ty množiny jsou super
1413 simplex = tuple(indices)
1414 #č ty množiny jsou super
1415 sx.simplices_set.add(simplex)
1416 sx._integrate_mixed_simplex(simplex, indices, fr, wfr, mfpdf)
1417
1418
1419 def _integrate_safe_simplex(sx, simplex, indices):
1420 pass
1421
1422
1423
1424
1336 1425
1337 1426
1338 1427
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/WellMet

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/WellMet

Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/WellMet

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main