ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/utilities/affineScale.in
Revision: 2963
Committed: Wed Jul 26 21:45:05 2006 UTC (17 years, 11 months ago) by gezelter
File size: 2430 byte(s)
Log Message:
fixed a spelling bug

File Contents

# Content
1 #!@PERLINTERP@ -w
2
3 # program that scales an OOPSE .in or .eor file to a new volume
4 # written by Chris Fennell
5
6 use Getopt::Std;
7
8 # some variables to get things going
9 $line1 = 1;
10 $line2 = 0;
11
12 # get our options
13 getopts('hv', \%opts);
14
15 # if we don't have a filename, drop to -h
16 $opts{h} = 'true' if $#ARGV != 1;
17
18 # our option output
19 if ($opts{h}){
20 print "affineScale: performs an affine transform on an OOPSE .in or .eor\n";
21 print "\tand writes to a new file named [file name].scale\n\n";
22 print "usage: affineScale [-hv] [file name] [new volume (Ang^3)]\n\n";
23 print " -h : show this message\n";
24 die " -v : more verbose output\n";
25 }
26
27 # set some variables to be used in the code
28 $fileName = $ARGV[0];
29 $newVolume = $ARGV[1];
30
31 # some crazy input checking
32 if ($newVolume =~ /^[0-9]/){
33 } else {
34 die "\t[new volume] value ($newVolume) is not a valid number\n\tPlease choose a non-negative numeric value for [new volume]\n";
35 }
36
37 # split up the name to obtain an output filename
38 @names = split('\.', $fileName);
39 $names[$#names] = 'scale';
40 $outName = join('.',@names);
41
42 open(STATFILE, "./$fileName") || die "\tError: can't find file $fileName\n";
43 open (SCALEFILE, ">./$outName") || die "\tError: can't open $outName";
44
45 while (<STATFILE>){
46 if ($line1 == 1){
47 print SCALEFILE;
48 $line1 = 0;
49 $line2 = 1;
50
51 } elsif ($line2 == 1){
52 @line = split;
53 chop $line[9];
54 $oldVolume = $line[1]*$line[5]*$line[9];
55
56 $scale = ($newVolume/$oldVolume)**0.333333333333333;
57 # scale the hmat vectors (only orthorhombic)
58 $line[1] *= $scale;
59 $line[5] *= $scale;
60 $line[9] *= $scale;
61 $volume = $line[1]*$line[5]*$line[9];
62
63 print SCALEFILE "$line[0]";
64 for ($i=1; $i<=$#line; $i++) {
65 print SCALEFILE "\t$line[$i]";
66 if ($i == 9) {print SCALEFILE ";";}
67 }
68 print SCALEFILE "\n";
69 $line2 = 0;
70
71 } else {
72 @line = split /\s+/;
73 $line[1] *= $scale;
74 $line[2] *= $scale;
75 $line[3] *= $scale;
76 print SCALEFILE "$line[0]";
77 for ($i=1; $i<=$#line; $i++) {
78 print SCALEFILE "\t$line[$i]";
79 }
80 print SCALEFILE "\n";
81 }
82 }
83
84 print "Affine transformed configuration written to $outName\n";
85
86 if (defined($opts{v})){
87 print "New Volume : $volume\n";
88 print "Old Volume : $oldVolume\n";
89 print "Scale Factor : $scale\n";
90 }
91

Properties

Name Value
svn:executable *