graintrace.material_calibration#
Crystal-plasticity material parameter calibration (NEML2 v3 + pyzag adjoint).
- class graintrace.material_calibration.MaterialCalibration(model_class, model_args, data_args, apply_elastic_correction=False, correction_method='with_experiment_average', strain_window=None, save_dir='calibration_results')[source]#
Bases:
objectParameter calibration on the NEML2 v3 + pyzag adjoint engine (LBFGS with analytic gradients, RangeRescale reparametrization, optional plotting).
- DEFAULT_PARAM_RANGES = {'elastic_tensor_E': (10000.0, 500000.0), 'elastic_tensor_G': (1000.0, 300000.0), 'elastic_tensor_nu': (-0.5, 0.5), 'slip_strength_constant_strength': (1.0, 2000.0), 'voce_hardening_initial_slope': (0.001, 50000.0), 'voce_hardening_saturated_hardening': (1.0, 2000.0)}#
- objective(params=None, default_err=1000000.0)[source]#
L2 norm of (model axial stress - experimental stress). If
paramsis given, evaluate at those values; otherwise at the current factory parameters. Kept for API compatibility / diagnostics.
- calibrate(method='lbfgs', maxiter=50, lr=0.1, max_iter_per_step=20, line_search_fn=None, param_ranges=None, plateau_rtol=0.001, plateau_window=3, autosave=True, full_field_weight=0.0, full_field_components=None, n_quantiles=64)[source]#
Calibrate the six parameters with analytic-adjoint gradients + LBFGS.
methodis accepted for backward compatibility only.full_field_weight(default 0.0) adds a distribution-matched per-grain elastic-strain term to the macroscopic-stress loss, i.e.loss = mean((sigma_model - sigma_exp)^2) + full_field_weight * fullfield_strain_loss. When 0.0 the objective is macroscopic-stress-only (unchanged behavior).full_field_componentsselects strain tensor components (default all 6);n_quantilessets the quantile resolution of the distribution match.
- plot_stress_strain(include_model=False, optimized=True, include_experiment_overlay=True)[source]#
Plot stress-strain data.
- plot_texture(direction=None, crystal_symmetry='432')[source]#
Plot experimental pole figures (neml2.texture).
- plot_strain_histogram(strain_index=None, include_initial_strain=False)[source]#
Plot elastic strain histograms (model vs experiment) at matching stress levels.