Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes in caching and comparison of Wyckoff positions #45

Merged
merged 8 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions gap/cryst.gi
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ InstallOtherMethod( \^,
IsCollsElms, [ IsAffineCrystGroupOnRight, IsMatrix ], 0,
function ( S, conj )

local d, c, C, Ci, gens, i, R, W, r, w;
local d, c, C, Ci, gens, i, R, W, r, w, t;

d := DimensionOfMatrixGroup( S ) - 1;
if not IsAffineMatrixOnRight( conj ) then
Expand All @@ -267,6 +267,7 @@ function ( S, conj )
C := conj;
Ci := conj^-1;
c := C {[1..d]}{[1..d]};
t := C [d+1]{[1..d]}; # Translation

# conjugate the generators of S
gens := ShallowCopy( GeneratorsOfGroup( S ) );
Expand All @@ -284,10 +285,11 @@ function ( S, conj )
if HasWyckoffPositions( S ) then
W := [];
for w in WyckoffPositions( S ) do
r := rec( basis := w!.basis*c,
translation := w!.translation*c,
class := w!.class,
spaceGroup := R );
r := rec( basis := w!.basis,
translation := w!.translation*c + t,
class := w!.class,
spaceGroup := R );
if r.basis <> [] then r.basis := r.basis * c; fi;
ReduceAffineSubspaceLattice( r );
Add( W, WyckoffPositionObject( r ) );
od;
Expand All @@ -302,7 +304,7 @@ InstallOtherMethod( \^,
IsCollsElms, [ IsAffineCrystGroupOnLeft, IsMatrix ], 0,
function ( S, conj )

local d, c, C, Ci, gens, i, R, W, r, w;
local d, c, C, Ci, gens, i, R, W, r, w, t;

d := DimensionOfMatrixGroup( S ) - 1;
if not IsAffineMatrixOnLeft( conj ) then
Expand All @@ -313,6 +315,7 @@ function ( S, conj )
C := conj;
Ci := conj^-1;
c := TransposedMat( C {[1..d]}{[1..d]} );
t := C {[1..d]}[d+1]; # Translation

# conjugate the generators of S
gens := ShallowCopy( GeneratorsOfGroup( S ) );
Expand All @@ -330,12 +333,13 @@ function ( S, conj )
if HasWyckoffPositions( S ) then
W := [];
for w in WyckoffPositions( S ) do
r := rec( basis := w!.basis*c,
translation := w!.translation*c,
class := w!.class,
spaceGroup := R );
ReduceAffineSubspaceLattice( r );
Add( W, WyckoffPositionObject( r ) );
r := rec( basis := w!.basis,
translation := w!.translation*c + t,
class := w!.class,
spaceGroup := R );
if r.basis <> [] then r.basis := r.basis * c; fi;
ReduceAffineSubspaceLattice( r );
Add( W, WyckoffPositionObject( r ) );
od;
SetWyckoffPositions( R, W );
fi;
Expand Down
6 changes: 6 additions & 0 deletions gap/wyckoff.gi
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ function( w1, w2 )
gens := Filtered( GeneratorsOfGroup( S ),
x -> x{[1..d]}{[1..d]} <> One( PointGroup( S ) ) );
U := SubgroupNC( S, gens );
if IsAffineCrystGroupOnLeft( U ) then
U := TransposedMatrixGroup( U );
fi;
rep := RepresentativeAction( U, r1, r2, ImageAffineSubspaceLattice );
return rep <> fail;
end );
Expand Down Expand Up @@ -200,6 +203,9 @@ function( w1, w2 )
gens := Filtered( GeneratorsOfGroup( S ),
x -> x{[1..d]}{[1..d]} <> One( PointGroup( S ) ) );
U := SubgroupNC( S, gens );
if IsAffineCrystGroupOnLeft( U ) then
U := TransposedMatrixGroup( U );
fi;
o1 := Orbit( U, r1, ImageAffineSubspaceLattice );
o2 := Orbit( U, r2, ImageAffineSubspaceLattice );
o1 := Set( List( o1, x -> rec( t := x.translation, b := x.basis ) ) );
Expand Down
20 changes: 20 additions & 0 deletions tst/cryst.tst
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,32 @@ gap> C := [ [ 3, 1, 0, 0 ], [ -1, -2, 0, 0 ], [ 2, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];;
gap> IsSpaceGroup( G^C );
true

# The next checks verify that including a translation component in conjugation
# works correctly, as from <https://github.com/gap-packages/cryst/issues/44>.
gap> C := [ [ 3, 1, 0, 0 ], [ -1, -2, 0, 0 ], [ 2, 0, 1, 0 ], [ 1/2, 0, 0, 1 ] ];;
gap> IsSpaceGroup( G^C );
true

# Test that caching of Wyckoff followed by conjugation works as expected
# Use Set because the order of the Wyckoff positions is semi-arbitrary.
gap> Set(WyckoffPositions( G^C )) = Set(WyckoffPositions(SpaceGroupIT(3,183)^C));
true

gap> G := TransposedMatrixGroup( G );
<matrix group with 6 generators>
gap> W := WyckoffPositions(G);;
gap> IsSpaceGroup( G^TransposedMat(C) );
true

gap> Set(WyckoffPositions( G^TransposedMat(C) )) = Set(WyckoffPositions(SpaceGroupOnLeftIT(3,183)^TransposedMat(C)));
true

# Test Wyckoff positions in a case that involves an empty basis (see <https://github.com/gap-packages/cryst/issues/42>).
gap> G := SpaceGroupIT( 3, 12 );;
gap> W := WyckoffPositions(G);;
gap> IsSpaceGroup( G^C );
true

gap> G := SpaceGroupIT( 3, 208 );
SpaceGroupOnRightIT(3,208,'1')
gap> M := MaximalSubgroupClassReps( G, rec( primes := [2,3] ) );
Expand Down
Loading