Skip to content

Structures from a formula: symmetry-based generation through PyXtal - #13

Merged
Starlitnightly merged 1 commit into
mainfrom
pyxtal-generation
Aug 3, 2026
Merged

Structures from a formula: symmetry-based generation through PyXtal#13
Starlitnightly merged 1 commit into
mainfrom
pyxtal-generation

Conversation

@Starlitnightly

Copy link
Copy Markdown
Contributor

mv.gen.from_symmetry places the atoms of a composition on Wyckoff positions of a chosen space group and randomises the free parameters that remain.

With mv.gen.compositions from #12 the funnel now runs end to end — elements → compositions → structures → energies — where before it could only start from a structure somebody already had.

The output is a starting geometry, and says so

Cell volume is estimated and the free coordinates are random, so generated BaTiO₃ in Pm-3m comes out near 5.06 Å against a measured 4.00. That is the dangerous part of a structure generator, so it is stated in the registry notes, in uns["from_symmetry"]["note"], and in the tutorial.

Two columns, and the second is the one that matters

requested_space_group is what PyXtal was asked for. space_group is what pymatgen finds in the structure that came back.

They disagree far more often than I expected. Asking for 40 random groups for TiO₂:

attempts 40
structures built 7
failed (group cannot host the composition) 33
came back at a different symmetry 5 of 7

P-6 asked for, P6/mmm delivered — with few atoms the random free parameters land on a special position. A generator reporting only the request would be reporting its input. A test asserts the disagreement is real and that it is always upward.

The 33 failures are honest rather than hidden: a failure is a missing row plus a counted reason in uns["from_symmetry"], never a substituted structure. The notes say plainly that passing space_groups= explicitly is both faster and more likely to give what you asked for.

The probe caught another of mine

I declared obs["formula"] as required. The probe deleted it, the call succeeded anyway — the composition matrix is a perfectly good fallback — so the claim was wrong and is gone.

That is the third false claim of mine this contract probe has caught in this run of work, after a uns slot that landed on a different object (#11) and a plotting function that could not in fact plot what its notes promised (#9).

Verification

  • 948 pass on py3.12; 846 pass on py3.10 where PyXtal is absent and its tests skip.
  • Contract-verified rate stays 165/165. All 16 notebooks execute. Docs build.
  • Tutorial output is generated, not described — the 7/33/5 numbers above are printed by the notebook itself.

🤖 Generated with Claude Code

https://claude.ai/code/session_016wh5NzNE9Wn49nuUm7zg2a

mv.gen.from_symmetry places the atoms of a composition on Wyckoff positions of
a chosen space group and randomises the free parameters that remain. With
mv.gen.compositions from the previous commit the funnel now runs end to end:
elements -> compositions -> structures -> energies, where before it could only
start from a structure somebody already had.

The output is a starting geometry and says so. Cell volume is estimated and the
free coordinates are random, so generated BaTiO3 in Pm-3m comes out near 5.06 A
against a measured 4.00. That is the dangerous part of a structure generator and
it is stated in the notes, in uns['from_symmetry']['note'] and in the tutorial.

Two columns rather than one, and the second is the one that matters.
requested_space_group is what PyXtal was asked for; space_group is what pymatgen
finds in the structure that came back. They disagree far more often than I
expected: asking for 40 random groups for TiO2 gave 7 structures and 5 of them
came back at *higher* symmetry than requested - P-6 asked for, P6/mmm delivered
- because with few atoms the random free parameters land on a special position.
A generator that reported only the request would be reporting its input, and a
test asserts the disagreement is real and is always upward.

The same run shows 33 of 40 attempts failing outright, because a random space
group usually cannot host a given composition at a given cell size. A failure is
a missing row plus a counted reason, never a substituted structure. The notes
say plainly that passing space_groups= explicitly is both faster and more likely
to give what was asked for.

The composition is read from obs[source_column] when present and from the
composition matrix otherwise. I had declared the column as required; the probe
deleted it, the call succeeded anyway, and the claim was wrong. That is the
third false claim of mine the contract probe has caught in this run of work,
after an uns slot that landed on a different object and a plotting function that
could not in fact plot what its notes promised.

948 tests pass on py3.12, 846 on py3.10 where PyXtal is absent and its tests
skip. Contract-verified rate stays 165/165, all 16 notebooks execute, docs
build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wh5NzNE9Wn49nuUm7zg2a
@Starlitnightly
Starlitnightly merged commit f94ba28 into main Aug 3, 2026
4 checks passed
@Starlitnightly
Starlitnightly deleted the pyxtal-generation branch August 3, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant