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
30 changes: 23 additions & 7 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,17 @@ function ( S, conj )
if HasWyckoffPositions( S ) then
W := [];
for w in WyckoffPositions( S ) do
r := rec( basis := w!.basis*c,
translation := w!.translation*c,
if w!.basis = [] then
r := rec( basis := w!.basis,
translation := w!.translation*c + t,
class := w!.class,
spaceGroup := R );
else
r := rec( basis := w!.basis*c,
translation := w!.translation*c + t,
class := w!.class,
spaceGroup := R );
fi;
ReduceAffineSubspaceLattice( r );
Add( W, WyckoffPositionObject( r ) );
od;
Expand All @@ -302,7 +310,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 +321,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 +339,19 @@ function ( S, conj )
if HasWyckoffPositions( S ) then
W := [];
for w in WyckoffPositions( S ) do
if w!.basis = [] then
r := rec( basis := w!.basis,
bfield1 marked this conversation as resolved.
Show resolved Hide resolved
translation := w!.translation*c + t,
class := w!.class,
spaceGroup := R );
else
r := rec( basis := w!.basis*c,
translation := w!.translation*c,
translation := w!.translation*c + t,
class := w!.class,
spaceGroup := R );
ReduceAffineSubspaceLattice( r );
Add( W, WyckoffPositionObject( r ) );
fi;
ReduceAffineSubspaceLattice( r );
Add( W, WyckoffPositionObject( r ) );
od;
SetWyckoffPositions( R, W );
fi;
Expand Down
2 changes: 2 additions & 0 deletions gap/wyckoff.gi
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ end );
##
InstallGlobalFunction( ImageAffineSubspaceLattice, function( s, g )
local d, m, t, b, r;
if IsAffineMatrixOnLeft(g) then g := TransposedMat(g); fi;
d := Length( s.translation );
m := g{[1..d]}{[1..d]};
t := g[d+1]{[1..d]};
Expand All @@ -136,6 +137,7 @@ end );
##
InstallGlobalFunction( ImageAffineSubspaceLatticePointwise, function( s, g )
local d, m, t, b, L, r;
if IsAffineMatrixOnLeft(g) then g := TransposedMat(g); fi;
d := Length( s.translation );
m := g{[1..d]}{[1..d]};
t := g[d+1]{[1..d]};
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