Skip to content

Commit

Permalink
tidying up test codes
Browse files Browse the repository at this point in the history
  • Loading branch information
vbertone committed Apr 5, 2019
1 parent 6ec82d7 commit 6ae312d
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 261 deletions.
3 changes: 1 addition & 2 deletions tests/coupling_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/alphaqcd.h>
#include <apfel/alphaqed.h>
#include <apfel/apfelxx.h>

#include <cmath>
#include <iostream>
Expand Down
229 changes: 47 additions & 182 deletions tests/dglap_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/grid.h>
#include <apfel/timer.h>
#include <apfel/alphaqcd.h>
#include <apfel/tabulateobject.h>
#include <apfel/evolutionbasisqcd.h>
#include <apfel/matchingbasisqcd.h>
#include <apfel/dglap.h>
#include <apfel/tools.h>
#include <apfel/constants.h>
#include <apfel/dglapbuilder.h>
#include <apfel/lhtoypdfs.h>
#include <apfel/apfelxx.h>

#include <functional>

Expand Down Expand Up @@ -45,27 +35,26 @@ int main()
const auto DglapObjOp = InitializeDglapObjectsQCD(g, Masses, Thresholds, true);

// Construct the DGLAP objects
const auto EvolvedPDFs = BuildDglap(DglapObj, apfel::LHToyPDFs, mu0, PerturbativeOrder, as);
const auto EvolvedOps = BuildDglap(DglapObjOp, mu0, PerturbativeOrder, as);
const auto EvolvedPDFs = BuildDglap(DglapObj, apfel::LHToyPDFs, mu0, PerturbativeOrder, as);
const auto EvolvedOps = BuildDglap(DglapObjOp, mu0, PerturbativeOrder, as);

// Tabulate PDFs
const apfel::TabulateObject<apfel::Set<apfel::Distribution>> TabulatedPDFs{*EvolvedPDFs, 50, 1, 1000, 3};

// Final scale
const double mu = 100;

// Print results
std::cout << std::scientific;
// Compute results
std::cout << std::scientific << "Direct evolution (4th order Runge-Kutta) from Q0 = " << mu0 << " GeV to Q = " << mu << " GeV... ";

// Evolve PDFs to the final Scale
std::cout << "Direct evolution (4th order Runge-Kutta) from Q0 = " << mu0 << " GeV to Q = " << mu << " GeV... ";
apfel::Timer t;
const apfel::Set<apfel::Distribution> pdfs = EvolvedPDFs->Evaluate(mu);
const std::map<int, apfel::Distribution> pdfs = apfel::QCDEvToPhys(EvolvedPDFs->Evaluate(mu).GetObjects());
t.stop();

std::cout << "Interpolation of the tabulated PDFs... ";
t.start();
const apfel::Set<apfel::Distribution> tpdfs = TabulatedPDFs.Evaluate(mu);
const std::map<int, apfel::Distribution> tpdfs = apfel::QCDEvToPhys(TabulatedPDFs.Evaluate(mu).GetObjects());
t.stop();

std::cout << "Direct evolution of the operators... ";
Expand All @@ -79,9 +68,10 @@ int main()
const apfel::MatchEvolOperatorBasisQCD matchbasis{apfel::NF(mu0, Thresholds)};
InDist.SetMap(matchbasis);
ops.SetMap(matchbasis);
const apfel::Set<apfel::Distribution> oppdfs = ops * InDist;
const std::map<int, apfel::Distribution> oppdfs = apfel::QCDEvToPhys((ops * InDist).GetObjects());

const double xlha[] = {1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 3e-1, 5e-1, 7e-1, 9e-1};
// Print results
const std::vector<double> xlha = {1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 3e-1, 5e-1, 7e-1, 9e-1};

std::cout << "\nAlphaQCD(Q) = " << Alphas.Evaluate(mu) << std::endl;
std::cout << "\n x "
Expand All @@ -93,190 +83,65 @@ int main()
<< std::endl;

std::cout << "Direct Evolution:" << std::endl;
for (int i = 2; i < 11; i++)
for (auto const& x : xlha)
{
std::cout.precision(1);
std::cout << xlha[i];
std::cout << x;
std::cout.precision(4);
std::cout << " " <<
pdfs.at(2).Evaluate(xlha[i]) / 6 +
pdfs.at(4).Evaluate(xlha[i]) / 2 +
pdfs.at(6).Evaluate(xlha[i]) / 6 +
pdfs.at(8).Evaluate(xlha[i]) / 12 +
pdfs.at(10).Evaluate(xlha[i]) / 20 +
pdfs.at(12).Evaluate(xlha[i]) / 30
<< " " <<
pdfs.at(2).Evaluate(xlha[i]) / 6 -
pdfs.at(4).Evaluate(xlha[i]) / 2 +
pdfs.at(6).Evaluate(xlha[i]) / 6 +
pdfs.at(8).Evaluate(xlha[i]) / 12 +
pdfs.at(10).Evaluate(xlha[i]) / 20 +
pdfs.at(12).Evaluate(xlha[i]) / 30
<< " " <<
( pdfs.at(1).Evaluate(xlha[i]) - pdfs.at(2).Evaluate(xlha[i]) ) / 3 +
( pdfs.at(5).Evaluate(xlha[i]) - pdfs.at(6).Evaluate(xlha[i]) ) / 3 +
( pdfs.at(7).Evaluate(xlha[i]) - pdfs.at(8).Evaluate(xlha[i]) ) / 6 +
( pdfs.at(9).Evaluate(xlha[i]) - pdfs.at(10).Evaluate(xlha[i]) ) / 10 +
( pdfs.at(11).Evaluate(xlha[i]) - pdfs.at(12).Evaluate(xlha[i]) ) / 15
<< " " <<
pdfs.at(1).Evaluate(xlha[i]) / 6 -
pdfs.at(7).Evaluate(xlha[i]) / 4 +
pdfs.at(9).Evaluate(xlha[i]) / 20 +
pdfs.at(11).Evaluate(xlha[i]) / 30
<< " " <<
pdfs.at(0).Evaluate(xlha[i]) << " "
<< std::endl;
std::cout << " " << (pdfs.at(2) - pdfs.at(-2)).Evaluate(x)
<< " " << (pdfs.at(1) - pdfs.at(-1)).Evaluate(x)
<< " " << 2 * (pdfs.at(-2) + pdfs.at(-1)).Evaluate(x)
<< " " << (pdfs.at(4) + pdfs.at(-4)).Evaluate(x)
<< " " << pdfs.at(0).Evaluate(x)
<< std::endl;
}
std::cout << " " << std::endl;
std::cout << "\n";

std::cout << "Direct Evolution through the evolution operators:" << std::endl;
for (int i = 2; i < 11; i++)
for (auto const& x : xlha)
{
std::cout.precision(1);
std::cout << xlha[i];
std::cout << x;
std::cout.precision(4);
std::cout << " " <<
oppdfs.at(2).Evaluate(xlha[i]) / 6 +
oppdfs.at(4).Evaluate(xlha[i]) / 2 +
oppdfs.at(6).Evaluate(xlha[i]) / 6 +
oppdfs.at(8).Evaluate(xlha[i]) / 12 +
oppdfs.at(10).Evaluate(xlha[i]) / 20 +
oppdfs.at(12).Evaluate(xlha[i]) / 30
<< " " <<
oppdfs.at(2).Evaluate(xlha[i]) / 6 -
oppdfs.at(4).Evaluate(xlha[i]) / 2 +
oppdfs.at(6).Evaluate(xlha[i]) / 6 +
oppdfs.at(8).Evaluate(xlha[i]) / 12 +
oppdfs.at(10).Evaluate(xlha[i]) / 20 +
oppdfs.at(12).Evaluate(xlha[i]) / 30
<< " " <<
( oppdfs.at(1).Evaluate(xlha[i]) - oppdfs.at(2).Evaluate(xlha[i]) ) / 3 +
( oppdfs.at(5).Evaluate(xlha[i]) - oppdfs.at(6).Evaluate(xlha[i]) ) / 3 +
( oppdfs.at(7).Evaluate(xlha[i]) - oppdfs.at(8).Evaluate(xlha[i]) ) / 6 +
( oppdfs.at(9).Evaluate(xlha[i]) - oppdfs.at(10).Evaluate(xlha[i]) ) / 10 +
( oppdfs.at(11).Evaluate(xlha[i]) - oppdfs.at(12).Evaluate(xlha[i]) ) / 15
<< " " <<
oppdfs.at(1).Evaluate(xlha[i]) / 6 -
oppdfs.at(7).Evaluate(xlha[i]) / 4 +
oppdfs.at(9).Evaluate(xlha[i]) / 20 +
oppdfs.at(11).Evaluate(xlha[i]) / 30
<< " " <<
oppdfs.at(0).Evaluate(xlha[i]) << " "
<< std::endl;
std::cout << " " << (oppdfs.at(2) - oppdfs.at(-2)).Evaluate(x)
<< " " << (oppdfs.at(1) - oppdfs.at(-1)).Evaluate(x)
<< " " << 2 * (oppdfs.at(-2) + oppdfs.at(-1)).Evaluate(x)
<< " " << (oppdfs.at(4) + oppdfs.at(-4)).Evaluate(x)
<< " " << oppdfs.at(0).Evaluate(x)
<< std::endl;
}
std::cout << " " << std::endl;
std::cout << "\n";

std::cout << "Interpolation on the PDF table (all x for each Q):" << std::endl;
for (int i = 2; i < 11; i++)
{
std::cout.precision(1);
std::cout << xlha[i];
std::cout.precision(4);
std::cout << " " <<
tpdfs.at(2).Evaluate(xlha[i]) / 6 +
tpdfs.at(4).Evaluate(xlha[i]) / 2 +
tpdfs.at(6).Evaluate(xlha[i]) / 6 +
tpdfs.at(8).Evaluate(xlha[i]) / 12 +
tpdfs.at(10).Evaluate(xlha[i]) / 20 +
tpdfs.at(12).Evaluate(xlha[i]) / 30
<< " " <<
tpdfs.at(2).Evaluate(xlha[i]) / 6 -
tpdfs.at(4).Evaluate(xlha[i]) / 2 +
tpdfs.at(6).Evaluate(xlha[i]) / 6 +
tpdfs.at(8).Evaluate(xlha[i]) / 12 +
tpdfs.at(10).Evaluate(xlha[i]) / 20 +
tpdfs.at(12).Evaluate(xlha[i]) / 30
<< " " <<
( tpdfs.at(1).Evaluate(xlha[i]) - tpdfs.at(2).Evaluate(xlha[i]) ) / 3 +
( tpdfs.at(5).Evaluate(xlha[i]) - tpdfs.at(6).Evaluate(xlha[i]) ) / 3 +
( tpdfs.at(7).Evaluate(xlha[i]) - tpdfs.at(8).Evaluate(xlha[i]) ) / 6 +
( tpdfs.at(9).Evaluate(xlha[i]) - tpdfs.at(10).Evaluate(xlha[i]) ) / 10 +
( tpdfs.at(11).Evaluate(xlha[i]) - tpdfs.at(12).Evaluate(xlha[i]) ) / 15
<< " " <<
tpdfs.at(1).Evaluate(xlha[i]) / 6 -
tpdfs.at(7).Evaluate(xlha[i]) / 4 +
tpdfs.at(9).Evaluate(xlha[i]) / 20 +
tpdfs.at(11).Evaluate(xlha[i]) / 30
<< " " <<
tpdfs.at(0).Evaluate(xlha[i]) << " "
<< std::endl;
}
std::cout << " " << std::endl;

std::cout << "Interpolation on the PDF table (x and Q independently):" << std::endl;
for (int i = 2; i < 11; i++)
for (auto const& x : xlha)
{
std::cout.precision(1);
std::cout << xlha[i];
std::cout << x;
std::cout.precision(4);
std::cout << " " <<
TabulatedPDFs.EvaluatexQ(2,xlha[i],mu) / 6 +
TabulatedPDFs.EvaluatexQ(4,xlha[i],mu) / 2 +
TabulatedPDFs.EvaluatexQ(6,xlha[i],mu) / 6 +
TabulatedPDFs.EvaluatexQ(8,xlha[i],mu) / 12 +
TabulatedPDFs.EvaluatexQ(10,xlha[i],mu) / 20 +
TabulatedPDFs.EvaluatexQ(12,xlha[i],mu) / 30
<< " " <<
TabulatedPDFs.EvaluatexQ(2,xlha[i],mu) / 6 -
TabulatedPDFs.EvaluatexQ(4,xlha[i],mu) / 2 +
TabulatedPDFs.EvaluatexQ(6,xlha[i],mu) / 6 +
TabulatedPDFs.EvaluatexQ(8,xlha[i],mu) / 12 +
TabulatedPDFs.EvaluatexQ(10,xlha[i],mu) / 20 +
TabulatedPDFs.EvaluatexQ(12,xlha[i],mu) / 30
<< " " <<
( TabulatedPDFs.EvaluatexQ(1,xlha[i],mu) - TabulatedPDFs.EvaluatexQ(2,xlha[i],mu) ) / 3 +
( TabulatedPDFs.EvaluatexQ(5,xlha[i],mu) - TabulatedPDFs.EvaluatexQ(6,xlha[i],mu) ) / 3 +
( TabulatedPDFs.EvaluatexQ(7,xlha[i],mu) - TabulatedPDFs.EvaluatexQ(8,xlha[i],mu) ) / 6 +
( TabulatedPDFs.EvaluatexQ(9,xlha[i],mu) - TabulatedPDFs.EvaluatexQ(10,xlha[i],mu) ) / 10 +
( TabulatedPDFs.EvaluatexQ(11,xlha[i],mu) - TabulatedPDFs.EvaluatexQ(12,xlha[i],mu) ) / 15
<< " " <<
TabulatedPDFs.EvaluatexQ(1,xlha[i],mu) / 6 -
TabulatedPDFs.EvaluatexQ(7,xlha[i],mu) / 4 +
TabulatedPDFs.EvaluatexQ(9,xlha[i],mu) / 20 +
TabulatedPDFs.EvaluatexQ(11,xlha[i],mu) / 30
<< " " <<
TabulatedPDFs.EvaluatexQ(0,xlha[i],mu) << " "
<< std::endl;
std::cout << " " << (tpdfs.at(2) - tpdfs.at(-2)).Evaluate(x)
<< " " << (tpdfs.at(1) - tpdfs.at(-1)).Evaluate(x)
<< " " << 2 * (tpdfs.at(-2) + tpdfs.at(-1)).Evaluate(x)
<< " " << (tpdfs.at(4) + tpdfs.at(-4)).Evaluate(x)
<< " " << tpdfs.at(0).Evaluate(x)
<< std::endl;
}
std::cout << " " << std::endl;
std::cout << "\n";

std::cout << "Interpolation on the PDF table as a map (x and Q independently):" << std::endl;
for (int i = 2; i < 11; i++)
for (auto const& x : xlha)
{
const std::map<int, double> DistMap = TabulatedPDFs.EvaluateMapxQ(xlha[i],mu);
const std::map<int, double> DistMap = apfel::QCDEvToPhys(TabulatedPDFs.EvaluateMapxQ(x,mu));
std::cout.precision(1);
std::cout << xlha[i];
std::cout << x;
std::cout.precision(4);
std::cout << " " <<
DistMap.at(2) / 6 +
DistMap.at(4) / 2 +
DistMap.at(6) / 6 +
DistMap.at(8) / 12 +
DistMap.at(10) / 20 +
DistMap.at(12) / 30
<< " " <<
DistMap.at(2) / 6 -
DistMap.at(4) / 2 +
DistMap.at(6) / 6 +
DistMap.at(8) / 12 +
DistMap.at(10) / 20 +
DistMap.at(12) / 30
<< " " <<
( DistMap.at(1) - DistMap.at(2) ) / 3 +
( DistMap.at(5) - DistMap.at(6) ) / 3 +
( DistMap.at(7) - DistMap.at(8) ) / 6 +
( DistMap.at(9) - DistMap.at(10) ) / 10 +
( DistMap.at(11) - DistMap.at(12) ) / 15
<< " " <<
DistMap.at(1) / 6 -
DistMap.at(7) / 4 +
DistMap.at(9) / 20 +
DistMap.at(11) / 30
<< " " <<
DistMap.at(0) << " "
<< std::endl;
std::cout << " " << DistMap.at(2) - DistMap.at(-2)
<< " " << DistMap.at(1) - DistMap.at(-1)
<< " " << 2 * ( DistMap.at(-2) + DistMap.at(-1) )
<< " " << DistMap.at(4) + DistMap.at(-4)
<< " " << DistMap.at(0)
<< std::endl;
}
std::cout << " " << std::endl;
std::cout << "\n";

int k = 1000000;
std::cout << "Interpolating " << k << " times a single PDF on the (x,Q) grid... ";
Expand Down
8 changes: 1 addition & 7 deletions tests/distribution_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/distribution.h>
#include <apfel/grid.h>
#include <apfel/subgrid.h>
#include <apfel/operator.h>
#include <apfel/expression.h>
#include <apfel/timer.h>
#include <apfel/constants.h>
#include <apfel/apfelxx.h>

#include <cmath>

Expand Down
3 changes: 1 addition & 2 deletions tests/grid_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/grid.h>
#include <apfel/subgrid.h>
#include <apfel/apfelxx.h>

#include <iostream>
#include <iomanip>
Expand Down
2 changes: 1 addition & 1 deletion tests/integrator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/integrator.h>
#include <apfel/apfelxx.h>

#include <iostream>
#include <cmath>
Expand Down
8 changes: 2 additions & 6 deletions tests/interpolation_test.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
//
// APFEL++ 2017
//
// Authors: Valerio Bertone: [email protected]
// Stefano Carrazza: [email protected]
// Author: Valerio Bertone: [email protected]
//

#include <apfel/grid.h>
#include <apfel/subgrid.h>
#include <apfel/distribution.h>
#include <apfel/timer.h>
#include <apfel/apfelxx.h>

#include <iostream>
#include <iomanip>
Expand Down
2 changes: 1 addition & 1 deletion tests/ogata_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/ogataquadrature.h>
#include <apfel/apfelxx.h>

#include <iostream>
#include <math.h>
Expand Down
11 changes: 1 addition & 10 deletions tests/operator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/constants.h>
#include <apfel/expression.h>
#include <apfel/lagrangeinterpolator.h>
#include <apfel/grid.h>
#include <apfel/subgrid.h>
#include <apfel/operator.h>
#include <apfel/timer.h>
#include <apfel/apfelxx.h>

#include <cmath>

using namespace apfel;
using namespace std;

// Test expression (the LO Pqq splitting function)
class p0qq: public apfel::Expression
{
Expand Down
5 changes: 1 addition & 4 deletions tests/qgrid_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// Author: Valerio Bertone: [email protected]
//

#include <apfel/qgrid.h>
#include <apfel/alphaqcd.h>
#include <apfel/tabulateobject.h>
#include <apfel/timer.h>
#include <apfel/apfelxx.h>

#include <iostream>
#include <cmath>
Expand Down
Loading

0 comments on commit 6ae312d

Please sign in to comment.