Skip to content

Low dimensional benchmark#355

Open
JonathanSchmidt1 wants to merge 27 commits intoddmms:mainfrom
JonathanSchmidt1:low_dimensional_benchmark
Open

Low dimensional benchmark#355
JonathanSchmidt1 wants to merge 27 commits intoddmms:mainfrom
JonathanSchmidt1:low_dimensional_benchmark

Conversation

@JonathanSchmidt1
Copy link
Copy Markdown

Pre-review checklist for PR author

PR author must check the checkboxes below when creating the PR.

Summary

Adds relaxation of two-dimensional and one-dimensional crystal structures benchmarking energies and areas/lengths.

Linked issue

Resolves #354

Progress

  • Calculations
  • Analysis
  • Application
  • Documentation

Testing

mace-mpa-0

New decorators/callbacks

No

JonathanSchmidt1 and others added 25 commits February 2, 2026 22:25
Initial implementation of benchmark for 2D crystal structures from
Alexandria database. Uses cell mask to constrain relaxation to in-plane
directions only.

Metrics:
- Area MAE (Ų/atom): In-plane area per atom vs PBE reference
- Energy MAE (eV/atom): Energy per atom vs PBE reference
- Convergence (%): Percentage of structures that converged

Data source: alexandria_2d_001.json.bz2 from Alexandria database

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add generic download_data() and load_structures() functions for both 2D/1D
- Add get_length_per_atom() for 1D chain length calculation
- Add relax_low_dimensional() with dimensionality parameter for cell masks
- Add 1D metrics: Length MAE, Energy MAE, Convergence
- Add 1D parity plots for length and energy
- Parametrize test function for both 2D and 1D dimensionalities
- Update app with 1D plot configurations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Document the new low-dimensional relaxation benchmark including:
- Summary of 2D and 1D structure relaxation
- Metrics: Area/Length MAE, Energy MAE, and Convergence for both 2D and 1D
- Description of cell masks for constrained relaxation
- Data availability from Alexandria database

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add set_vacuum_padding() function that sets lattice constants to 100 Å
in non-periodic directions while preserving vector directions:
- 2D: sets c vector to 100 Å
- 1D: sets b and c vectors to 100 Å

Apply vacuum padding before relaxation in test function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add symmetrize_structure() using spglib.standardize_cell()
- Remove FixSymmetry constraint (doesn't work for low-d relaxations)
- Apply symmetrization before vacuum padding and relaxation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update DEFAULT_DATA_FILES to use lists (2 files for 2D, 1 for 1D)
- Add download_all_data() to download multiple files
- Update load_structures() to pool entries from all files before sampling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace 10 near-identical per-dimensionality fixtures with:
- DIM_CONFIGS dict mapping dimensionality to column/label/unit
- _compute_mae() and _compute_convergence() helpers
- _generate_all_plots() looping over DIM_CONFIGS
- Single parity_plots fixture and loop-based metrics fixture

Reduces 465 lines to 353 lines with no duplication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace custom symmetrize_structure implementation with
ase.spacegroup.symmetrize.refine_symmetry. Drop spglib import.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove symmetrize_structure(), call refine_symmetry() directly
- Add test_get_area_per_atom and test_get_length_per_atom unit tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ElliottKasoar ElliottKasoar added the new benchmark Proposals and suggestions for new benchmarks label Feb 9, 2026
geom_opt.run()
relaxed = geom_opt.struct
# assess forces to determine convergence
max_force = max(relaxed.get_forces().flatten(), key=abs)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think key=abs chooses the largest value regardless of the sign (good), but returns the signed version of the value (bad).

steps=max_steps,
# Use cell mask to constrain relaxation to appropriate dimensions
filter_kwargs={"mask": CELL_MASKS[dimensionality]},
calc_kwargs={"default_dtype": "float64"},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue as in pr #340

@joehart2001
Copy link
Copy Markdown
Collaborator

Thanks for the PR @JonathanSchmidt1 ! some comments:

  • i think a good place for the data download would be in ~/cache/ml_peg/low_dimensional_relaxation, as this is where the s3 download stores the other data
  • i think we should add structure visualisaitont to the density scatters
  • can you mark the test with either slow or very slow using e.g. @pytest.mark.slow
  • rebase

Convergence:

  • i think i remember discussing this in a drop in on how to best visualise this?
  • one option could be a bar chart, which is being added in PR Water slab dipoles #349
  • but it is probably interesting to see which are the structures which fail, so maybe a scatter of energy vs area where the colour is converged or not converged? i did something like this ish for the phonon benchmakr wehre we colour the points based on which quater of the confusion matrix the point is in
  • or maybe we save the forces and do a violin plot with the final max force, and we have a dashed line indicated the fmax thrreshold. maybe i like this idea the most. we can plot the points so we can still visualise the structures. heres the example from the phonon benchmark BZ metric:
Screenshot 2026-04-15 at 21 17 07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new benchmark Proposals and suggestions for new benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2D/1D Crystal Structure Relaxations

3 participants