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)
convex_hull.QHull: implement chi cubature integration 7537b642967b7dd5d8475c20aff2a930a5bcd3ad I am 2023-01-20 15:54:05
convex_hull: implement QHullCubature class 6f1b51ba6fe281f7cae4f44889db96787d916a99 I am 2023-01-20 10:46:54
convex_hull.QHull: add proof-of-concept get_inside() method 6013fbac742d6070771d7798c928538ebc54495e I am 2023-01-19 10:19:32
whitebox: add r exact for common nD boxes 7c4ab62f069f0efeb48a403dac5d27033003ded2 I am 2023-01-17 15:09:08
qt_gui: improve GRaph to show r-R bounds 59fa5bde7be2197b1f739bd1f829f927cef62603 I am 2023-01-17 14:26:16
dicebox.circumtri: calculate event's radia c6868cfbde7c8a86b73217da544f60e94a117bd8 I am 2023-01-16 06:12:34
simplex.Triangulation.get_averaged_mixed_normals: implement deep averaging 6dfb056e477479331c7a903ea52a98301fca4e71 I am 2023-01-15 23:26:43
replace flatten() by reshape(-1) everywhere. The former always allocates new array 97b35c989a5ad8e459bb60133222d50c7f78e1f0 I am 2023-01-15 12:04:30
qt_gui.qt_gui: explicitly export sample_box to console's namespace dd2e50245157082ddb645b693a8a8c573215d50c I am 2023-01-15 11:42:01
replace everywhere np.bool by just bool (it looks like newer numpy dropped it) ac208f89bbf0ad76d38790686041ea778a9b6376 I am 2023-01-15 11:31:56
simplex._Triangulation: implement averaged gradients() f6608597cf490dd6cf1a6af3b7d8e6d0a72732d9 I am 2023-01-15 09:37:14
add line and two lines problems for sensitivity analysis 0c620f7960399ed8b34e02d663772d0eb34e66f1 I am 2023-01-14 08:30:56
simplex.FullCubatureIntegration.get_sensitivities: do not normalize global gradient c648c484a5599a00236ab70c36cdf407c24f5306 I am 2023-01-14 04:51:16
simplex: implement sensitivities 65056319c51fd93deb76ce14e52c08869dfc04a2 I am 2023-01-13 11:27:46
mplot.maxes: prepare GRaph plot 68774535915af3deaf6104a0bbe9b3c4d24c0cec I am 2023-01-12 02:43:20
mplot.mgraph.tri_estimation_plot: use planar vertex estimator 1d300fa56248be9cdab5a4e5b0d4372f68fd5255 I am 2023-01-11 15:48:28
mplot.mart: implement lsf_boundary() contouring 8642d2f0c043f4e71af1cc45b9e25da326afd3ca I am 2023-01-11 05:20:00
mplot.mart.setup_labels: make labels more adaptive 60cd0b34a67b38df1c730dddc9e0771139818f33 I am 2023-01-11 04:35:47
simplex._SamplingTriangulation: self reference fix 79204ff15cba7c5ca24bb5b48e2073058acf00ae I am 2023-01-11 03:21:34
testcases.testcases_2D: add pf for rastrigin 4f3b35fe18496fcb9f59860174c876cb7a82749a I am 2023-01-10 23:39:45
Commit 7537b642967b7dd5d8475c20aff2a930a5bcd3ad - convex_hull.QHull: implement chi cubature integration
Author: I am
Author date (UTC): 2023-01-20 15:54
Committer name: I am
Committer date (UTC): 2023-01-20 15:54
Parent(s): 6f1b51ba6fe281f7cae4f44889db96787d916a99
Signer:
Signing key:
Signing status: N
Tree: 1ba5068108fd35612c82df253b5acc013204855b
File Lines added Lines deleted
wellmet/convex_hull.py 102 13
File wellmet/convex_hull.py changed (mode: 100644) (index c5f0c29..520661e)
... ... import mpmath
6 6 from scipy import stats from scipy import stats
7 7 from scipy import spatial # for QHull from scipy import spatial # for QHull
8 8
9 from . import sball
10
9 11 import quadpy import quadpy
10 12
11 13 from collections import namedtuple from collections import namedtuple
 
... ... class CompleteHull:
803 805
804 806
805 807
808
809
810
811 QHullEstimation = namedtuple('QHullEstimation', (
812 'nvar',
813 'nsim',
814 'nfacets',
815 'r', 'R',
816 'inner',
817 'shell',
818 'outer',
819 'chi_outside',
820 'orth_outside',
821 #'tn_scheme',
822 #'tn_scheme_points',
823 'inside',
824 'outside'
825 ))
826
827
806 828 class QHull: class QHull:
807 829 # take some global function # take some global function
808 830 _orth_helper = _orth_helper _orth_helper = _orth_helper
 
... ... class QHull:
813 835 #get_2FORM_outside = get_2FORM_outside #get_2FORM_outside = get_2FORM_outside
814 836 get_2FORM_equations = get_2FORM_equations get_2FORM_equations = get_2FORM_equations
815 837
816 def __init__(self, sample, space='G', incremental=True, auto_update=True):
838 def __init__(self, sample, space='G', incremental=True, auto_update=True, tn_scheme=None):
817 839 self.sample = sample self.sample = sample
818 840 self.incremental = incremental self.incremental = incremental
819 841 self.space = space self.space = space
820 842 self.auto_update = auto_update self.auto_update = auto_update
843 self.tn_scheme = tn_scheme
844 self.sball = sball.Sball(sample.nvar)
845 self.shell = sball.Shell(sample.nvar)
821 846 self.fallback_plan = quadpy.un.mysovskikh_1(sample.nvar).points self.fallback_plan = quadpy.un.mysovskikh_1(sample.nvar).points
822 847
823 848 def regen(self): def regen(self):
 
... ... class QHull:
965 990 else: else:
966 991 return 0 return 0
967 992
993 def get_R(self):
994 assert self.space == 'G'
995 sum_squared = np.sum(np.square(self.sample.G), axis=1)
996 #index = np.argmax(sum_squared)
997 return np.sqrt(np.nanmax(sum_squared))
998
968 999 def shot(hull, ns, use_MC=False): def shot(hull, ns, use_MC=False):
969 1000 try: try:
970 1001 # take global function for shot() # take global function for shot()
 
... ... class QHull:
997 1028 #č neřikejte mi, že musím pěčlivějc zpracovavat chyby! #č neřikejte mi, že musím pěčlivějc zpracovavat chyby!
998 1029 return 1 return 1
999 1030
1000 def get_inside(hull):
1031 def get_norm_inside(hull):
1032 hull._update()
1001 1033 if hull.space != 'G': if hull.space != 'G':
1002 1034 raise raise
1003 scheme = quadpy.tn.grundmann_moeller(hull.sample.nvar - 1, 5)
1004 1035
1005 #np.sum(quadpy.tn.get_vol(box.G[box.convex_hull.simplices].transpose((1,0,2)))*np.sum(PQR * box.convex_hull.A, axis=1)) / 3
1036 vertices_model = hull.points[hull.simplices].transpose((1, 0, 2))
1037 result = hull.tn_scheme.integrate(hull._norm_inside_callback, vertices_model)
1006 1038
1039 return np.sum(result, axis=1)
1007 1040
1008 #np.sum(sheme.integrate(lambda x: np.full((26,1), 1), box.G[box.convex_hull.simplices].transpose((1, 0, 2))))
1009 #np.sum(sheme.integrate(hull._quadpy_callback, box.G[box.convex_hull.simplices].transpose((1, 0, 2))),axis=1)
1010 1041
1042 def get_chi_outside(hull):
1043 hull._update()
1044 if hull.space != 'G':
1045 raise
1046 scheme = quadpy.tn.grundmann_moeller(hull.sample.nvar - 1, 5)
1011 1047
1012 1048 vertices_model = hull.points[hull.simplices].transpose((1, 0, 2)) vertices_model = hull.points[hull.simplices].transpose((1, 0, 2))
1049 result = hull.tn_scheme.integrate(hull._chi_outside_callback, vertices_model)
1013 1050
1014 return np.sum(scheme.integrate(hull._quadpy_callback, vertices_model), axis=1)
1051 return np.sum(result)
1015 1052
1016 1053 # quadpy # quadpy
1017 def _quadpy_callback(hull, x):
1054 def _norm_inside_callback(hull, x):
1018 1055 # x.shape == (simplex_dim + 1, nsimplex, scheme_npoints) #(3, 26, 56) # x.shape == (simplex_dim + 1, nsimplex, scheme_npoints) #(3, 26, 56)
1019 1056
1020 1057 cdfs = stats.norm.cdf(x) cdfs = stats.norm.cdf(x)
 
... ... class QHull:
1028 1065
1029 1066 # n_values x nsimplex x scheme_points # n_values x nsimplex x scheme_points
1030 1067 return cdfs return cdfs
1068
1069
1070 # quadpy
1071 def _chi_outside_callback(hull, x):
1072 # x.shape == (simplex_dim + 1, nsimplex, scheme_npoints) #(3, 26, 56)
1073 nvar, nsimplex, ninodes = x.shape
1031 1074
1075 r = np.sqrt(np.sum(np.square(x), axis=0))
1076 cdfs = hull.sball.sf(r)
1077 # chi_pdf * bůhvíco == phi(x) * phi(y) * phi(z)
1078 chi_pdf = stats.chi.pdf(r, nvar)
1079 norm_pdf = np.prod(stats.norm.pdf(x), axis=0)
1032 1080
1081 # cdfs /= r
1082 # cdfs /= nvar * 2 * np.pi
1033 1083
1084 # n_values x nsimplex x scheme_points
1085 return cdfs * norm_pdf / chi_pdf
1086
1087
1088
1089 def get_convex_hull_estimation(hull):
1090
1091 r = hull.get_r()
1092 R = hull.get_R()
1093 if r<0:
1094 hull.shell.set_bounds(0, R)
1095 else:
1096 hull.shell.set_bounds(r, R)
1097
1098 outer = hull.shell.pf
1099 shell = hull.shell.p_shell
1100
1101 chi_outside = hull.get_chi_outside()
1102
1103 r_outside = outer + shell
1104 if chi_outside > r_outside:
1105 outside = r_outside
1106 else:
1107 outside = chi_outside
1108
1109 return QHullEstimation(
1110 hull.sample.nvar,
1111 hull.npoints,
1112 hull.nsimplex,
1113 r, R,
1114 hull.shell.ps,
1115 shell,
1116 outer,
1117 chi_outside,
1118 hull.get_orth_outside(),
1119 #'tn_scheme',
1120 #'tn_scheme_points',
1121 1 - outside,
1122 outside
1123 )
1124
1125
1126
1127
1034 1128
1035 1129 # Gaussian brick # Gaussian brick
1036 1130 #č Gaussovská cihla #č Gaussovská cihla
 
... ... class QHullCubature(QHull):
1314 1408 else: else:
1315 1409 self.regen() self.regen()
1316 1410
1317 def get_R(self):
1318 sum_squared = np.sum(np.square(self.sample.G), axis=1)
1319 #index = np.argmax(sum_squared)
1320 return np.sqrt(np.nanmax(sum_squared))
1321
1322 1411
1323 1412 def get_inside(hull): def get_inside(hull):
1324 1413 hull._update() hull._update()
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