Command line
Every tool of the workflow, with all its options. Run the commands from the repository
root; relative paths in the options of export.py, the converters and rollout.py are
resolved against it. --help prints the same list for every tool. How the tools work
together: how CrashDefNet works.
export
Export simulation runs (DeepMind TFRecord, LS-DYNA d3plot, VTK time series) into a dataset folder: dataset.db, metadata.json, normalizer.json. Without arguments the small test set of deforming_plate is written.
python -m dataset_preprocessor.export [options]
| Option |
Default |
Description |
--config CONFIG |
– |
TOML file that defines the dataset: raw data, components with their roles, features (docs/guides/export.md); options given here override it |
--list-parts |
False |
List the parts of the first run with nodes, elements, node type and thickness, and their roles with --components, then stop |
--raw-format {tfrecord,d3plot,vtk} |
tfrecord |
Raw data: DeepMind TFRecord (standard), d3plot of OpenRadioss or LS-DYNA runs (docs/guides/openradioss.md, docs/guides/ls-dyna.md) or VTK time series |
--raw-dir RAW_DIR |
– |
Directory with meta.json and the .tfrecord or the run folders (default: datasets/deforming_plate/raw_dataset; d3plot: datasets/deforming_plate/raw_d3plot; vtk: datasets/deforming_plate/raw_vtk) |
--sources NAME [NAME ...], --source-tfrecord NAME [NAME ...] |
test.tfrecord |
Where the runs come from, one name, or three, one per split: train val test. TFRecord: the file inside --raw-dir (test.tfrecord: 100 trajectories); d3plot / vtk: the folder below --raw-dir (<name without .tfrecord> for converted runs), else all runs below --raw-dir |
--contact-radius CONTACT_RADIUS |
– |
World edge radius, in the length unit of the raw data; default: collision_radius of meta.json (required for d3plot / vtk raw data without meta.json) |
--contact-pairs [A:B ...] |
– |
Contact rules of raw data with components (LS-DYNA and VTK parts): world edges only between these pairs, e.g. plate:impactor plate:plate (self-contact), also with patterns (box_*:beam_*); none given: every pair |
--contact-gap, --no-contact-gap |
--no-contact-gap |
Two more world edge features: the distance of the receiver from the sender's shell surface along its normal, and the clearance between the shell surfaces (that distance minus half of both thicknesses, from the static feature thickness) |
--deck-walls, --no-deck-walls |
--deck-walls |
D3plot: use the rigid walls of the decks (*RIGIDWALL_PLANAR, /RWALL/CYL) as node features |
--length-unit {m,cm,mm} |
m |
Unit of the lengths in the raw data (positions, contact radius, e.g. mm for LS-DYNA models); the values are kept, the reports convert to SI |
--stress-unit {Pa,kPa,MPa,GPa} |
Pa |
Unit of the stress in the raw data (e.g. MPa for LS-DYNA models in mm, t, s); the values are kept, the reports convert to SI |
--out-dir OUT_DIR |
data/deforming_plate_s10_small |
Output directory (== [data].data_dir in the config) |
--n-train N_TRAIN |
8 |
Train trajectories |
--n-val N_VAL |
2 |
Validation trajectories |
--n-test N_TEST |
2 |
Test trajectories |
--select-seed SELECT_SEED |
– |
Draw the trajectories of each split at random with this seed (stored in metadata.json); default: the first ones |
--num-steps NUM_STEPS |
40 |
Frames per trajectory (samples per trajectory = num_steps - 1) |
--time-stride TIME_STRIDE |
10 |
Raw frames between two selected frames |
--history {0,1} |
0 |
1: append velocity_prev (+ stress_prev) to the node features (enables residual_target / scheduled sampling / rollout training); 0: the features of the deforming_plate benchmark |
--prev-stress, --no-prev-stress |
--prev-stress |
With --history 1: include stress_prev |
--overwrite, --no-overwrite |
--overwrite |
Replace an existing dataset.db |
LS-DYNA and VTK raw data: components, result fields, static node features, run parameters and free rigid parts
| Option |
Default |
Description |
--components [PATTERN=ROLE ...] |
– |
What goes into the dataset: name patterns of the parts with their role (deformable, actuator, fixed, free_rigid); every other part is left out; instead of --free-rigid-parts, --exclude-parts, --actuator-parts and --clamped-parts; default: every part, roles from the raw data |
--global-features [NAME ...] |
– |
Run parameters in the dataset, one input per graph; default: all that the runs have |
--globals-file GLOBALS_FILE |
– |
JSON file with the run parameters of all runs, by the name of the run folder; default: a globals.json in every run folder |
--fields [FIELDS ...] |
– |
Further result fields per state as targets, each under its own name; vtk: point or cell fields, e.g. plastic_strain (vectors: one per component); d3plot: plastic_strain, thickness (shells), mean_stress (of the membrane part, tension positive), bending_stress (shells with two or more integration points) |
--static-fields [STATIC_FIELDS ...] |
– |
Static node features; vtk: point or cell fields of the first state (vectors: one per component); d3plot: thickness, initial_velocity and the material properties of the deck density, youngs_modulus, poisson_ratio, yield_stress (default: thickness and initial_velocity where the runs have them) |
--edge-fields [EDGE_FIELDS ...] |
– |
D3plot: element properties on the mesh edges, the mean over the elements next to an edge: thickness (shells, from the deck) and the material properties density, youngs_modulus, poisson_ratio, yield_stress; unlike --static-fields they keep parts apart that share nodes |
--free-rigid-parts [PART ...] |
– |
Rigid parts whose motion results from the crash (e.g. a barrier with mass): the model predicts it and the rollout moves each as a rigid body; default: rigid parts are actuators, their motion given. d3plot: *MAT_RIGID and /RBODY parts without prescribed motion, by title; vtk: any parts |
--exclude-parts [PART ...] |
– |
D3plot only: parts left out of the export, named as the components, e.g. display models written as shells: their elements and the nodes only they hold; nodal fields are averaged without them; default: every part stays |
VTK raw data (--raw-format vtk): field names and parts
| Option |
Default |
Description |
--stress-field STRESS_FIELD |
stress |
Point or cell field of the target stress: scalar, or stress tensor (6 / 9 components, gives the von Mises stress); '': no stress |
--node-type-field NODE_TYPE_FIELD |
node_type |
Point field with the node types 0 / 1 / 3; absent: all normal |
--displacement-field DISPLACEMENT_FIELD |
– |
Positions = points + this field (exports with reference geometry) |
--node-id-field NODE_ID_FIELD |
– |
Point field with node IDs: copies of a node in several parts become one node; None: the field marked as global IDs (e.g. UserID of ParaView's LS-DYNA reader), '': ignore IDs |
--part-field PART_FIELD |
– |
Cell field with part IDs for --actuator-parts / --clamped-parts; None: parts named by their block or file |
--actuator-parts [ACTUATOR_PARTS ...] |
– |
Parts whose nodes are actuators (motion given, e.g. rigid impactor) |
--clamped-parts [CLAMPED_PARTS ...] |
– |
Parts whose nodes are clamped |
large data
| Option |
Default |
Description |
--resume, --no-resume |
--no-resume |
Continue an interrupted export in --out-dir (same options) after its last complete trajectory |
--edge-stats-stride EDGE_STATS_STRIDE |
1 |
Fit the edge statistics (a contact search per frame) on every k-th sample of a trajectory only; 1 = all |
--block-mb BLOCK_MB |
1024 |
LS-DYNA / VTK: read the frames of a run in blocks of about this size (MB), so a run need not fit into memory |
tfrecord_to_d3plot
Convert DeepMind deforming_plate trajectories into LS-DYNA runs (d3plot + model.k, all frames): the raw data for export.py --raw-format d3plot.
python -m dataset_preprocessor.tfrecord_to_d3plot [options]
| Option |
Default |
Description |
--raw-dir RAW_DIR |
datasets/deforming_plate/raw_dataset |
Directory with the .tfrecord and meta.json |
--source-tfrecord SOURCE_TFRECORD |
test.tfrecord |
TFRecord inside --raw-dir (test.tfrecord: 100 trajectories) |
--out-dir OUT_DIR |
datasets/deforming_plate/raw_d3plot |
Raw d3plot directory; runs go to <out-dir>/<tfrecord name>/ |
--count COUNT |
– |
First N trajectories (default: all) |
--overwrite, --no-overwrite |
--overwrite |
Replace existing runs |
tfrecord_to_vtk
Convert DeepMind deforming_plate trajectories into VTK time series (one file per state, all frames): the raw data for export.py --raw-format vtk.
python -m dataset_preprocessor.tfrecord_to_vtk [options]
| Option |
Default |
Description |
--raw-dir RAW_DIR |
datasets/deforming_plate/raw_dataset |
Directory with the .tfrecord and meta.json |
--source-tfrecord SOURCE_TFRECORD |
test.tfrecord |
TFRecord inside --raw-dir (test.tfrecord: 100 trajectories) |
--out-dir OUT_DIR |
datasets/deforming_plate/raw_vtk |
Raw VTK directory; runs go to <out-dir>/<tfrecord name>/ |
--count COUNT |
– |
First N trajectories (default: all) |
--format {vtu,vtk} |
vtu |
XML .vtu or legacy .vtk files |
--overwrite, --no-overwrite |
--overwrite |
Replace existing runs |
remesh_pole
remesh_pole.py — Remesh the pole of BumperBeamCrashExample so that contact edges form.
python utils/remesh_pole.py [options]
| Option |
Default |
Description |
--raw-dir RAW_DIR |
datasets/BumperBeamCrashExample/RAW_DATA |
Folder of the originals, with the sources |
--out-dir OUT_DIR |
– |
Target folder, empty or not there yet |
--sources SOURCES [SOURCES ...] |
TRAINING_DATA VALIDATION_DATA |
Subfolders of --raw-dir |
--part PART |
RWALL |
Title of the part that displays the pole, that of the /RWALL in the deck; a run without it gets a new part of this title |
--element-size ELEMENT_SIZE |
10.0 |
Edge length of the new shells in the unit of the data (mm) |
--half-height HALF_HEIGHT |
140.0 |
Meshed region: this far to both sides of the point on the axis |
--contact-radius CONTACT_RADIUS |
30.0 |
Contact radius of the export, only for the check of the reach |
--count COUNT |
– |
Only the first N runs per source; default: all |
train
Train a model on an exported dataset (config: TOML, the options below override it).
python train/train.py [options]
| Option |
Default |
Description |
--config CONFIG |
examples/quick_start/train.toml |
TOML config (default: examples/quick_start/train.toml) |
--data-dir DATA_DIR, --data_dir DATA_DIR |
– |
Dataset directory with dataset.db / metadata.json / normalizer.json ([data].data_dir) |
--architecture {meshgraphnets,mgn_t} |
– |
Model architecture, sized by its section of the config ([model].architecture) |
--checkpoint-dir CHECKPOINT_DIR |
– |
Output directory ([checkpointing].checkpoint_dir) |
--epochs EPOCHS |
– |
Training epochs ([training].epochs) |
--batch-size BATCH_SIZE |
– |
Graphs per optimizer step ([training].batch_size) |
--learning-rate LEARNING_RATE, --lr LEARNING_RATE |
– |
Initial learning rate ([training].learning_rate) |
--device {auto,cpu,cuda} |
– |
Auto: the GPU if available ([training].device) |
--seed SEED |
– |
Random seed ([training].seed) |
--num-workers NUM_DATALOADER_WORKERS |
– |
DataLoader workers ([data].num_dataloader_workers) |
--resume RESUME |
– |
Checkpoint to continue from |
prepare
Check new FE runs against the training data of a model and prepare them for a prediction from their initial state.
python predict/prepare.py [options]
| Option |
Default |
Description |
--checkpoint CHECKPOINT |
– |
Trained model (best_model.pt or checkpoint_epoch_N.pt) |
--raw-dir RAW_DIR |
– |
Folder with the new runs: d3plot with at least the initial state and the deck next to it, one folder per run |
--source SOURCE |
`` |
Subfolder of --raw-dir with the runs (default: every run below --raw-dir) |
--out-dir OUT_DIR |
– |
Folder of the prediction data (dataset.db, metadata.json, normalizer.json, applicability.json); needed unless --check-only |
--train-data-dir TRAIN_DATA_DIR |
– |
Export the model was trained on (default: data_dir of its training config); its train runs are the reference of the checks |
--frame-interval FRAME_INTERVAL |
– |
Time between two frames of the training data in the time unit of the decks (default: from the raw data of the training data) |
--num-steps NUM_STEPS |
– |
Frames to predict, the initial state included (default: those of the training data) |
--check-only |
False |
Only check the runs, write nothing but applicability.json (with --out-dir) |
--force |
False |
Prepare runs whose check failed as well |
--overwrite |
False |
Replace an existing dataset.db in --out-dir |
rollout
Autoregressive rollout of a trained model over every trajectory of a split.
python predict/rollout.py [options]
| Option |
Default |
Description |
--config CONFIG |
– |
TOML file with the settings of the rollout and of the evaluation after it (docs/guides/rollout.md); options given here override it |
--checkpoint CHECKPOINT |
checkpoints/example_run/best_model.pt |
Trainer checkpoint (.pt) |
--data-dir DATA_DIR |
data/deforming_plate_s10_small |
Dataset.db + normalizer.json — the dataset the checkpoint was trained on |
--output-dir OUTPUT_DIR |
– |
New or empty folder (default: rollouts/<time><training run><checkpoint>_<split>) |
--split {train,val,test} |
test |
Split of the dataset to roll out |
--max-sequences MAX_SEQUENCES |
– |
Roll out only the first N trajectories (default: all) |
--start-frame START_FRAME |
– |
Raw frame of the run the rollout starts from, its ground truth (default: that of the training, else the first frame of the dataset) |
--end-frame END_FRAME |
– |
Raw frame of the run the rollout ends with (default: that of the training, else the last frame of the dataset) |
--max-steps MAX_STEPS |
– |
Steps per trajectory (default: all) |
--device {auto,cpu,cuda} |
auto |
Auto: the GPU if available |
--export-vtu, --no-export-vtu |
--export-vtu |
Write one .vtu per step (prediction / ground truth / error); needs pyvista |
--one-step, --no-one-step |
--one-step |
Also compute the one-step rollout metrics RMSE-1 (a second model call per step) |
--lazy, --no-lazy |
– |
Read the frames from dataset.db on access instead of loading the split (default: as in the training) |
--evaluate, --no-evaluate |
--no-evaluate |
Evaluate the run on this rollout right after it (utils/evaluate_run.py) |
--evaluation-output-dir EVALUATION_OUTPUT_DIR |
– |
With --evaluate: new or empty folder for the evaluation (default: evaluations/<time>_<run>_evaluation) |
--animate, --no-animate |
--no-animate |
Render one trajectory of this rollout as an animated GIF right after it (utils/animate_rollout.py); needs the .vtu export |
--animation-trajectory ANIMATION_TRAJECTORY |
– |
With --animate: e.g. test_traj0136 (default: the trajectory at the median of the position error) |
--animation-output-dir ANIMATION_OUTPUT_DIR |
– |
With --animate: new or empty folder for the GIF (default: evaluations/<time>_animation) |
plot_losses
Plot the loss curves of a training run.
python utils/plot_losses.py [options]
| Option |
Default |
Description |
--run-dir RUN_DIR, --base_path RUN_DIR |
checkpoints/example_run |
Checkpoint directory with history.json |
evaluate_run
Evaluate one training run on its own: training, single step, rollout.
python utils/evaluate_run.py folder [options]
| Argument |
Default |
Description |
folder |
– |
Checkpoint folder (checkpoints/<run>) or rollout folder (rollouts/<rollout>) |
| Option |
Default |
Description |
--output-dir OUTPUT_DIR |
– |
New or empty folder (default: evaluations/<time>_<run>_evaluation) |
compare_paper
Compare rollout results with the MGN-T paper (deforming_plate).
python utils/compare_paper.py [rollouts ...] [options]
| Argument |
Default |
Description |
rollouts |
– |
Rollout folders (default: every folder in rollouts/) |
| Option |
Default |
Description |
--split SPLIT |
test |
Only rollouts of this split (default: test) |
--exclude [EXCLUDE ...] |
– |
Trajectories for additional rows without them, e.g. test_traj0149 |
--output-dir OUTPUT_DIR |
– |
Default: evaluations/<time>_paper_comparison |
check_protocol
Check rollouts against a comparison protocol and compare them with the reference per trajectory (docs/guides/comparison-protocol.md).
python utils/check_protocol.py reference [candidates ...] [options]
| Argument |
Default |
Description |
reference |
– |
Rollout folder of the reference |
candidates |
– |
Further rollout folders |
| Option |
Default |
Description |
--protocol PROTOCOL |
protocols/deforming_plate_s4_t150.toml |
Protocol training config (default: protocols/deforming_plate_s4_t150.toml) |
--exclude [EXCLUDE ...] |
– |
Trajectories counted separately, e.g. test_traj0149 |
explore_data
Explore an exported dataset: descriptors, data checks and the splits against each other.
python utils/explore_data.py data_dir [options]
| Argument |
Default |
Description |
data_dir |
– |
Export folder (data/<name>) |
| Option |
Default |
Description |
--rollout ROLLOUT |
– |
Rollout folder on this dataset; sets its errors per trajectory against the descriptors (repeatable) |
--output-dir OUTPUT_DIR |
– |
New or empty folder (default: evaluations/<time>_<name>_data_exploration) |
animate_rollout
Animated GIF of one rollout trajectory: ground truth and models.
python utils/animate_rollout.py rollouts [rollouts ...] [options]
| Argument |
Default |
Description |
rollouts |
– |
Rollout folders with .vtu export; the first one also provides the ground truth |
| Option |
Default |
Description |
--trajectory TRAJECTORY |
– |
E.g. test_traj0136 (default: the first of the split) |
--labels LABELS [LABELS ...] |
– |
Panel titles, one per rollout (default: architecture and parameters) |
--stress-max STRESS_MAX |
– |
Upper end of the colour scale: the stress in kPa, for data in MPa or GPa (--stress-unit of the export) in that unit; for a dataset without stress in the unit of its first result field (default: 99.9th percentile of the ground truth, a stress of at least 50 rounded up to the next 50, any other value to 1, 2 or 5 times a power of ten) |
--output OUTPUT |
– |
GIF file (default: evaluations/<time>animation/rollout<trajectory>.gif) |
app
The CrashDefNet app (early stage): the workflow as a local web page, made mainly for the quick start: raw data, dataset, training, prediction and result, without a terminal.
python utils/app.py [options]
| Option |
Default |
Description |
--port PORT |
8765 |
Port of the page on 127.0.0.1 |
--browser, --no-browser |
--browser |
Open the page in the default browser |