File: symmul

package info (click to toggle)
cod-tools 3.1.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 149,700 kB
  • sloc: perl: 56,946; sh: 32,158; ansic: 6,385; xml: 1,982; yacc: 1,117; makefile: 728; python: 166
file content (88 lines) | stat: -rwxr-xr-x 2,332 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
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2019-12-05 21:37:22 +0200 (Thu, 05 Dec 2019) $ 
#$Revision: 7549 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.1.0/scripts/symmul $
#------------------------------------------------------------------------------
#*
#* Multiply all symmetry operators provided on the command line.
#*
#* USAGE: 
#*    $0 --options -- -y,-x,z -x,y,z
#*    $0 --options -- -y,-x,z -x,y,z z,y,x
#**

use strict;
use warnings;
use COD::CIF::Data;
use COD::Spacegroups::Symop::Parse qw( 
    symop_from_string
    string_from_symop
);
use COD::Spacegroups::Symop::Algebra qw( 
    symop_mul
    symop_modulo_1
    snap_to_crystallographic
);
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion;

my $print_matrix = 0; # Print output as matrix or as a string.

#* OPTIONS:
#*   -m, --matrix
#*                     Print output in matrix form.
#*   -s, --string
#*                     Print output in string form as general position
#*                     coordinates (default).
#*
#*   --help, --usage
#*                     Output a short usage message (this message) and exit.
#*
#*   --version
#*                     Output version information and exit.
#**
@ARGV = getOptions(
    "-m,--matrix" => sub { $print_matrix = 1 },
    "-s,--string" => sub { $print_matrix = 0 },
    "--help,--usage" => sub { usage; exit },
    '--version'      => sub { print 'cod-tools version ',
                              $COD::ToolsVersion::Version, "\n";
                              exit }
);

my $result =
    [
     [ 1, 0, 0, 0 ],
     [ 0, 1, 0, 0 ],
     [ 0, 0, 1, 0 ],
     [ 0, 0, 0, 1 ],
    ];

for my $symop_string (@ARGV) {
    my $symop = symop_from_string( $symop_string );
    $result = 
        snap_to_crystallographic(
            symop_modulo_1(
                symop_mul( $result, $symop )
            )
        );
}

if( $print_matrix ) {
    for my $row (@$result) {
        my $separator = "";
        for (@$row) {
            print $separator, $_;
            $separator = "\t";
        }
        print "\n";
    }
} else {
    print string_from_symop( $result ), "\n";
}