weac.analysis.plotter module

This module provides plotting functions for visualizing the results of the WEAC model.

class weac.analysis.plotter.MidpointNormalize(vmin, vmax, midpoint=0, clip=False)[source]

Bases: Normalize

Colormap normalization to a specified midpoint. Default is 0.

__init__(vmin, vmax, midpoint=0, clip=False)[source]

Initialize normalization.

__call__(value, clip=None)[source]

Apply normalization.

class weac.analysis.plotter.Plotter(plot_dir='plots')[source]

Bases: object

Modern plotting class for WEAC simulations with support for multiple system comparisons.

This class provides comprehensive visualization capabilities for weak layer anticrack nucleation simulations, including single system analysis and multi-system comparisons.

Features: - Single and multi-system plotting - System override functionality for selective plotting - Comprehensive dashboard creation - Modern matplotlib styling - Jupyter notebook integration - Automatic plot directory management

Parameters:

plot_dir (str)

__init__(plot_dir='plots')[source]

Initialize the plotter.

Parameters:
  • system (SystemModel, optional) – Single system model for analysis

  • systems (List[SystemModel], optional) – List of system models for comparison

  • labels (List[str], optional) – Labels for each system in plots

  • colors (List[str], optional) – Colors for each system in plots

  • plot_dir (str, default "plots") – Directory to save plots

plot_slab_profile(weak_layers, slabs, filename='slab_profile', labels=None, colors=None)[source]

Plot slab layer profiles for comparison.

Parameters:
  • weak_layers (List[WeakLayer] | WeakLayer) – The weak layer or layers to plot.

  • slabs (List[Slab] | Slab) – The slab or slabs to plot.

  • filename (str, optional) – Filename for saving plot

  • labels (list of str, optional) – Labels for each system.

  • colors (list of str, optional) – Colors for each system.

Returns:

The generated plot figure.

Return type:

matplotlib.figure.Figure

plot_rotated_slab_profile(weak_layer, slab, angle=0, weight=0, slab_width=200, filename='rotated_slab_profile', title='Rotated Slab Profile')[source]

Plot a rectangular slab profile with layers stacked vertically, colored by density, and rotated by the specified angle.

Parameters:
  • weak_layer (WeakLayer) – The weak layer to plot at the bottom.

  • slab (Slab) – The slab with layers to plot.

  • angle (float, optional) – Rotation angle in degrees. Default is 0.

  • slab_width (float, optional) – Width of the slab rectangle in mm. Default is 200.

  • filename (str, optional) – Filename for saving plot. Default is “rotated_slab_profile”.

  • title (str, optional) – Plot title. Default is “Rotated Slab Profile”.

  • weight (float)

Returns:

The generated plot figure.

Return type:

matplotlib.figure.Figure

plot_section_forces(system_model=None, system_models=None, filename='section_forces', labels=None, colors=None)[source]

Plot section forces (N, M, V) for comparison.

Parameters:
  • system_model (SystemModel, optional) – Single system to plot (overrides default)

  • system_models (List[SystemModel], optional) – Multiple systems to plot (overrides default)

  • filename (str, optional) – Filename for saving plot

  • labels (list of str, optional) – Labels for each system.

  • colors (list of str, optional) – Colors for each system.

plot_energy_release_rates(system_model=None, system_models=None, filename='ERR', labels=None, colors=None)[source]

Plot energy release rates (G_I, G_II) for comparison.

Parameters:
  • system_model (SystemModel, optional) – Single system to plot (overrides default)

  • system_models (List[SystemModel], optional) – Multiple systems to plot (overrides default)

  • filename (str, optional) – Filename for saving plot

  • labels (list of str, optional) – Labels for each system.

  • colors (list of str, optional) – Colors for each system.

plot_deformed(xsl, xwl, z, analyzer, dz=2, scale=100, window=np.inf, pad=2, levels=300, aspect=2, field='w', normalize=True, filename='deformed_slab')[source]

Plot deformed slab with field contours.

Parameters:
  • xsl (np.ndarray) – Slab x-coordinates.

  • xwl (np.ndarray) – Weak layer x-coordinates.

  • z (np.ndarray) – Solution vector.

  • analyzer (Analyzer) – Analyzer instance.

  • dz (int, optional) – Element size along z-axis (mm). Default is 2 mm.

  • scale (int, optional) – Deformation scale factor. Default is 100.

  • window (float, optional) – Plot window width. Default is inf.

  • pad (int, optional) – Padding around plot. Default is 2.

  • levels (int, optional) – Number of contour levels. Default is 300.

  • aspect (int, optional) – Aspect ratio. Default is 2.

  • field (str, optional) – Field to plot (‘w’, ‘u’, ‘principal’, ‘Sxx’, ‘Txz’, ‘Szz’). Default is ‘w’.

  • normalize (bool, optional) – Toggle normalization. Default is True.

  • filename (str, optional) – Filename for saving plot. Default is “deformed_slab”.

Returns:

The generated plot figure.

Return type:

matplotlib.figure.Figure

plot_stress_envelope(system_model, criteria_evaluator, all_envelopes=False, filename=None)[source]

Plot stress envelope in τ-σ space.

Parameters:
  • system_model (SystemModel) – System to plot

  • criteria_evaluator (CriteriaEvaluator) – Criteria evaluator to use for the stress envelope

  • all_envelopes (bool, optional) – Whether to plot all four quadrants of the envelope

  • filename (str, optional) – Filename for saving plot

plot_err_envelope(system_model, criteria_evaluator, filename='err_envelope')[source]

Plot the ERR envelope.

Parameters:
Return type:

Figure

plot_analysis(system, criteria_evaluator, min_force_result, min_crack_length, coupled_criterion_result, dz=2, deformation_scale=100.0, window=np.inf, levels=300, filename='analysis')[source]

Plot deformed slab with field contours.

Parameters:
  • field (str, default 'w') – Field to plot (‘w’, ‘u’, ‘principal’, ‘sigma’, ‘tau’)

  • system_model (SystemModel, optional) – System to plot (uses first system if not specified)

  • filename (str, optional) – Filename for saving plot

  • system (SystemModel)

  • criteria_evaluator (CriteriaEvaluator)

  • min_force_result (FindMinimumForceResult)

  • min_crack_length (float)

  • coupled_criterion_result (CoupledCriterionResult)

  • dz (int)

  • deformation_scale (float)

  • window (int)

  • levels (int)

Return type:

Figure

plot_displacements(analyzer, x, z, filename='displacements')[source]

Wrap for displacements plot.

Parameters:
  • analyzer (Analyzer)

  • x (ndarray)

  • z (ndarray)

  • filename (str)

Return type:

Figure

plot_stresses(analyzer, x, z, filename='stresses')[source]

Wrap stress plot.

Parameters:
  • analyzer (Analyzer)

  • x (ndarray)

  • z (ndarray)

  • filename (str)

Return type:

Figure

plot_stress_criteria(analyzer, x, stress)[source]

Wrap plot of stress and energy criteria.

Parameters:
  • analyzer (Analyzer)

  • x (ndarray)

  • stress (ndarray)

Return type:

Figure

plot_ERR_comp(analyzer, da, Gdif, Ginc, mode=0)[source]

Wrap energy release rate plot.

Parameters:
  • analyzer (Analyzer)

  • da (ndarray)

  • Gdif (ndarray)

  • Ginc (ndarray)

  • mode (int)

Return type:

Figure

plot_ERR_modes(analyzer, da, G, kind='inc')[source]

Wrap energy release rate plot.

Parameters:
  • analyzer (Analyzer)

  • da (ndarray)

  • G (ndarray)

  • kind (str)

Return type:

Figure

plot_fea_disp(analyzer, x, z, fea)[source]

Wrap displacements plot.

Parameters:
  • analyzer (Analyzer)

  • x (ndarray)

  • z (ndarray)

  • fea (ndarray)

Return type:

Figure

plot_fea_stress(analyzer, xb, zb, fea)[source]

Wrap stress plot.

Parameters:
  • analyzer (Analyzer)

  • xb (ndarray)

  • zb (ndarray)

  • fea (ndarray)

Return type:

Figure