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