Quickstart#

This walks through a pure-Python path that runs from pip install graintrace alone (no NEML2, MOOSE, NEPER, or CUBIT). It uses the sample data under mwe_data/, so clone the repo (the PyPI package does not ship the datasets):

git clone https://github.com/applied-material-modeling/graintrace.git
cd graintrace
pip install -e .

Load CPFE output#

SimulationResults loads the block CSV and the per-time field CSVs written by a CPFE run. The repo ships a small example set (mwe_data/out.csv and mwe_data/grid_out/):

from graintrace.simulation_postprocessing import SimulationResults, FieldFileNaming

field_naming = FieldFileNaming(
    prefix="out_element_centroid", index_width=4, sep="_", suffix=".csv"
)
res = SimulationResults(
    block_csv="mwe_data/out.csv",
    field_dir="mwe_data/grid_out",
    field_naming=field_naming,
)

Plot a macroscopic stress-strain curve#

from graintrace import plot_postprocessing as postprocess

postprocess.plot_macroscopic_stress_strain(
    res,
    stress_tensor_prefix="cauchy_stress",
    strain_tensor_prefix="strain",
    volume_prefix="volume",
    output_folder="out/postprocess",
)

Identify rare events#

Rare-event identification (REI) groups a field into spatially coherent clusters and flags the rare ones. It is pure Python. The examples/demonstrate_rei_pipeline.py script runs the full pipeline on a shipped seed dataset:

python examples/demonstrate_rei_pipeline.py

See Rare-event identification (REI) for the full walk-through.

Next steps#