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
31 changes: 24 additions & 7 deletions gap/cryst.gi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
##
## Methods for affine crystallographic groups
##
## MODIFIED BY BERNARD FIELD (2023)
bfield1 marked this conversation as resolved.
Show resolved Hide resolved

#############################################################################
##
Expand Down Expand Up @@ -256,7 +257,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 +268,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 +286,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 +311,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 +322,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 +340,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
16 changes: 15 additions & 1 deletion tst/cryst.tst
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,30 @@ false

gap> G := SpaceGroupIT(3,183);;
gap> W := WyckoffPositions(G);;
gap> C := [ [ 3, 1, 0, 0 ], [ -1, -2, 0, 0 ], [ 2, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];;
gap> C := [ [ 3, 1, 0, 0 ], [ -1, -2, 0, 0 ], [ 2, 0, 1, 0 ], [ 1/2, 0, 0, 1 ] ];;
gap> IsSpaceGroup( G^C );
true
bfield1 marked this conversation as resolved.
Show resolved Hide resolved

# Test that caching of Wyckoff followed by conjugation works as expected
# I use Set because the order of the Wyckoff Positions is semi-arbitrary.
bfield1 marked this conversation as resolved.
Show resolved Hide resolved
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 with a Wyckoff positions that has empty basis.
bfield1 marked this conversation as resolved.
Show resolved Hide resolved
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