%22%22%22Reproduce%20the%20MERC-3%20worked%20crack-growth%20example.%22%22%22%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.26.0%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22%2C%20css_file%3D%22..%2Fdocs%2Fstylesheets%2Fcustom.css%22)%0A%0A%0A%40app.cell%0Adef%20introduction()%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%0A%20%20%20%20from%20_examples.charts%20import%20plot_views%0A%20%20%20%20from%20_examples.synthetic%20import%20display_indices%0A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%20%20%20%20%23%20MERC-3%20%C2%B7%20Crack-growth%20sensitivity%0A%0A%20%20%20%20%20%20%20%20How%20much%20does%20an%20error%20in%20the%20geometry%20factor%20%CE%B2%20change%20predicted%0A%20%20%20%20%20%20%20%20life%3F%20Follow%20the%20handbook's%20constant-%CE%B2%20derivation%2C%20then%20reproduce%0A%20%20%20%20%20%20%20%20the%20aircraft%20longeron%20example%20with%20a%20variable%20%CE%B2.%0A%0A%20%20%20%20%20%20%20%20Both%20calculations%20use%20the%20handbook's%20Paris%20fit%20for%207075-T6%20Al%0A%20%20%20%20%20%20%20%20at%20R%20%3D%200%2C%20with%20exponent%203.6%20and%20coefficient%202.5%20%C3%97%2010%E2%81%BB%E2%81%B9%20in%20the%0A%20%20%20%20%20%20%20%20inch-cycle%20and%20ksi%20%E2%88%9Ain%20unit%20system.%20The%20stress%20range%20is%2010%20ksi.%0A%20%20%20%20%20%20%20%20The%20crack%20grows%20from%200.05%20to%201.25%20in.%0A%20%20%20%20%20%20%20%20%5BHandbook%20problem%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%20return%20display_indices%2C%20mo%2C%20np%2C%20plot_views%2C%20plt%0A%0A%0A%40app.cell%0Adef%20constant_factor(display_indices%2C%20mo%2C%20plot_views%2C%20plt)%3A%0A%20%20%20%20from%20_examples.afgrow%20import%20merc3_constant_beta%0A%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(7%2C%204)%2C%20layout%3D%22constrained%22)%0A%20%20%20%20_rows%20%3D%20%5B%5D%0A%20%20%20%20for%20_beta%20in%20(1.0%2C%201.1)%3A%0A%20%20%20%20%20%20%20%20_exact%2C%20_result%20%3D%20merc3_constant_beta(_beta)%0A%20%20%20%20%20%20%20%20_indices%20%3D%20display_indices(_result.crack_depth.size)%0A%20%20%20%20%20%20%20%20_ax.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20_indices%2C%20_result.crack_depth%5B_indices%5D%2C%20label%3Df%22%CE%B2%20%3D%20%7B_beta%3Ag%7D%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20_rows.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%22%CE%B2%22%3A%20_beta%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Eq.%20(11)%2C%20cycles%22%3A%20round(_exact%2C%201)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22py-fatigue%2C%20cycles%22%3A%20int(_result.final_cycles)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Difference%2C%20cycles%22%3A%20round(_result.final_cycles%20-%20_exact%2C%201)%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%20_ax.set(xlabel%3D%22Cycles%22%2C%20ylabel%3D%22Crack%20length%20(in)%22)%0A%20%20%20%20_ax.legend()%0A%20%20%20%20_drop%20%3D%201%20-%20_rows%5B1%5D%5B%22Eq.%20(11)%2C%20cycles%22%5D%20%2F%20_rows%5B0%5D%5B%22Eq.%20(11)%2C%20cycles%22%5D%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(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%23%23%20Constant%20geometry%20factor%5Cn%5Cn%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22With%20constant%20%CE%B2%2C%20%CE%94K%20%3D%20%CE%B2%20%CE%94%CF%83%20%E2%88%9A(%CF%80a).%20The%20exact%20life%20in%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Eq.%20(11)%20comes%20from%20integrating%20the%20inverse%20Paris%20rate.%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22In%20py-fatigue%2C%20the%20unit-factor%20%60InfiniteSurface%60%20takes%20the%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22effective%20range%20%CE%B2%20%CE%94%CF%83.%20Set%20%60ParisCurve.critical%60%20to%20the%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22intensity%20at%201.25%20in%20so%20the%20native%20solver%20reaches%20the%20same%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22end%20criterion.%20Give%20it%20a%20stress%20history%201%25%20longer%20than%20the%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22analytical%20life%20to%20let%20the%20stop%20occur%20with%20one-cycle%20steps.%5Cn%5Cn%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22Increasing%20%CE%B2%20by%2010%25%20shortens%20the%20exact%20life%20by%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7B_drop%3A.1%25%7D.%20The%20handbook's%20%E2%88%923.6%20sensitivity%20gives%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20first-order%20estimate%20of%20a%2036%25%20reduction.%22%0A%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%20mo.ui.table(_rows)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20plot_views(_fig%2C%20height%3D%22460px%22)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20longeron(mo%2C%20np%2C%20plot_views%2C%20plt)%3A%0A%20%20%20%20from%20_examples.afgrow%20import%20(%0A%20%20%20%20%20%20%20%20MERC3_DIGITIZED%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_beta_histories%2C%0A%20%20%20%20)%0A%0A%20%20%20%20length%20%3D%20np.linspace(MERC3_INITIAL_LENGTH%2C%20MERC3_FINAL_LENGTH%2C%201201)%0A%20%20%20%20histories%20%3D%20merc3_beta_histories(length)%0A%20%20%20%20_fig%2C%20(_beta_ax%2C%20_life_ax)%20%3D%20plt.subplots(%0A%20%20%20%20%20%20%20%202%2C%201%2C%20figsize%3D(7%2C%207)%2C%20layout%3D%22constrained%22%0A%20%20%20%20)%0A%20%20%20%20_rows%20%3D%20%5B%5D%0A%20%20%20%20for%20_case%2C%20(_beta%2C%20_cycles)%20in%20histories.items()%3A%0A%20%20%20%20%20%20%20%20_beta_ax.plot(length%2C%20_beta%2C%20label%3D_case)%0A%20%20%20%20%20%20%20%20_life_ax.plot(_cycles%2C%20length%2C%20label%3D_case)%0A%20%20%20%20%20%20%20%20_published%20%3D%20MERC3_PUBLISHED_CYCLES%5B_case%5D%0A%20%20%20%20%20%20%20%20_rows.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%20_case%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Handbook%20cycles%22%3A%20_published%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Calculated%20cycles%22%3A%20round(_cycles%5B-1%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Difference%20from%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(_cycles%5B-1%5D%20%2F%20_published%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%7D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20_beta_ax.plot(*MERC3_DIGITIZED.T%2C%20%22k.%22%2C%20label%3D%22Digitized%20samples%22)%0A%20%20%20%20_beta_ax.set(xlabel%3D%22Crack%20length%20(in)%22%2C%20ylabel%3D%22Geometry%20factor%20%CE%B2%22)%0A%20%20%20%20_life_ax.set(xlabel%3D%22Cycles%22%2C%20ylabel%3D%22Crack%20length%20(in)%22)%0A%20%20%20%20_beta_ax.legend()%0A%20%20%20%20_life_ax.legend()%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%20%20%20%20%23%23%20Variable%20%CE%B2%20in%20the%20longeron%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Interpolate%20the%20samples%20digitized%20from%20Figure%20MERC-3.4.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20The%20final%20sample%20is%20at%201.235%20in.%20Hold%20its%20%CE%B2%20through%201.25%20in.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Follow%20the%20handbook's%2010%25%20increases%20at%20%CE%B2%20%E2%89%A5%203%20and%20%CE%B2%20%E2%89%A4%201%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20with%20linear%20transitions%20between%20those%20values.%20Calculate%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20each%20local%20rate%20from%20the%20published%20Paris%20equation%20and%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20integrate%20its%20reciprocal%20over%20crack%20length.%20Tutorial%2040%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20compares%20this%20calculation%20with%20%60get_crack_growth%60.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Compare%20the%20resulting%20lives%20with%20Figure%20MERC-3.5.%20The%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20small-%CE%B2%20correction%20has%20a%20larger%20effect%20because%20the%20crack%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20spends%20more%20cycles%20in%20that%20part%20of%20the%20history.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5BDigitized%20%CE%B2%20source%5D(https%3A%2F%2Fwww.afgrow.net%2Fapplications%2FDTDHandbook%2FExamples%2Fimages%2Fpage2_3%2Fimage055.gif)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%C2%B7%20%5BPublished%20crack-growth%20lives%5D(https%3A%2F%2Fwww.afgrow.net%2Fapplications%2FDTDHandbook%2FExamples%2Fimages%2Fpage2_3%2Fimage057.gif)%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%20height%3D%22860px%22)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%20histories%2C%20length%0A%0A%0A%40app.cell%0Adef%20long_case(display_indices%2C%20histories%2C%20length%2C%20np%2C%20plt)%3A%0A%20%20%20%20from%20_examples.afgrow%20import%20MERC3_EXPONENT%2C%20MERC3_STRESS_RANGE%0A%20%20%20%20from%20_examples.synthetic%20import%20(%0A%20%20%20%20%20%20%20%20MINIMUM_STRESS%2C%0A%20%20%20%20%20%20%20%20long_case_view%2C%0A%20%20%20%20%20%20%20%20synthetic_peaks%2C%0A%20%20%20%20)%0A%0A%20%20%20%20_stress_range%20%3D%20(synthetic_peaks()%20-%20MINIMUM_STRESS)%20%2F%206.894757293168%0A%20%20%20%20%23%20A%20variable-amplitude%20cycle%20advances%20the%20constant-range%20history%20by%0A%20%20%20%20%23%20(%CE%94%CF%83%20%2F%2010%20ksi)%5En%20equivalent%20cycles%20under%20this%20Paris%20model.%0A%20%20%20%20_equivalent%20%3D%20np.r_%5B%0A%20%20%20%20%20%20%20%200.0%2C%20np.cumsum((_stress_range%20%2F%20MERC3_STRESS_RANGE)%20**%20MERC3_EXPONENT)%0A%20%20%20%20%5D%0A%20%20%20%20_fig%2C%20(_stress_ax%2C%20_life_ax)%20%3D%20plt.subplots(%0A%20%20%20%20%20%20%20%202%2C%201%2C%20figsize%3D(7%2C%207)%2C%20layout%3D%22constrained%22%0A%20%20%20%20)%0A%20%20%20%20_stress_indices%20%3D%20display_indices(_stress_range.size)%0A%20%20%20%20_stress_ax.plot(_stress_indices%20%2B%201%2C%20_stress_range%5B_stress_indices%5D)%0A%20%20%20%20_stress_ax.set(xlabel%3D%22Applied%20cycles%22%2C%20ylabel%3D%22Stress%20range%20(ksi)%22)%0A%20%20%20%20_summary%20%3D%20%5B%5D%0A%20%20%20%20for%20_case%2C%20(_%2C%20_reference_cycles)%20in%20histories.items()%3A%0A%20%20%20%20%20%20%20%20_reached%20%3D%20np.searchsorted(_equivalent%2C%20_reference_cycles%5B-1%5D)%0A%20%20%20%20%20%20%20%20_end%20%3D%20min(_reached%2C%20_stress_range.size)%0A%20%20%20%20%20%20%20%20_indices%20%3D%20display_indices(_end%20%2B%201)%0A%20%20%20%20%20%20%20%20_depth%20%3D%20np.interp(_equivalent%5B_indices%5D%2C%20_reference_cycles%2C%20length)%0A%20%20%20%20%20%20%20%20_life_ax.plot(_indices%2C%20_depth%2C%20label%3D_case)%0A%20%20%20%20%20%20%20%20if%20_reached%20%3C%20_equivalent.size%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20_summary.append(f%22**%7B_case%7D**%20reaches%201.25%20in%20by%20cycle%20%7B_end%3A%2C%7D.%22)%0A%20%20%20%20_life_ax.set(xlabel%3D%22Applied%20cycles%22%2C%20ylabel%3D%22Crack%20length%20(in)%22)%0A%20%20%20%20_life_ax.legend()%0A%20%20%20%20long_case_view(%0A%20%20%20%20%20%20%20%20_fig%2C%0A%20%20%20%20%20%20%20%20%22Use%20the%20same%20%CE%B2%20curves%20and%20R%20%3D%200%20Paris%20fit%20with%20the%20package's%20%22%0A%20%20%20%20%20%20%20%20%22300%2C000%20synthetic%20stress%20ranges%20converted%20to%20ksi.%20Each%20range%20%22%0A%20%20%20%20%20%20%20%20%22advances%20the%20constant-range%20model%20by%20(%CE%94%CF%83%20%2F%2010%20ksi)%C2%B3%C2%B7%E2%81%B6%20equivalent%20%22%0A%20%20%20%20%20%20%20%20%22cycles.%20This%20follows%20from%20the%20separable%20Paris%20law.%20It%20treats%20%22%0A%20%20%20%20%20%20%20%20%22growth%20as%20a%20function%20of%20%CE%94K%20alone.%20All%20cycles%20contribute%20to%20the%20%22%0A%20%20%20%20%20%20%20%20%22calculation%20before%20sampling%20for%20display.%5Cn%5Cn%22%20%2B%20%22%20%22.join(_summary)%2C%0A%20%20%20%20%20%20%20%20height%3D%22860px%22%2C%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
8cae7143ac49fcfc262cbd0d12768dec