Skip to content

Commit

Permalink
fix code dup (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
vb64 authored Dec 2, 2023
1 parent ae8b72d commit 34318d0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pipeline_integrity/method/asme/b31g_2012.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,8 @@ def get_stress_fail(self):
"(1 - 2/3 * (depth / wallthickness) / M).",
self
),
'\n', "stress_fail = {} * (1 - 2/3 * ({} / {})) / (1 - 2/3 * ({} / {} / {})) = {}.".format(
round(s_f, EXPL_ROUND),
round(self.anomaly.depth, EXPL_ROUND), round(self.anomaly.pipe.wallthickness, EXPL_ROUND),
round(self.anomaly.depth, EXPL_ROUND), round(self.anomaly.pipe.wallthickness, EXPL_ROUND),
round(m_val, EXPL_ROUND), round(s_p, EXPL_ROUND),
),

'\n', self.explain_stress_fail(s_f, m_val, s_p),
])

return s_p
Expand All @@ -137,6 +133,18 @@ def get_stress_fail(self):

return s_p

def explain_stress_fail(self, s_f, m_val, s_p):
"""Return text that explain stress_fail calculation."""
return "stress_fail = {} * (1 - 0.85 * ({} / {})) / (1 - 0.85 * ({} / {}) / {}) = {}.".format(
round(s_f, EXPL_ROUND),
round(self.anomaly.depth, EXPL_ROUND),
round(self.anomaly.pipe.wallthickness, EXPL_ROUND),
round(self.anomaly.depth, EXPL_ROUND),
round(self.anomaly.pipe.wallthickness, EXPL_ROUND),
round(m_val, EXPL_ROUND),
round(s_p, EXPL_ROUND),
)

def get_stress_fail_mod(self):
"""Return estimated failure stress level by modified method."""
self.add_explain([
Expand Down Expand Up @@ -178,15 +186,7 @@ def get_stress_fail_mod(self):
"(1 - 0.85 * (depth / wallthickness) / M).",
self
),
'\n', "stress_fail = {} * (1 - 0.85 * ({} / {})) / (1 - 0.85 * ({} / {}) / {}) = {}.".format(
round(s_f, EXPL_ROUND),
round(self.anomaly.depth, EXPL_ROUND),
round(self.anomaly.pipe.wallthickness, EXPL_ROUND),
round(self.anomaly.depth, EXPL_ROUND),
round(self.anomaly.pipe.wallthickness, EXPL_ROUND),
round(m_val, EXPL_ROUND),
round(s_p, EXPL_ROUND),
),
'\n', self.explain_stress_fail(s_f, m_val, s_p),
])

return s_p
Expand Down

0 comments on commit 34318d0

Please sign in to comment.