|
RadCluster
Graph-based cluster dynamics for irradiated materials
|
Functions | |
| set_plot_config (cfg) | |
| _set_title (ax, text, **kw) | |
| _apply_axis_config (ax, group) | |
| _apply_axis_config_to_fig (fig, group) | |
| _legend_fs () | |
| _legend_below (fig, axes, ncol=8, fontsize=None, bottom=0.28) | |
| _check_mpl () | |
| _dose_xlim (dose) | |
| _align_dose_to_y (results) | |
| plot_point_defects (results, out_path=None, title='') | |
| plot_totals (results, out_path=None, title='') | |
| plot_swelling (results, out_path=None, title='') | |
| plot_network_density (results, out_path=None, title='') | |
| _has_conversion (results) | |
| plot_mean_sizes (results, out_path=None, title='') | |
| plot_he_content (results, out_path=None, title='') | |
| plot_size_distribution (results, input_data, t_idx=-1, out_path=None, title='') | |
| _extract_cluster_arrays (results, input_data) | |
| plot_sia_clusters (results, input_data, out_path=None, title='') | |
| plot_vac_clusters (results, input_data, out_path=None, title='') | |
| _log_snapshot_indices (dose, n_times=10) | |
| _b_100 (results, input_data, b_111) | |
| _loop_dist_evolution (c_src, b, Omega, dose, n_times, char, title) | |
| _save_pair (figs, out_path) | |
| plot_sia_distribution_evolution (results, input_data, n_times=10, out_path=None, title='') | |
| plot_100_distribution_evolution (results, input_data, n_times=10, out_path=None, title='') | |
| plot_void_distribution_evolution (results, input_data, n_times=10, out_path=None, title='') | |
| plot_number_densities (results, out_path=None, title='') | |
| plot_loop_fraction (results, out_path=None, title='') | |
| _tem_filter (c_arr, n_min=_N_MIN_TEM) | |
| plot_number_densities_tem (results, input_data, rate_eq_obj, out_path=None, title='') | |
| plot_mean_sizes_tem (results, input_data, rate_eq_obj, out_path=None, title='') | |
| _visualization_bins (rate_eq_obj, max_size, kind) | |
| _aggregate_to_bins (c_per_size, bins_full) | |
| _plot_tem_density_panel (bins_full, mu0_arr, dose, *n_times, xform, n_min, xlabel, ylabel, plot_title, cmap_name, use_logx, out_path, ymin=None) | |
| plot_sia_distribution_tem_size (results, input_data, rate_eq_obj, n_times=8, out_path=None, title='') | |
| plot_sia_distribution_tem_diameter (results, input_data, rate_eq_obj, n_times=8, out_path=None, title='') | |
| plot_vac_distribution_tem_size (results, input_data, rate_eq_obj, n_times=8, out_path=None, title='') | |
| plot_vac_distribution_tem_diameter (results, input_data, rate_eq_obj, n_times=8, out_path=None, title='') | |
| _interp_bins_at_doses (mu0_arr, dose, targets) | |
| _plot_smooth_diameter_panel (bins_full, mu0_arr, dose, *xform, n_min, xlabel, ylabel, plot_title, cmap_name, out_path, ymin, xmax=None, doses=_SMOOTH_DOSES) | |
| plot_vac_distribution_diameter_smooth (results, input_data, rate_eq_obj, out_path=None, title='') | |
| plot_sia_distribution_diameter_smooth (results, input_data, rate_eq_obj, out_path=None, title='') | |
| _reconstruct_distributions (results, input_data, rate_eq_obj) | |
| plot_sia_conc_vs_dose (results, input_data, rate_eq_obj, out_path=None, title='') | |
| _plot_vac_moment_vs_dose (results, input_data, rate_eq_obj, *weight, ylabel, plot_title, out_path, ymin=None) | |
| plot_vac_conc_vs_dose (results, input_data, rate_eq_obj, out_path=None, title='') | |
| plot_vac_content_vs_dose (results, input_data, rate_eq_obj, out_path=None, title='') | |
| _quarter_indices (dose) | |
| _logspaced_indices (dose, n_snap=8) | |
| plot_sia_fraction_breakdown (results, out_path=None, title='') | |
| plot_vac_fraction_breakdown (results, out_path=None, title='') | |
| _atomic_pickle_dump (payload, out_path) | |
| save_plot_data (results, input_data, out_path, *rate_eq_obj=None, label='') | |
| load_plot_data (path) | |
| _safe_save (artifact, fn, *args, **kwargs) | |
| save_all_plots (results, input_data, out_dir, label='', rate_eq_obj=None) | |
Variables | |
| bool | _HAS_MPL = True |
| str | _CONC_LABEL = r'Concentration (m$^{-3}$)' |
| int | _PLOT_FONTSIZE = 16 |
| int | _LABEL_FONTSIZE = 22 |
| int | _TICK_FONTSIZE = 20 |
| int | _INTERIOR_LEGEND_FONTSIZE = 12 |
| _LW | |
| _LW_THIN | |
| dict | _PLOT_CONFIG |
| str | _LBL_111 = r'$\frac{1}{2}\langle 111\rangle$ loops' |
| str | _LBL_100 = r'$\langle 100\rangle$ loops' |
| str | _C_111 = 'steelblue' |
| str | _C_100 = 'darkviolet' |
| _DIST_N_MAX | |
| _DIST_D_MAX_NM | |
| int | _N_MIN_TEM = 10 |
| float | _OMEGA = 1.18e-29 |
| float | _B_111 = 2.482e-10 |
| str | _DENSITY_LABEL_SIZE = r'$dc/dn$ (m$^{-3}$)' |
| str | _DENSITY_LABEL_DIAM = r'$dc/dD$ (m$^{-3}$ nm$^{-1}$)' |
| tuple | _SMOOTH_DOSES = (1.0, 5.0, 10.0, 20.0, 40.0) |
| str | PLOT_DATA_FILENAME = 'plot_data.pkl' |
visualization.py — Plotting routines for RadCluster_2_1. Generates standardized figures from the ODE post-processing results. All concentration quantities are in m^-3 (converted in post_process.py).
|
protected |
Sum per-size concentrations over each visualization bin. Returns mu0 of shape [K, n_t] where K = len(bins_full). For width-1 bins this is just c_n; for grouped bins it is the bin's zeroth moment (the lognormal/linear closure preserves this exactly).
Definition at line 975 of file visualization.py.
|
protected |
Return (y, dose) with matching time dimensions. After adaptive domain-doubling, ``results['y']`` may contain only the last segment (its row count changed), while ``results['dose']`` spans the full run. When the two lengths differ, take the *tail* of dose to match ``y``.
Definition at line 158 of file visualization.py.
|
protected |
Apply the named group's scale and limits to a single axis.
Definition at line 88 of file visualization.py.
|
protected |
Definition at line 106 of file visualization.py.
|
protected |
Pickle to a sibling .tmp file, fsync, then atomic-rename to out_path. A crash, Ctrl+C, or OOM during the dump leaves the .tmp behind (cleaned up here on its way out) and never touches an existing good file at out_path. Callers can therefore re-load the previous run's pickle even if the latest save was interrupted.
Definition at line 1673 of file visualization.py.
|
protected |
⟨100⟩ Burgers vector (= lattice parameter a) [m].
Definition at line 546 of file visualization.py.
|
protected |
Definition at line 142 of file visualization.py.
|
protected |
Return the left x-limit for a dose axis. Uses the minimum positive dose value in the data so the plot is never reversed when the run ends at a dose below any hard-coded threshold.
Definition at line 147 of file visualization.py.
|
protected |
Return (c_n, c_v, dose) arrays [size x n_t] in m^-3. Works only for full_CD modes (y has per-cluster rows). Returns None for bin-moment runs where y rows are moments.
Definition at line 425 of file visualization.py.
|
protected |
True if the run carries a populated ⟨100⟩ loop population.
Definition at line 276 of file visualization.py.
|
protected |
Interpolate every bin's mu0 onto `targets`, linearly in log-log. The solution is written out on a coarse dose grid -- in the reference run only 37 points, with a single stored point covering 6.2-15.7 dpa -- so snapping to the nearest stored dose would hand two different requested doses the same curve. Interpolating in log(mu0) vs log(dose) is exact at the stored points and smooth between them. THESE CURVES ARE THEREFORE A DISPLAY INTERPOLATION, not solver output at those doses; write the run out on a finer dose grid if the intermediate curves need to be exact.
Definition at line 1159 of file visualization.py.
|
protected |
Place a single shared legend underneath the plot area. Removes any existing per-axes legends, then adds a figure-level legend using the handles from the first axis (cluster-concentration plots duplicate the same labels across panels).
Definition at line 115 of file visualization.py.
|
protected |
Definition at line 111 of file visualization.py.
|
protected |
Return n_times indices log-spaced across the dose array.
Definition at line 534 of file visualization.py.
|
protected |
Return *n_snap* time indices log-spaced over the dose range.
Definition at line 1557 of file visualization.py.
|
protected |
Shared SIA-loop size-distribution-evolution figures. c_src : [I, n_t] loop densities in at.frac; b : Burgers vector [m]; char : population label for titles/axes (e.g. '1/2<111>', '<100>'). Returns TWO figures -- (vs cluster size n, vs loop diameter nm). They were one stacked 8x9 canvas until 2026-09-06, which left both panels squeezed and their titles colliding; separate figures let each carry a real axis range.
Definition at line 558 of file visualization.py.
|
protected |
Per-bin density vs diameter as smooth curves through the bin midpoints. The stair rendering of `_plot_tem_density_panel` is faithful to the coarse-grained representation but hard to read when several doses overlap. Here each visualization bin contributes one point -- the midpoint of its diameter interval, at height rho_k = mu0_k / (d_hi - d_lo) -- and the points are joined. Same quantity, same normalisation: the area under the curve still approximates the concentration in the displayed range.
Definition at line 1182 of file visualization.py.
|
protected |
TEM-visible per-bin density plot. Each visualization bin is rendered as a stair segment of height rho_k = mu_0(k) / (x_hi - x_lo) where the x-edges come from `xform` (identity for size axis, diameter formula for diameter axes). This is the standard microstructure-distribution representation: integral under the stairs equals total concentration in the displayed range. Per-bin density is well defined regardless of the intra-bin shape function, so the comb artefact of integer-resolved lognormal reconstruction is avoided by construction.
Definition at line 991 of file visualization.py.
|
protected |
Cavity moment vs. dose — discrete sizes + bin mu0, weighted by `weight`.
weight='mu0' → plot mu0 (number density per bin).
weight='content'→ plot mu0 * (m or midpoint) (vacancy content per bin).
ymin → fixed y floor; None leaves it to the data (the two
weightings do not share a scale).
Definition at line 1454 of file visualization.py.
|
protected |
Return 4 time indices at ~25%, 50%, 75%, 100% of the log-dose range.
Definition at line 1552 of file visualization.py.
|
protected |
Reconstruct per-size c_n [N, n_t] and c_v [M, n_t] in m^-3 from ODE state, handling both full_CD and bin-moment modes. Returns (c_n, c_v, dose) or (None, None, None) on failure.
Definition at line 1287 of file visualization.py.
|
protected |
Run a save call, catching/printing any failure with a traceback. KeyboardInterrupt is NOT caught here — it propagates so the outer interrupt shield (see simulation._InterruptDeferred) can decide whether to defer it through the rest of the save or escalate.
Definition at line 1725 of file visualization.py.
|
protected |
Write the (size, diameter) figure pair as <stem>_size / _diameter PNGs.
Definition at line 602 of file visualization.py.
|
protected |
Axes (or panel) title, drawn only when `show_titles` is on.
Definition at line 82 of file visualization.py.
|
protected |
Return mask for TEM-visible clusters (size index >= n_min - 1).
Definition at line 785 of file visualization.py.
|
protected |
Build the visualization bin list covering sizes 1..max_size. Each entry is (n_lo, n_hi) with n_hi exclusive (matching the bin_moment_rates convention). For full_CD modes every integer is its own width-1 bin. For bin_moment modes the discrete portion is width-1 integers and the grouped portion is taken from rate_eq_obj.bins (kind='sia') or rate_eq_obj.vac_bins (kind='vac').
Definition at line 951 of file visualization.py.
| py_utils.visualization.load_plot_data | ( | path | ) |
Inverse of save_plot_data — returns the dict that was pickled.
Definition at line 1718 of file visualization.py.
| py_utils.visualization.plot_100_distribution_evolution | ( | results, | |
| input_data, | |||
n_times = 10, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
⟨100⟩ loop size distribution c_n(n) at n_times log-spaced snapshots (loop conversion). Mirrors plot_sia_distribution_evolution for the sessile ⟨100⟩ population; returns None when conversion is off.
Definition at line 636 of file visualization.py.
| py_utils.visualization.plot_he_content | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Free and total He vs. dose.
Definition at line 314 of file visualization.py.
| py_utils.visualization.plot_loop_fraction | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
½⟨111⟩ loop fraction f₁₁₁ vs. dose (loop conversion).
f₁₁₁ = Σ n c_n^{111} / Σ n (c_n^{111}+c_n^{100}) — the content-weighted
fraction of SIA-loop atoms still in ½⟨111⟩ loops, directly comparable to the
experimental Burgers-vector fraction. Returns None if conversion is off.
Definition at line 742 of file visualization.py.
| py_utils.visualization.plot_mean_sizes | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Mean SIA and vacancy cluster sizes vs. dose. With loop conversion, the SIA loops are split into ½⟨111⟩ and ⟨100⟩.
Definition at line 282 of file visualization.py.
| py_utils.visualization.plot_mean_sizes_tem | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
Mean cluster sizes vs dose — TEM-visible only (n,m ≥ 10). Shows both atoms (left axis) and physical diameter in nm (right axis).
Definition at line 856 of file visualization.py.
| py_utils.visualization.plot_network_density | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Network dislocation density ρ_net vs. dose (loop_network_loss.tex). With the LOOP_NETWORK_LOSS channel active, sessile loops are swept into the pre-existing network, so ρ_net rises with dose and (with a calibrated recovery sink) saturates — the feedback that bounds the loop density. When the channel is off the curve is flat at the static ρ_d, which is still a valid reading of the network density.
Definition at line 238 of file visualization.py.
| py_utils.visualization.plot_number_densities | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Loop and void number densities (clusters n,m ≥ 2) vs. dose.
Definition at line 710 of file visualization.py.
| py_utils.visualization.plot_number_densities_tem | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
Loop and void number densities vs dose — TEM-visible only (n,m ≥ 10). Plotted alongside the total (all sizes) for comparison.
Definition at line 791 of file visualization.py.
| py_utils.visualization.plot_point_defects | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Free SIA (Ci1) and vacancy (Cv1) monomers vs. dose.
Definition at line 175 of file visualization.py.
| py_utils.visualization.plot_sia_clusters | ( | results, | |
| input_data, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
SIA cluster concentrations vs. dose, split into small / mid / large.
Definition at line 447 of file visualization.py.
| py_utils.visualization.plot_sia_conc_vs_dose | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
(1) SIA concentrations vs. dose — discrete sizes + bin mu0. Discrete sizes plotted individually; each bin as one curve.
Definition at line 1388 of file visualization.py.
| py_utils.visualization.plot_sia_distribution_diameter_smooth | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
SIA loop diameter distribution as smooth curves at fixed doses.
Definition at line 1260 of file visualization.py.
| py_utils.visualization.plot_sia_distribution_evolution | ( | results, | |
| input_data, | |||
n_times = 10, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
½⟨111⟩ SIA cluster size distribution c_n(n) at n_times log-spaced snapshots. Top panel: log-scale concentration vs cluster size n. Bottom panel: linear-scale concentration vs loop diameter (nm).
Definition at line 614 of file visualization.py.
| py_utils.visualization.plot_sia_distribution_tem_diameter | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
n_times = 8, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
SIA distribution density vs loop diameter (TEM-visible, n ≥ N_MIN_TEM).
Definition at line 1075 of file visualization.py.
| py_utils.visualization.plot_sia_distribution_tem_size | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
n_times = 8, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
SIA distribution density vs cluster size (TEM-visible, n ≥ N_MIN_TEM).
Definition at line 1050 of file visualization.py.
| py_utils.visualization.plot_sia_fraction_breakdown | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
SIA content fraction breakdown vs. dose. Three curves that should sum to 1.0 at every dose: - In clusters (content in system / total produced) - At fixed sinks (cumulative fixed-sink loss / total produced) - Recombined + cavity (mutual annihilation / total produced)
Definition at line 1569 of file visualization.py.
| py_utils.visualization.plot_size_distribution | ( | results, | |
| input_data, | |||
t_idx = -1, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
SIA and vacancy cluster size distributions at a given time index.
Definition at line 341 of file visualization.py.
| py_utils.visualization.plot_swelling | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Void swelling S(t) vs. dose.
Definition at line 221 of file visualization.py.
| py_utils.visualization.plot_totals | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Total SIA, vacancy, and He contents vs. dose.
Definition at line 199 of file visualization.py.
| py_utils.visualization.plot_vac_clusters | ( | results, | |
| input_data, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
Vacancy cluster concentrations vs. dose, split into small / mid / large.
Definition at line 491 of file visualization.py.
| py_utils.visualization.plot_vac_conc_vs_dose | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
Cavity zeroth moment μ_k^(0) (number density per bin) vs. dose.
Definition at line 1530 of file visualization.py.
| py_utils.visualization.plot_vac_content_vs_dose | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
Cavity content per bin (μ_k^(0) × m̄_k) vs. dose.
Definition at line 1541 of file visualization.py.
| py_utils.visualization.plot_vac_distribution_diameter_smooth | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
out_path = None, |
|||
title = '' |
|||
| ) |
Cavity diameter distribution as smooth curves at fixed doses.
Definition at line 1234 of file visualization.py.
| py_utils.visualization.plot_vac_distribution_tem_diameter | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
n_times = 8, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
Cavity distribution density vs void diameter (TEM-visible, m ≥ N_MIN_TEM).
Definition at line 1128 of file visualization.py.
| py_utils.visualization.plot_vac_distribution_tem_size | ( | results, | |
| input_data, | |||
| rate_eq_obj, | |||
n_times = 8, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
Cavity distribution density vs cluster size (TEM-visible, m ≥ N_MIN_TEM).
Definition at line 1103 of file visualization.py.
| py_utils.visualization.plot_vac_fraction_breakdown | ( | results, | |
out_path = None, |
|||
title = '' |
|||
| ) |
Vacancy content fraction breakdown vs. dose. Three curves that should sum to 1.0: - In clusters (swelling content / total produced) - At fixed sinks (cumulative fixed-sink loss / total produced) - Annihilated by SIA (SIA-cavity + recombination / total produced)
Definition at line 1620 of file visualization.py.
| py_utils.visualization.plot_void_distribution_evolution | ( | results, | |
| input_data, | |||
n_times = 10, |
|||
out_path = None, |
|||
title = '' |
|||
| ) |
Void/vacancy cluster size distribution c_m(m) at n_times log-spaced dose snapshots. Top panel: log-scale concentration vs vacancy cluster size m. Bottom panel: linear-scale concentration vs void diameter (nm).
Definition at line 657 of file visualization.py.
| py_utils.visualization.save_all_plots | ( | results, | |
| input_data, | |||
| out_dir, | |||
label = '', |
|||
rate_eq_obj = None |
|||
| ) |
Save all standard plots to out_dir/. Each artifact (the pickle and every PNG) is wrapped in its own try/except so a single failure cannot abort the rest. The pickle uses atomic writes; if it fails, any pre-existing good pickle is preserved.
Definition at line 1744 of file visualization.py.
| py_utils.visualization.save_plot_data | ( | results, | |
| input_data, | |||
| out_path, | |||
| * | rate_eq_obj = None, |
||
label = '' |
|||
| ) |
Pickle everything needed to regenerate the plots later. The dump contains the full `results` dict, the `InputData` object, the rate-equation object (if provided), and the title `label` so a notebook can call any plot function later without re-running the simulation. Writes are atomic (temp file + os.replace) so an interrupt mid-dump never leaves a truncated pickle at `out_path`.
Definition at line 1698 of file visualization.py.
| py_utils.visualization.set_plot_config | ( | cfg | ) |
Update the module-level plot config; partial overrides are merged.
Definition at line 72 of file visualization.py.
|
protected |
Definition at line 782 of file visualization.py.
|
protected |
Definition at line 273 of file visualization.py.
|
protected |
Definition at line 272 of file visualization.py.
|
protected |
Definition at line 16 of file visualization.py.
|
protected |
Definition at line 1047 of file visualization.py.
|
protected |
Definition at line 1046 of file visualization.py.
|
protected |
Definition at line 555 of file visualization.py.
|
protected |
Definition at line 555 of file visualization.py.
|
protected |
Definition at line 12 of file visualization.py.
|
protected |
Definition at line 21 of file visualization.py.
|
protected |
Definition at line 19 of file visualization.py.
|
protected |
Definition at line 271 of file visualization.py.
|
protected |
Definition at line 270 of file visualization.py.
|
protected |
Definition at line 24 of file visualization.py.
|
protected |
Definition at line 24 of file visualization.py.
|
protected |
Definition at line 780 of file visualization.py.
|
protected |
Definition at line 781 of file visualization.py.
|
protected |
Definition at line 49 of file visualization.py.
|
protected |
Definition at line 18 of file visualization.py.
|
protected |
Definition at line 1156 of file visualization.py.
|
protected |
Definition at line 20 of file visualization.py.
| str py_utils.visualization.PLOT_DATA_FILENAME = 'plot_data.pkl' |
Definition at line 1670 of file visualization.py.