%22%22%22Reproduce%20the%20MERC-3%20longeron%20life%20and%20apply%20a%20variable%20load%20history.%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%20model()%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%20(%0A%20%20%20%20%20%20%20%20MERC3_COEFFICIENT%2C%0A%20%20%20%20%20%20%20%20MERC3_DIGITIZED%2C%0A%20%20%20%20%20%20%20%20MERC3_EXPONENT%2C%0A%20%20%20%20%20%20%20%20MERC3_FINAL_LENGTH%2C%0A%20%20%20%20%20%20%20%20MERC3_INITIAL_LENGTH%2C%0A%20%20%20%20%20%20%20%20MERC3_PUBLISHED_CYCLES%2C%0A%20%20%20%20%20%20%20%20MERC3_STRESS_RANGE%2C%0A%20%20%20%20%20%20%20%20crack_history%2C%0A%20%20%20%20%20%20%20%20merc3_geometry_factors%2C%0A%20%20%20%20%20%20%20%20native_paris_growth%2C%0A%20%20%20%20%20%20%20%20paris_reference_cycles%2C%0A%20%20%20%20)%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%20MERC-3%20%C2%B7%20Life%20of%20an%20aircraft%20longeron%0A%0A%20%20%20%20%20%20%20%20Follow%20the%20through-crack%20path%20from%20a%20fastener%20hole%20toward%20the%0A%20%20%20%20%20%20%20%20longeron%20edge.%20Define%20the%20geometry%20by%20its%20published%20%CE%B2(a)%20data%0A%20%20%20%20%20%20%20%20and%20use%20the%207075-T6%20aluminum%20Paris%20fit%20at%20R%20%3D%200%20from%20Figure%0A%20%20%20%20%20%20%20%20MERC-3.1.%20Use%20inches%20and%20ksi%20throughout%20the%20analysis.%0A%0A%20%20%20%20%20%20%20%20Reconstruct%20the%20handbook's%20constant-range%20lives%20independently%0A%20%20%20%20%20%20%20%20and%20run%20the%20same%20cases%20with%20Py-Fatigue's%20crack-growth%20solver.%0A%20%20%20%20%20%20%20%20Compare%20both%20methods%20again%20under%20a%20seeded%20variable-amplitude%0A%20%20%20%20%20%20%20%20history%2C%20using%201.25%20in%20as%20the%20end%20of%20each%20geometry%20table.%0A%20%20%20%20%20%20%20%20%5BUSAF%20DTD%20Handbook%2C%20MERC-3%5D(https%3A%2F%2Fwww.afgrow.net%2Fapplications%2FDTDHandbook%2FExamples%2Fpage2_2.aspx)%0A%20%20%20%20%20%20%20%20%22%22%22)%0A%20%20%20%20curve%20%3D%20ParisCurve(%0A%20%20%20%20%20%20%20%20slope%3DMERC3_EXPONENT%2C%20intercept%3DMERC3_COEFFICIENT%2C%20unit_string%3D%22ksi%20%E2%88%9Ain%22%0A%20%20%20%20)%0A%20%20%20%20length%20%3D%20np.linspace(MERC3_INITIAL_LENGTH%2C%20MERC3_FINAL_LENGTH%2C%201201)%0A%20%20%20%20factors%20%3D%20merc3_geometry_factors(length)%0A%20%20%20%20%23%20The%20generated%20peaks%20are%20in%20MPa.%20Use%20zero%20as%20the%20minimum%20for%20R%20%3D%200.%0A%20%20%20%20stress_range%20%3D%20synthetic_peaks()%20%2F%206.894757293168%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20MERC3_COEFFICIENT%2C%0A%20%20%20%20%20%20%20%20MERC3_DIGITIZED%2C%0A%20%20%20%20%20%20%20%20MERC3_EXPONENT%2C%0A%20%20%20%20%20%20%20%20MERC3_PUBLISHED_CYCLES%2C%0A%20%20%20%20%20%20%20%20MERC3_STRESS_RANGE%2C%0A%20%20%20%20%20%20%20%20TabulatedGeometryFactor%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%20factors%2C%0A%20%20%20%20%20%20%20%20length%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%20paris_reference_cycles%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%20stress_range%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20results(%0A%20%20%20%20MERC3_COEFFICIENT%2C%0A%20%20%20%20MERC3_DIGITIZED%2C%0A%20%20%20%20MERC3_EXPONENT%2C%0A%20%20%20%20MERC3_PUBLISHED_CYCLES%2C%0A%20%20%20%20MERC3_STRESS_RANGE%2C%0A%20%20%20%20TabulatedGeometryFactor%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%20factors%2C%0A%20%20%20%20length%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%20paris_reference_cycles%2C%0A%20%20%20%20plot_views%2C%0A%20%20%20%20plt%2C%0A%20%20%20%20stress_range%2C%0A)%3A%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%20curve.plot(ax%3Daxes%5B0%2C%200%5D%2C%20scale%3D%22loglog%22)%0A%20%20%20%20axes%5B0%2C%200%5D.set(ylabel%3D%22Growth%20rate%20(in%2Fcycle)%22)%0A%20%20%20%20indices%20%3D%20display_indices(stress_range.size)%0A%20%20%20%20axes%5B0%2C%201%5D.plot(indices%20%2B%201%2C%20stress_range%5Bindices%5D)%0A%20%20%20%20axes%5B0%2C%201%5D.set(xlabel%3D%22Applied%20cycles%22%2C%20ylabel%3D%22Stress%20range%20(ksi)%22)%0A%20%20%20%20geometry%2C%20constant%2C%20variable%2C%20profile%20%3D%20(%0A%20%20%20%20%20%20%20%20axes%5B1%2C%200%5D%2C%0A%20%20%20%20%20%20%20%20axes%5B1%2C%201%5D%2C%0A%20%20%20%20%20%20%20%20axes%5B2%2C%200%5D%2C%0A%20%20%20%20%20%20%20%20axes%5B2%2C%201%5D%2C%0A%20%20%20%20)%0A%20%20%20%20geometry.plot(*MERC3_DIGITIZED.T%2C%20%22k.%22%2C%20label%3D%22Digitized%20samples%22)%0A%20%20%20%20reference_stress%20%3D%20np.full_like(stress_range%2C%20MERC3_STRESS_RANGE)%0A%20%20%20%20rows%20%3D%20%5B%5D%0A%20%20%20%20for%20i%2C%20(case%2C%20geometry_factor)%20in%20enumerate(factors.items())%3A%0A%20%20%20%20%20%20%20%20reference_k%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20MERC3_STRESS_RANGE%20*%20geometry_factor%20*%20np.sqrt(np.pi%20*%20length)%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20reference%20%3D%20paris_reference_cycles(%0A%20%20%20%20%20%20%20%20%20%20%20%20length%2C%20reference_k%2C%20MERC3_COEFFICIENT%2C%20MERC3_EXPONENT%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20factor_table%20%3D%20TabulatedGeometryFactor(%0A%20%20%20%20%20%20%20%20%20%20%20%20length%5B0%5D%2C%20length%2C%20geometry_factor%0A%20%20%20%20%20%20%20%20)%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%20factor_table%2C%20curve%2C%20reference_stress%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20native_variable%20%3D%20native_paris_growth(factor_table%2C%20curve%2C%20stress_range)%0A%20%20%20%20%20%20%20%20history%2C%20reached%20%3D%20crack_history(%0A%20%20%20%20%20%20%20%20%20%20%20%20length%2C%20reference%2C%20stress_range%20%2F%20MERC3_STRESS_RANGE%2C%20MERC3_EXPONENT%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20saved%20%3D%20display_indices(history.size)%0A%20%20%20%20%20%20%20%20(beta_line%2C)%20%3D%20geometry.plot(length%2C%20geometry_factor%2C%20label%3Dcase)%0A%20%20%20%20%20%20%20%20color%20%3D%20beta_line.get_color()%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%20depths%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%20depths%20%3D%20np.r_%5Bdepths%2C%20length%5B-1%5D%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20native_samples%20%3D%20display_indices(depths.size)%0A%20%20%20%20%20%20%20%20%20%20%20%20axis.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20native_samples%2C%20depths%5Bnative_samples%5D%2C%20color%3Dcolor%2C%20label%3Dcase%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20final_length%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20length%5B-1%5D%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%5B0%2C%20final_length%5D%2C%20%5Bi%2C%20i%5D%2C%20color%3Dcolor%2C%20label%3Df%22%7Bcase%7D%20final%22%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%5B0%2C%20length%5B0%5D%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Bi%2C%20i%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%20i%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%20published%20%3D%20MERC3_PUBLISHED_CYCLES%5Bcase%5D%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%22Case%22%3A%20case%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Handbook%20cycles%22%3A%20published%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Reconstructed%20cycles%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%22Py-Fatigue%20vs%20handbook%20(%25)%22%3A%20round(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20100%20*%20(native_constant.final_cycles%20%2F%20published%20-%201)%2C%202%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Variable%20reference%20cycles%22%3A%20history.size%20-%201%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%20%20%20%20%22Variable%20reference%20outcome%22%3A%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Target%20length%22%20if%20reached%20else%20%22Spectrum%20ended%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Variable%20Py-Fatigue%20stop%22%3A%20native_variable.termination.replace(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22_%22%2C%20%22%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%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%20geometry.set(xlabel%3D%22Crack%20length%20(in)%22%2C%20ylabel%3D%22Geometry%20factor%20%CE%B2%22)%0A%20%20%20%20constant.set(xlabel%3D%22Constant-range%20cycles%22%2C%20ylabel%3D%22Crack%20length%20(in)%22)%0A%20%20%20%20variable.set(xlabel%3D%22Applied%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%20crack%20origin%20(in)%22%2C%20title%3D%22Crack%20path%20schematic%22%0A%20%20%20%20)%0A%20%20%20%20profile.yaxis.set_visible(False)%0A%20%20%20%20for%20axis%20in%20(geometry%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(%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%23%20Compare%20the%20handbook%2C%20numerical%20reconstruction%20and%20Py-Fatigue%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20Interpolate%20the%20digitized%20%CE%B2%20curve%20and%20hold%20the%20last%20sample%0A%20%20%20%20%20%20%20%20%20%20%20%20from%201.235%20to%201.25%20in.%20Apply%20the%20handbook's%2010%25%20perturbations%0A%20%20%20%20%20%20%20%20%20%20%20%20to%20the%20small%20and%20large%20%CE%B2%20values.%20Compute%20%CE%94K%20at%20the%2010%20ksi%0A%20%20%20%20%20%20%20%20%20%20%20%20reference%20range%20and%20integrate%20the%20inverse%20growth%20rate%20in%0A%20%20%20%20%20%20%20%20%20%20%20%20crack%20length.%20Py-Fatigue%20instead%20advances%20the%20crack%20one%20cycle%0A%20%20%20%20%20%20%20%20%20%20%20%20at%20a%20time%20with%20%60get_crack_growth%60%20and%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20%60TabulatedGeometryFactor%60.%20Dashed%20lines%20show%20the%20independent%0A%20%20%20%20%20%20%20%20%20%20%20%20reconstruction.%20Solid%20lines%20show%20Py-Fatigue.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20The%20variable-amplitude%20run%20advances%20that%20reference%20history%0A%20%20%20%20%20%20%20%20%20%20%20%20by%20(%CE%94%CF%83%20%2F%2010%20ksi)%E2%81%BF%20equivalent%20cycles%20per%20applied%20cycle.%20This%0A%20%20%20%20%20%20%20%20%20%20%20%20follows%20from%20the%20single-slope%20Paris%20law%20at%20R%20%3D%200.%20The%20two%0A%20%20%20%20%20%20%20%20%20%20%20%20inputs%20are%20separable%20because%20%CE%94K%20is%20proportional%20to%20stress%0A%20%20%20%20%20%20%20%20%20%20%20%20range%20for%20a%20given%20crack%20length.%20The%20full%20300%2C000-cycle%0A%20%20%20%20%20%20%20%20%20%20%20%20spectrum%20is%20available%20to%20each%20case.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20MERC-1%E2%80%99s%20full%20center-wing%20prediction%20uses%20an%20unpublished%20load%0A%20%20%20%20%20%20%20%20%20%20%20%20spectrum%20and%20material%20curve%2C%20plus%20Willenborg%20retardation.%0A%20%20%20%20%20%20%20%20%20%20%20%20MERC-3%20publishes%20the%20inputs%20needed%20for%20this%20life%20comparison.%0A%20%20%20%20%20%20%20%20%20%20%20%20%5BMERC-1%20model%20description%5D(https%3A%2F%2Fwww.afgrow.net%2Fapplications%2FDTDHandbook%2FExamples%2Fpage2_0.aspx)%0A%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
24421d23d96c9e82b22ac673074d44b1