forked from pystra/pystra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
executable file
·59 lines (42 loc) · 1.46 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
# import pyre library
from pyre import *
import time
import datetime
start_time = time.time()
# Define a main() function.
def main():
# Define random variables
X1 = Lognormal('X1',500,100)
X2 = Normal('X2',2000,400)
X3 = Uniform('X3',5,0.5)
# If the random variables are correlatet, then define a correlation matrix,
# else no correlatin matrix is needed
Corr = CorrelationMatrix([[1.0, 0.3, 0.2],
[0.3, 1.0, 0.2],
[0.2, 0.2, 1.0]])
# Define limit state function
# - case 1: define directly
# g = LimitStateFunction('1 - X2*(1000*X3)**(-1) - (X1*(200*X3)**(-1))**2')
# - case 2: define load function, wich is defined in function.py
g = LimitStateFunction('function(X1,X2,X3)')
# Set some options (optional)
options = AnalysisOptions()
# options.printResults(False)
# Performe FORM analysis
Analysis = Form(options)
# Performe Distribution analysis
# Analysis = DistributionAnalysis(options)
# Performe Crude Monte Carlo Simulation
# Analysis = CrudeMonteCarlo(options)
# Performe Importance Sampling
# Analysis = ImportanceSampling(options)
# Some single results:
# beta = Analysis.getBeta()
# failure = Analysis.getFailure()
run_time = time.time() - start_time
print str(datetime.timedelta(seconds=run_time))
# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
main()