File: fromOutSpace.pl

package info (click to toggle)
dmrgpp 6.06-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 113,900 kB
  • sloc: cpp: 80,986; perl: 14,772; ansic: 2,923; makefile: 83; sh: 17
file content (109 lines) | stat: -rw-r--r-- 2,584 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
#!/usr/bin/perl

use strict;
use warnings;
use Math::Trig;
use lib ".";
use OmegaUtils;
my ($outSpace, $templateInput, $isPeriodic) = @ARGV;
defined($isPeriodic) or die "USAGE: $0 out.space inputFile isPeriodic\n";

my $isAinur = OmegaUtils::isAinur($templateInput);
my $geometryName;
my $geometrySubName = "";
my $geometryLeg = 1;
my $centralSite;
my $tspSites= ($isAinur) ? "TSPSites" : "TSPSites 1";

my $hptr = {"GeometryKind" => \$geometryName,
            "GeometrySubKind" => \$geometrySubName,
            "LadderLeg" => \$geometryLeg,
            "$tspSites" => \$centralSite};

OmegaUtils::getLabels($hptr,$templateInput);

if ($isAinur) {
	$geometryName =~ s/\"//g;
	$geometryName =~ s/ *; *$//;
	$centralSite =~ s/^ *\[//;
	$centralSite =~ s/ *\] *; *$//;
}

my $geometry = {"name" => $geometryName, "leg" => $geometryLeg, "subname" => $geometrySubName};

$hptr->{"centralSite"} = $centralSite;
$hptr->{"isPeriodic"} = $isPeriodic;
$hptr->{"multicenter"} = 0;
$hptr->{"isAinur"} = $isAinur;
$geometry->{"isPeriodic"} = $isPeriodic;

my %h;
readSpaceValues(\%h, $outSpace);

if ($geometrySubName eq "ModifierTakeOddOnly") {
	OmegaUtils::modifierTakeOddOnly(\%h, \$geometry, $hptr);
}

print STDERR "Central site is ".$hptr->{"centralSite"}."\n";

my $outSpectrum = $outSpace;
$outSpectrum =~ s/\.space/\.spectrum/;
($outSpectrum ne $outSpace) or die "$0: $outSpectrum eq $outSpace ERROR FATAL\n";

open(FOUTSPECTRUM, ">", "$outSpectrum") or die "$0: Cannot write to $outSpectrum : $!\n";

foreach my $omega (sort keys %h) {
	print FOUTSPECTRUM "$omega ";
	my $spaceValues = $h{"$omega"};
	defined($spaceValues) or last;
	my @qValues;
	OmegaUtils::fourier(\@qValues,$spaceValues,$geometry,$hptr);
	my @array;
	OmegaUtils::writeFourier(\@array,\@qValues,$geometry);
	printSpectrum(\@array);
}

close(FOUTSPECTRUM);

print STDERR "$0: Wrote $outSpectrum\n";

sub readSpaceValues
{
	my ($h, $file) = @_;
	my $counter = 0;
	open(SPACEIN, "<", $file) or die "$0: Cannot open $file : $!\n";
	while (<SPACEIN>) {
		chomp;
		my ($omega, $n) = split;
		defined($n) or last;

		my @array;
		for (my $i = 0; $i < $n; ++$i) {
			$_ = <SPACEIN>;
			chomp;
			my ($i, $vv1, $vv2) = split;
			my @a = ($vv1, $vv2);
			$array[$i] = \@a;
		}

		$h->{"$omega"} = \@array;
		++$counter;
	}

	close(SPACEIN);
	print STDERR "$0: Read $counter omega values from $file\n";
}

sub printSpectrum
{
	my ($array) = @_;

	for (my $j = 0; $j < scalar(@$array); ++$j) {
		my $array2 = $array->[$j];
		my @array2 = @$array2;
		print FOUTSPECTRUM "$array2[1] $array2[2] ";
	}

	print FOUTSPECTRUM "\n";
}