import%20marimo%0A%0A__generated_with%20%3D%20%220.26.0%22%0Aapp%20%3D%20marimo.App(width%3D%22full%22%2C%20css_file%3D%22..%2Fstylesheets%2Fcustom.css%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20from%20notebooks._examples.charts%20import%20plot_views%0A%20%20%20%20from%20notebooks._examples.synthetic%20import%20display_indices%0A%0A%20%20%20%20return%20display_indices%2C%20mo%2C%20plot_views%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Getting%20started%0A%0A%20%20%20%20Welcome%20to%20the%20absolute%20beginner's%20guide%20to%20py-fatigue!%20If%20you%20have%20comments%20or%20suggestions%2C%20please%20don't%20hesitate%20to%20file%20an%20issue%20or%20make%20a%20pull%20request%20on%20our%20GitHub%20repo%3A%20**https%3A%2F%2Fgithub.com%2FOWI-Lab%2Fpy_fatigue%2F**.%0A%0A%20%20%20%20%23%23%20Welcome%20to%20py-fatigue!%0A%0A%20%20%20%20py-fatigue%20was%20originally%20part%20of%20the%20DYNAwind%20suite%20of%20tools%20for%20wind%20turbine%20structural%20health%20monitoring%20and%20analysis.%20The%20tool%20has%20been%20detached%20from%20the%20project%20and%20now%20relies%20on%20the%20following%20PyPi%20packages%20only%3A%0A%0A%20%20%20%20-%20NumPy%0A%20%20%20%20-%20pyecharts%0A%20%20%20%20-%20pandas%0A%20%20%20%20-%20Matplotlib%0A%20%20%20%20-%20Pydantic%0A%0A%20%20%20%20The%20package%20bundles%20the%20main%20functionality%20for%20performing%20cyclic%20stress%20(fatigue%20and%20crack%20growth)%20analysis%20and%20cycle-counting.%0A%0A%20%20%20%20%23%23%20Installing%20py-fatigue%0A%0A%20%20%20%20py-fatigue%20is%20freely%20available%20on%20GitHub%20and%20gets%20maintained%20through%20CI%2FCD%20phylosophy.%20Py-Fatigue%203%20targets%2064-bit%20CPython%203.10%E2%80%933.15.%20A%20source%20build%20requires%20Rust.%0A%0A%20%20%20%20Choose%20the%20command%20that%20matches%20your%20environment.%0A%0A%20%20%20%20**pip**%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20python%20-m%20pip%20install%20py-fatigue%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20**uv**%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20uv%20pip%20install%20py-fatigue%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20%23%23%20How%20to%20import%20py-fatigue%0A%0A%20%20%20%20To%20access%20py-fatigue%20and%20its%20functions%20import%20it%20in%20your%20Python%20code%20like%20this%3A%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20py_fatigue%20as%20pf%0A%0A%20%20%20%20return%20np%2C%20pf%2C%20plt%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Static%20and%20interactive%20plots%0A%0A%20%20%20%20Use%20%60.plot()%60%20for%20a%20Matplotlib%20figure%20and%20axes%2C%20or%20%60.echarts()%60%20for%20an%0A%20%20%20%20interactive%20chart.%20Both%20methods%20take%20the%20same%20domain%20inputs%2C%20such%20as%20the%0A%20%20%20%20intensity%20samples%20to%20evaluate%20a%20NASGRO%20curve.%0A%0A%20%20%20%20%7C%20Object%20%7C%20What%20its%20plot%20shows%20%7C%0A%20%20%20%20%7C%20---%20%7C%20---%20%7C%0A%20%20%20%20%7C%20%60CycleCount%60%20%7C%20Rainflow%20histogram.%20Use%20%60plot_type%60%20to%20select%20the%20axes.%20%7C%0A%20%20%20%20%7C%20%60SNCurve%60%2C%20%60ParisCurve%60%2C%20%60WalkerCurve%60%2C%20%60NasgroCurve%60%20%7C%20The%20material%20curve%2C%20including%20any%20supplied%20measurement%20overlay%20for%20S%E2%80%93N%2C%20Paris%2C%20or%20Walker%20curves.%20%7C%0A%20%20%20%20%7C%20Plate%2C%20cylinder%20and%20infinite-surface%20geometries%20%7C%20A%20sketch%20using%20the%20dimensions%20supplied%20to%20the%20geometry.%20%7C%0A%20%20%20%20%7C%20%60CalcCrackGrowth%60%20from%20%60get_crack_growth%60%20%7C%20Crack%20depth%20recorded%20at%20the%20start%20of%20each%20legacy%20step.%20%7C%0A%20%20%20%20%7C%20%60GrowthResult%60%20from%20%60simulate_crack_growth%60%20%7C%20Accepted%20crack%20dimensions%20against%20cumulative%20cycles.%20%7C%0A%20%20%20%20%7C%20%60df.miner%60%20and%20%60df.gassner%60%20%7C%20Contributions%20by%20stress%20range%20after%20calculating%20Miner%20damage%20or%20Gassner%20shift%20factors.%20%7C%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(pf%2C%20plot_views)%3A%0A%20%20%20%20curve%20%3D%20pf.SNCurve(slope%3D3%2C%20intercept%3D12.0)%0A%20%20%20%20sn_figure%2C%20sn_axis%20%3D%20curve.plot()%0A%20%20%20%20plot_views(sn_figure)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Use%20%60sn_figure.savefig(%22sn-curve.png%22)%60%20to%20save%20the%20static%20plot%20or%0A%20%20%20%20%60curve.echarts().render(%22sn-curve.html%22)%60%20to%20write%20the%20interactive%20view.%0A%0A%20%20%20%20For%20material%20curves%2C%20pass%20%60scale%3D%22loglog%22%60%2C%20%60scale%3D%22semilogx%22%60%2C%20or%0A%20%20%20%20%60scale%3D%22semilogy%22%60%20to%20either%20method.%20The%20semilog%20options%20put%20the%20x%20or%20y%20axis%0A%20%20%20%20on%20a%20logarithmic%20scale%2C%20respectively.%20S%E2%80%93N%2C%20Paris%2C%20and%20Walker%20curves%20default%0A%20%20%20%20to%20log%E2%80%93log.%20NASGRO%20defaults%20to%20a%20logarithmic%20growth-rate%20axis.%0A%0A%20%20%20%20Use%20%60to_echarts(fig)%60%20from%20%60py_fatigue.plotting%60%20when%20you%20have%20composed%0A%20%20%20%20several%20plots%20into%20an%20existing%20figure.%20Pass%20%60to_echarts(ax)%60%20for%20a%20single%0A%20%20%20%20panel.%20The%20HTML%20includes%20hover%2C%20zoom%2C%20reset%20and%20PNG%20export%2C%20and%20loads%0A%20%20%20%20ECharts%20from%20the%20pyecharts%20CDN.%0A%0A%20%20%20%20For%20calculations%20that%20display%20a%20mean%20stress%20correction%20figure%2C%20pass%20a%0A%20%20%20%20callback%20to%20%60plot%60%20to%20receive%20the%20figure%20and%20render%20it%20separately.%0A%0A%20%20%20%20%60%60%60py%0A%20%20%20%20from%20py_fatigue.plotting%20import%20to_echarts%0A%0A%20%20%20%20def%20save_interactive(fig)%3A%0A%20%20%20%20%20%20%20%20to_echarts(fig).render(%22mean-stress.html%22)%0A%0A%20%20%20%20corrected%20%3D%20cycle_count.mean_stress_correction(plot%3Dsave_interactive)%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20%23%23%20How%20to%20use%20py-fatigue%0A%0A%20%20%20%201.%20Use%20%5B%60CycleCount%60%5D(..%2Fapi%2Fcycle_count%2Fcycle_count_.html)%20to%20extract%20cycles%0A%20%20%20%20%20%20%20from%20a%20stress%20history.%0A%20%20%20%202.%20Choose%20the%20material%20curve%20for%20the%20calculation.%0A%20%20%20%20%20%20%20%20-%20An%20%5BS%E2%80%93N%20curve%5D(additional%2Fglossary.html%23sn-curve)%20gives%20the%20life%20at%20a%0A%20%20%20%20%20%20%20%20%20%20given%20stress%20range.%0A%20%20%20%20%20%20%20%20-%20A%20%5BParis%2C%20Walker%2C%20or%20NASGRO%20curve%5D(examples%2F02-crack-growth-curves.html)%20gives%20the%0A%20%20%20%20%20%20%20%20%20%20growth%20rate%20of%20an%20existing%20crack.%0A%20%20%20%203.%20Choose%20an%20analysis.%0A%20%20%20%20%20%20%20%20-%20For%20%5Bstress%E2%80%93life%20damage%5D(examples%2F06-stress-life-damage.html)%2C%20combine%20cycle%0A%20%20%20%20%20%20%20%20%20%20counts%20with%20the%20S%E2%80%93N%20curve.%0A%20%20%20%20%20%20%20%20-%20For%20%5Bcrack%20growth%5D(examples%2F07-ordered-crack-growth.html)%2C%20choose%20a%0A%20%20%20%20%20%20%20%20%20%20geometry%20and%20combine%20its%20stress-intensity%20solution%20with%20a%20growth%20curve.%0A%20%20%20%204.%20Use%20%5B%60get_sampled_time%60%20and%20%60get_random_data%60%5D(..%2Fapi%2Ftesting.html)%20to%0A%20%20%20%20%20%20%20generate%20a%20sample%20history%20for%20the%20example%20below.%0A%0A%20%20%20%20%5BUpgrading%20an%20existing%20installation%3F%5D(migrate-v3.html)%0A%0A%20%20%20%20%23%23%20Example%0A%0A%20%20%20%20In%20the%20following%20example%2C%20starting%20from%20a%20randomly%20generated%20signal%2C%20we%20will%3A%0A%0A%20%20%20%20-%20calculate%20the%20rainflow%0A%20%20%20%20-%20export%20the%20cycle-count%20matrix%0A%20%20%20%20-%20reconstruct%20the%20CycleCount%20object%20from%20the%20exported%20matrix%0A%20%20%20%20-%20define%20the%20SN%20curve%0A%20%20%20%20-%20calculate%20the%20Palmgren-Miner%20damage%0A%20%20%20%20-%20define%20the%20Paris'%20law%0A%20%20%20%20-%20define%20a%20crack%20geometry%0A%20%20%20%20-%20run%20a%20crack%20growth%20analysis.%0A%0A%20%20%20%20The%20damage%20and%20crack%20growth%20analyses%20will%20be%20also%20executed%20by%20means%20of%20the%20pandas%20DataFrame%20accessors%20that%20Py-Fatigue%20implements.%0A%0A%20%20%20%20%23%23%23%20Random%20signal%20simulation%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(plot_views%2C%20plt)%3A%0A%20%20%20%20import%20py_fatigue.testing%20as%20test%0A%0A%20%20%20%20%23%20Simulate%20a%20random%20signal%0A%20%20%20%20t%20%3D%20test.get_sampled_time(duration%3D10000%2C%20fs%3D10)%0A%20%20%20%20s%20%3D%20test.get_random_data(%0A%20%20%20%20%20%20%20%20t%3Dt%2C%20min_%3D-30%2C%20range_%3D180%2C%20random_type%3D%22weibull%22%2C%20a%3D2.%2C%20seed%3D42%0A%20%20%20%20)%0A%20%20%20%20%23%20Plot%20the%20signal%0A%20%20%20%20signal_figure%2C%20signal_axis%20%3D%20plt.subplots()%0A%20%20%20%20signal_axis.plot(t%5B%3A1001%5D%2C%20s%5B%3A1001%5D%2C%20lw%3D0.5)%0A%20%20%20%20signal_axis.set(%0A%20%20%20%20%20%20%20%20xlabel%3D%22Time%2C%20s%22%2C%20ylabel%3D%22Signal%2C%20MPa%22%2C%20title%3D%22First%20100%20seconds%22%0A%20%20%20%20)%0A%20%20%20%20plot_views(signal_figure)%0A%20%20%20%20return%20s%2C%20t%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Cycle-count%20definition%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(pf%2C%20s%2C%20t)%3A%0A%20%20%20%20%23%20CycleCount%20definition%0A%20%20%20%20cycle_count%20%3D%20pf.CycleCount.from_timeseries(%0A%20%20%20%20%20%20%20%20time%3Dt%2C%20data%3Ds%2C%20mean_bin_width%3D3.%2C%20range_bin_width%3D3.%2C%0A%20%20%20%20)%0A%20%20%20%20cycle_count.summary()%0A%20%20%20%20return%20(cycle_count%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Cycle-count%20matrix%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(cycle_count)%3A%0A%20%20%20%20%23%20Exporting%20the%20cycle-count%20matrix%20in%20the%20legacy%20format%2C%20i.e.%20not%0A%20%20%20%20%23%20accounting%20for%20mean%20stresses.%20This%20function%20has%20been%20kept%20for%0A%20%20%20%20%23%20backwards%20compatibility.%0A%20%20%20%20exp_dict_legacy%20%3D%20cycle_count.as_dict(%0A%20%20%20%20%20%20%20%20max_consecutive_zeros%3D20%2C%0A%20%20%20%20%20%20%20%20damage_tolerance_for_binning%3D0.2%2C%0A%20%20%20%20%20%20%20%20legacy_export%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20print(exp_dict_legacy)%0A%0A%0A%40app.cell%0Adef%20_(cycle_count)%3A%0A%20%20%20%20%23%20Exporting%20the%20cycle-count%20matrix%0A%20%20%20%20exp_dict%20%3D%20cycle_count.as_dict(%0A%20%20%20%20%20%20%20%20max_consecutive_zeros%3D20%2C%20damage_tolerance_for_binning%3D1%0A%20%20%20%20)%0A%20%20%20%20print(exp_dict)%0A%20%20%20%20return%20(exp_dict%2C)%0A%0A%0A%40app.cell%0Adef%20_(exp_dict%2C%20pf)%3A%0A%20%20%20%20%23%20Reconstructing%20the%20CycleCount%20instance%20from%20the%20exported%20matrix%0A%20%20%20%20cycle_count_d%20%3D%20pf.CycleCount.from_rainflow(exp_dict%2C%20name%3D%22Random%20Signal%22)%0A%20%20%20%20cycle_count_d.summary()%0A%20%20%20%20return%20(cycle_count_d%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Compare%20the%20two%20spectra%20on%20a%20common%20mean-stress%20and%20stress-range%20grid.%0A%20%20%20%20Each%20marker%20represents%20an%20occupied%20bin.%20Its%20color%20gives%20the%20cycle%20count%2C%0A%20%20%20%20including%20half%20cycles.%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(cycle_count%2C%20cycle_count_d%2C%20np%2C%20plot_views%2C%20plt)%3A%0A%20%20%20%20mean_edges%20%3D%20np.histogram_bin_edges(%0A%20%20%20%20%20%20%20%20np.r_%5Bcycle_count.mean_stress%2C%20cycle_count_d.mean_stress%5D%2C%20bins%3D50%0A%20%20%20%20)%0A%20%20%20%20range_edges%20%3D%20np.histogram_bin_edges(%0A%20%20%20%20%20%20%20%20np.r_%5Bcycle_count.stress_range%2C%20cycle_count_d.stress_range%5D%2C%20bins%3D50%0A%20%20%20%20)%0A%20%20%20%20histograms%20%3D%20%5B%0A%20%20%20%20%20%20%20%20np.histogram2d(%0A%20%20%20%20%20%20%20%20%20%20%20%20spectrum.mean_stress%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20spectrum.stress_range%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20bins%3D(mean_edges%2C%20range_edges)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20weights%3Dspectrum.count_cycle%2C%0A%20%20%20%20%20%20%20%20)%5B0%5D%0A%20%20%20%20%20%20%20%20for%20spectrum%20in%20(cycle_count%2C%20cycle_count_d)%0A%20%20%20%20%5D%0A%20%20%20%20mean_centers%20%3D%20(mean_edges%5B%3A-1%5D%20%2B%20mean_edges%5B1%3A%5D)%20%2F%202%0A%20%20%20%20range_centers%20%3D%20(range_edges%5B%3A-1%5D%20%2B%20range_edges%5B1%3A%5D)%20%2F%202%0A%20%20%20%20max_count%20%3D%20max(histogram.max()%20for%20histogram%20in%20histograms)%0A%20%20%20%20histogram_figure%2C%20axs%20%3D%20plt.subplots(%0A%20%20%20%20%20%20%20%201%2C%202%2C%20figsize%3D(12%2C%204.5)%2C%20layout%3D%22constrained%22%0A%20%20%20%20)%0A%20%20%20%20for%20axis%2C%20histogram%2C%20title%20in%20zip(%0A%20%20%20%20%20%20%20%20axs%2C%20histograms%2C%20(%22Cycle%20count%20from%20signal%22%2C%20%22Cycle%20count%20from%20matrix%22)%0A%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20mean_bin%2C%20range_bin%20%3D%20histogram.nonzero()%0A%20%20%20%20%20%20%20%20markers%20%3D%20axis.scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20mean_centers%5Bmean_bin%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20range_centers%5Brange_bin%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20c%3Dhistogram%5Bmean_bin%2C%20range_bin%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20vmin%3D0%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20vmax%3Dmax_count%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20cmap%3D%22viridis%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20histogram_figure.colorbar(markers%2C%20ax%3Daxis%2C%20label%3D%22Cycles%20per%20bin%22)%0A%20%20%20%20%20%20%20%20axis.set(%0A%20%20%20%20%20%20%20%20%20%20%20%20title%3Dtitle%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20xlabel%3D%22Mean%20stress%20(MPa)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20ylabel%3D%22Stress%20range%20(MPa)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20xlim%3D(mean_edges%5B0%5D%2C%20mean_edges%5B-1%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20ylim%3D(range_edges%5B0%5D%2C%20range_edges%5B-1%5D)%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20plot_views(histogram_figure)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Stress-Life%0A%0A%20%20%20%20%23%23%23%23%20SN%20Curve%20definition%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(pf%2C%20plot_views)%3A%0A%20%20%20%20c_air%20%3D%20pf.SNCurve(%0A%20%20%20%20%20%20%20%20%5B3%2C%205%5D%2C%0A%20%20%20%20%20%20%20%20intercept%3D%5B12.592%2C%2016.320%5D%2C%0A%20%20%20%20%20%20%20%20norm%3D%22DNVGL-RP-C203%2F2016%22%2C%0A%20%20%20%20%20%20%20%20environment%3D'Air'%2C%0A%20%20%20%20%20%20%20%20curve%3D'C'%0A%20%20%20%20)%0A%20%20%20%20sn_code_figure%2C%20sn_code_axis%20%3D%20c_air.plot()%0A%20%20%20%20plot_views(sn_code_figure)%0A%20%20%20%20return%20(c_air%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%23%20Damage%20calculation%20analysis%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(c_air%2C%20cycle_count%2C%20cycle_count_d%2C%20pf)%3A%0A%20%20%20%20%23%20Calculate%20damage%20for%20the%20cycle-count%20objects%0A%20%20%20%20damage%20%3D%20pf.damage.stress_life.get_pm(cycle_count%3Dcycle_count%2C%20sn_curve%3Dc_air)%0A%20%20%20%20damage_d%20%3D%20pf.damage.stress_life.get_pm(cycle_count%3Dcycle_count_d%2C%20sn_curve%3Dc_air)%0A%20%20%20%20print(f%22damage%20from%20signal%3A%20%7Bsum(damage)%7D%22)%0A%20%20%20%20print(f%22damage%20from%20matrix%3A%20%7Bsum(damage_d)%7D%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Crack%20growth%0A%0A%20%20%20%20A%20crack%20growth%20simulation%20necessitates%20of%20three%20ingredients%20(objects)%3A%0A%0A%20%20%20%20-%20Cycle-counted%20stress%20history%0A%20%20%20%20-%20Crack%20growth%20curve%20(e.g.%20Paris'%20law)%0A%20%20%20%20-%20Crack%20geometry%0A%0A%20%20%20%20%23%23%23%23%20Paris'%20curve%20definition%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20pf%2C%20plot_views)%3A%0A%20%20%20%20SLOPE%20%3D%20np.array(%5B2.88%2C%205.1%2C%208.16%2C%205.1%2C%202.88%5D)%0A%20%20%20%20INTER%20%3D%20np.array(%5B1E-16%2C%201E-20%2C%201E-27%2C%201E-19%2C%201E-13%5D)%0A%20%20%20%20THRESHOLD%20%3D%2020%0A%20%20%20%20CRITICAL%20%3D%202000%0A%20%20%20%20pc%20%3D%20pf.ParisCurve(slope%3DSLOPE%2C%20intercept%3DINTER%2C%20threshold%3DTHRESHOLD%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20critical%3DCRITICAL%2C%20norm%3D%22The%20norm%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20environment%3D%22Environment%22%2C%20curve%3D%22nr.%22)%0A%20%20%20%20paris_figure%2C%20paris_axis%20%3D%20pc.plot()%0A%20%20%20%20plot_views(paris_figure)%0A%20%20%20%20return%20(pc%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%23%20Crack%20geometry%20definition%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(pf)%3A%0A%20%20%20%20geo%20%3D%20pf.geometry.HollowCylinder(%0A%20%20%20%20%20%20initial_depth%3D5.%2C%0A%20%20%20%20%20%20thickness%3D10.%2C%0A%20%20%20%20%20%20height%3D30.%2C%0A%20%20%20%20%20%20outer_diameter%3D30.%2C%0A%20%20%20%20%20%20crack_position%3D%22external%22%0A%20%20%20%20)%0A%20%20%20%20geo%0A%20%20%20%20return%20(geo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%23%20Crack%20growth%20analysis%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(cycle_count%2C%20geo%2C%20pc%2C%20pf)%3A%0A%20%20%20%20cg%20%3D%20pf.damage.crack_growth.get_crack_growth(%0A%20%20%20%20%20%20cycle_count%2C%20pc%2C%20geo%2C%20express_mode%3DTrue%0A%20%20%20%20)%0A%20%20%20%20print(f%22Cycles%20to%20end%3A%20%7Bint(cg.final_cycles)%7D%22)%0A%0A%0A%40app.cell%0Adef%20_(cycle_count_d%2C%20geo%2C%20pc%2C%20pf)%3A%0A%20%20%20%20cg_d%20%3D%20pf.damage.crack_growth.get_crack_growth(%0A%20%20%20%20%20%20cycle_count_d%2C%20pc%2C%20geo%2C%20express_mode%3DTrue%0A%20%20%20%20)%0A%20%20%20%20print(f%22Cycles%20to%20end%3A%20%7Bint(cg_d.final_cycles)%7D%22)%0A%20%20%20%20return%20(cg_d%2C)%0A%0A%0A%40app.cell%0Adef%20_(cg_d%2C%20display_indices%2C%20np%2C%20plot_views%2C%20plt)%3A%0A%20%20%20%20growth_figure%2C%20growth_axis%20%3D%20plt.subplots()%0A%20%20%20%20growth_rows%20%3D%20display_indices(cg_d.crack_depth.size)%0A%20%20%20%20growth_axis.plot(np.cumsum(cg_d.count_cycle)%5Bgrowth_rows%5D%2C%20cg_d.crack_depth%5Bgrowth_rows%5D)%0A%20%20%20%20growth_axis.set(xlabel%3D%22Cumulative%20cycles%22%2C%20ylabel%3D%22Crack%20size%2C%20mm%22)%0A%20%20%20%20plot_views(growth_figure)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Working%20with%20pandas%20DataFrames%0A%0A%20%20%20%20It's%20possible%20to%20translate%20the%20CycleCount%20object%20to%20a%20pandas%20DataFrame%20and%20use%20the%20implemented%20accessors%20%60py_fatigue.damage.stress_life.PalmgrenMiner%60%20(%60miner%60)%20and%20%60py_fatigue.damage.crack_growth.CrackGrowth%60%20(%60cg%60)%20to%20perform%20the%20stress-life%20and%20propagation%20analyses%20as%20shown%20above.%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(c_air%2C%20cycle_count%2C%20geo%2C%20pc)%3A%0A%20%20%20%20df%20%3D%20cycle_count.to_df()%0A%0A%20%20%20%20%23%20Stress-life%0A%20%20%20%20df.miner.damage(sn_curve%3Dc_air)%0A%20%20%20%20%23%20Crack-growth%0A%20%20%20%20df.cg.calc_growth(cg_curve%3Dpc%2C%20crack_geometry%3Dgeo)%0A%20%20%20%20df.head()%0A%20%20%20%20return%20(df%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20plots%20show%20a%20sample%20of%20the%20calculated%20rows.%20The%20damage%20plot%20includes%0A%20%20%20%20the%20largest%20stress%20range%20and%20largest%20damage%20contribution.%20The%20crack%0A%20%20%20%20history%20includes%20the%20first%20and%20last%20rows.%0A%20%20%20%20%22%22%22)%0A%0A%0A%40app.cell%0Adef%20_(df%2C%20display_indices%2C%20np%2C%20plot_views)%3A%0A%20%20%20%20damage_rows%20%3D%20np.union1d(%0A%20%20%20%20%20%20%20%20display_indices(len(df))%2C%0A%20%20%20%20%20%20%20%20%5Bdf.stress_range.argmax()%2C%20df.pm_damage.argmax()%5D%2C%0A%20%20%20%20)%0A%20%20%20%20damage_figure%2C%20damage_axis%20%3D%20df.iloc%5Bdamage_rows%5D.miner.plot_histogram()%0A%20%20%20%20plot_views(damage_figure)%0A%0A%0A%40app.cell%0Adef%20_(df%2C%20display_indices%2C%20plot_views)%3A%0A%20%20%20%20accessor_axis%20%3D%20df.iloc%5Bdisplay_indices(len(df))%5D.plot(%0A%20%20%20%20%20%20%20%20kind%3D%22scatter%22%2C%20x%3D%22cumul_cycle%22%2C%20y%3D%22crack_depth%22%2C%20s%3D2%0A%20%20%20%20)%0A%20%20%20%20plot_views(accessor_axis.figure)%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
f3b177cba909d1f37df629e54b7dbf58