%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%20%20%20%20return%20(mo%2C)%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.geometry.plate%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_long_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_long_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%0A%40app.cell(hide_code%3DTrue)%0Adef%20geometry_gallery(mo)%3A%0A%20%20%20%20from%20base64%20import%20b64encode%0A%20%20%20%20from%20io%20import%20BytesIO%0A%20%20%20%20from%20matplotlib%20import%20pyplot%20as%20gallery_plt%0A%20%20%20%20from%20py_fatigue.geometry.cylinder%20import%20(%0A%20%20%20%20%20%20%20%20AxialCylinderThroughCrack%2C%0A%20%20%20%20%20%20%20%20CircumferentialCylinderSurfaceCrack%2C%0A%20%20%20%20%20%20%20%20CircumferentialCylinderThroughCrack%2C%0A%20%20%20%20%20%20%20%20RoundBarSurfaceCrack%2C%0A%20%20%20%20)%0A%20%20%20%20from%20py_fatigue.geometry.plate%20import%20(%0A%20%20%20%20%20%20%20%20CenterThroughCrack%20as%20_CenterThroughCrack%2C%0A%20%20%20%20%20%20%20%20EdgeThroughCrack%2C%0A%20%20%20%20%20%20%20%20HoleBoreSurfaceCrack%2C%0A%20%20%20%20%20%20%20%20SemiEllipticalSurfaceCrack%20as%20_SemiEllipticalSurfaceCrack%2C%0A%20%20%20%20)%0A%20%20%20%20from%20py_fatigue.geometry.sphere%20import%20SphereThroughCrack%0A%20%20%20%20from%20py_fatigue.geometry.threaded%20import%20RolledBoltThreadSurfaceCrack%0A%0A%20%20%20%20geometry_cases%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22TC01%22%3A%20_CenterThroughCrack(50.0%2C%204.0)%2C%0A%20%20%20%20%20%20%20%20%22TC02%22%3A%20EdgeThroughCrack(100.0%2C%204.0)%2C%0A%20%20%20%20%20%20%20%20%22TC06%22%3A%20SphereThroughCrack(100.0%2C%201.0%2C%204.0)%2C%0A%20%20%20%20%20%20%20%20%22TC07%22%3A%20AxialCylinderThroughCrack(100.0%2C%201.0%2C%204.0)%2C%0A%20%20%20%20%20%20%20%20%22TC08%22%3A%20CircumferentialCylinderThroughCrack(%0A%20%20%20%20%20%20%20%20%20%20%20%20100.0%2C%201.0%2C%204.0%2C%202500.0%2C%200.3%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%22SC01%22%3A%20_SemiEllipticalSurfaceCrack(50.0%2C%2015.0%2C%204.0%2C%208.0)%2C%0A%20%20%20%20%20%20%20%20%22SC05%22%3A%20CircumferentialCylinderSurfaceCrack(20.0%2C%2010.0%2C%204.0%2C%205.0)%2C%0A%20%20%20%20%20%20%20%20%22SC07%22%3A%20RoundBarSurfaceCrack(20.0%2C%202.0)%2C%0A%20%20%20%20%20%20%20%20%22SC08%22%3A%20RolledBoltThreadSurfaceCrack(12.0%2C%2010.0%2C%201.5)%2C%0A%20%20%20%20%20%20%20%20%22SC11%22%3A%20HoleBoreSurfaceCrack(80.0%2C%2012.0%2C%2012.0%2C%202.2%2C%202.5%2C%202)%2C%0A%20%20%20%20%7D%0A%20%20%20%20gallery%20%3D%20%7B%7D%0A%20%20%20%20for%20case%2C%20shape%20in%20geometry_cases.items()%3A%0A%20%20%20%20%20%20%20%20figure%2C%20_%20%3D%20shape.plot()%0A%20%20%20%20%20%20%20%20with%20BytesIO()%20as%20svg%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20figure.savefig(svg%2C%20format%3D%22svg%22%2C%20bbox_inches%3D%22tight%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20encoded%20%3D%20b64encode(svg.getvalue()).decode(%22ascii%22)%0A%20%20%20%20%20%20%20%20image%20%3D%20mo.image(%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22data%3Aimage%2Fsvg%2Bxml%3Bbase64%2C%7Bencoded%7D%22%2C%20alt%3Df%22%7Bcase%7D%20schematic%22%0A%20%20%20%20%20%20%20%20).style(%7B%22filter%22%3A%20%22var(--notebook-plot-filter%2C%20none)%22%7D)%0A%20%20%20%20%20%20%20%20gallery_plt.close(figure)%0A%20%20%20%20%20%20%20%20details%20%3D%20f%22%60%7Bshape!r%7D%60%22%0A%20%20%20%20%20%20%20%20details%20%2B%3D%20f%22%5Cn%5CnK%20at%2045%20MPa%20%C2%B7%20%7Bshape.stress_intensity(45.0)%7D%20MPa%20%E2%88%9Amm%22%0A%20%20%20%20%20%20%20%20gallery%5Bcase%5D%20%3D%20mo.vstack(%5Bmo.md(details)%2C%20image%5D)%0A%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%23%23%20Geometry%20SVGs%20from%20the%20public%20plot%20methods%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.tabs(gallery)%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
da8b511a55bc0682fe89fc1b44dc1231