mirror of https://github.com/QMCPACK/qmcpack.git
More perl scripts added...
git-svn-id: https://subversion.assembla.com/svn/qmcdev/trunk@5375 e5b18d87-469d-4833-9cc0-8cdfa06e9491
This commit is contained in:
parent
89188b7850
commit
7ab257849f
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use File::Copy;
|
||||
|
||||
my $dir = `pwd`;
|
||||
chomp($dir);
|
||||
print "Changing all scripts to use configure script at: $dir/setup-qmc-conf.pl\n";
|
||||
my $newline = 'my %config = do \"' . "$dir/setup-qmc-conf.pl" .'\";';
|
||||
|
||||
opendir DIR, ".";
|
||||
my @files = grep { $_ ne '.' && $_ ne '..'} readdir DIR;
|
||||
closedir DIR;
|
||||
|
||||
foreach my $file (@files) {
|
||||
if ($file =~ /\.pl$/ && !($file eq "ConfigureScripts.pl") ) {
|
||||
my $sedline = 'sed \'/my %config = do/c ' . $newline . "\' $file";
|
||||
# print $sedline . "\n";
|
||||
`$sedline > $file.tmp`;
|
||||
move ("$file.tmp", "$file");
|
||||
`chmod 755 $file`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#**************************************************************************
|
||||
# $RCSfile$ $Author: lshulenburger $
|
||||
# $Revision: 5115 $ $Date: 2011-9-15 10:19:08 -0700 (Thu, 15 Sep 2011) $
|
||||
# $Id: ConfigureScripts.pl 5115 2011-9-15 10:19:08 lshulenburger $
|
||||
#*************************************************************************/
|
|
@ -0,0 +1,243 @@
|
|||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use POSIX qw/floor/;
|
||||
use Getopt::Long;
|
||||
use FileHandle;
|
||||
|
||||
|
||||
# This tool uses energy.pl to plot the energy of a series of VMC optimizations.
|
||||
# Simply give it the filename of one of the .scalar.dat files and it will plot
|
||||
# the energy as a function of sequence. The locations of gnuplot and energy.pl
|
||||
# may need to be configured on the next lines
|
||||
|
||||
my $exactke;
|
||||
my $epsfile;
|
||||
GetOptions('ke=f' => \$exactke,
|
||||
'eps=s' => \$epsfile);
|
||||
|
||||
|
||||
my %config = do "/remote/lshulen/sharedmaintenance/qmcpack/utils/setup-qmc-conf.pl";
|
||||
|
||||
my $gnuplot = $config{gnuplot};
|
||||
my $energytool = $config{energytool};
|
||||
|
||||
my $template = shift || die "Must give a template file name as the first argument here\n";
|
||||
my $start = 50;
|
||||
$start = shift;
|
||||
(defined $start) || ($start = 0);
|
||||
my $plotstart = shift @ARGV;
|
||||
if (!(defined $plotstart)) {
|
||||
$plotstart = 1;
|
||||
}
|
||||
|
||||
|
||||
$template =~ /(.*f)(\d\.\d\d)(.*\.s\d\d\d\.scalar\.dat)/;
|
||||
my $prefix = $1;
|
||||
my $fact = $2;
|
||||
my $suffix = $3;
|
||||
#print "prefix = $prefix, factor = $fact, suffix = $suffix\n";
|
||||
|
||||
|
||||
opendir DIR, ".";
|
||||
my @files = grep { $_ ne '.' && $_ ne '..' } readdir DIR;
|
||||
closedir DIR;
|
||||
|
||||
my @rawfiles;
|
||||
foreach my $str (@files) {
|
||||
if ($str =~ /(.*f)(\d\.\d\d)(.*\.s\d\d\d\.scalar\.dat)/) {
|
||||
push @rawfiles, $str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my @factors;
|
||||
my @fulldata;
|
||||
my $varmin = 10000000000;
|
||||
my $varmax = -1;
|
||||
my $kemin = 1000000000;
|
||||
my $kemax = -100000000;
|
||||
my $minen = 1000000000;
|
||||
my $maxen = -1000000000;
|
||||
foreach my $file (sort byFactor @rawfiles) {
|
||||
$file =~ /(.*f)(\d\.\d\d)(.*\.s\d\d\d\.scalar\.dat)/;
|
||||
my $factor = $2;
|
||||
push @factors, $factor;
|
||||
|
||||
my $str = `$energytool $file $start`;
|
||||
# print "String = $str\n";
|
||||
my @data = split(/\n/, $str);
|
||||
# print "data[0] = $data[0]\n";
|
||||
my $en;
|
||||
my $ke;
|
||||
my $var;
|
||||
foreach my $line (@data) {
|
||||
if ($line =~ /LocalEnergy/) {
|
||||
# print "LocEnLine = $line\n";
|
||||
my @linedata = split(/\s+/,$line);
|
||||
$en = "$linedata[2] $linedata[4]";
|
||||
# print "en = $en\n";
|
||||
if ($linedata[2] < $minen) {
|
||||
$minen = $linedata[2];
|
||||
}
|
||||
if ($linedata[2] > $maxen) {
|
||||
$maxen = $linedata[2];
|
||||
}
|
||||
} elsif ($line =~ /Variance/) {
|
||||
my @linedata = split(/\s+/,$line);
|
||||
# print "VarLine = $line\n";
|
||||
$var = "$linedata[2] $linedata[4]";
|
||||
if ($linedata[2] < $varmin) {
|
||||
$varmin = $linedata[2];
|
||||
}
|
||||
if ($linedata[2] > $varmax) {
|
||||
$varmax = $linedata[2];
|
||||
}
|
||||
} elsif ($line =~ /Kinetic/) {
|
||||
my @linedata = split(/\s+/,$line);
|
||||
$ke = "$linedata[2] $linedata[4]";
|
||||
if ($linedata[2] < $kemin) {
|
||||
$kemin = $linedata[2];
|
||||
}
|
||||
if ($linedata[2] > $kemax) {
|
||||
$kemax = $linedata[2];
|
||||
}
|
||||
# print "KELine = $line\n";
|
||||
}
|
||||
}
|
||||
$str = "$factor $en $var $ke";
|
||||
# print "data = $str\n";
|
||||
push(@fulldata, $str);
|
||||
|
||||
# my $str = `$energytool $file $start | head -1`;
|
||||
# my @data = split(/\s+/,$str);
|
||||
# my $energy = "$data[2] $data[4]";
|
||||
# push @energies, $energy;
|
||||
|
||||
# $str = `$energytool $file $start | grep Kinetic`;
|
||||
# @data = split(/\s+/, $str);
|
||||
# my $kenergy = "$data[2] $data[4]";
|
||||
# push @kenergies, $kenergy;
|
||||
}
|
||||
|
||||
my $plotstring;
|
||||
if ($epsfile) {
|
||||
$plotstring .= "set term post color enhanced 16\n set output \"$epsfile\" \n";
|
||||
}
|
||||
$plotstring .= "set title \"B-spline factor vs energies for VMC\" \n";
|
||||
$plotstring .= "set multiplot \n set origin 0,0.6\n set size 1,0.4\n";
|
||||
$plotstring .= "set ylabel \"total energy (Ha)\"\n unset xtics\n";
|
||||
$plotstring .= "set lmargin 15\n";
|
||||
my $st = $factors[0]-0.05;
|
||||
my $ed = $factors[$#factors]+0.05;
|
||||
my $xtics = "set xtics (";
|
||||
for (my $i = 0; $i <= $#factors; $i++) {
|
||||
$xtics .= "\"$factors[$i]\" $factors[$i]";
|
||||
if ($i < $#factors) {
|
||||
$xtics .= ", " ;
|
||||
}
|
||||
}
|
||||
$plotstring .= "$xtics )\n";
|
||||
my $yincr = ($maxen-$minen)/4.0;
|
||||
$plotstring .= "set ytics $yincr\n";
|
||||
$plotstring .= "plot [$st:$ed] \"-\" u 1:2:3 notitle w e \n";
|
||||
for (my $i = 0; $i <= $#factors; $i++) {
|
||||
# $plotstring .= "$factors[$i] $energies[$i]\n";
|
||||
$plotstring .= "$fulldata[$i]\n";
|
||||
|
||||
}
|
||||
$plotstring .= "end \n";
|
||||
|
||||
# Do plot of variance
|
||||
$plotstring .= "set origin 0,0.33\n set size 1,0.3\n";
|
||||
$plotstring .= "unset title\n";
|
||||
$plotstring .= "set ylabel \"LocEn Variance\"\n set logscale y\n";
|
||||
$yincr = ($varmax-$varmin)/4.0;
|
||||
$plotstring .= "set ytics (";
|
||||
for (my $yticval = $varmin; $yticval <= $varmax; $yticval += $yincr) {
|
||||
$plotstring .= "\"$yticval\" $yticval";
|
||||
if ($yticval + $yincr <= $varmax) {
|
||||
$plotstring .= ", ";
|
||||
}
|
||||
}
|
||||
$plotstring .= ")\n";
|
||||
|
||||
|
||||
$plotstring .= "plot [$st:$ed][0.95*$varmin:1.05*$varmax] \"-\" u 1:4:5 notitle w e \n";
|
||||
|
||||
for (my $i = 0; $i <= $#factors; $i++) {
|
||||
# $plotstring .= "$factors[$i] $kenergies[$i]\n";
|
||||
$plotstring .= "$fulldata[$i]\n";
|
||||
}
|
||||
$plotstring .= "end \n";
|
||||
$plotstring .= "unset logscale y\n";
|
||||
|
||||
# Do plot of kinetic energy
|
||||
$plotstring .= "set origin 0,0\n set size 1,0.35\n";
|
||||
$plotstring .= "unset title\n";
|
||||
$plotstring .= "set xlabel \"b-spline factor\"\n";
|
||||
$plotstring .= "set ylabel \"kinetic energy (Ha)\"\n";
|
||||
$yincr = ($kemax-$kemin)/4.0;
|
||||
$plotstring .= "set ytics $yincr\n";
|
||||
if ($exactke) {
|
||||
$plotstring .= "f(x) = $exactke\n";
|
||||
$plotstring .= "plot [$st:$ed] f(x) lw 3 lt 1 notitle, \"-\" u 1:6:7 notitle w e \n";
|
||||
} else {
|
||||
$plotstring .= "plot [$st:$ed] \"-\" u 1:6:7 notitle w e \n";
|
||||
}
|
||||
for (my $i = 0; $i <= $#factors; $i++) {
|
||||
# $plotstring .= "$factors[$i] $kenergies[$i]\n";
|
||||
$plotstring .= "$fulldata[$i]\n";
|
||||
}
|
||||
$plotstring .= "end \n";
|
||||
$plotstring .= "unset multiplot\n";
|
||||
unless($epsfile) {
|
||||
$plotstring .= "pause -1\n";
|
||||
}
|
||||
|
||||
open(GPL, "|$gnuplot");
|
||||
GPL->autoflush(1);
|
||||
print GPL $plotstring;
|
||||
unless($epsfile) {
|
||||
my $redundantString = <>; # Hack to leave graph up until user hits a key
|
||||
}
|
||||
close(GPL);
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
||||
sub byFactor {
|
||||
my $left = $a;
|
||||
my $right = $b;
|
||||
$left =~ /(.*f)(\d\.\d\d)(.*\.s\d\d\d\.scalar\.dat)/;
|
||||
my $leftseq = $2;
|
||||
$right =~ /(.*f)(\d\.\d\d)(.*\.s\d\d\d\.scalar\.dat)/;
|
||||
my $rightseq = $2;
|
||||
$leftseq <=> $rightseq;
|
||||
}
|
||||
|
||||
sub getColumn {
|
||||
my $matrix = shift;
|
||||
my $colnum = shift;
|
||||
my $startnum = shift;
|
||||
my $end = shift;
|
||||
|
||||
if ($end < 0) {
|
||||
$end = $#{$matrix};
|
||||
}
|
||||
|
||||
$startnum || ($startnum = 0);
|
||||
my @outmat;
|
||||
for (my $i = $startnum+1; $i <= $end; $i++) {
|
||||
push @outmat, ${$matrix}[$i][$colnum];
|
||||
}
|
||||
return @outmat;
|
||||
}
|
||||
|
||||
|
||||
#**************************************************************************
|
||||
# $RCSfile$ $Author: lshulenburger $
|
||||
# $Revision: 5115 $ $Date: 2011-9-15 10:19:08 -0700 (Thu, 15 Sep 2011) $
|
||||
# $Id: PlotBsplConv.pl 5115 2011-9-15 10:19:08 lshulenburger $
|
||||
#*************************************************************************/
|
||||
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use FileHandle;
|
||||
use Getopt::Long;
|
||||
|
||||
my %config = do "/remote/lshulen/sharedmaintenance/qmcpack/utils/setup-qmc-conf.pl";
|
||||
my $gnuplot = $config{gnuplot};
|
||||
my $energytool = $config{energytool};
|
||||
|
||||
my $epsfile;
|
||||
GetOptions('eps=s' => \$epsfile);
|
||||
|
||||
|
||||
my $fname = shift;
|
||||
my $start = shift;
|
||||
$start > 0 || die "second command line argument must be the starting value at which to take data from the DMC output\n";
|
||||
|
||||
|
||||
open (XMLFILE, "$fname") || die "Cannot open template xml file: $fname\n";
|
||||
my @temdata = <XMLFILE>;
|
||||
close (XMLFILE);
|
||||
|
||||
|
||||
|
||||
|
||||
my $projid;
|
||||
my $seriesStart;
|
||||
my $counter = -1;
|
||||
my $startdmcsec = 0;
|
||||
my $stopdmcsec = 0;
|
||||
my $largesttstep = -1.0;
|
||||
my %tsteps;
|
||||
my %fnames;
|
||||
foreach my $line (@temdata) {
|
||||
if ($line =~ /project/ && $line =~ /id/) {
|
||||
$line =~ /id\s*?=\s*?"(.*?)"/;
|
||||
$projid = $1;
|
||||
$line =~ /series\s*?=\s*?"(.*)"/;
|
||||
$seriesStart = $1;
|
||||
$counter = $seriesStart;
|
||||
}
|
||||
|
||||
if ($line =~ /qmc/ && $line =~ /method/) {
|
||||
if ($line =~ /dmc/) {
|
||||
my $prettyseries;
|
||||
if ($counter < 10) {
|
||||
$prettyseries = sprintf("00%d", $counter);
|
||||
} elsif ($counter < 100) {
|
||||
$prettyseries = sprintf("0%2d", $counter);
|
||||
} else {
|
||||
$prettyseries = $counter;
|
||||
}
|
||||
$fnames{$counter} = "$projid.s$prettyseries.scalar.dat";
|
||||
# print "series $counter is dmc, scalars in: $projid.s$prettyseries.scalar.dat\n";
|
||||
$startdmcsec = 1;
|
||||
} else {
|
||||
# print "series $counter is not dmc\n";
|
||||
}
|
||||
}
|
||||
if ($startdmcsec) {
|
||||
if ($line =~ /timestep/) {
|
||||
$line =~ />\s*(.*?)\s*</;
|
||||
my $tstep = $1;
|
||||
if ($tstep > $largesttstep) {
|
||||
$largesttstep = $tstep;
|
||||
}
|
||||
$tsteps{$counter} = $tstep;
|
||||
# print " For series $counter the timestep is $tstep\n";
|
||||
}
|
||||
if ($line =~ /<\/qmc>/) {
|
||||
$startdmcsec = 0;
|
||||
}
|
||||
}
|
||||
if ($line =~ /<\/qmc>/) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#print "Project id = $projid\n";
|
||||
#print "Starting series = $seriesStart\n";
|
||||
|
||||
|
||||
my $gplstring = "set title \"timestep convergence of DMC\" \n";
|
||||
if ($epsfile) {
|
||||
$gplstring .= "set term post color enhanced 20\n set output \"$epsfile\"\n";
|
||||
}
|
||||
$gplstring .= "set xlabel \"timestep\"; set ylabel \"energy (Ha)\"\n";
|
||||
$gplstring .= "f(x) = a+b*x\n";
|
||||
$gplstring .= "fit f(x) \"-\" u 1:2:3 via a,b\n";
|
||||
foreach my $key ( sort by_key keys %fnames ) {
|
||||
my $str = `$energytool $fnames{$key} $start | head -1`;
|
||||
my @data = split(/\s+/,$str);
|
||||
my $energy = "$tsteps{$key} $data[2] $data[4]\n";
|
||||
$gplstring .= "$energy";
|
||||
}
|
||||
$gplstring .= "end\n";
|
||||
|
||||
my $plotmax = $largesttstep*1.05;
|
||||
$gplstring .= "plot [0:$plotmax] \"-\" u 1:2:3 lw 3 ps 2 pt 7 notitle w e, f(x) w l lw 3 notitle \n";
|
||||
|
||||
#my $xtics = "set xtics (";
|
||||
foreach my $key ( sort by_key keys %fnames ) {
|
||||
my $str = `$energytool $fnames{$key} $start | head -1`;
|
||||
my @data = split(/\s+/,$str);
|
||||
my $energy = "$tsteps{$key} $data[2] $data[4]\n";
|
||||
$gplstring .= "$energy";
|
||||
}
|
||||
|
||||
$gplstring .= "end \n";
|
||||
unless($epsfile) {
|
||||
$gplstring .= "pause -1\n";
|
||||
}
|
||||
open(GPL, "|$gnuplot");
|
||||
GPL->autoflush(1);
|
||||
print GPL $gplstring;
|
||||
#print $gplstring;
|
||||
unless($epsfile) {
|
||||
my $redundantString = <>; # Hack to leave graph up until user hits a key
|
||||
}
|
||||
close(GPL);
|
||||
|
||||
|
||||
|
||||
|
||||
sub by_key {
|
||||
return $a <=> $b;
|
||||
}
|
||||
|
||||
|
||||
#**************************************************************************
|
||||
# $RCSfile$ $Author: lshulenburger $
|
||||
# $Revision: 5115 $ $Date: 2011-9-15 10:19:08 -0700 (Thu, 15 Sep 2011) $
|
||||
# $Id: PlotTstepConv.pl 5115 2011-9-15 10:19:08 lshulenburger $
|
||||
#*************************************************************************/
|
|
@ -0,0 +1,316 @@
|
|||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use FileHandle;
|
||||
use Getopt::Long;
|
||||
|
||||
|
||||
my %config = do "/remote/lshulen/sharedmaintenance/qmcpack/utils/setup-qmc-conf.pl";
|
||||
|
||||
my $supercellsize;
|
||||
my $start;
|
||||
my $epsfile;
|
||||
my $smallestTwist;
|
||||
GetOptions('supercellsize=i' => \$supercellsize,
|
||||
'start=i' => \$start,
|
||||
'eps=s' => \$epsfile,
|
||||
'smallesttwist=i' => \$smallestTwist);
|
||||
|
||||
$#ARGV == 0 || die "Must give a pwscf input file as the argument to this script\n";
|
||||
my $inputFile = $ARGV[0];
|
||||
|
||||
my $baseName = $inputFile;
|
||||
$baseName =~ s/\.in//g;
|
||||
$baseName =~ s/-scf//g;
|
||||
|
||||
|
||||
unless ($supercellsize) {
|
||||
$supercellsize = 1;
|
||||
}
|
||||
unless ($start) {
|
||||
$start = 50;
|
||||
}
|
||||
unless ($smallestTwist) {
|
||||
$smallestTwist = 0;
|
||||
}
|
||||
|
||||
opendir DIR, ".";
|
||||
my @files = grep { $_ ne '.' && $_ ne '..'} readdir DIR;
|
||||
closedir DIR;
|
||||
|
||||
my %numToDir;
|
||||
getDirs(\@files, $supercellsize, \%numToDir);
|
||||
|
||||
$inputFile =~ s/\.in/\.out/;
|
||||
my $scfenout = `grep \"\\!\" $inputFile\n`;
|
||||
my @arr = split('\s+', $scfenout);
|
||||
my $scfen = $arr[4];
|
||||
|
||||
|
||||
my %numToEn;
|
||||
my %numToErr;
|
||||
my %numToCorrection;
|
||||
my $allWithCorrections = 1;
|
||||
|
||||
# Loop over different calcs and get twist averaged energy
|
||||
foreach my $keyval ( sort {$a <=> $b} keys %numToDir ) {
|
||||
if ($keyval > $smallestTwist) {
|
||||
my $pscfname = $baseName;
|
||||
if ($numToDir{$keyval} =~ /-S(\d+)/) {
|
||||
$pscfname .= "-S$1";
|
||||
}
|
||||
if ($keyval > 1) {
|
||||
$pscfname .= "-${keyval}twists-pscf.out";
|
||||
} else {
|
||||
$pscfname .= "-pscf.out";
|
||||
}
|
||||
my $pscfen;
|
||||
if (-e $pscfname) {
|
||||
my $pscfenout = `grep \"total energy\" $pscfname`;
|
||||
my @arr2 = split('\s+', $pscfenout);
|
||||
$pscfen = $arr2[4];
|
||||
} else {
|
||||
$allWithCorrections = 0;
|
||||
}
|
||||
my $dftcorr = ($scfen-$pscfen)/2.0;
|
||||
$numToCorrection{$keyval} = $dftcorr;
|
||||
|
||||
|
||||
my $templatefile = getTwistTemplateFile($keyval, $numToDir{$keyval}, $baseName);
|
||||
my $enln = `cd $numToDir{$keyval}; $config{twenergytool} $templatefile $keyval $start | head -1`;
|
||||
`cd ..`;
|
||||
chomp($enln);
|
||||
my @locdata = split('\s+', $enln);
|
||||
$numToEn{$keyval} = $locdata[2];
|
||||
$numToErr{$keyval} = $locdata[4];
|
||||
}
|
||||
}
|
||||
|
||||
# Now write the input for gnuplot
|
||||
my $gplstring;
|
||||
if ($epsfile) {
|
||||
$gplstring .= "set term post color enhanced 20\n set output \"$epsfile\"\n";
|
||||
}
|
||||
$gplstring .= "set title \"Convergence of DMC energy with Twist Averaging\"\n";
|
||||
$gplstring .= "set xlabel \"Number of Twists\"\n";
|
||||
$gplstring .= "set ylabel \"Energy (Ha)\"\n";
|
||||
|
||||
$gplstring .= "set xtics (";
|
||||
my $counter = 0;
|
||||
foreach my $keyval (sort {$a <=> $b} keys %numToEn) {
|
||||
$gplstring .= "\"$keyval\" $counter,";
|
||||
$counter++;
|
||||
}
|
||||
$gplstring = substr($gplstring,0,-1);
|
||||
$gplstring .= ")\n";
|
||||
|
||||
if ($allWithCorrections) {
|
||||
$gplstring .= "plot [-0.5:$counter-0.5] \"-\" u 0:2:3 w e ti \"DMC Energy with DFT correction\"\n";
|
||||
} else {
|
||||
$gplstring .= "plot [-0.5:$counter-0.5] \"-\" u 0:2:3 w e ti \"DMC Energy\"\n";
|
||||
}
|
||||
|
||||
foreach my $keyval (sort {$a <=> $b} keys %numToEn) {
|
||||
my $en = $numToEn{$keyval};
|
||||
if ($allWithCorrections) {
|
||||
$en += $numToCorrection{$keyval};
|
||||
}
|
||||
$gplstring .= "$keyval $en $numToErr{$keyval}\n";
|
||||
}
|
||||
$gplstring .= "end \n";
|
||||
unless ($epsfile) {
|
||||
$gplstring .= "pause -1\n";
|
||||
}
|
||||
|
||||
my $gnuplot = $config{gnuplot};
|
||||
open (GPL, "|$gnuplot");
|
||||
GPL->autoflush(1);
|
||||
print GPL $gplstring;
|
||||
|
||||
unless($epsfile) {
|
||||
<STDIN>;
|
||||
}
|
||||
close(GPL);
|
||||
|
||||
#print $gplstring;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# subroutines
|
||||
##########################################################################################
|
||||
|
||||
sub getTwistTemplateFile {
|
||||
my $numTwists = shift;
|
||||
my $dir = shift;
|
||||
my $baseName = shift;
|
||||
|
||||
if ($dir =~ /-S(\d+)/) {
|
||||
$baseName .= "-S$1";
|
||||
}
|
||||
|
||||
|
||||
my $outfname;
|
||||
my $xmlbase;
|
||||
|
||||
my $isProd = 0;
|
||||
my $isDMC = 0;
|
||||
|
||||
|
||||
if ($dir =~ /production/) {
|
||||
$isProd = 1;
|
||||
} else {
|
||||
$isDMC = 1;
|
||||
}
|
||||
|
||||
## Now we know which input file created the output
|
||||
if ($numTwists == 1) {
|
||||
if ($isDMC) {
|
||||
$xmlbase = "$baseName-dmc";
|
||||
} else {
|
||||
$xmlbase = "$baseName-production";
|
||||
}
|
||||
} else {
|
||||
if ($isDMC) {
|
||||
$xmlbase = "$baseName-dmc-tw0";
|
||||
} else {
|
||||
$xmlbase = "$baseName-production-tw0";
|
||||
}
|
||||
}
|
||||
|
||||
## Now find which output sequence from this was the dmc sequence
|
||||
open (XMLFILE, "$dir/$xmlbase.xml");
|
||||
my @temdata = <XMLFILE>;
|
||||
close (XMLFILE);
|
||||
|
||||
my $projid;
|
||||
my $seriesStart;
|
||||
my $counter;
|
||||
my $prettyseries;
|
||||
|
||||
foreach my $line (@temdata) {
|
||||
if ($line =~ /project/ && $line =~ /id/) {
|
||||
$line =~ /id\s*?=\s*?"(.*?)"/;
|
||||
$projid = $1;
|
||||
$line =~ /series\s*?=\s*?"(.*)"/;
|
||||
$seriesStart = $1;
|
||||
$counter = $seriesStart;
|
||||
}
|
||||
if ($line =~ /qmc/ && $line =~ /method/) {
|
||||
if ($line =~ /dmc/) {
|
||||
if ($counter < 10) {
|
||||
$prettyseries = sprintf("00%d", $counter);
|
||||
} elsif ($counter < 100) {
|
||||
$prettyseries = sprintf("0%2d", $counter);
|
||||
} else {
|
||||
$prettyseries = $counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($line =~ /<\/qmc>/) {
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
## now we look through the files in the directory for one whose name
|
||||
## contains $projid and s$prettyseries.scalar.dat
|
||||
|
||||
opendir DIR, "$dir";
|
||||
my @locfiles = grep { $_ ne '.' && $_ ne '..'} readdir DIR;
|
||||
closedir DIR;
|
||||
|
||||
|
||||
foreach my $file (@locfiles) {
|
||||
if ($file =~ /$projid.*s$prettyseries\.scalar\.dat/) {
|
||||
$outfname = $file;
|
||||
}
|
||||
}
|
||||
|
||||
return $outfname;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub getDirs {
|
||||
my $fileref = shift;
|
||||
my $ssize = shift;
|
||||
my $ndref = shift;
|
||||
|
||||
foreach my $str (@{$fileref}) {
|
||||
if ($ssize > 1) {
|
||||
if ($str =~ /^dmc-S$ssize-(\d+)twists$/) {
|
||||
my $numtwist = $1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
#print "directory: $str, number of twists: $numtwist\n";
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
if ($$ndref{$numtwist} =~ /production/) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
} elsif ($str =~ /^dmc-S$ssize$/) {
|
||||
my $numtwist = 1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
#print "directory: $str, number of twists: $numtwist\n";
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
if ($$ndref{$numtwist} =~ /production/) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
} elsif ($str =~ /^production-S$ssize-(\d+)twists$/) {
|
||||
my $numtwist = $1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
} elsif ($str =~/^production-S$ssize*/) {
|
||||
my $numtwist = 1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($str =~ /^dmc-(\d+)twists$/) {
|
||||
my $numtwist = $1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
#print "directory: $str, number of twists: $numtwist\n";
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
if ($$ndref{$numtwist} =~ /production/) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
}
|
||||
if ($str =~ /^dmc$/) {
|
||||
my $numtwist = 1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
#print "directory: $str, number of twists: $numtwist\n";
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
if ($$ndref{$numtwist} =~ /production/) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
} elsif ($str =~ /^production-(\d+)twists$/) {
|
||||
my $numtwist = $1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
} elsif ($str =~/^production$/) {
|
||||
my $numtwist = 1;
|
||||
unless ($$ndref{$numtwist}) {
|
||||
$$ndref{$numtwist} = $str;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#**************************************************************************
|
||||
# $RCSfile$ $Author: lshulenburger $
|
||||
# $Revision: 5115 $ $Date: 2011-9-15 10:19:08 -0700 (Thu, 15 Sep 2011) $
|
||||
# $Id: PlotTwistConv.pl 5115 2011-9-15 10:19:08 lshulenburger $
|
||||
#*************************************************************************/
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use POSIX qw/floor/;
|
||||
|
||||
my %config = do '/remote/lshulen/sharedmaintenance/qmcpack/utils/setup-qmc-conf.pl';
|
||||
my $getSupercell = $config{supercell};
|
||||
|
||||
print "Supercell command is at: $getSupercell\n";
|
||||
|
||||
|
||||
|
||||
my @ptvs;
|
||||
my $mindet = -1;
|
||||
my $maxdet = -1;
|
||||
my $maxentry = 7;
|
||||
|
||||
GetOptions('ptvs=f{9}' => \@ptvs,
|
||||
'min=i' => \$mindet,
|
||||
'max=i' => \$maxdet,
|
||||
'maxentry=i' => \$maxentry);
|
||||
|
||||
if ($mindet < 0 || $maxdet < 0 || $maxdet < $mindet) {
|
||||
die "Must specify maximium and minum size for tilemat using --max and --min where max > min\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $radius;
|
||||
my $numbins = 32;
|
||||
my $binsize = 0.1;
|
||||
my $binmin = 0.45;
|
||||
|
||||
my @bins;
|
||||
my @radii;
|
||||
my @volratios;
|
||||
|
||||
for (my $i = 0; $i < $numbins; $i++) {
|
||||
$bins[$i] = 0.0;
|
||||
$radii[$i] = 0.0;
|
||||
$volratios[$i] = 1000.0;
|
||||
}
|
||||
my $primcelldet = getDet(\@ptvs);
|
||||
|
||||
for (my $i = $mindet; $i <= $maxdet; $i++) {
|
||||
# print "i = $i\n";
|
||||
my $out = `$getSupercell --ptvs @ptvs --target $i --maxentry $maxentry`;
|
||||
# print "output of supercell command is: $out\n";
|
||||
my @parsed = split(/\s+/, $out);
|
||||
$radius = $parsed[0];
|
||||
print "radius for i = $i is $radius\n";
|
||||
my $volratio = abs($primcelldet)*$i/4.18879020478639098458/$radius**3;
|
||||
my $binnum = floor(($radius-$binmin)/$binsize);
|
||||
if ($volratio < $volratios[$binnum]) {
|
||||
$bins[$binnum] = $i;
|
||||
$radii[$binnum] = $radius;
|
||||
$volratios[$binnum] = $volratio;
|
||||
}
|
||||
}
|
||||
|
||||
for (my $i = 0; $i < $numbins; $i++) {
|
||||
if ($bins[$i] > 0) {
|
||||
print "Good value for tilemat with det = $bins[$i], giving radius $radii[$i], and volratio $volratios[$i]\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
######################################################################
|
||||
|
||||
|
||||
|
||||
sub getDet {
|
||||
my $matref = shift;
|
||||
my $val = $$matref[0]*($$matref[4]*$$matref[8] - $$matref[7]*$$matref[5])
|
||||
- $$matref[1]*($$matref[3]*$$matref[8] - $$matref[5]*$$matref[6])
|
||||
+ $$matref[2]*($$matref[3]*$$matref[7]-$$matref[4]*$$matref[6]);
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
||||
#**************************************************************************
|
||||
# $RCSfile$ $Author: lshulenburger $
|
||||
# $Revision: 5115 $ $Date: 2011-9-15 10:19:08 -0700 (Thu, 15 Sep 2011) $
|
||||
# $Id: getBestSupercell.pl 5115 2011-9-15 10:19:08 lshulenburger $
|
||||
#*************************************************************************/
|
|
@ -0,0 +1,12 @@
|
|||
ppconvert => '/remote/lshulen/sharedmaintenance/mywfconv/build/ppconvert',
|
||||
energytool => '/remote/lshulen/bin/energy.pl',
|
||||
supercell => '/remote/lshulen/sharedmaintenance/qmcpack/src/QMCTools/getSupercell',
|
||||
twenergytool => '/remote/lshulen/bin/TwistAvg.pl',
|
||||
gnuplot => '/usr/bin/gnuplot',
|
||||
|
||||
|
||||
#**************************************************************************
|
||||
# $RCSfile$ $Author: lshulenburger $
|
||||
# $Revision: 5115 $ $Date: 2011-9-15 10:19:08 -0700 (Thu, 15 Sep 2011) $
|
||||
# $Id: setup-qmc-conf.pl 5115 2011-9-15 10:19:08 lshulenburger $
|
||||
#*************************************************************************/
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue