%22%22%22Example%20of%20plate%20stress%20intensity.%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%20Plate%20stress%20intensity%0A%0A%20%20%20%20%20%20%20%20Compare%20the%20tip%20of%20a%20center%20crack%20with%20the%20deepest%20and%20free-surface%0A%20%20%20%20%20%20%20%20points%20of%20a%20surface%20crack%20under%20tension%20up%20to%2060%20MPa.%20The%20slope%20of%0A%20%20%20%20%20%20%20%20each%20line%20shows%20how%20much%20the%20intensity%20changes%20per%20MPa%20of%20stress.%0A%20%20%20%20%20%20%20%20The%20sketches%20show%20where%20each%20intensity%20is%20evaluated.%20Then%20hold%20the%0A%20%20%20%20%20%20%20%20stress%20and%20half-length%20fixed%20and%20increase%20the%20surface%20crack%20depth%20to%0A%20%20%20%20%20%20%20%20see%20how%20the%20two%20front%20points%20respond.%0A%20%20%20%20%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20calculate()%3A%0A%20%20%20%20from%20dataclasses%20import%20replace%0A%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%20(%0A%20%20%20%20%20%20%20%20CenterThroughCrack%2C%0A%20%20%20%20%20%20%20%20SemiEllipticalSurfaceCrack%2C%0A%20%20%20%20)%0A%20%20%20%20from%20_examples.charts%20import%20plot_views%0A%0A%20%20%20%20center%20%3D%20CenterThroughCrack(half_width%3D50.0%2C%20half_length%3D4.0)%0A%20%20%20%20surface%20%3D%20SemiEllipticalSurfaceCrack(%0A%20%20%20%20%20%20%20%20half_width%3D50.0%2C%20thickness%3D15.0%2C%20depth%3D4.0%2C%20half_length%3D8.0%0A%20%20%20%20)%0A%20%20%20%20stress%20%3D%20%5B0.0%2C%2060.0%5D%0A%20%20%20%20center_tip%20%3D%20%5Bcenter.stress_intensity(value)%20for%20value%20in%20stress%5D%0A%20%20%20%20deepest%2C%20surface_tip%20%3D%20zip(%0A%20%20%20%20%20%20%20%20*(surface.stress_intensity(value)%20for%20value%20in%20stress)%0A%20%20%20%20)%0A%0A%20%20%20%20fig%2C%20(ax%2C%20sweep)%20%3D%20plt.subplots(2%2C%201%2C%20layout%3D%22constrained%22)%0A%20%20%20%20ax.plot(stress%2C%20center_tip%2C%20%22o-%22%2C%20label%3D%22Center%20crack%20tip%22)%0A%20%20%20%20ax.plot(stress%2C%20deepest%2C%20%22o-%22%2C%20label%3D%22Surface%20crack%2C%20deepest%20point%22)%0A%20%20%20%20ax.plot(%0A%20%20%20%20%20%20%20%20stress%2C%20surface_tip%2C%20%22o-%22%2C%20label%3D%22Surface%20crack%2C%20free-surface%20point%22%0A%20%20%20%20)%0A%20%20%20%20ax.set(xlabel%3D%22Tensile%20stress%20(MPa)%22%2C%20ylabel%3D%22Stress%20intensity%20(MPa%20%E2%88%9Amm)%22)%0A%20%20%20%20ax.legend()%0A%0A%20%20%20%20depths%20%3D%20np.linspace(surface.depth%2C%20surface.half_length%2C%2025)%0A%20%20%20%20deepest_by_depth%2C%20surface_by_depth%20%3D%20zip(%0A%20%20%20%20%20%20%20%20*(%0A%20%20%20%20%20%20%20%20%20%20%20%20replace(surface%2C%20depth%3Dfloat(depth)).stress_intensity(stress%5B-1%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20depth%20in%20depths%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20sweep.plot(%0A%20%20%20%20%20%20%20%20depths%20%2F%20surface.thickness%2C%20deepest_by_depth%2C%20label%3D%22Deepest%20point%22%0A%20%20%20%20)%0A%20%20%20%20sweep.plot(%0A%20%20%20%20%20%20%20%20depths%20%2F%20surface.thickness%2C%20surface_by_depth%2C%20label%3D%22Free%20surface%22%0A%20%20%20%20)%0A%20%20%20%20sweep.set(%0A%20%20%20%20%20%20%20%20xlabel%3D%22Crack%20depth%20%2F%20plate%20thickness%22%2C%0A%20%20%20%20%20%20%20%20ylabel%3D%22Stress%20intensity%20(MPa%20%E2%88%9Amm)%22%2C%0A%20%20%20%20%20%20%20%20title%3Df%22Surface%20crack%20at%20%7Bstress%5B-1%5D%3Ag%7D%20MPa%22%2C%0A%20%20%20%20)%0A%20%20%20%20sweep.legend()%0A%0A%20%20%20%20plot_views(fig%2C%20height%3D%22830px%22)%0A%20%20%20%20return%20center%2C%20surface%0A%0A%0A%40app.cell%0Adef%20geometry_views(center%2C%20surface)%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20_plt%0A%20%20%20%20from%20_examples.charts%20import%20plot_views%20as%20_plot_views%0A%0A%20%20%20%20profiles%2C%20(center_ax%2C%20surface_ax)%20%3D%20_plt.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%20center.plot(fig%3Dprofiles%2C%20ax%3Dcenter_ax)%0A%20%20%20%20surface.plot(fig%3Dprofiles%2C%20ax%3Dsurface_ax)%0A%20%20%20%20_plot_views(profiles%2C%20height%3D%22830px%22)%0A%0A%0A%40app.cell%0Adef%20long_case(center%2C%20surface)%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%20long_case_view%2C%20synthetic_peaks%0A%0A%20%20%20%20peaks%20%3D%20synthetic_peaks()%0A%20%20%20%20depth_factor%2C%20surface_factor%20%3D%20surface.stress_intensity(1.0)%0A%20%20%20%20intensities%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22Center%20tip%22%3A%20peaks%20*%20center.stress_intensity(1.0)%2C%0A%20%20%20%20%20%20%20%20%22Surface%20crack%20%C2%B7%20deepest%20point%22%3A%20peaks%20*%20depth_factor%2C%0A%20%20%20%20%20%20%20%20%22Surface%20crack%20%C2%B7%20free%20surface%22%3A%20peaks%20*%20surface_factor%2C%0A%20%20%20%20%7D%0A%20%20%20%20edges%20%3D%20_np.histogram_bin_edges(%0A%20%20%20%20%20%20%20%20_np.concatenate(list(intensities.values()))%2C%20bins%3D60%0A%20%20%20%20)%0A%20%20%20%20centres%20%3D%20(edges%5B%3A-1%5D%20%2B%20edges%5B1%3A%5D)%20%2F%202%0A%20%20%20%20long_fig%2C%20long_ax%20%3D%20_plt.subplots()%0A%20%20%20%20for%20label%2C%20intensity%20in%20intensities.items()%3A%0A%20%20%20%20%20%20%20%20counts%2C%20_%20%3D%20_np.histogram(intensity%2C%20bins%3Dedges)%0A%20%20%20%20%20%20%20%20long_ax.plot(centres%2C%20counts%2C%20label%3Dlabel)%0A%20%20%20%20long_ax.set(%0A%20%20%20%20%20%20%20%20xlabel%3D%22Peak%20stress%20intensity%20(MPa%20%E2%88%9Amm)%22%2C%20ylabel%3D%22Cycles%20per%20bin%22%0A%20%20%20%20)%0A%20%20%20%20long_ax.legend()%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%22Keep%20both%20crack%20geometries%20fixed%20and%20evaluate%20**%7Bpeaks.size%3A%2C%7D%20%22%0A%20%20%20%20%20%20%20%20%22generated%20stress%20peaks**%20at%20their%20tips.%20The%20distribution%20shows%20%22%0A%20%20%20%20%20%20%20%20%22how%20the%20same%20tensile%20loading%20maps%20to%20different%20peak%20intensities.%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
b72cb3a40db007cf915b63f6303e8504