File: spacegroup_properties

package info (click to toggle)
cod-tools 3.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 159,136 kB
  • sloc: perl: 58,707; sh: 41,323; ansic: 7,268; xml: 1,982; yacc: 1,117; makefile: 731; python: 166
file content (153 lines) | stat: -rwxr-xr-x 4,554 bytes parent folder | download
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: saulius $
#$Date: 2024-09-13 11:34:17 +0300 (Fri, 13 Sep 2024) $
#$Revision: 10305 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.11.0/scripts/spacegroup_properties $
#------------------------------------------------------------------------------
#*
#* Lookup or determine space group properties and write them out in
#* TSV format.
#*
#* USAGE:
#*   $0 > spacegroup_properties.tsv
#**

use strict;
use warnings;
use COD::Spacegroups::Lookup::COD;
use COD::Spacegroups::Lookup qw( make_symop_hash make_symop_key );
use COD::Spacegroups::Symop::Parse qw( string_from_symop );
use COD::Spacegroups::Builder;
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion qw( get_version_string );

my $debug = 0;
my $space_group_builder_type = 'optimised';

#* OPTIONS:
#*   --debug
#*                     Switch on debug printouts.
#*   --no-debug
#*                     Switch of debug printouts (default).
#*
#*   --help, --usage
#*                     Output a short usage message (this message) and exit.
#*
#*   --version
#*                     Output version information and exit.
#**
@ARGV = getOptions(
    '--debug'        => sub { $debug = 1 },
    '--no-debug'     => sub { $debug = 0 },

    '--help,--usage' => sub { usage; exit },
    '--version'      => sub { print get_version_string(), "\n"; exit }
);

my @symop_lookup_table = (
    @COD::Spacegroups::Lookup::COD::table,
    @COD::Spacegroups::Lookup::COD::extra_settings
);

my %symop_lookup_table = make_symop_hash( [
    \@symop_lookup_table
] );

do {
    # line separator (aka "group separator", ASCII 29 DEC 1D HEX "GS" ):
    local $\ = "\n";
    # column separator (aka "record separator", ASCII 30 DEC 1E HEX "RS"):
    local $, = "\t";

    print
        'no.'
        ,'sgNum'
        ,'nsymop'
        ,'hasinv'
        ,'ncent'
        ,'sgHall'
        ,'sgHM'
        ;
};

my $n = 0;

for my $space_group_description (@symop_lookup_table) {

    $n ++;
    
    my $space_group_builder = COD::Spacegroups::Builder->new();

    if ( $debug ) {
        $space_group_builder->debug(1);
    }

    my @table_symops = @{$space_group_description->{symops}};

    for my $symop (@table_symops) {
        $space_group_builder->insert_symop_string( $symop );
    }

    my @constructed_symops = $space_group_builder->all_symops();

    ## $space_group_builder->print();

    # Do some sanity checks to rule out certain classes of incorrect
    # results:

    # The number of estimated and tabled symmetry operations must
    # match:

    die unless
        scalar(@{$space_group_description->{symops}}) ==
               scalar(@{$space_group_builder->all_symops()});
               
    # The number of centering operations must match:
    
    die "!!! '$space_group_description->{universal_h_m}' " .
        "('$space_group_description->{hall}'), " .
        "recorded ncent: " .
        scalar(@{$space_group_description->{symops}}) /
        scalar(@{$space_group_description->{ncsym}}) .
        " calculated ncent: " .
        scalar(@{$space_group_builder->{centering_translations}})
        unless
        scalar(@{$space_group_description->{symops}}) /
        scalar(@{$space_group_description->{ncsym}})
        ==
        scalar(@{$space_group_builder->{centering_translations}});
               
    # The generated symmetry operations must be in the COD tables:
    
    my $key = make_symop_key( [ map { string_from_symop($_) }
                                @constructed_symops ] );

    if( ! exists $symop_lookup_table{$key} ) {
        die "$0: spacegroup at index $n, " .
            "'$space_group_description->{universal_h_m}', " .
            "could not be identified\n"
    }

    do {
        # line separator (aka "group separator", ASCII 29 DEC 1D HEX "GS" ):
        local $\ = "\n";
        # column separator (aka "record separator", ASCII 30 DEC 1E HEX "RS"):
        local $, = "\t";

        print
            $n
            ,$space_group_description->{number}
            ,scalar(@{$space_group_builder->all_symops()})
            ,$space_group_builder->{has_inversion}
            ,scalar(@{$space_group_builder->{centering_translations}})
            ,$space_group_description->{hall}
            ,$space_group_description->{universal_h_m}
            ;
    };

} # for my $space_group_description ...