File README.md changed (mode: 100644) (index b94faa2..c9a2ecc) |
1 |
1 |
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". |
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". |
2 |
2 |
|
|
3 |
|
Main dependencies are numpy+scipy, pandas, quadpy. |
|
4 |
|
Qt frontend requires pyqtgraph. |
|
|
3 |
|
# Installation |
|
4 |
|
## For users of conda-based distributions |
|
5 |
|
Anaconda users are encouraged to manually install WellMet's dependencies: |
|
6 |
|
``` |
|
7 |
|
conda install -c anaconda scipy |
|
8 |
|
conda install -c anaconda matplotlib |
|
9 |
|
conda install -c anaconda pandas |
|
10 |
|
conda install -c anaconda mpmath |
|
11 |
|
conda install -c anaconda pyqtgraph |
5 |
12 |
|
|
6 |
|
To run graphical frontend with predefined reliability problems type in shell: python -m wellmet |
|
|
13 |
|
conda install -c conda-forge quadpy |
|
14 |
|
``` |
|
15 |
|
pyopengl for 3D view (optionally): |
|
16 |
|
``` |
|
17 |
|
conda install -c anaconda pyopengl |
|
18 |
|
``` |
7 |
19 |
|
|
8 |
|
The software has been developed as part of an internal academic project no. FAST-K-21-6943 sponsored by the Czech Ministry of Education, Youth and Sports and also by project named ``Quality Internal Grants of BUT (KInG BUT)'', Reg. No. CZ.02.2.69/0.0/0.0/19\_073/0016948, which is financed from the OP RDE. |
|
|
20 |
|
Finally, install WellMet from PyPI: |
|
21 |
|
``` |
|
22 |
|
pip install wellmet |
|
23 |
|
``` |
|
24 |
|
|
|
25 |
|
## For other users |
|
26 |
|
Install WellMet from PyPI: |
|
27 |
|
``` |
|
28 |
|
pip install wellmet |
|
29 |
|
``` |
|
30 |
|
|
|
31 |
|
WellMet relies on ```quadpy``` for simplex integration. However, quadpy became a closed source software and requires licence fee now. |
|
32 |
|
One probably could install official quadpy package and obtain a licence in order to support Nico Schloemer. |
|
33 |
|
However, WellMet has never been tested with commertial quadpy versions. |
|
34 |
|
So, we separately share the last GPL version: |
|
35 |
|
``` |
|
36 |
|
pip install quadpy-gpl |
|
37 |
|
``` |
|
38 |
|
|
|
39 |
|
|
|
40 |
|
# How to use: |
|
41 |
|
## A. To run GUI with predefined benchmark problems: |
|
42 |
|
1. Type in shell: ```python -m wellmet``` |
|
43 |
|
2. Choose problem to solve, choose (optionally) filename to store samples and estimations, set up the algorithm. |
|
44 |
|
3. Press "Batch run..." button and type desired number of LSF calls. |
|
45 |
|
|
|
46 |
|
## B. To test the algorithm on your own problem use the following code: |
|
47 |
|
``` |
|
48 |
|
import numpy as np |
|
49 |
|
import scipy.stats as stats |
|
50 |
|
|
|
51 |
|
from wellmet.qt_gui import qt_box_functions as gui |
|
52 |
|
from wellmet import whitebox |
|
53 |
|
from wellmet.samplebox import SampleBox |
|
54 |
|
from wellmet import f_models |
|
55 |
|
|
|
56 |
|
|
|
57 |
|
# 1. Set up probability distribution |
|
58 |
|
# Standard Gaussian variables, 2D |
|
59 |
|
#f = f_models.SNorm(2) |
|
60 |
|
# Just normal variables |
|
61 |
|
f = f_models.Norm(mean=[-1, 0], std=[2, 1]) |
|
62 |
|
# Independent non-Gaussian variables |
|
63 |
|
#f = f_models.UnCorD((stats.gumbel_r, stats.uniform)) |
|
64 |
|
# Correlated non-Gaussian marginals |
|
65 |
|
#f = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]]) |
|
66 |
|
|
|
67 |
|
# 2. Define LSF function |
|
68 |
|
def my_problem(input_sample): |
|
69 |
|
# get real (physical) space coordinates |
|
70 |
|
# X is a numpy array with shape (nsim, ndim) |
|
71 |
|
# the algorithm normally sends (1, ndim) sample |
|
72 |
|
X = input_sample.R |
|
73 |
|
# LSF |
|
74 |
|
g = X[:, 0] - X[:, 1] + 3 |
|
75 |
|
# we should return an instance of SampleBox class |
|
76 |
|
# this instance stores coordinates along with LSF calculation result |
|
77 |
|
return SampleBox(input_sample, g, "my_problem") |
|
78 |
|
|
|
79 |
|
# 3. Put them together |
|
80 |
|
wt = whitebox.WhiteBox(f, my_problem) |
|
81 |
|
|
|
82 |
|
# choose filename to store samples and estimations |
|
83 |
|
gui.read_box(wt) |
|
84 |
|
# setup algorithm |
|
85 |
|
gui.setup_dicebox(wt) |
|
86 |
|
|
|
87 |
|
# start GUI |
|
88 |
|
gui.show_box(wt) |
|
89 |
|
``` |
|
90 |
|
|
|
91 |
|
## C. The same without GUI: |
|
92 |
|
``` |
|
93 |
|
import numpy as np |
|
94 |
|
import scipy.stats as stats |
|
95 |
|
|
|
96 |
|
from wellmet.samplebox import SampleBox |
|
97 |
|
from wellmet import f_models |
|
98 |
|
|
|
99 |
|
|
|
100 |
|
# 1. Set up probability distribution |
|
101 |
|
# Standard Gaussian variables, 2D |
|
102 |
|
#f = f_models.SNorm(2) |
|
103 |
|
# Just normal variables |
|
104 |
|
f = f_models.Norm(mean=[-1, 0], std=[2, 1]) |
|
105 |
|
# Independent non-Gaussian variables |
|
106 |
|
#f = f_models.UnCorD((stats.gumbel_r, stats.uniform)) |
|
107 |
|
# Correlated: |
|
108 |
|
# Nataf model with correlations of the respective _Gaussian_ marginals |
|
109 |
|
#f = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]]) |
|
110 |
|
|
|
111 |
|
# 2. Define LSF function |
|
112 |
|
def my_problem(input_sample): |
|
113 |
|
# get real (physical) space coordinates |
|
114 |
|
# X is a numpy array with shape (nsim, ndim) |
|
115 |
|
# the algorithm normally sends (1, ndim) sample |
|
116 |
|
X = input_sample.R |
|
117 |
|
# LSF |
|
118 |
|
g = X[:, 0] - X[:, 1] + 3 |
|
119 |
|
# we should return an instance of SampleBox class |
|
120 |
|
# it stores coordinates along with LSF calculation result |
|
121 |
|
# with kind of signature |
|
122 |
|
return SampleBox(input_sample, g, "my_problem") |
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
# 3. Prepare storage |
|
130 |
|
# no need to store anything |
|
131 |
|
#sample_box = SampleBox(f) |
|
132 |
|
|
|
133 |
|
# keep samples and estimations continiously stored |
|
134 |
|
from wellmet import reader |
|
135 |
|
sample_box = reader.Reader("meow_problem", f) |
|
136 |
|
|
|
137 |
|
# 4. Setup the algorithm |
|
138 |
|
from wellmet.dicebox.circumtri import CirQTri |
|
139 |
|
import quadpy |
|
140 |
|
|
|
141 |
|
scheme = quadpy.tn.stroud_tn_3_6b(sample_box.nvar) |
|
142 |
|
convex_hull_degree = 5 # degreee of Grundmann-Moeller cubature scheme |
|
143 |
|
q = 1 # should be > 0. Greater values slightly enforces exploration |
|
144 |
|
screening_rate = 0 # 10 means to sacrifice every tenth sample for screening |
|
145 |
|
box = CirQTri(sample_box, scheme, convex_hull_degree, q, screening_rate) |
|
146 |
|
|
|
147 |
|
|
|
148 |
|
# 5. Here we go! |
|
149 |
|
for i in range(20): |
|
150 |
|
# ask where to sample the next point |
|
151 |
|
# next_node is an f_model instance |
|
152 |
|
next_node = box() |
|
153 |
|
# call LSF |
|
154 |
|
new_sample = my_problem(next_node) |
|
155 |
|
# put calculation result to the box |
|
156 |
|
box.add_sample(new_sample) |
|
157 |
|
|
|
158 |
|
print(box.get_pf_estimation()) |
|
159 |
|
sensitivities_results = box.Tri.perform_sensitivity_analysis() |
|
160 |
|
print(sensitivities_results.sensitivities) |
|
161 |
|
``` |
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
This software has been developed under internal academic project no. FAST-K-21-6943 "Quality Internal Grants of BUT (KInG BUT)'' supported by the Czech Operational Programme ``Research, Development and Education'' (CZ.02.2.69/0.0/0.0/19\_073/0016948, managed by the Czech Ministry of Education. |
File cli_example.py added (mode: 100644) (index 0000000..6cd17c9) |
|
1 |
|
#!/usr/bin/env python |
|
2 |
|
# coding: utf-8 |
|
3 |
|
|
|
4 |
|
import numpy as np |
|
5 |
|
import scipy.stats as stats |
|
6 |
|
|
|
7 |
|
from wellmet.samplebox import SampleBox |
|
8 |
|
from wellmet import f_models |
|
9 |
|
|
|
10 |
|
|
|
11 |
|
# 1. Set up probability distribution |
|
12 |
|
# Standard Gaussian variables, 2D |
|
13 |
|
#f = f_models.SNorm(2) |
|
14 |
|
# Just normal variables |
|
15 |
|
f = f_models.Norm(mean=[-1, 0], std=[2, 1]) |
|
16 |
|
# Independent non-Gaussian variables |
|
17 |
|
#f = f_models.UnCorD((stats.gumbel_r, stats.uniform)) |
|
18 |
|
# Correlated: |
|
19 |
|
# Nataf model with correlations of the respective _Gaussian_ marginals |
|
20 |
|
#f = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]]) |
|
21 |
|
|
|
22 |
|
# 2. Define LSF function |
|
23 |
|
def my_problem(input_sample): |
|
24 |
|
# get real (physical) space coordinates |
|
25 |
|
# X is a numpy array with shape (nsim, ndim) |
|
26 |
|
# the algorithm normally sends (1, ndim) sample |
|
27 |
|
X = input_sample.R |
|
28 |
|
# LSF |
|
29 |
|
g = X[:, 0] - X[:, 1] + 3 |
|
30 |
|
# we should return an instance of SampleBox class |
|
31 |
|
# it stores coordinates along with LSF calculation result |
|
32 |
|
# with kind of signature |
|
33 |
|
return SampleBox(input_sample, g, "my_problem") |
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
# 3. Prepare storage |
|
41 |
|
# no need to store anything |
|
42 |
|
#sample_box = SampleBox(f) |
|
43 |
|
|
|
44 |
|
# keep samples and estimations continiously stored |
|
45 |
|
from wellmet import reader |
|
46 |
|
sample_box = reader.Reader("meow_problem", f) |
|
47 |
|
|
|
48 |
|
# 4. Setup the algorithm |
|
49 |
|
from wellmet.dicebox.circumtri import CirQTri |
|
50 |
|
import quadpy |
|
51 |
|
|
|
52 |
|
scheme = quadpy.tn.stroud_tn_3_6b(sample_box.nvar) |
|
53 |
|
convex_hull_degree = 5 # degreee of Grundmann-Möller cubature scheme |
|
54 |
|
q = 1 # should be > 0. Greater values slightly enforces exploration |
|
55 |
|
screening_rate = 0 # 10 means to sacrifice every tenth sample for screening |
|
56 |
|
box = CirQTri(sample_box, scheme, convex_hull_degree, q, screening_rate) |
|
57 |
|
|
|
58 |
|
|
|
59 |
|
# 5. Here we go! |
|
60 |
|
for i in range(20): |
|
61 |
|
# ask where to sample the next point |
|
62 |
|
# next_node is an f_model instance |
|
63 |
|
next_node = box() |
|
64 |
|
# call LSF |
|
65 |
|
new_sample = my_problem(next_node) |
|
66 |
|
# put calculation result to the box |
|
67 |
|
box.add_sample(new_sample) |
|
68 |
|
|
|
69 |
|
print(box.get_pf_estimation()) |
|
70 |
|
sensitivities_results = box.Tri.perform_sensitivity_analysis() |
|
71 |
|
print(sensitivities_results.sensitivities) |
|
72 |
|
|
|
73 |
|
|
File gui_example.py added (mode: 100644) (index 0000000..52ad825) |
|
1 |
|
#!/usr/bin/env python |
|
2 |
|
# coding: utf-8 |
|
3 |
|
|
|
4 |
|
import numpy as np |
|
5 |
|
import scipy.stats as stats |
|
6 |
|
|
|
7 |
|
from wellmet.qt_gui import qt_box_functions as gui |
|
8 |
|
from wellmet import whitebox |
|
9 |
|
from wellmet.samplebox import SampleBox |
|
10 |
|
from wellmet import f_models |
|
11 |
|
|
|
12 |
|
|
|
13 |
|
# 1. Set up probability distribution |
|
14 |
|
# Standard Gaussian variables, 2D |
|
15 |
|
#f = f_models.SNorm(2) |
|
16 |
|
# Just normal variables |
|
17 |
|
f = f_models.Norm(mean=[-1, 0], std=[2, 1]) |
|
18 |
|
# Independent non-Gaussian variables |
|
19 |
|
#f = f_models.UnCorD((stats.gumbel_r, stats.uniform)) |
|
20 |
|
# Correlated non-Gaussian marginals |
|
21 |
|
#f = f_models.Nataf((stats.gumbel_r, stats.weibull_min(c=1.5)), [[1,0.8], [0.8,1]]) |
|
22 |
|
|
|
23 |
|
# 2. Define LSF function |
|
24 |
|
def my_problem(input_sample): |
|
25 |
|
# get real (physical) space coordinates |
|
26 |
|
# X is a numpy array with shape (nsim, ndim) |
|
27 |
|
# the algorithm normally sends (1, ndim) sample |
|
28 |
|
X = input_sample.R |
|
29 |
|
# LSF |
|
30 |
|
g = X[:, 0] - X[:, 1] + 3 |
|
31 |
|
# we should return an instance of SampleBox class |
|
32 |
|
# this instance stores coordinates along with LSF calculation result |
|
33 |
|
return SampleBox(input_sample, g, "my_problem") |
|
34 |
|
|
|
35 |
|
# 3. Put them together |
|
36 |
|
wt = whitebox.WhiteBox(f, my_problem) |
|
37 |
|
|
|
38 |
|
# choose filename to store samples and estimations |
|
39 |
|
gui.read_box(wt) |
|
40 |
|
# algorithm setup |
|
41 |
|
gui.setup_dicebox(wt) |
|
42 |
|
|
|
43 |
|
# start GUI |
|
44 |
|
gui.show_box(wt) |
|
45 |
|
|
|
46 |
|
|