%22%22%22Check%20the%20handbook's%20blend-out%20repair%20life%20using%20Py-Fatigue.%22%22%22%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.26.0%22%0Aapp%20%3D%20marimo.App(css_file%3D%22..%2F..%2Fdocs%2Fstylesheets%2Fcustom.css%22)%0A%0A%0A%40app.cell%0Adef%20inputs()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20from%20notebooks._examples.afgrow%20import%20crack_history%2C%20native_paris_growth%0A%20%20%20%20from%20notebooks._examples.synthetic%20import%20(%0A%20%20%20%20%20%20%20%20display_indices%2C%0A%20%20%20%20%20%20%20%20plot_views%2C%0A%20%20%20%20%20%20%20%20synthetic_peaks%2C%0A%20%20%20%20)%0A%20%20%20%20from%20py_fatigue%20import%20ParisCurve%0A%20%20%20%20from%20py_fatigue.geometry%20import%20TabulatedGeometryFactor%0A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%20%20%20%20%23%20AFGROW%20handbook%20%C2%B7%20Edge%20crack%20after%20a%20blend-out%20repair%0A%0A%20%20%20%20%20%20%20%20Example%209.6.1%20compares%20an%20as-manufactured%20edge%20with%20a%20shallow%0A%20%20%20%20%20%20%20%20machined%20repair%20in%20a%207079-T6%20aluminum%20angle.%20Both%20start%20with%0A%20%20%20%20%20%20%20%20a%200.050%20in%20crack%20measured%20from%20the%20local%20surface.%20The%20published%0A%20%20%20%20%20%20%20%20load%20is%200%E2%80%9327%20ksi.%20The%20repair%20removes%200.080%20in%20of%20material%20and%0A%20%20%20%20%20%20%20%20has%20a%20short-crack%20stress%20concentration%20factor%20of%201.16.%0A%0A%20%20%20%20%20%20%20%20Use%20the%20handbook's%20Paris%20fit%20and%20its%20reported%20terminal%20crack%0A%20%20%20%20%20%20%20%20sizes%20of%200.325%20in%20and%200.245%20in.%20Compare%20the%20reported%20lives%2C%0A%20%20%20%20%20%20%20%20the%20analytic%20integral%20and%20Py-Fatigue's%20cycle-by-cycle%20result.%0A%20%20%20%20%20%20%20%20%5BUSAF%20DTD%20Handbook%2C%20Example%209.6.1%5D(https%3A%2F%2Fwww.afgrow.net%2Fapplications%2FDTDHandbook%2Fpdfs%2Fsec9_6.pdf)%0A%20%20%20%20%20%20%20%20%22%22%22)%0A%20%20%20%20coefficient%2C%20exponent%20%3D%205.84e-10%2C%204.09%0A%20%20%20%20curve%20%3D%20ParisCurve(exponent%2C%20coefficient%2C%20unit_string%3D%22ksi%20%E2%88%9Ain%22)%0A%20%20%20%20stress%20%3D%2027.0%0A%20%20%20%20initial%20%3D%200.050%0A%20%20%20%20blueprint_limit%20%3D%200.325%0A%20%20%20%20repair_depth%20%3D%200.080%0A%20%20%20%20concentration%20%3D%201.16%0A%20%20%20%20peaks%20%3D%20stress%20*%20synthetic_peaks()%20%2F%20100%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20TabulatedGeometryFactor%2C%0A%20%20%20%20%20%20%20%20blueprint_limit%2C%0A%20%20%20%20%20%20%20%20coefficient%2C%0A%20%20%20%20%20%20%20%20concentration%2C%0A%20%20%20%20%20%20%20%20crack_history%2C%0A%20%20%20%20%20%20%20%20curve%2C%0A%20%20%20%20%20%20%20%20display_indices%2C%0A%20%20%20%20%20%20%20%20exponent%2C%0A%20%20%20%20%20%20%20%20initial%2C%0A%20%20%20%20%20%20%20%20mo%2C%0A%20%20%20%20%20%20%20%20native_paris_growth%2C%0A%20%20%20%20%20%20%20%20np%2C%0A%20%20%20%20%20%20%20%20peaks%2C%0A%20%20%20%20%20%20%20%20plot_views%2C%0A%20%20%20%20%20%20%20%20plt%2C%0A%20%20%20%20%20%20%20%20repair_depth%2C%0A%20%20%20%20%20%20%20%20stress%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20analysis(%0A%20%20%20%20TabulatedGeometryFactor%2C%0A%20%20%20%20blueprint_limit%2C%0A%20%20%20%20coefficient%2C%0A%20%20%20%20concentration%2C%0A%20%20%20%20crack_history%2C%0A%20%20%20%20curve%2C%0A%20%20%20%20display_indices%2C%0A%20%20%20%20exponent%2C%0A%20%20%20%20initial%2C%0A%20%20%20%20mo%2C%0A%20%20%20%20native_paris_growth%2C%0A%20%20%20%20np%2C%0A%20%20%20%20peaks%2C%0A%20%20%20%20plot_views%2C%0A%20%20%20%20plt%2C%0A%20%20%20%20repair_depth%2C%0A%20%20%20%20stress%2C%0A)%3A%0A%20%20%20%20transition%20%3D%20repair_depth%20%2F%20(concentration**2%20-%201)%0A%20%20%20%20power%20%3D%201%20-%20exponent%20%2F%202%0A%20%20%20%20edge_factor%20%3D%201.12%0A%0A%20%20%20%20def%20life_between(start%2C%20end)%3A%0A%20%20%20%20%20%20%20%20return%20(end**power%20-%20start**power)%20%2F%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20power%0A%20%20%20%20%20%20%20%20%20%20%20%20*%20coefficient%0A%20%20%20%20%20%20%20%20%20%20%20%20*%20(edge_factor%20*%20stress%20*%20np.sqrt(np.pi))%20**%20exponent%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20_fig%2C%20axes%20%3D%20plt.subplots(3%2C%202%2C%20figsize%3D(11%2C%2011)%2C%20layout%3D%22constrained%22)%0A%20%20%20%20law%2C%20load%2C%20beta_plot%2C%20constant%2C%20variable%2C%20profile%20%3D%20axes.ravel()%0A%20%20%20%20curve.plot(ax%3Dlaw)%0A%20%20%20%20law.set(ylabel%3D%22Growth%20rate%20(in%2Fcycle)%22)%0A%20%20%20%20samples%20%3D%20display_indices(peaks.size)%0A%20%20%20%20load.plot(samples%20%2B%201%2C%20peaks%5Bsamples%5D)%0A%20%20%20%20load.axhline(stress%2C%20linestyle%3D%22--%22%2C%20label%3D%22Handbook%20range%22)%0A%20%20%20%20load.set(xlabel%3D%22Applied%20cycles%22%2C%20ylabel%3D%22Stress%20range%20(ksi)%22)%0A%20%20%20%20load.legend()%0A%20%20%20%20rows%20%3D%20%5B%5D%0A%20%20%20%20for%20index%2C%20(case%2C%20offset%2C%20published)%20in%20enumerate(%0A%20%20%20%20%20%20%20%20%5B(%22As%20manufactured%22%2C%200.0%2C%202910)%2C%20(%22Blend-out%22%2C%20repair_depth%2C%202033)%5D%0A%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20limit%20%3D%20blueprint_limit%20-%20offset%0A%20%20%20%20%20%20%20%20length%20%3D%20np.linspace(initial%2C%20limit%2C%201001)%0A%20%20%20%20%20%20%20%20factor%20%3D%20np.full_like(length%2C%20edge_factor)%0A%20%20%20%20%20%20%20%20reference%20%3D%20life_between(initial%2C%20length)%0A%20%20%20%20%20%20%20%20printed_life%20%3D%20reference%5B-1%5D%0A%20%20%20%20%20%20%20%20if%20offset%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20length%20%3D%20np.union1d(length%2C%20%5Btransition%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20factor%20%3D%20edge_factor%20*%20np.minimum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20concentration%2C%20np.sqrt((length%20%2B%20offset)%20%2F%20length)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20short_life%20%3D%20life_between(initial%2C%20np.minimum(length%2C%20transition))%0A%20%20%20%20%20%20%20%20%20%20%20%20long_life%20%3D%20life_between(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition%20%2B%20offset%2C%20np.maximum(length%2C%20transition)%20%2B%20offset%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20reference%20%3D%20short_life%20%2F%20concentration**exponent%20%2B%20long_life%0A%20%20%20%20%20%20%20%20%20%20%20%20printed_life%20%3D%20short_life%5B-1%5D%20%2F%20concentration**2%20%2B%20long_life%5B-1%5D%0A%0A%20%20%20%20%20%20%20%20geometry%20%3D%20TabulatedGeometryFactor(initial%2C%20length%2C%20factor)%0A%20%20%20%20%20%20%20%20(line%2C)%20%3D%20beta_plot.plot(length%2C%20factor%2C%20label%3Dcase)%0A%20%20%20%20%20%20%20%20color%20%3D%20line.get_color()%0A%20%20%20%20%20%20%20%20native_constant%20%3D%20native_paris_growth(%0A%20%20%20%20%20%20%20%20%20%20%20%20geometry%2C%20curve%2C%20np.full_like(peaks%2C%20stress)%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20native_variable%20%3D%20native_paris_growth(geometry%2C%20curve%2C%20peaks)%0A%20%20%20%20%20%20%20%20history%2C%20_%20%3D%20crack_history(length%2C%20reference%2C%20peaks%20%2F%20stress%2C%20exponent)%0A%20%20%20%20%20%20%20%20saved%20%3D%20display_indices(history.size)%0A%20%20%20%20%20%20%20%20constant.plot(reference%2C%20length%2C%20%22--%22%2C%20color%3Dcolor)%0A%20%20%20%20%20%20%20%20variable.plot(saved%2C%20history%5Bsaved%5D%2C%20%22--%22%2C%20color%3Dcolor)%0A%20%20%20%20%20%20%20%20for%20axis%2C%20result%20in%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20(constant%2C%20native_constant)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20(variable%2C%20native_variable)%2C%0A%20%20%20%20%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20depth_history%20%3D%20result.crack_depth%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20result.termination%20%3D%3D%20%22geometry_limit%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20depth_history%20%3D%20np.r_%5Bdepth_history%2C%20limit%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20saved%20%3D%20display_indices(depth_history.size)%0A%20%20%20%20%20%20%20%20%20%20%20%20axis.plot(saved%2C%20depth_history%5Bsaved%5D%2C%20color%3Dcolor%2C%20label%3Dcase)%0A%0A%20%20%20%20%20%20%20%20final%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20limit%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20native_variable.termination%20%3D%3D%20%22geometry_limit%22%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20native_variable.crack_depth%5B-1%5D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20profile.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Boffset%2C%20offset%20%2B%20final%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Bindex%2C%20index%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22-%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3Dcolor%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Dcase%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20profile.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Boffset%2C%20offset%20%2B%20initial%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Bindex%2C%20index%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22k--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Initial%22%20if%20index%20%3D%3D%200%20else%20%22_initial%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20profile.plot(%5Boffset%5D%2C%20%5Bindex%5D%2C%20%22%7C%22%2C%20color%3D%22black%22%2C%20markersize%3D12)%0A%20%20%20%20%20%20%20%20rows.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Geometry%22%3A%20case%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Handbook%20reported%20cycles%22%3A%20published%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Handbook%20printed%20integral%22%3A%20round(printed_life)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Paris%20equation%20integral%22%3A%20round(reference%5B-1%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Py-Fatigue%20cycles%22%3A%20int(native_constant.final_cycles)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Variable%20Py-Fatigue%20cycles%22%3A%20int(native_variable.final_cycles)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20beta_plot.set(xlabel%3D%22Crack%20length%20(in)%22%2C%20ylabel%3D%22Geometry%20factor%22)%0A%20%20%20%20constant.set(xlabel%3D%22Constant-amplitude%20cycles%22%2C%20ylabel%3D%22Crack%20length%20(in)%22)%0A%20%20%20%20variable.set(xlabel%3D%22Variable-amplitude%20cycles%22%2C%20ylabel%3D%22Crack%20length%20(in)%22)%0A%20%20%20%20profile.set(%0A%20%20%20%20%20%20%20%20xlabel%3D%22Distance%20from%20original%20edge%20(in)%22%2C%0A%20%20%20%20%20%20%20%20title%3D%22Crack%20profiles%20%C2%B7%20bars%20mark%20local%20edges%22%2C%0A%20%20%20%20%20%20%20%20yticks%3D%5B0%2C%201%5D%2C%0A%20%20%20%20%20%20%20%20yticklabels%3D%5B%22Original%22%2C%20%22Repair%22%5D%2C%0A%20%20%20%20)%0A%20%20%20%20for%20axis%20in%20(beta_plot%2C%20constant%2C%20variable%2C%20profile)%3A%0A%20%20%20%20%20%20%20%20axis.legend(fontsize%3D%22small%22)%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%23%20Check%20the%20published%20life%20calculation%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20The%20handbook%20uses%20a%20Paris%20fit%20to%20data%20at%20R%20%3D%200.05%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20this%20R%20%3D%200%20example.%20Its%20short-crack%20factor%20is%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201.12%20k%E2%82%9C.%20Its%20long-crack%20factor%20is%201.12%20%E2%88%9A((a%20%2B%20d)%20%2F%20a).%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20They%20meet%20at%20**%7Btransition%3A.3f%7D%20in**.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Substitution%20in%20the%20Paris%20law%20makes%20the%20short-crack%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20life%20scale%20by%201%2Fk%E2%82%9C%E2%81%BF.%20The%20printed%20repair%20integral%20uses%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%2Fk%E2%82%9C%C2%B2.%20The%20table%20evaluates%20both%20expressions%2C%20using%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20handbook%E2%80%99s%20reported%20terminal%20sizes.%20The%20printed%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20integrals%20also%20differ%20from%20the%20reported%20cycle%20counts.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Dashed%20lines%20show%20the%20analytic%20histories%20using%201%2Fk%E2%82%9C%E2%81%BF.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Solid%20lines%20show%20Py-Fatigue.%20The%20variable-load%20run%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20makes%20**%7Bpeaks.size%3A%2C%7D%20synthetic%20cycles**%20available%20and%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20uses%20the%20same%20crack-length%20endpoints%20for%20comparison.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.table(rows)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20plot_views(_fig)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
1cec41294941681fd952979ed6e9c5c5