diff --git a/pipeline_integrity/method/asme/b31g_2012.py b/pipeline_integrity/method/asme/b31g_2012.py index 93a0b7f..f3727f4 100644 --- a/pipeline_integrity/method/asme/b31g_2012.py +++ b/pipeline_integrity/method/asme/b31g_2012.py @@ -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 @@ -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([ @@ -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