1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2021-04-28 19:35:53 +0300 (Wed, 28 Apr 2021) $
#$Revision: 8738 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.7.0/scripts/cosets $
#------------------------------------------------------------------------------
#*
#* Generate and print out cosets of a subgroup in a group.
#*
#* Both the group and the subgroup can be given either as H-M symbols
#* of crystallographic groups or as lists of (generating) symmetry
#* operators.
#*
#* USAGE:
#* $0 --options P222 P2
#* $0 --options -- "x,y,z -x,-y,z x,y,-z -x,-y,-z" "-x,-y,z"
#**
use strict;
use warnings;
use COD::CIF::Data;
use COD::Spacegroups::Symop::Parse qw(
string_from_symop_reduced
symop_from_string
);
use COD::Spacegroups::Cosets qw(
find_left_cosets
find_right_cosets
);
use COD::Spacegroups::SimpleBuilder;
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion qw( get_version_string );
my $cosets = 'both'; # Other options are 'right' or 'left'.
#* OPTIONS:
#* -r, --right-cosets
#* -l, --left-cosets
#* -a, --all-cosets
#* Find the specified cosets (left cosets, right
#* cosets or both (default: both)).
#*
#* --help, --usage
#* Output a short usage message (this message) and exit.
#*
#* --version
#* Output version information and exit.
#**
@ARGV = getOptions(
"-r,--right-cosets" => sub { $cosets = 'right' },
"-l,--left-cosets" => sub { $cosets = 'left' },
"-a,--all-cosets" => sub { $cosets = 'both' },
'--help,--usage' => sub { usage; exit },
'--version' => sub { print get_version_string(), "\n"; exit }
);
if( @ARGV < 2 ) {
print STDERR "$0: usage: $0 SG1 SG1\n";
print STDERR " e.g.: $0 P212121 P21\n";
exit 1;
}
my $spacegroup_description_1 = shift( @ARGV );
my $spacegroup_description_2 = shift( @ARGV );
my $sym_data_1 =
COD::CIF::Data::lookup_space_group( 'hermann_mauguin',
$spacegroup_description_1 );
my $sym_data_2 =
COD::CIF::Data::lookup_space_group( 'hermann_mauguin',
$spacegroup_description_2 );
my ($symops_1, $symops_2);
if( defined $sym_data_1 ) {
$symops_1 = [ map { symop_from_string($_) } @{$sym_data_1->{symops}} ];
} else {
my $spacegroup = COD::Spacegroups::SimpleBuilder->new;
my @user_symops = split( " ", $spacegroup_description_1 );
$spacegroup->insert_symop_strings( \@user_symops );
$symops_1 = $spacegroup->all_symops_ref();
}
if( defined $sym_data_2 ) {
$symops_2 = [ map { symop_from_string($_) } @{$sym_data_2->{symops}} ];
} else {
my $spacegroup = COD::Spacegroups::SimpleBuilder->new;
my @user_symops = split( " ", $spacegroup_description_2 );
$spacegroup->insert_symop_strings( \@user_symops );
$symops_2 = $spacegroup->all_symops_ref();
}
if( $cosets eq 'left' || $cosets eq 'both' ) {
my @coset_symops = find_left_cosets( $symops_1, $symops_2 );
my $separator = "";
for( my $i = 0; $i <= $#coset_symops; $i++ ) {
print $separator;
for my $symop (@{$coset_symops[$i]}) {
print( "LCOSET\t", $i, "\t",
string_from_symop_reduced( $symop ), "\n" );
}
$separator = "\n";
}
print "\n", '#', '-' x 79, "\n\n" if $cosets eq 'both';
}
if( $cosets eq 'right' || $cosets eq 'both' ) {
my @coset_symops = find_right_cosets( $symops_1, $symops_2 );
my $separator = "";
for( my $i = 0; $i <= $#coset_symops; $i++ ) {
print $separator;
for my $symop (@{$coset_symops[$i]}) {
print( "RCOSET\t", $i, "\t",
string_from_symop_reduced( $symop ), "\n" );
}
$separator = "\n";
}
}
|