#!/usr/bin/env perl

open (F, "<custom-SZd.dat") or die;
<F>;
($T, $SZd) = split(' ', <F>);
chomp($SZd);
print "Sz (custom) = $SZd\n";

proc("FT");
proc("DMNRG");
proc("CFS");

print "\n";

tot("FT");
tot("DMNRG");
tot("CFS");

sub proc {
    $what = shift;
    $weight_u = `integrateneg spec_${what}_dens_A_d-A_d-u.dat`;
    $weight_d = `integrateneg spec_${what}_dens_A_d-A_d-d.dat`;
    $sz = 0.5*($weight_u - $weight_d);
    $delta = ($sz-$SZd)/$SZd*100;
    print "Sz ($what) = $sz  diff=$delta\%\n";
}

sub tot {
    $what = shift;
    $weight_u = `integrate spec_${what}_dens_A_d-A_d-u.dat`;
    $weight_d = `integrate spec_${what}_dens_A_d-A_d-d.dat`;
    $tot = ($weight_u + $weight_d)/2;
    $delta = ($tot-1)*100;
    print "weight ($what) = $tot  diff=$delta\%\n";
}
