Repository navigation
Fix DiffractionSim coordination polyhedra for Si, SrTiO3 and elemental metals - #249
Merged
Merged
Conversation
…ements In a compound, polyhedron centres now bond only to the most numerous species and are drawn for 4 to 8 ligands, so Ti in SrTiO3 gets TiO6 instead of the cube of its 8 Sr neighbours. An elemental crystal gets polyhedra on one set of a two-set neighbour network, the set with fewer sites on the cell boundary, so Si shows four SiSi4 tetrahedra inside the cell instead of tetrahedra on all eight atoms, and fcc, bcc and hcp metals get none. GaAs, NaCl, Al2O3 and GaN are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does it solve?
The coordination polyhedra of DiffractionSim (
cellGeometryinjs/diffractionsim/crystal3d.ts) were wrong for elemental crystals and for compounds with more than one cation species. The rule drew a polyhedron around every species except the most numerous one, bonded each centre to every atom of another species within 1.2 (r_i + r_j) of the covalent radii, and accepted 4 to 14 neighbours. The presets, CIFs loaded in the browser (including the quantem.diffsim page planned for the Materials Project TEM tab) and the Jupyter widget all showed two problems:This PR changes the rule. In a compound, centres bond only to the ligand species (the most numerous species, as before), and a polyhedron is drawn for 4 to 8 ligands. In an elemental crystal, polyhedra are drawn on one set of a two-set (bipartite) neighbour network, choosing the set with fewer sites on the cell boundary so that its polyhedra stay inside the cell. Elemental crystals without such a network, including the fcc, bcc and hcp metals, get no polyhedra. The polyhedron faces of one unit cell on main and on this branch are:
The quantem.diffsim 0.1.0 release waits for this fix, since its page draws the same polyhedra.
What should reviewer(s) do?
polyhedronSitesand the neighbour loop incellGeometry(js/diffractionsim/crystal3d.ts). The two-set test colours the neighbour network of the sites over periodic images, so a one-atom simple cubic cell, whose two sets differ only by a lattice translation, also gets no polyhedra.js/diffractionsim/crystal3d.test.tschecks Si (16 faces with edges of a/√2 = 3.84 Å and every vertex on a drawn atom), SrTiO3 (8 triangles with edges of 2.76 Å) and fcc Al (no faces).Verification
npx vitest run js/diffractionsim js/diffractionsim-webwith Node 22: 14 passed, including the 3 new cases.npx tsc --noEmit: no errors.npm run build:webandnpm run build -- diffractionsim(quantem.gpu dc8f0398): both bundles build, and they are the only bundles that importcrystal3d.ts.pytest -q tests/diffractionsim tests/diffsim tests/infrastructure/test_public_repository.py: 59 passed and 2 skipped.npm run buildbuilds every bundle,npx vitest rungives 392 passed and 2 skipped (5 display and show3dslices test files call Python for NumPy reference values and need a Python whose NumPy loads), andPYTHONPATH=src pytest -qgives 668 passed and 223 skipped, with the same 2 local-environment failures as in Add DiffractionSim and quantem.diffsim, and remove the abTEM dependency #245 (a sibling quantem.gpu checkout at another commit, and an lxml withoutlxml_html_clean).cellGeometryon main and on this branch for the 9 presets and for Si, SrTiO3 and GaN written byquantem.diffsim.structure_to_ciffrom pymatgen structures.save_htmlpages with polyhedra on: Si along [112] shows 4 tetrahedra inside the cell with their corners on drawn atoms, SrTiO3 along [112] shows the TiO6 octahedron with Sr drawn as spheres, and GaN along [11-23] shows the same NGa4 tetrahedra as on main, with no console errors.Written by Colin Ophus and Claude (Claude Code).