CP-Agent: A Harness-Engineered Agent for Crystal Plasticity Simulation Workflows
Organizations: Department of Aerospace Engineering, University of Michigan, Ann Arbor, 48109, MI, USA
Abstract
Crystal plasticity (CP) simulations predict the mechanical behavior of polycrystalline metals, yet their routine use is hindered by the manual effort of configuring heterogeneous tools, orchestrating multi-step data pipelines, and calibrating constitutive parameters against experiments. These bottlenecks impede productivity in systematic parameter studies, motivating interest in automated workflows. This study presents CP-Agent, a harness-engineered LLM-based agent that autonomously executes complete CP modeling workflows from natural-language tasks. Operating under the ReAct paradigm, the agent reasons about tool selection and sequencing while delegating numerical search to established optimizers. The harness comprises a minimal system prompt, typed tool definitions, a dispatcher, and a safety-bounded iteration loop, encoding domain knowledge through tool schemas rather than hard-coded logic. CP-Agent is demonstrated on four case studies: calibrating four slip parameters of additively manufactured stainless steel 316L against tensile data; validating the workflow against published copper benchmarks, reproducing stress-strain and texture evolution; recovering the initial crystallographic texture of copper, where the agent correctly identifies a diffuse initial texture; and reproducing the multi-pass rolling texture evolution of a Mg-Zn-Ca alloy, where the agent chains five deformation passes and recovers the experimentally observed weakened, split basal texture. In all cases, the agent inferred the correct execution sequence from the task statement, robustly across repeated runs, and delivered physically interpretable results. This work establishes harness engineering as a systematic approach to automating CP modeling workflows while maintaining physical interpretability and auditability through visible reasoning traces.
Figures & tables
| Tool | Key inputs | Description |
| inject_simulation_parameters | orientation_type, fiber_direction, sigma_spread, and slip-system hardening parameters | Writes texture and constitutive slip parameters into the microstructure generation script and the CP configuration file via regular-expression substitution. Enforces schema-defined defaults for any parameter not explicitly specified in the user query. |
| generate_microstructure | None (reads from injected config) | Launches MATLAB in batch mode to generate a synthetic polycrystalline microstructure using MTEX and saves the grain ID map and per-grain Rodrigues orientation vectors to an HDF5 file. Also computes and saves pre-deformation pole figures. |
| convert_hdf5_to_prisms | None (reads HDF5 output) | Reads the HDF5 microstructure file and converts it to the CP code input format. Applies Fortran column-major array ordering to preserve the MATLAB memory layout. Updates the CP configuration file with the correct voxel grid dimensions. |
| run_simulation | None (reads CP configuration file) | Executes a CP simulation using the current configuration. Streams solver output in real time with a configurable timeout. Produces per-quadrature-point output files containing deformed grain orientations and stress-strain data. |
| extract_post_orientations | None (reads CP output) | Locates the final per-quadrature-point output file and extracts the post-deformation Rodrigues vector components. Saves extracted orientations for use in post-deformation texture analysis. |
| generate_pole_figures | None (reads pre- and post-deformation orientations) | Runs a MATLAB post-processing script that computes orientation distribution functions (ODFs) for both orientation sets and generates {100}, {110}, and {111} pole figures with matched color scales. |
| Tool | Algorithm | When the agent selects this tool |
| run_bayesian_optimization | Latin Hypercube Sampling + Gaussian Process + Expected Improvement | Default selection when no specific preference is stated. Most sample-efficient optimizer; preferred when the simulation budget is limited or an initial estimate of the optimum is unavailable. |
| run_differential_evolution | Population-based global search with mutation and crossover | Selected when the user specifies a broad or global parameter search, or when the query indicates uncertainty about the location of the optimum in the parameter space. |
| run_nelder_mead | Nelder-Mead simplex local optimizer | Selected when the user provides an initial parameter estimate and requests fast local refinement. Converges quickly near the optimum but may fail to escape local minima. |
| run_random_bo | Random Search followed by Bayesian Optimization | Selected when the user requests an exploratory phase before exploitation, or when a broad baseline is needed before Gaussian Process refinement. |
| Feature | CS1: Calibration | CS2: Forward Validation | CS3: Inverse Problem | CS4: Multi-pass Evolution |
| Material | SS316L | Copper | Copper | ZX31 (Mg–3Zn–0.3Ca), HCP |
| Question | What slip parameters fit the stress-strain data? | Does the model reproduce a known benchmark? | What initial texture produces the target deformation texture? | How does the basal texture evolve over multiple rolling passes? |
| Unknown (solved for) | Four slip parameters ( , , , ) | none (single forward run) | initial texture (random vs fiber, spread) | none (chained forward run) |
| Held fixed | microstructure, loading | everything (literature params) | slip params, loading, grain count | everything (Table-1 params) |
| Target/reference | experimental tensile curve [ 11 ] | experimental compression curve [ 44 ] ; pole figure [ 44 ] | pole figures [ 44 ] | 5-pass simulation + EBSD pole figures [ 45 ] |
| Method | agent selects optimizer search | agent runs pipeline once | agent selects Bayesian optimizer search over textures | agent chains five passes |
| Parameter | Lower | Upper | Physical Meaning and its role |
| Initial slip resistance, | 100 MPa | 150 MPa | Stress to initiate slip; controls yield stress |
| Initial hardening modulus, | 800 MPa | 2500 MPa | Rate of initial strengthening; controls initial hardening rate |
| Saturation stress, | 350 MPa | 600 MPa | Maximum achievable stress; controls the flow stress plateau |
| Power law exponent, | 1 | 3 | Strain rate sensitivity; controls sharpness of the hardening transition / strain rate sensitivity |
| Stopping: RMSE | - | 5 MPa | Absolute agreement criterion |
| Stopping: MAPE | - | 2 % | Relative agreement criterion |
| Quantity | Value | Comment |
| Initial slip resistance, | 121 MPa | Interior of the bounds |
| Initial hardening modulus, | 2399 MPa | 97.5 per cent of the upper bound |
| Saturation stress, | 542 MPa | 97.8 per cent of the upper bound |
| Power law exponent, | 2.9 | Interior of the bounds |
| RMSE | 4.95 MPa | Below the 5 MPa stopping threshold |
| MAPE | 2.85 % | Above the 2 per cent stopping threshold |
| Feature (MRD) | This study | Reference |
| Peak intensity, | 2.16 | 2.0 |
| Peak intensity, | 3.75 | 3.5 |
| Peak intensity, | 2.23 | 2.0 |
| Central ( compression fiber) | 3.47 | 3.5 |
| Central (axial depletion) | 0.01 | 0 |
| Item | Specification |
| Design variable 1 | Texture mode: random, or fiber about , , or |
| Design variable 2 | Fiber spread , 3 to 85 degrees (larger spread gives a more diffuse fiber) |
| Objective | Texture-match loss vs target pole figures |
| Search method | Bayesian optimization (Gaussian process + expected improvement) |
| Budget | 15 forward evaluations |
| Fixed | Rate-dependent Taylor Cu parameters ( ), compression to true strain , 400-grain equal-size RVE |
| Initial texture | Spread (deg) | Loss | Note |
| [110] fiber | 27 | 0.262 | Recovered optimum (diffuse) |
| [110] fiber | 32 | 0.271 | Diffuse [110], low loss |
| [110] fiber | 37 | 0.343 | Diffuse [110], low loss |
| [111] fiber | 27 | 0.369 | Diffuse [111], low loss |
| [110] fiber | 46 | 0.436 | Diffuse [110] |
| [110] fiber | 85 | 0.551 | Very diffuse [110] |
| Feature (MRD) | This study | Reference |
| Peak intensity, | 2.27 | 2.5 |
| Peak intensity, | 2.18 | 2.35 |
| Peak intensity, | 3.73 | 3.5 |
| Central ( compression fiber) | 3.11 | 3.3 |
| Central (axial depletion) | 0.04 | 0.3 (min) |
| Central (axial depletion) | 0.12 | 0.3 (min) |
| Pass | This study | Yaghoobi et al. [ 45 ] Sim. | Experiment [ 45 ] |
| 1 | 2.10 | 1.94 | 7.3 |
| 5 | 5.66 | 5.46 | 4.6 |
Scientific Workflow Automation
Scientific workflow automation uses software, AI agents, and laboratory systems to plan, execute, validate, and reproduce research tasks.
See all 161 papers