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)
delete sball_old :( 792d9d83fde0f38e7396162788ec8aa922b0fd0c Aleksei Gerasimov 2021-10-21 14:47:06
whitebox: add Z_sum, Z_prod, small clean up faec934bb03c20906c9091fc196cc0daf824b54f Aleksei Gerasimov 2021-10-21 13:48:07
g_models: add neverfall, add sign parameter to Z_prod 129abf19da15a5dfcb5a02614d92a233f914d146 Aleksei Gerasimov 2021-10-21 13:45:47
mplot: add one more qhull plot 32e7003aac4887bd83bfff640093f755b4f6cffe I am 2021-09-14 11:42:56
mplot: add ESREL-related figures cba805ba8e7f3c2337027eec6e760aa9234dfdc2 I am 2021-09-12 10:17:21
mplot.mart: allow set up fill keyword cf94410513091b5f96e0e17e8de2f7a3feee1a03 I am 2021-09-12 10:15:55
mplot: add qhull&density figure a36fb606e9f425742925aa4953c0ae07d6b51409 I am 2021-09-10 15:17:58
qt_plot: send sliced sample box to matplotlib fda486b90c56e77bc88b38d0d94d08a751277cfb I am 2021-09-10 15:01:55
mplot: include Axes3d patch 8f5dc7f04b6c804b5ec169ec7b744a8618b3bb69 I am 2021-09-10 11:05:20
rework mplot module considerably 5343602c63032f6f7fd06701b0883eaabb4fc6c1 I am 2021-09-09 13:24:45
convex_hull: reduce max R to that not overflows everything everytime 2108df698e4d45bfae9d9882d4b4cc62340b03cc Aleksei Gerasimov 2021-07-21 13:56:41
sball: make Sball a little bit more scipy.stats-compatible 9414aceedf826e7fc6e35c722b2eecee81dead1e Aleksei Gerasimov 2021-07-21 13:40:28
convex_hull: fire() function has been reworked. shot() function is introduced 4e6b7546f163a9a32fdb4bf5790f416300b2c1ec Aleksei Gerasimov 2021-07-21 13:11:52
ghull: 1DS integration scheme has been implemented. convex_hull has been divided into convex_hull itself and separated ghull module. 29b21b4fc1396384bf8c9bb21b91f82005850574 Aleksei Gerasimov 2021-07-20 13:26:47
IS_stat: add 1D IS-like helpful sampling function 58416707171522e8129333e8bd93f512c7578879 Aleksei Gerasimov 2021-07-20 11:06:27
convex_hull: orth estimation is ready. Uses QR decomposition. 75f20d8771021b037c360df9c7207b8f46f65d91 Aleksei Gerasimov 2021-07-20 08:25:20
convex_hull: 2FORM za mně je Ready. Orth potřebuje Gram-Schmidtovou ortogonalizaci. Oboje jsou otestovany ve 2D. There is some weirdness with candidates inherited from WIP recent commit. It need to be fixed. ffae78d5a15884476760b8ab759963d7ef8ff5fc Aleksei Gerasimov 2021-07-19 14:48:34
convex_hull: 2FORM estimation WIP a0f04ef282d6dacbda52c9734f36f9e7ec9b46da I am 2021-07-19 06:14:54
convex_hull.fire: use sf instead of cdf function to fix precision issue in distant areas. e3b9f036f9d50994357e32827586fb98d85d43a7 I am 2021-07-15 09:13:58
qt_plot: add matplotlib menu 73835a59908b82f08d618a06c4c05a96703715b1 I am 2021-07-14 17:01:54
Commit 792d9d83fde0f38e7396162788ec8aa922b0fd0c - delete sball_old :(
Author: Aleksei Gerasimov
Author date (UTC): 2021-10-21 14:47
Committer name: Aleksei Gerasimov
Committer date (UTC): 2021-10-21 14:47
Parent(s): faec934bb03c20906c9091fc196cc0daf824b54f
Signer:
Signing key:
Signing status: N
Tree: bf6896108e81e912ea8e2470c85f0e1711a6614a
File Lines added Lines deleted
sball_old.py 0 137
File sball_old.py deleted (index bac994a..0000000)
1 #!/usr/bin/env python
2 # coding: utf-8
3
4 import numpy as np
5 #from scipy import stats
6 from scipy import special # for S_ball
7 from scipy import integrate # for S_ball
8
9 # нельзя просто так взять и написать Ньютонову методу
10 # fails on nvar = 501, fails on Sball(500).get_r(0), fails on Sball(800).get_r(0.999)
11
12 class Sball:
13 def __init__(self, nvar):
14 self.nvar = nvar
15 if nvar != 2:
16 self.C = 2**(1-nvar/2) / special.gamma(nvar/2)
17 self.logC = (1-nvar/2)*np.log(2) - special.gammaln(nvar/2)
18 self.flex = self.current_r = np.sqrt(self.nvar-1)
19 self.flex_pf = self.current_pf = self.get_pf(self.flex)
20
21 def get_pf(self, r):
22 """
23 returns pf, i.e. complementary part of multidimensional Gaussian distribution
24 """
25 if self.nvar == 1:
26 #return 1 - 2**(1-nvar/2) / special.gamma(nvar/2) * (np.sqrt(np.pi)*special.erf(r/np.sqrt(2)))/np.sqrt(2)
27 return 1 - special.erf(r/1.4142135623730951)
28 elif self.nvar == 2:
29 return np.exp(-r**2/2)
30 elif self.nvar == 3:
31 #return 1 - 2**(1-nvar/2) / special.gamma(nvar/2) * (np.exp(-r**2/2)*(np.sqrt(np.pi)*np.exp(r**2/2)*special.erf(r/np.sqrt(2))-np.sqrt(2)*r))/np.sqrt(2)
32 return 1 - 0.5641895835477564 * (np.exp(-r**2/2)*(np.sqrt(np.pi)*np.exp(r**2/2)*special.erf(r/np.sqrt(2))-np.sqrt(2)*r))
33 elif self.nvar == 4:
34 return (r**2/2+1)*np.exp(-r**2/2)
35 elif self.nvar == 6:
36 return (r**4+4*r**2+8)*np.exp(-r**2/2)/8
37
38 # nvar=8: (48-(r^6+6*r^4+24*r^2+48)*e^(-r^2/2) / 2**(nvar/2))/48
39
40 # hračička ve hračce
41 # nemám žádnou jistotu, že tohle počítá přesněji
42 # ale ve výsokých dimenzích aspoň počítá
43 elif self.nvar % 2 == 0: # sudé
44 poly = [1]
45 for i in range(self.nvar-2, 0, -2):
46 poly.append(0)
47 poly.append(i*poly[-2])
48 return np.polyval(np.array(poly) / poly[-1], r) * np.exp(-r**2/2)
49
50 else:
51 try:
52 pf = self.C * integrate.quad(lambda x: np.exp(-(x**2)/2)*x**(self.nvar-1), r, np.inf)[0]
53 except OverflowError:
54 pf = 1 - self.C * integrate.quad(lambda x: np.exp(-(x**2)/2)*x**(self.nvar-1), 0, r)[0]
55
56 return pf
57
58 def get_r(self, desired_pf):
59 """
60 sball_inversion
61 returns r
62 """
63 if self.nvar == 2:
64 return np.sqrt(-2*np.log(desired_pf))
65 elif self.flex_pf == desired_pf:
66 return self.flex
67 else:
68 # je to jistější
69 self.current_r = self.flex
70 self.current_pf = previous_pf = self.flex_pf
71
72 self.__do_iter(desired_pf)
73 self.current_pf = self.get_pf(self.current_r)
74 # hrůza
75 # pokračujeme, dokud to nezkonverguje, přenejmenším pokud to konvergue a neosciluje.
76 while self.current_pf != previous_pf and self.current_pf != desired_pf\
77 and (self.current_pf > desired_pf or previous_pf < desired_pf):
78
79 previous_pf = self.current_pf
80 self.__do_iter(desired_pf)
81 self.current_pf = self.get_pf(self.current_r)
82
83 return self.current_r
84
85 def __do_iter(self, desired_pf):
86 r = self.current_r
87 denominator = (self.C * np.exp(-(r**2)/2)*r**(self.nvar-1))
88 if denominator != 0 and not np.isnan(denominator):
89 self.current_r += (self.current_pf - desired_pf) / denominator
90 else:
91 # zkombinujeme C a r^nvar, ale stejně nikoho to nezahraní
92 log_delta = np.log(abs(self.current_pf - desired_pf)) + (r**2)/2 - (np.log(r)*(self.nvar-1) + self.logC)
93 self.current_r += np.exp(log_delta)*np.sign(self.current_pf - desired_pf)
94
95 if self.current_r < 0:
96 self.current_r = r/2
97
98
99 def get_r_iteration(self, desired_pf):
100 """
101 Same as get_r, but do just one iteration
102 """
103
104
105 if self.nvar == 2:
106 return np.sqrt(-2*np.log(desired_pf)), desired_pf
107
108 # logaritmus je na nulu citelný
109 elif self.current_pf - desired_pf != 0:
110
111 # hrůza, nečitelný
112 # pokud je současné r-ko v jiné straně od chtěného r-ka, tak se vrátíme do inflexního bodu
113 if (self.flex_pf > self.current_pf) is (self.flex_pf < desired_pf):
114 # vstupní kontrola
115 self.current_r = self.flex
116 self.current_pf = self.flex_pf
117
118
119 r = self.current_r # pro výstupní kontrolu
120
121 self.__do_iter(desired_pf)
122
123
124 # vystupní kontrola
125 if (self.flex > self.current_r) is (self.flex < r):
126 # preskočili jsme inflexní bod
127 self.current_r = self.flex
128 self.current_pf = self.flex_pf
129 # ještě jednou
130 self.__do_iter(desired_pf)
131
132 self.current_pf = self.get_pf(self.current_r) # ne že bychom pf potrebovali v tomto kroce, ale...
133 return self.current_r, self.current_pf
134
135
136
137
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