%22%22%22Example%20of%20nasgro%20growth%20rate.%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..%2Fdocs%2Fstylesheets%2Fcustom.css%22)%0A%0A%0A%40app.cell%0Adef%20introduction()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%20%20%20%20%23%20NASGRO%20growth%20rate%0A%0A%20%20%20%20%20%20%20%20%60curve.plot()%60%20and%20%60curve.echarts()%60%20show%20the%20long-crack%20reference%20at%0A%20%20%20%20%20%20%20%20stress%20ratio%20R%20%3D%200.%20Both%20sweep%20maximum%20stress%20intensity%20up%20to%20the%0A%20%20%20%20%20%20%20%20dashed%20toughness%20limit.%20The%20semilog%20X%20panel%20shows%20zero%20growth%20below%0A%20%20%20%20%20%20%20%20threshold.%20The%20log%E2%80%93log%20panel%20shows%20the%20positive%20rates.%0A%0A%20%20%20%20%20%20%20%20The%20last%20panel%20applies%20the%20short-crack%20threshold%20correction%20at%20a%0A%20%20%20%20%20%20%20%20crack%20length%20of%204%20mm.%20Set%20%60k_min%20%3D%20R%20*%20k_max%60%20for%20each%20sample%20to%0A%20%20%20%20%20%20%20%20compare%20two%20stress%20ratios%20at%20the%20same%20maximum%20intensity.%0A%20%20%20%20%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20calculate()%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20from%20py_fatigue.crack_growth%20import%20NasgroCurve%0A%20%20%20%20from%20_examples.charts%20import%20plot_views%0A%0A%20%20%20%20curve%20%3D%20NasgroCurve(%0A%20%20%20%20%20%20%20%20coefficient%3D1e-10%2C%0A%20%20%20%20%20%20%20%20exponent%3D2.0%2C%0A%20%20%20%20%20%20%20%20p%3D0.5%2C%0A%20%20%20%20%20%20%20%20q%3D1.0%2C%0A%20%20%20%20%20%20%20%20threshold_zero%3D25.0%2C%0A%20%20%20%20%20%20%20%20threshold_fanning%3D0.0%2C%0A%20%20%20%20%20%20%20%20toughness%3D500.0%2C%0A%20%20%20%20%20%20%20%20constraint%3D2.0%2C%0A%20%20%20%20%20%20%20%20peak_to_flow%3D0.3%2C%0A%20%20%20%20)%0A%20%20%20%20length%20%3D%204.0%0A%20%20%20%20fig%2C%20(semilog%2C%20loglog%2C%20ratios)%20%3D%20plt.subplots(%0A%20%20%20%20%20%20%20%203%2C%201%2C%20figsize%3D(7%2C%209)%2C%20layout%3D%22constrained%22%0A%20%20%20%20)%0A%20%20%20%20curve.plot(ax%3Dsemilog%2C%20scale%3D%22semilogx%22)%0A%20%20%20%20curve.plot(ax%3Dloglog%2C%20scale%3D%22loglog%22)%0A%20%20%20%20semilog.set_title(%22Semilog%20X%20%C2%B7%20includes%20zero%20growth%22)%0A%20%20%20%20loglog.set_title(%22Log%E2%80%93log%20%C2%B7%20positive%20growth%20rates%22)%0A%20%20%20%20semilog.legend()%0A%0A%20%20%20%20k_max%20%3D%20np.linspace(0.0%2C%20curve.toughness%2C%20201)%5B1%3A-1%5D%0A%20%20%20%20for%20ratio%20in%20(0.0%2C%200.4)%3A%0A%20%20%20%20%20%20%20%20curve.plot(length%2C%20ratio%20*%20k_max%2C%20k_max%2C%20ax%3Dratios%2C%20scale%3D%22loglog%22)%0A%20%20%20%20%20%20%20%20ratios.lines%5B-1%5D.set_label(f%22R%20%3D%20%7Bratio%3Ag%7D%22)%0A%20%20%20%20ratios.axvline(%0A%20%20%20%20%20%20%20%20curve.toughness%2C%20color%3D%220.4%22%2C%20linestyle%3D%22--%22%2C%20label%3D%22Toughness%22%0A%20%20%20%20)%0A%20%20%20%20ratios.set_title(%22Compare%20fixed%20stress%20ratios%22)%0A%20%20%20%20ratios.legend()%0A%0A%20%20%20%20plot_views(fig%2C%20height%3D%221240px%22)%0A%20%20%20%20return%20curve%2C%20length%0A%0A%0A%40app.cell%0Adef%20long_case(curve%2C%20length)%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20_plt%0A%20%20%20%20import%20numpy%20as%20_np%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%20%20%20%20from%20py_fatigue.crack_growth%20import%20CenterThroughCrack%0A%0A%20%20%20%20peaks%20%3D%20synthetic_peaks()%0A%20%20%20%20geometry%20%3D%20CenterThroughCrack(half_width%3D50.0%2C%20half_length%3Dlength)%0A%20%20%20%20factor%20%3D%20geometry.stress_intensity(1.0)%0A%20%20%20%20k_min%20%3D%20MINIMUM_STRESS%20*%20factor%0A%20%20%20%20long_k_max%20%3D%20peaks%20*%20factor%0A%20%20%20%20rates%20%3D%20_np.fromiter(%0A%20%20%20%20%20%20%20%20(curve.get_growth_rate(length%2C%20k_min%2C%20value)%20for%20value%20in%20long_k_max)%2C%0A%20%20%20%20%20%20%20%20dtype%3Dfloat%2C%0A%20%20%20%20%20%20%20%20count%3Dpeaks.size%2C%0A%20%20%20%20)%0A%20%20%20%20positive%20%3D%20rates%5Brates%20%3E%200%5D%0A%20%20%20%20zero_count%20%3D%20peaks.size%20-%20positive.size%0A%20%20%20%20long_fig%2C%20ax%20%3D%20_plt.subplots()%0A%20%20%20%20if%20positive.size%3A%0A%20%20%20%20%20%20%20%20edges%20%3D%20_np.geomspace(positive.min()%2C%20positive.max()%2C%2061)%0A%20%20%20%20%20%20%20%20counts%2C%20_%20%3D%20_np.histogram(positive%2C%20bins%3Dedges)%0A%20%20%20%20%20%20%20%20ax.semilogx(_np.sqrt(edges%5B%3A-1%5D%20*%20edges%5B1%3A%5D)%2C%20counts)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20ax.set_title(%22Zero%20growth%20across%20this%20history%22)%0A%20%20%20%20ax.set(xlabel%3D%22Growth%20rate%20(mm%2Fcycle)%22%2C%20ylabel%3D%22Cycles%20per%20rate%20bin%22)%0A%20%20%20%20long_case_view(%0A%20%20%20%20%20%20%20%20long_fig%2C%0A%20%20%20%20%20%20%20%20f%22Evaluate%20the%20NASGRO%20law%20for%20**%7Bpeaks.size%3A%2C%7D%20generated%20cycles**%20%22%0A%20%20%20%20%20%20%20%20f%22with%20the%20center%20crack%20held%20at%20a%20**%7Blength%3Ag%7D%20mm**%20half-length.%20%22%0A%20%20%20%20%20%20%20%20%22The%20histogram%20shows%20positive%20rates.%20%22%0A%20%20%20%20%20%20%20%20f%22**%7Bzero_count%3A%2C%7D%20cycles**%20give%20zero%20growth%20at%20this%20crack%20length.%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
a065f96308a27651cbf335a70146ce48