ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/utilities/affineScale.in
Revision: 2993
Committed: Fri Sep 1 18:29:19 2006 UTC (18 years ago) by chrisfen
File size: 2832 byte(s)
Log Message:
modified affineScale to work with the new OOPSE files

File Contents

# User Rev Content
1 gezelter 2959 #!@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 chrisfen 2993 $startSnap = 0;
10     $startFrame = 0;
11     $startStunts = 0;
12 gezelter 2959
13     # get our options
14     getopts('hv', \%opts);
15    
16     # if we don't have a filename, drop to -h
17     $opts{h} = 'true' if $#ARGV != 1;
18    
19     # our option output
20     if ($opts{h}){
21 chrisfen 2993 print "affineScale: performs an affine transform on an OOPSE .in or .eor\n";
22     print "\tand writes to a new file named [file name].scale\n\n";
23     print "usage: affineScale [-hv] [file name] [new volume (Ang^3)]\n\n";
24     print " -h : show this message\n";
25     die " -v : more verbose output\n";
26 gezelter 2959 }
27    
28     # set some variables to be used in the code
29     $fileName = $ARGV[0];
30     $newVolume = $ARGV[1];
31    
32     # some crazy input checking
33     if ($newVolume =~ /^[0-9]/){
34     } else {
35 chrisfen 2993 die "\t[new volume] value ($newVolume) is not a valid number\n\tPlease choose a non-negative numeric value for [new volume]\n";
36 gezelter 2959 }
37    
38     # split up the name to obtain an output filename
39     @names = split('\.', $fileName);
40     $names[$#names] = 'scale';
41     $outName = join('.',@names);
42    
43     open(STATFILE, "./$fileName") || die "\tError: can't find file $fileName\n";
44     open (SCALEFILE, ">./$outName") || die "\tError: can't open $outName";
45    
46     while (<STATFILE>){
47 chrisfen 2993 $startSnap = 0 if /\/Snapshot/;
48     $startFrame = 0 if /\/FrameData/;
49     $startStunts = 0 if /\/StuntDoubles/;
50 gezelter 2959
51 chrisfen 2993 if ($startSnap == 1){
52     if ($startFrame == 1){
53     if (/Hmat/){
54     @line = split;
55    
56     chop $line[2];
57     chop $line[8];
58     $oldVolume = $line[2]*$line[8]*$line[14];
59    
60     $scale = ($newVolume/$oldVolume)**0.333333333333333;
61     # scale the hmat vectors (only orthorhombic)
62     $line[2] *= $scale;
63     $line[8] *= $scale;
64     $line[14] *= $scale;
65     $volume = $line[2]*$line[8]*$line[14];
66    
67     print SCALEFILE "\t$line[0]";
68     for ($i=1; $i<=$#line; $i++) {
69     print SCALEFILE " $line[$i]";
70     if ($i == 2 || $i == 8) {print SCALEFILE ",";}
71     }
72     print SCALEFILE "\n";
73     } else {
74     print SCALEFILE;
75     }
76 gezelter 2959 }
77 chrisfen 2993 if ($startStunts == 1){
78     @line = split;
79     $line[2] *= $scale;
80     $line[3] *= $scale;
81     $line[4] *= $scale;
82     print SCALEFILE "$line[0]\t$line[1]\t";
83     for ($i=2; $i<=$#line; $i++) {
84     print SCALEFILE "$line[$i] ";
85     }
86     print SCALEFILE "\n";
87     }
88     if ($startFrame == 0 && $startStunts == 0) {
89     print SCALEFILE;
90     }
91     } else {
92     print SCALEFILE;
93     }
94     $startSnap = 1 if /Snapshot/;
95     $startFrame = 1 if /FrameData/;
96     $startStunts = 1 if /StuntDoubles/;
97     # check again since "/value" contains "value"
98     $startSnap = 0 if /\/Snapshot/;
99     $startFrame = 0 if /\/FrameData/;
100     $startStunts = 0 if /\/StuntDoubles/;
101 gezelter 2959 }
102    
103     print "Affine transformed configuration written to $outName\n";
104    
105     if (defined($opts{v})){
106 chrisfen 2993 print "New Volume : $volume\n";
107     print "Old Volume : $oldVolume\n";
108     print "Scale Factor : $scale\n";
109 gezelter 2959 }
110    

Properties

Name Value
svn:executable *