RadCluster
Graph-based cluster dynamics for irradiated materials
Loading...
Searching...
No Matches
Functions | Variables
compare_window_modes Namespace Reference

Functions

 build_sim (solver_mode, physics_option=None)
 
 run_mode (label, solver_mode, solver_cfg)
 
 _load_run_from_dir (d, solver_mode, label)
 
 find_reference_run (ref_dir=None)
 
 find_window_run (load_dir=None)
 
 _relerr (ref, new)
 
 make_comparison_plots (res_dict, wall_dict, out_path)
 
 make_distribution_plots (res_dict, out_path)
 
 write_report (res_dict, wall_dict, report_path)
 
 main ()
 

Variables

 CODES_DIR = Path(__file__).resolve().parent.parent
 
 MODULE_ROOT = CODES_DIR.parent
 
 REPO_ROOT = MODULE_ROOT.parent
 
 I = int(1e4)
 
 V = int(1e4)
 
int i_mobile = 1
 
int v_mobile = 1
 
 i_discrete = I
 
 v_discrete = V
 
int I_bin = 0
 
int V_bin = 0
 
int C_FLOOR = 1e-25
 
str HE_KINETICS = 'quasi_steady_state'
 
dict PARAM_OVERRIDES
 
dict BASE_SOLVER_CFG
 
dict WINDOW_METHOD
 
dict MODE4_CFG = {**BASE_SOLVER_CFG, 'solver_method': WINDOW_METHOD}
 
dict MODE0_CFG
 
str PHYSICS_OPTION = 'full_CD_fission'
 
dict COLORS = {'mode0': '#1f77b4', 'mode4': '#2ca02c'}
 
dict LABELS
 
dict LS = {'mode0': '-', 'mode4': '--'}
 

Detailed Description

compare_window_modes.py
=======================
Run and compare the two solver modes for the I=V=10000 full_CD system:

  Mode 0 — full_system     : reference (20 006 ODEs, no window)
  Mode 4 — active_window   : two independent sliding windows + OpenMP-parallel
                              RHS (auto-serial when threads=1)

Physical parameters are taken verbatim from the notebook cell:
  T=573 K, G=1e-6 dpa/s, I=V=10000, i_mobile=v_mobile=1,
  i_discrete=I, v_discrete=V, I_bin=V_bin=0 (full per-size),
  he_kinetics=quasi_steady_state, fission cascade.

Window design (derived from I=V=1000 reference run):
  SIA front saturates at n≈62 at t=1e4 s,  VAC front reaches m≈1000 at t=1e4 s.
  Initial width must accommodate both axes  →  window_width = 500.
  (expand thresholds / pads tuned to match these observations)

Usage:
  cd EuroferMicrostructure/radcluster_code/codes
  python compare_window_modes.py [--ref-dir <path>] [--skip-mode0]

Function Documentation

◆ _load_run_from_dir()

compare_window_modes._load_run_from_dir (   d,
  solver_mode,
  label 
)
protected
Load a saved run from directory *d*.  Returns (results_dict, dir_name) or
(None, None) if the directory doesn't contain valid results.

Definition at line 221 of file compare_window_modes.py.

◆ _relerr()

compare_window_modes._relerr (   ref,
  new 
)
protected
Element-wise relative error |new - ref| / (|ref| + 1e-30).

Definition at line 323 of file compare_window_modes.py.

◆ build_sim()

compare_window_modes.build_sim (   solver_mode,
  physics_option = None 
)
Construct an RadClusterSimulation with the reference parameters.

Definition at line 133 of file compare_window_modes.py.

◆ find_reference_run()

compare_window_modes.find_reference_run (   ref_dir = None)
Return the results dict for mode-0.  If ref_dir is given, load from there.
Otherwise scan the output directory for the most recent full_system run
with N_eq == 20006 (I=V=10000, QSS He) matching PHYSICS_OPTION (or
bin_moment fallback since they are mathematically identical with I_bin=0).
Legacy `cpp_full` directory names are also matched.

Definition at line 248 of file compare_window_modes.py.

◆ find_window_run()

compare_window_modes.find_window_run (   load_dir = None)
Return the results dict for active_window.  If load_dir is given, load
from there; otherwise find the most recent matching output directory for
PHYSICS_OPTION.  Legacy `sliding_OpenMP` directory names are also matched.

Definition at line 288 of file compare_window_modes.py.

◆ main()

compare_window_modes.main ( )

Definition at line 654 of file compare_window_modes.py.

◆ make_comparison_plots()

compare_window_modes.make_comparison_plots (   res_dict,
  wall_dict,
  out_path 
)
res_dict : {'mode0': results, 'mode4': results}  (any key may be absent)
wall_dict: {'mode0': float,   'mode4': float}
out_path : Path to save the figure

Definition at line 328 of file compare_window_modes.py.

◆ make_distribution_plots()

compare_window_modes.make_distribution_plots (   res_dict,
  out_path 
)

Definition at line 505 of file compare_window_modes.py.

◆ run_mode()

compare_window_modes.run_mode (   label,
  solver_mode,
  solver_cfg 
)

Definition at line 181 of file compare_window_modes.py.

◆ write_report()

compare_window_modes.write_report (   res_dict,
  wall_dict,
  report_path 
)

Definition at line 549 of file compare_window_modes.py.

Variable Documentation

◆ BASE_SOLVER_CFG

dict compare_window_modes.BASE_SOLVER_CFG
Initial value:
1= {
2 't_span': (1e-6, 1e4),
3 'n_points': 200,
4 'log_time': True,
5 'rtol': 1e-6,
6 'atol': 1e-25,
7}

Definition at line 96 of file compare_window_modes.py.

◆ C_FLOOR

int compare_window_modes.C_FLOOR = 1e-25

Definition at line 74 of file compare_window_modes.py.

◆ CODES_DIR

compare_window_modes.CODES_DIR = Path(__file__).resolve().parent.parent

Definition at line 34 of file compare_window_modes.py.

◆ COLORS

dict compare_window_modes.COLORS = {'mode0': '#1f77b4', 'mode4': '#2ca02c'}

Definition at line 318 of file compare_window_modes.py.

◆ HE_KINETICS

str compare_window_modes.HE_KINETICS = 'quasi_steady_state'

Definition at line 75 of file compare_window_modes.py.

◆ I

compare_window_modes.I = int(1e4)

Definition at line 66 of file compare_window_modes.py.

◆ I_bin

int compare_window_modes.I_bin = 0

Definition at line 72 of file compare_window_modes.py.

◆ i_discrete

compare_window_modes.i_discrete = I

Definition at line 70 of file compare_window_modes.py.

◆ i_mobile

int compare_window_modes.i_mobile = 1

Definition at line 68 of file compare_window_modes.py.

◆ LABELS

dict compare_window_modes.LABELS
Initial value:
1= {'mode0': 'Mode 0 — full_system (ref)',
2 'mode4': 'Mode IV — active_window'}

Definition at line 319 of file compare_window_modes.py.

◆ LS

dict compare_window_modes.LS = {'mode0': '-', 'mode4': '--'}

Definition at line 321 of file compare_window_modes.py.

◆ MODE0_CFG

dict compare_window_modes.MODE0_CFG
Initial value:
1= {**BASE_SOLVER_CFG, 'solver_method': {
2 'linsol': 'gmres',
3}}

Definition at line 121 of file compare_window_modes.py.

◆ MODE4_CFG

dict compare_window_modes.MODE4_CFG = {**BASE_SOLVER_CFG, 'solver_method': WINDOW_METHOD}

Definition at line 120 of file compare_window_modes.py.

◆ MODULE_ROOT

compare_window_modes.MODULE_ROOT = CODES_DIR.parent

Definition at line 35 of file compare_window_modes.py.

◆ PARAM_OVERRIDES

dict compare_window_modes.PARAM_OVERRIDES
Initial value:
1= {
2 'eta': 0.3,
3 'f_cl_i': 0.58,
4 'f_cl_v': 0.45,
5 'E_m_1D': 0.34,
6 'i_mobile': i_mobile,
7 'L_hat': 71.8,
8 'c_C': 1.94e-4,
9 'E_b_C_SIA': 0.45,
10 'rho_d': 1e14,
11 'Z_i': 1.1,
12 'Z_ii': 1.1,
13 'shape_function': 'linear',
14 'i_discrete': i_discrete,
15 'v_discrete': v_discrete,
16 'I_bin': I_bin,
17 'V_bin': V_bin,
18}

Definition at line 77 of file compare_window_modes.py.

◆ PHYSICS_OPTION

str compare_window_modes.PHYSICS_OPTION = 'full_CD_fission'

Definition at line 130 of file compare_window_modes.py.

◆ REPO_ROOT

compare_window_modes.REPO_ROOT = MODULE_ROOT.parent

Definition at line 36 of file compare_window_modes.py.

◆ V

compare_window_modes.V = int(1e4)

Definition at line 67 of file compare_window_modes.py.

◆ V_bin

int compare_window_modes.V_bin = 0

Definition at line 73 of file compare_window_modes.py.

◆ v_discrete

compare_window_modes.v_discrete = V

Definition at line 71 of file compare_window_modes.py.

◆ v_mobile

int compare_window_modes.v_mobile = 1

Definition at line 69 of file compare_window_modes.py.

◆ WINDOW_METHOD

dict compare_window_modes.WINDOW_METHOD
Initial value:
1= {
2 'linsol': 'gmres',
3 # Shared initial width and expansion threshold (SIA + VAC)
4 'window_width': 500, # initial active window: sizes 1..500
5 'concentration_threshold': 1e-22, # expand when leading concentration > 1e-22
6 # Per-axis expansion pads
7 'window_pad': 50, # grow SIA window by 50 at a time
8 'window_pad_v': 200, # grow VAC window by 200 at a time
9 # Misc
10 'window_check_every': 1,
11}

Definition at line 108 of file compare_window_modes.py.