Hi folks, I'm testing some code changes and would like to iterate over every space group and for each generate a random unit cell compatible with the Bravais symmetry. I've got the iteration sorted with space_group_symbol_iterator, but I'm not sure how best to generate some compatible unit cell from the space_group object. Is this something I could do easily with cctbx? Cheers, -- David
There are only 6 sets of cell dimension constraints, so it’s not hard to be explicit Phil Sent from my iPad
On 15 Sep 2023, at 19:59, David Waterman
wrote: Hi folks,
I'm testing some code changes and would like to iterate over every space group and for each generate a random unit cell compatible with the Bravais symmetry. I've got the iteration sorted with space_group_symbol_iterator, but I'm not sure how best to generate some compatible unit cell from the space_group object. Is this something I could do easily with cctbx?
Cheers, -- David
-- CAUTION: This email originated from outside of the LMB. Do not click links or open attachments unless you recognize the sender and know the content is safe. [email protected]. _______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
Hi David, there is a constraints object that tells you which elements of the metrical matrix can be varied:
from cctbx.sgtbx import space_group_info sg = space_group_info('P4').group() c = sg.adp_constraints() c.independent_indices (1, 2)
This means elements 1 and 2 of the metrical matrix are independent and can be varied. So you could randomly vary those elements of the metrical matrix. Say here we pick (25,100). Then to convert those back to a unit cell:
from cctbx.uctbx import unit_cell uc = unit_cell(metrical_matrix=c.all_params(independent_params=(25,100))) print(uc) (5, 5, 10, 90, 90, 90)
This code is part of symmetrize_reduce_enlarge in
./rstbx/symmetry/constraints/parameter_reduction.py
I would presume this works for any space group. Is this along the lines
you were looking for?
-Aaron
On Fri, Sep 15, 2023 at 11:59 AM David Waterman
Hi folks,
I'm testing some code changes and would like to iterate over every space group and for each generate a random unit cell compatible with the Bravais symmetry. I've got the iteration sorted with space_group_symbol_iterator, but I'm not sure how best to generate some compatible unit cell from the space_group object. Is this something I could do easily with cctbx?
Cheers, -- David _______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
Thanks everyone for the great suggestions! I think there are multiple ways I could have got this to work, but in the end, as I suspected, cctbx *does* already have a ready-made function. Us human crystallographers might not have been able to find it immediately, but some assistance from ChatGPT could unearth it. All credit to Peter Zwart for acting as "prompt engineer" here. It wasn't totally straightforward, as shown by the conversation at the link below. I think it's a good example of how to use these tools though. One has to be insistent in the face of confabulation. From Peter's email: https://chat.openai.com/share/b0a3ca0b-01ab-4469-a965-b54b4a3fed3d
which essentially tells me to look at the source code Computational Crystallography Toolbox / Code / [r25775] /trunk/cctbx/development/random_structure.py (sourceforge.net) https://sourceforge.net/p/cctbx/code/HEAD/tree/trunk/cctbx/development/rando... go to line 344, it uses space_group_info.any_compatible_unit_cell(volume=1000)
This is what my loop looks like now, following these pointers:
for space_group_symbol in sgtbx.space_group_symbol_iterator():
space_group = sgtbx.space_group(space_group_symbol)
unit_cell = space_group.info().any_compatible_unit_cell(volume=1000)
print(space_group_symbol.universal_hermann_mauguin(),
unit_cell.parameters())
Admittedly the cells do not explore the full random space within the
constraints, but actually for my purposes that's fine.
For what it's worth, this was Bard's attempt:
https://g.co/bard/share/7340bcdde4b3
This sort of looks promising, but fails because space_group.bravais_lattice
does not exist. I got disillusioned at that point, but what Peter's
conversation shows is that you've just got to keep pushing. At least,
that's the case right now. I wonder how long before these tools just write
the whole test I wanted correctly the first time.
Cheers
-- David
On Sat, 16 Sept 2023 at 09:33, Aaron Brewster
Hi David, there is a constraints object that tells you which elements of the metrical matrix can be varied:
from cctbx.sgtbx import space_group_info sg = space_group_info('P4').group() c = sg.adp_constraints() c.independent_indices (1, 2)
This means elements 1 and 2 of the metrical matrix are independent and can be varied. So you could randomly vary those elements of the metrical matrix. Say here we pick (25,100). Then to convert those back to a unit cell:
from cctbx.uctbx import unit_cell uc = unit_cell(metrical_matrix=c.all_params(independent_params=(25,100))) print(uc) (5, 5, 10, 90, 90, 90)
This code is part of symmetrize_reduce_enlarge in ./rstbx/symmetry/constraints/parameter_reduction.py
I would presume this works for any space group. Is this along the lines you were looking for? -Aaron
On Fri, Sep 15, 2023 at 11:59 AM David Waterman
wrote: Hi folks,
I'm testing some code changes and would like to iterate over every space group and for each generate a random unit cell compatible with the Bravais symmetry. I've got the iteration sorted with space_group_symbol_iterator, but I'm not sure how best to generate some compatible unit cell from the space_group object. Is this something I could do easily with cctbx?
Cheers, -- David _______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
_______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
I was wondering the same thing some time back.
And then I thought that it's easier and probably sufficient to use
unit cells and symmetries from the PDB. The file crystal.idx on
https://files.wwpdb.org/pub/pdb/derived_data/index/ has just this -
CRYST1 records from all entries.
On Fri, Sep 15, 2023 at 8:59 PM David Waterman
Hi folks,
I'm testing some code changes and would like to iterate over every space group and for each generate a random unit cell compatible with the Bravais symmetry. I've got the iteration sorted with space_group_symbol_iterator, but I'm not sure how best to generate some compatible unit cell from the space_group object. Is this something I could do easily with cctbx?
Cheers, -- David _______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
participants (4)
-
Aaron Brewster
-
David Waterman
-
Marcin Wojdyr
-
Phil Evans