Repository navigation
WP3: anisotropic ADPs and molecules through the C interface; next steps (asymmetric unit, option E pilot) - #61
Merged
Conversation
…next-steps write-up C interface version 4: * dc_get_type_anis (per type, as given), dc_adp_count / dc_get_adps (distinct tensors after symmetry, principal axes) / dc_get_atom_adps (tensor per atom); dc_set_crystal takes per-type tensors (has_anis, anis). prep_anis sets the first 5*ncatoms atoms only; dc_set_crystal gives the others the tensor of their type (nothing is rotated there) and lets prep_anis look at all atoms if a type first appears beyond that range. * dc_molecule_size / dc_get_molecules / dc_set_molecules (type, character, length, atoms; molecule flag and number per atom). Python: Crystal.adps() (per atom U11..U12, CIF convention), Crystal.molecules() (types, atom indices); make_crystal(u_aniso=per name or per atom, molecules=, molecule_types=); a type is name + B + occupancy + U. to_ase() keeps the tensors in atoms.arrays["discus_u_aniso"], from_ase() uses them. Tests (test_wp3_adp_molecules.py, test_capi): the four-fold axis of I41/amd swaps U11/U22 of O while Ti keeps U11 = U22, for every atom of a 4x4x2 supercell; principal values kept; B = 8 pi^2 U_eq; isotropic atoms carry the tensor of B; round trip file -> adps() -> make_crystal -> adps() identical and the same Fourier map (an isotropic crystal differs); per-name tensors; hexagonal P6; a type first seen late; molecules out, round trip (flags and numbers per atom), reload; bad input; ASE round trip keeps tensors. Found a DISCUS bug, kept as strict xfail: save writes one type per distinct tensor but read stru assigns atoms by name, B and occupancy, so rotated tensors are lost (236 of 384 atoms). Docs: notebook crystals_and_ase.ipynb gains ADPs (h0l maps, isotropic vs O vibrating along c) and molecules; api.md. New migration/WP3_Next_Steps.md: status, an asymmetric unit + space group from Python (what DISCUS's read cell does and what a dc_set_cell must repeat, open points, tests, effort) and the option E pilot in detail (Debye histogram kernel; Fortran, C++, NumPy, Numba, later GPU; correctness incl. the Fortran's sine table; benchmark matrix, repeats, memory, recorded environment, fairness rules, effort record, decision criteria, 1.5-week plan). Linked from CLAUDE.md, the plan, the binding decision and the docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Yw8KkfPLawp8Po4f5Bc9v
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.
Targets
claude-python-app(notmaster).What
Displacement parameters and molecules, out and in (C interface version 4)
dc_get_type_anisdc_adp_count,dc_get_adps,dc_get_atom_adpsdc_set_crystaldc_molecule_size,dc_get_molecules,dc_set_moleculesprep_anisonly sets up the first 5 × (atoms per cell) atoms.dc_set_crystaltherefore gives every later atom the tensor of its type; nothing is rotated on this path, so all atoms of a type share one tensor. If a type first appears beyond that range, it letsprep_anislook at all atoms.Python
Crystal.adps(): U11, U22, U33, U23, U13, U12 per atom, CIF convention, symmetry-rotated.Crystal.molecules(): molecule types and the atom indices of each molecule.make_crystal:u_aniso=per name or per atom;molecules=andmolecule_types=;to_ase()stores the tensors inatoms.arrays["discus_u_aniso"], andfrom_ase()uses them.DISCUS bug found, kept as a strict xfail test:
savewrites one atom type per distinct tensor, butread struassigns atoms by name, B and occupancy. So the symmetry-rotated tensors are lost: 236 of 384 atoms in an anatase 4×4×2 crystal get the wrong tensor.Next steps, written up: new
migration/WP3_Next_Steps.md.crystal_from_sites):make_crystal;read celldoes, so what adc_set_cellhas to repeat;dc.powder;It is linked from
CLAUDE.md, the plan, the binding decision and the docs.Tests
New file
tests/python/test_wp3_adp_molecules.py:adps()→make_crystal→adps()is identical and gives the same Fourier map; an isotropic crystal gives a different one.test_capicalls all the new functions.The notebook
crystals_and_ase.ipynbgains a section on displacement parameters (h0l maps: isotropic, against O vibrating along c) and one on molecules. It ran in a Jupyter kernel and as a script.Local results:
tests/python: 187 passed, 34 skipped, 3 xfailed-W: OKGenerated by Claude Code