Commit 5566e18e authored by kraus's avatar kraus
Browse files

Merge branch...

Merge branch '299-implement-a-better-format-for-the-material-parameters-in-collimatorphysics' into 'master'

Resolve "Implement a better format for the material parameters in CollimatorPhysics"

Closes #299

See merge request OPAL/src!77
parents 98218d17 cf2d9d8c
#ifndef AIR_H
#define AIR_H
#include "Physics/Material.h"
namespace Physics {
class Air: public Material {
public:
Air():
Material(7,
14,
0.0012,
37.99,
85.7,
{{3.350, 1.683e3, 1.900e3, 2.513e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef ALUMINAAL2O3_H
#define ALUMINAAL2O3_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class AluminaAL2O3: public Material {
public:
AluminaAL2O3():
Material(50,
101.96,
3.97,
27.94,
145.2,
{{7.227, 1.121e4, 3.864e2, 4.474e-3}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef ALUMINUM_H
#define ALUMINUM_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class Aluminum: public Material {
public:
Aluminum():
Material(13,
26.98,
2.7,
24.01,
166.0,
{{4.739, 2.766e3, 1.645e2, 2.023e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef BERYLLIUM_H
#define BERYLLIUM_H
#include "Physics/Material.h"
namespace Physics {
class Beryllium: public Material {
public:
Beryllium():
Material(4,
9.012,
1.848,
65.19,
63.7,
{{2.590, 9.660e2, 1.538e2, 3.475e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef BORONCARBIDE_H
#define BORONCARBIDE_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class BoronCarbide: public Material {
public:
BoronCarbide():
Material(26,
55.25,
2.48,
50.14,
84.7,
{{3.963, 6065.0, 1243.0, 7.782e-3}})
{ }
};
}
#endif
\ No newline at end of file
set (_SRCS
Material.cpp
)
include_directories (
......@@ -8,7 +9,8 @@ include_directories (
ADD_OPAL_SOURCES(${_SRCS})
set (HDRS
Material.h
Physics.h
)
install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Physics")
install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Physics")
\ No newline at end of file
#ifndef COPPER_H
#define COPPER_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class Copper: public Material {
public:
Copper():
Material(29,
63.54,
8.96,
12.86,
322.0,
{{4.194, 4.649e3, 8.113e1, 2.242e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef GOLD_H
#define GOLD_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class Gold: public Material {
public:
Gold():
Material(79,
197,
19.3,
6.46,
790.0,
{{5.458, 7.852e3, 9.758e2, 2.077e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef GRAPHITE_H
#define GRAPHITE_H
#include "Physics/Material.h"
namespace Physics {
class Graphite: public Material {
public:
Graphite():
Material(6,
12.0107,
2.210,
42.70,
78.0,
{{2.601, 1.701e3, 1.279e3, 1.638e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef GRAPHITER6710_H
#define GRAPHITER6710_H
#include "Physics/Material.h"
namespace Physics {
class GraphiteR6710: public Material {
public:
GraphiteR6710():
Material(6,
12.0107,
1.88,
42.70,
78.0,
{{2.601, 1.701e3, 1.279e3, 1.638e-2}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef KAPTON_H
#define KAPTON_H
#include "Physics/Material.h"
namespace Physics {
class Kapton: public Material {
public:
Kapton():
Material(6,
12,
1.4,
39.95,
79.6, // source: pstar from NIST
{{2.601, 1.701e3, 1.279e3, 1.638e-2}})
{ }
};
}
#endif
\ No newline at end of file
#include "Physics/Material.h"
#include "Physics/Air.h"
#include "Physics/AluminaAL2O3.h"
#include "Physics/Aluminum.h"
#include "Physics/Beryllium.h"
#include "Physics/BoronCarbide.h"
#include "Physics/Copper.h"
#include "Physics/Gold.h"
#include "Physics/Graphite.h"
#include "Physics/GraphiteR6710.h"
#include "Physics/Kapton.h"
#include "Physics/Molybdenum.h"
#include "Physics/Mylar.h"
#include "Physics/Titanium.h"
#include "Physics/Water.h"
#include "Utilities/GeneralClassicException.h"
#include "Utilities/Util.h"
#include <iostream>
using namespace Physics;
std::map<std::string, std::shared_ptr<Material> > Material::protoTable_sm;
std::shared_ptr<Material> Material::addMaterial(const std::string &name,
std::shared_ptr<Material> mat_ptr) {
std::string nameUp = Util::toUpper(name);
if (protoTable_sm.find(nameUp) != protoTable_sm.end())
return protoTable_sm[nameUp];
protoTable_sm.insert(std::make_pair(nameUp, mat_ptr));
return mat_ptr;
}
std::shared_ptr<Material> Material::getMaterial(const std::string &name) {
std::string nameUp = Util::toUpper(name);
if (protoTable_sm.find(nameUp) != protoTable_sm.end()) return protoTable_sm[nameUp];
throw GeneralClassicException("Material::getMaterial", "Unknown material '" + name + "'");
}
namespace {
auto air = Material::addMaterial("Air",
std::shared_ptr<Material>(new Air()));
auto aluminaal2o3 = Material::addMaterial("AluminaAL2O3",
std::shared_ptr<Material>(new AluminaAL2O3()));
auto aluminum = Material::addMaterial("Aluminum",
std::shared_ptr<Material>(new Aluminum()));
auto beryllium = Material::addMaterial("Beryllium",
std::shared_ptr<Material>(new Beryllium()));
auto berilium = Material::addMaterial("Berilium",
beryllium);
auto boroncarbide = Material::addMaterial("BoronCarbide",
std::shared_ptr<Material>(new BoronCarbide()));
auto copper = Material::addMaterial("Copper",
std::shared_ptr<Material>(new Copper()));
auto gold = Material::addMaterial("Gold",
std::shared_ptr<Material>(new Gold()));
auto graphite = Material::addMaterial("Graphite",
std::shared_ptr<Material>(new Graphite()));
auto graphiter6710 = Material::addMaterial("GraphiteR6710",
std::shared_ptr<Material>(new GraphiteR6710()));
auto kapton = Material::addMaterial("Kapton",
std::shared_ptr<Material>(new Kapton()));
auto molybdenum = Material::addMaterial("Molybdenum",
std::shared_ptr<Material>(new Molybdenum()));
auto mylar = Material::addMaterial("Mylar",
std::shared_ptr<Material>(new Mylar()));
auto titanium = Material::addMaterial("Titanium",
std::shared_ptr<Material>(new Titanium()));
auto titan = Material::addMaterial("Titan",
titanium);
auto water = Material::addMaterial("Water",
std::shared_ptr<Material>(new Water()));
}
\ No newline at end of file
#ifndef MATERIAL_H
#define MATERIAL_H
#include <map>
#include <array>
#include <string>
#include <memory>
#include <cmath>
namespace Physics {
class Material {
public:
enum FitCoeffs {
A2 = 0,
A3,
A4,
A5
};
Material(double atomicNumber,
double atomicMass,
double massDensity,
double radiationLength,
double meanExcitationEnergy,
std::array<double, 4> fitCoefficients):
atomicNumber_m(atomicNumber),
atomicMass_m(atomicMass),
massDensity_m(massDensity),
radiationLength_m(radiationLength / massDensity / 100),
meanExcitationEnergy_m(meanExcitationEnergy),
stoppingPowerFitCoefficients_m(fitCoefficients)
{ }
double getAtomicNumber() const; // [1]
double getAtomicMass() const; // [u]
double getMassDensity() const; // [g cm^-3]
double getRadiationLength() const; // [m]
double getMeanExcitationEnergy() const; // [eV]
double getStoppingPowerFitCoefficients(FitCoeffs n) const;
static std::shared_ptr<Material> getMaterial(const std::string &name);
static std::shared_ptr<Material> addMaterial(const std::string &name,
std::shared_ptr<Material> mat_ptr);
private:
static
std::map<std::string, std::shared_ptr<Material> > protoTable_sm;
const double atomicNumber_m;
const double atomicMass_m;
const double massDensity_m;
const double radiationLength_m;
const double meanExcitationEnergy_m;
const std::array<double,4> stoppingPowerFitCoefficients_m;
};
inline
double Material::getAtomicNumber() const {
return atomicNumber_m;
}
inline
double Material::getAtomicMass() const {
return atomicMass_m;
}
inline
double Material::getMassDensity() const {
return massDensity_m;
}
inline
double Material::getRadiationLength() const {
return radiationLength_m;
}
inline
double Material::getMeanExcitationEnergy() const {
return meanExcitationEnergy_m;
}
inline
double Material::getStoppingPowerFitCoefficients(Material::FitCoeffs n) const {
if (n >= 4) return 0.0;
return stoppingPowerFitCoefficients_m[n];
}
// inline
// double Material::getMeanExcitationEnergy() const {
// double Z = getAtomicNumber();
// if (Z < 13.0)
// return 12 * Z + 7;
// return 9.76 * Z + 58.8 * std::pow(Z, -.19);
// }
}
#endif
\ No newline at end of file
#ifndef MOLYBDENUM_H
#define MOLYBDENUM_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class Molybdenum: public Material {
public:
Molybdenum():
Material(42,
95.94,
10.22,
9.8,
424.0,
{{7.248, 9.545e3, 4.802e2, 5.376e-3}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef MYLAR_H
#define MYLAR_H
#include "Physics/Material.h"
namespace Physics {
class Mylar: public Material {
public:
Mylar():
Material(6.702,
12.88,
1.4,
39.95,
78.7,
{{3.350, 1683, 1900, 2.513e-02}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef TITANIUM_H
#define TITANIUM_H
#include "Physics/Material.h"
#include <cmath>
namespace Physics {
class Titanium: public Material {
public:
Titanium():
Material(22,
47.8,
4.54,
16.16,
233.0,
{{5.489, 5.260e3, 6.511e2, 8.930e-3}})
{ }
};
}
#endif
\ No newline at end of file
#ifndef WATER_H
#define WATER_H
#include "Physics/Material.h"
namespace Physics {
class Water: public Material {
public:
Water():
Material(10,
18,
1,
36.08,
75.0, // source: pstar from NIST
{{2.199, 2.393e3, 2.699e3, 1.568e-2}})
{ }
};
}
#endif
\ No newline at end of file
......@@ -8,6 +8,7 @@
//-------------------------------------------------------------------------
#include "Solvers/CollimatorPhysics.hh"
#include "Physics/Physics.h"
#include "Physics/Material.h"
#include "Algorithms/PartBunchBase.h"
#include "AbsBeamline/CCollimator.h"
#include "AbsBeamline/FlexibleCollimator.h"
......@@ -86,6 +87,7 @@ CollimatorPhysics::CollimatorPhysics(const std::string &name, ElementBase *eleme
ParticleMatterInteractionHandler(name, element),
T_m(0.0),
dT_m(0.0),
material_m(material),
hitTester_m(nullptr),
Z_m(0),
A_m(0.0),
......@@ -118,7 +120,6 @@ CollimatorPhysics::CollimatorPhysics(const std::string &name, ElementBase *eleme
rGen_m = gsl_rng_alloc(gsl_rng_default);
gsl_rng_set(rGen_m, Options::seed);
material_m = Util::toUpper(material);
configureMaterialParameters();
collshape_m = element_ref_m->getType();
......@@ -457,221 +458,16 @@ void CollimatorPhysics::applyNonDKS(PartBunchBase<double, 3> *bunch,
// ------------------------------------------------------------------------
void CollimatorPhysics::configureMaterialParameters() {
if (material_m == "BERYLLIUM" || material_m == "BERILIUM") {
Z_m = 4.0;
A_m = 9.012;
rho_m = 1.848;
X0_m = 65.19 / rho_m / 100;
I_m = 10 * Z_m;
A2_c = 2.590;
A3_c = 9.660e2;
A4_c = 1.538e2;
A5_c = 3.475e-2;
}
else if (material_m == "GRAPHITE") {
Z_m = 6.0;
A_m = 12.0107;
rho_m = 2.210;
X0_m = 42.70 / rho_m / 100;
I_m = 10 * Z_m;
A2_c = 2.601;
A3_c = 1.701e3;
A4_c = 1.279e3;
A5_c = 1.638e-2;
}
else if (material_m == "GRAPHITER6710") {
Z_m = 6.0;
A_m = 12.0107;
rho_m = 1.88;
X0_m = 42.70 / rho_m / 100;
I_m = 10 * Z_m;
A2_c = 2.601;
A3_c = 1.701e3;
A4_c = 1.279e3;
A5_c = 1.638e-2;
}
else if (material_m == "MOLYBDENUM") {
Z_m = 42.0;
A_m = 95.94;
rho_m = 10.22;
X0_m = 9.8 / rho_m / 100;
I_m = 10 * Z_m;
A2_c = 7.248;
A3_c = 9.545e3;
A4_c = 4.802e2;
A5_c = 5.376e-3;
}
/*
needs to be checked !
Z from http://journals.aps.org/prb/pdf/10.1103/PhysRevB.40.8530
*/
else if (material_m == "MYLAR") {
Z_m = 6.702;
A_m = 12.88;
rho_m = 1.4;
X0_m = 39.95 / rho_m / 100;
I_m = 10 * Z_m;
A2_c = 3.350;
A3_c = 1683;
A4_c = 1900;
A5_c = 2.513e-02;
}
//new materials
else if (material_m == "ALUMINUM") {
Z_m = 13;
A_m = 26.98;
rho_m = 2.7;
X0_m = 24.01 / rho_m / 100;
I_m = 10 * Z_m;
A2_c = 4.739;
A3_c = 2.766e3;
A4_c = 1.645e2;
A5_c = 2.023e-2;
}
else if (material_m == "COPPER") {
Z_m = 29;
A_m