Skip to content

Commit

Permalink
Minor changes to fix reliability examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtsap committed Jul 27, 2023
1 parent ee0fa3e commit 174d578
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
dist3 = Normal(loc=4., scale=0.4)

model = PythonModel(model_script='local_pfn.py', model_object_name="example3",)
RunModelObject3 = RunModel(model=model)
run_model = RunModel(model=model)

Z0 = FORM(distributions=[dist1, dist2, dist3], runmodel_object=RunModelObject3)
Z0.run()
form = FORM(distributions=[dist1, dist2, dist3], runmodel_object=run_model)
form.run()

print('Design point in standard normal space: %s' % Z0.design_point_u)
print('Design point in original space: %s' % Z0.design_point_x)
print('Hasofer-Lind reliability index: %s' % Z0.beta)
print('FORM probability of failure: %s' % Z0.failure_probability)
print('Design point in standard normal space: %s' % form.design_point_u)
print('Design point in original space: %s' % form.design_point_x)
print('Hasofer-Lind reliability index: %s' % form.beta)
print('FORM probability of failure: %s' % form.failure_probability)

8 changes: 8 additions & 0 deletions docs/code/reliability/sorm/local_model4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import numpy as np


def example4(samples=None):
g = np.zeros(samples.shape[0])
for i in range(samples.shape[0]):
g[i] = samples[i, 0] * samples[i, 1] - 80
return g
18 changes: 8 additions & 10 deletions docs/code/reliability/sorm/local_pfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,31 @@
"""
import numpy as np


def example1(samples=None):
g = np.zeros(samples.shape[0])
for i in range(samples.shape[0]):
for i in range(samples.shape[0]):
R = samples[i, 0]
S = samples[i, 1]
g[i] = R - S
return g


def example2(samples=None):
import numpy as np
d = 2
beta = 3.0902
g = np.zeros(samples.shape[0])
for i in range(samples.shape[0]):
g[i] = -1/np.sqrt(d) * (samples[i, 0] + samples[i, 1]) + beta
g[i] = -1 / np.sqrt(d) * (samples[i, 0] + samples[i, 1]) + beta
return g


def example3(samples=None):
g = np.zeros(samples.shape[0])
for i in range(samples.shape[0]):
g[i] = 6.2*samples[i, 0] - samples[i, 1]*samples[i, 2]**2
g[i] = 6.2 * samples[i, 0] - samples[i, 1] * samples[i, 2] ** 2
return g

def example4(samples=None):
g = np.zeros(samples.shape[0])
for i in range(samples.shape[0]):
g[i] = samples[i, 0]*samples[i, 1] - 80
return g



6 changes: 3 additions & 3 deletions docs/code/reliability/sorm/plot_SORM_nonlinear_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

dist1 = Normal(loc=20., scale=2)
dist2 = Lognormal(s=s, loc=0.0, scale=scale)
model = PythonModel(model_script='local_pfn.py', model_object_name="example4",)
model = PythonModel(model_script='local_model4.py', model_object_name="example4")
RunModelObject4 = RunModel(model=model)
form = FORM(distributions=[dist1, dist2], runmodel_object=RunModelObject4)
form.run()
Q0 = SORM(form_object=form)
sorm = SORM(form_object=form)


# print results
print('SORM probability of failure: %s' % Q0.failure_probability)
print('SORM probability of failure: %s' % sorm.failure_probability)

0 comments on commit 174d578

Please sign in to comment.