Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield Namespace Reference

Namespaces

namespace  Degrade
namespace  Magboltz
namespace  Numerics
 Collection of numerical routines.
namespace  Polygon

Classes

class  AvalancheGrid
 Calculate avalanches in a uniform electric field using avalanche statistics. More...
class  AvalancheGridSpaceCharge
 Propagates avalanches with the 2d (axi-symmetric) space-charge routine from Lippmann, Riegler (2004) in uniform background fields. More...
class  AvalancheMC
 Calculate drift lines and avalanches based on macroscopic transport coefficients, using Monte Carlo integration. More...
class  AvalancheMicroscopic
 Calculate electron drift lines and avalanches using microscopic tracking. More...
class  Component
 Abstract base class for components. More...
class  ComponentAnalyticField
 Semi-analytic calculation of two-dimensional configurations consisting of wires, planes, and tubes. More...
class  ComponentAnsys121
 Component for importing and interpolating two-dimensional ANSYS field maps. More...
class  ComponentAnsys123
 Component for importing and interpolating three-dimensional ANSYS field maps. More...
class  ComponentChargedRing
 Component for calculating the field of a system of charged r,z rings. More...
class  ComponentComsol
 Component for importing and interpolating Comsol field maps. More...
class  ComponentConstant
 Component with constant electric field. More...
class  ComponentCST
 Component for importing and interpolating field maps from CST. More...
class  ComponentElmer
 Component for importing field maps computed by Elmer. More...
class  ComponentElmer2d
 Component for importing two-dimensional field maps computed by Elmer. More...
class  ComponentFieldMap
 Base class for components based on finite-element field maps. More...
class  ComponentGrid
 Component for interpolating field maps on a regular mesh. More...
class  ComponentNeBem2d
 Two-dimensional implementation of the nearly exact Boundary Element Method. More...
class  ComponentNeBem3d
 Interface to neBEM. More...
class  ComponentNeBem3dMap
 Component for interpolating field maps stored in a mesh generated by neBEM. More...
class  ComponentParallelPlate
 Component for parallel-plate geometries. More...
class  ComponentTcad2d
 Interpolation in a two-dimensional field map created by Sentaurus Device. More...
class  ComponentTcad3d
 Interpolation in a three-dimensional field map created by Sentaurus Device. More...
class  ComponentTcadBase
 Interpolation in a field map created by Sentaurus Device. More...
class  ComponentUser
 Simple component with electric field given by a user function. More...
class  ComponentVoxel
 Component for interpolating field maps stored in a regular mesh. More...
class  DriftLineRKF
 Calculation of drift lines based on macroscopic transport coefficients using Runge-Kutta-Fehlberg integration. More...
class  Geometry
 Abstract base class for geometry classes. More...
class  GeometryRoot
 Use a geometry defined using the ROOT TGeo package. More...
class  GeometrySimple
 "Native" geometry, using simple shapes. More...
class  KDTree
 Main k-d tree class. More...
class  KDTreeNode
 A node in the k-d tree. More...
struct  KDTreeResult
 Search result. More...
class  Medium
 Abstract base class for components. More...
class  MediumCdTe
 Cadmium-Telluride. More...
class  MediumConductor
 Conducting medium. More...
class  MediumDiamond
 Diamond. More...
class  MediumGaAs
 Gallium-Arsenide. More...
class  MediumGaN
 Gallium-Nitride. More...
class  MediumGas
 Base class for gas media. More...
class  MediumMagboltz
 Interface to Magboltz (version 11). More...
class  MediumPlastic
 Plastic medium. More...
class  MediumSilicon
 Solid crystalline silicon More...
class  OpticalData
 Photoabsorption cross-sections for some gases. More...
struct  Panel
 Surface panel. More...
class  PlottingEngine
 Plotting style. More...
class  QuadTree
 Quadtree search. More...
class  Random
class  RandomEngine
 Abstract base class for random number generators. More...
class  RandomEngineRoot
class  RandomEngineSTL
class  Sensor
 Sensor. More...
class  Shaper
 Class for signal processing. More...
class  Solid
 Abstract base class for solids. More...
class  SolidBox
 Box. More...
class  SolidExtrusion
 Extrusion. More...
class  SolidHole
 Box with a cylindrical hole. More...
class  SolidRidge
 Triangular prism (Toblerone bar). More...
class  SolidSphere
 Sphere. More...
class  SolidTube
 Cylindrical tube. More...
class  SolidWire
 Wire. More...
class  Track
 Abstract base class for track generation. More...
class  TrackBichsel
 Generate tracks using differential cross-sections for silicon computed by Hans Bichsel. More...
class  TrackDegrade
 Interface to Degrade. More...
class  TrackElectron
 [WIP] Ionization calculation based on MIP program (S. Biagi). More...
class  TrackHeed
 Generate tracks using Heed++. More...
class  TrackPAI
class  TrackSimple
 Generate tracks based on a cluster density given by the user. More...
class  TrackSrim
 Generate tracks based on SRIM energy loss, range and straggling tables. More...
class  TrackTrim
 Generate tracks based on TRIM output files. More...
class  Vec1Impl
class  Vec2Impl
class  Vec3Impl
class  Vector
class  ViewBase
 Base class for visualization classes. More...
class  ViewCell
 Visualize the "cell" defined in an analytic-field component. More...
class  ViewDrift
 Visualize drift lines and tracks. More...
class  ViewFEMesh
 Draw the mesh of a field-map component. More...
class  ViewField
 Visualize the potential or electric field of a component or sensor. More...
class  ViewGeometry
 Visualize a geometry defined using the "native" shapes. More...
class  ViewIsochrons
 Draw equal time contour lines. More...
class  ViewMedium
 Plot transport coefficients as function of electric and magnetic field. More...
class  ViewSignal
 Plot the signal computed by a sensor as a ROOT histogram. More...

Typedefs

typedef std::vector< std::vector< double > > KDTreeArray
using Vec3 = Vec3Impl<double>
using Vec3D = Vec3Impl<double>
using Vec3F = Vec3Impl<float>
using ViewMesh = ViewFEMesh

Enumerations

enum class  Particle {
  Electron = 0 , Ion , Hole , Positron ,
  NegativeIon , Photon
}
enum class  MPRunMode { Normal = 0 , GPUExclusive }

Functions

double RndmUniform ()
 Draw a random number uniformly distributed in the range [0, 1).
double RndmUniformPos ()
 Draw a random number uniformly distributed in the range (0, 1).
std::pair< double, double > RndmGaussians ()
 Draw two Gaussian random variates with mean zero and standard deviation one.
double RndmGaussian ()
 Draw a Gaussian random variate with mean zero and standard deviation one.
std::pair< double, double > RndmGaussians (const double mu, const double sigma)
 Draw two Gaussian random variates with mean mu and standard deviation sigma.
double RndmGaussian (const double mu, const double sigma)
 Draw a Gaussian random variate with mean mu and standard deviation sigma.
double RndmLorentzian (const double mu, const double gamma)
 Draw a Lorentzian random variate with mean mu and half-width at half maximum gamma.
double RndmVoigt (const double mu, const double sigma, const double gamma)
 Draw a random number according to a Voigt function with mean mu.
unsigned int RndmYuleFurry (const double mean)
 Draw a random number from a geometric distribution.
double RndmPolya (const double theta)
 Draw a Polya distributed random number.
double RndmLandau ()
 Draw a random number from a Landau distribution.
double RndmVavilov (const double rkappa, const double beta2)
 Draw a random number from a Vavilov distribution.
int RndmPoisson (const double mean)
 Draw a random number from a Poisson distribution.
double RndmHeedWF (const double w, const double f)
 Draw a random energy needed to create a single electron in a material asymptotic work function W and Fano factor F, according to Igor Smirnov's phenomenological model.
void RndmDirection (double &dx, double &dy, double &dz, const double length=1.)
 Draw a random (isotropic) direction vector.
class GARFIELD_CLASS_NAME (TetrahedralTree)
 Helper class for searches in field maps.
void ltrim (std::string &line)
void rtrim (std::string &line)
std::vector< std::string > tokenize (const std::string &line)
bool startsWith (const std::string &line, const std::string &s)

Variables

ComponentNeBem3dgComponentNeBem3d

Typedef Documentation

◆ KDTreeArray

typedef std::vector<std::vector<double> > Garfield::KDTreeArray

Definition at line 19 of file KDTree.hh.

◆ Vec3

using Garfield::Vec3 = Vec3Impl<double>

Definition at line 27 of file TetrahedralTree.hh.

◆ Vec3D

using Garfield::Vec3D = Vec3Impl<double>

Definition at line 98 of file Vector.hh.

◆ Vec3F

using Garfield::Vec3F = Vec3Impl<float>

Definition at line 99 of file Vector.hh.

◆ ViewMesh

Definition at line 163 of file ViewFEMesh.hh.

Enumeration Type Documentation

◆ MPRunMode

enum class Garfield::MPRunMode
strong
Enumerator
Normal 
GPUExclusive 

Definition at line 7 of file MultiProcessInterface.hh.

◆ Particle

enum class Garfield::Particle
strong
Enumerator
Electron 
Ion 
Hole 
Positron 
NegativeIon 
Photon 

Definition at line 7 of file GarfieldConstants.hh.

Function Documentation

◆ GARFIELD_CLASS_NAME()

class Garfield::GARFIELD_CLASS_NAME ( TetrahedralTree )

Helper class for searches in field maps.

This class stores the mesh nodes and elements in an Octree data structure to optimize the element search operations

Author: Ali Sheharyar

Organization: Texas A&M University at Qatar

Destructor

Insert a mesh element with given bounding box and index to the tree.

Create and initialise GPU Transfer class

Definition at line 1 of file TetrahedralTree.hh.

42 {
43 public:
44#ifdef __GPUCOMPILE__
45 // Constructor
46 GARFIELD_CLASS_NAME(TetrahedralTree)() = default;
47
48 // Destructor
49 ~GARFIELD_CLASS_NAME(TetrahedralTree)() = default;
50#else
51 // Constructor
52 GARFIELD_CLASS_NAME(TetrahedralTree)(const Vec3& origin,
53 const Vec3& halfDimension);
54
56 ~GARFIELD_CLASS_NAME(TetrahedralTree)();
57#endif
58
59#ifndef __GPUCOMPILE__
60 // Insert a mesh node (a vertex/point) to the tree
61 void InsertMeshNode(Vec3 point, const int index);
62
64 void InsertMeshElement(const double bb[6], const int index);
65
67 double CreateGPUTransferObject(TetrahedralTreeGPU*& tree_gpu);
68#endif
69
70 private:
71 static std::vector<int> emptyBlock;
72
73 // Physical centre of this tree node.
74 Vec3 m_origin;
75 // Half the width/height/depth of this tree node.
76 Vec3 m_halfDimension;
77 // Storing min and max points for convenience
78 Vec3 m_min, m_max;
79
80 // The tree has up to eight children and can additionally store
81 // a list of mesh nodes and mesh elements.
82 // Pointers to child octants.
83 GARFIELD_CLASS_NAME(TetrahedralTree) * children[8];
84
85 // Children follow a predictable pattern to make accesses simple.
86 // Here, - means less than 'origin' in that dimension, + means greater than.
87 // child: 0 1 2 3 4 5 6 7
88 // x: - - - - + + + +
89 // y: - - + + - - + +
90 // z: - + - + - + - +
91
92#ifndef __GPUCOMPILE__
93 std::vector<std::pair<Vec3, int> > nodes;
94#endif
95
96#ifdef __GPUCOMPILE__
97 int* elements{nullptr};
98 int numelements{0};
99#else
100 std::vector<int> elements;
101#endif
102
103 static const size_t BlockCapacity = 10;
104
105#ifndef __GPUCOMPILE__
106 // Check if the given box overlaps with this tree node.
107 bool DoesBoxOverlap(const double bb[6]) const;
108#endif
109 // Check if this tree node is a leaf or intermediate node.
110 __DEVICE__ bool IsLeafNode() const;
111
112 public:
113// Get all tetrahedra linked to a block corresponding to the given point
114#ifdef __GPUCOMPILE__
115 __device__ void GetElementsInBlock(const Vec3& point,
116 const int*& tet_list_elems,
117 int& num_elems) const;
118#else
119 const std::vector<int>& GetElementsInBlock(const Vec3& point) const;
120#endif
121
122 private:
123 __DEVICE__ int GetOctantContainingPoint(const Vec3& point) const;
124 // Get a block containing the input point
125 __DEVICE__ const GARFIELD_CLASS_NAME(TetrahedralTree) *
126 GetBlockFromPoint(const Vec3& point) const;
127 // A helper function used by the function above.
128 // Called recursively on the child nodes.
129 __DEVICE__ const GARFIELD_CLASS_NAME(TetrahedralTree) *
130 GetBlockFromPointHelper(const Vec3& point) const;
131
132#ifdef __GPUCOMPILE__
133 friend class TetrahedralTree;
134#endif
135};
#define GARFIELD_CLASS_NAME(name)
#define __DEVICE__
#define __device__
Definition Vector.hh:12
class GARFIELD_CLASS_NAME(TetrahedralTree)
Helper class for searches in field maps.
Vec3Impl< double > Vec3

◆ ltrim()

void Garfield::ltrim ( std::string & line)
inline

Definition at line 11 of file Utilities.hh.

11 {
12 line.erase(line.begin(), std::find_if(line.begin(), line.end(), [](int ch) {
13 return !std::isspace(ch);
14 }));
15}

◆ RndmDirection()

void Garfield::RndmDirection ( double & dx,
double & dy,
double & dz,
const double length = 1. )
inline

Draw a random (isotropic) direction vector.

Definition at line 146 of file Random.hh.

147 {
148 const double phi = TwoPi * RndmUniform();
149 const double ctheta = 2 * RndmUniform() - 1.;
150 const double stheta = sqrt(1. - ctheta * ctheta);
151 dx = length * cos(phi) * stheta;
152 dy = length * sin(phi) * stheta;
153 dz = length * ctheta;
154}
double RndmUniform()
Draw a random number uniformly distributed in the range [0, 1).
Definition Random.hh:26

◆ RndmGaussian() [1/2]

double Garfield::RndmGaussian ( )
inline

Draw a Gaussian random variate with mean zero and standard deviation one.

Definition at line 51 of file Random.hh.

51 {
52 const auto r = RndmGaussians();
53 return r.first;
54}
std::pair< double, double > RndmGaussians()
Draw two Gaussian random variates with mean zero and standard deviation one.
Definition Random.hh:36

◆ RndmGaussian() [2/2]

double Garfield::RndmGaussian ( const double mu,
const double sigma )
inline

Draw a Gaussian random variate with mean mu and standard deviation sigma.

Definition at line 66 of file Random.hh.

66 {
67 return mu + sigma * RndmGaussian();
68}
double RndmGaussian()
Draw a Gaussian random variate with mean zero and standard deviation one.
Definition Random.hh:51

◆ RndmGaussians() [1/2]

std::pair< double, double > Garfield::RndmGaussians ( )
inline

Draw two Gaussian random variates with mean zero and standard deviation one.

Definition at line 36 of file Random.hh.

36 {
37 // Box-Muller algorithm
38 double u = 2. * RndmUniform() - 1.;
39 double v = 2. * RndmUniform() - 1.;
40 double r2 = u * u + v * v;
41 while (r2 > 1.) {
42 u = 2. * RndmUniform() - 1.;
43 v = 2. * RndmUniform() - 1.;
44 r2 = u * u + v * v;
45 }
46 const double p = sqrt(-2. * log(r2) / r2);
47 return std::make_pair(u * p, v * p);
48}

◆ RndmGaussians() [2/2]

std::pair< double, double > Garfield::RndmGaussians ( const double mu,
const double sigma )
inline

Draw two Gaussian random variates with mean mu and standard deviation sigma.

Definition at line 57 of file Random.hh.

58 {
59 auto r = RndmGaussians();
60 r.first = mu + sigma * r.first;
61 r.second = mu + sigma * r.second;
62 return r;
63}

◆ RndmHeedWF()

double Garfield::RndmHeedWF ( const double w,
const double f )

Draw a random energy needed to create a single electron in a material asymptotic work function W and Fano factor F, according to Igor Smirnov's phenomenological model.

◆ RndmLandau()

double Garfield::RndmLandau ( )

Draw a random number from a Landau distribution.

◆ RndmLorentzian()

double Garfield::RndmLorentzian ( const double mu,
const double gamma )
inline

Draw a Lorentzian random variate with mean mu and half-width at half maximum gamma.

Definition at line 72 of file Random.hh.

72 {
73 return mu + gamma * tan(Pi * (RndmUniform() - 0.5));
74}

◆ RndmPoisson()

int Garfield::RndmPoisson ( const double mean)

Draw a random number from a Poisson distribution.

◆ RndmPolya()

double Garfield::RndmPolya ( const double theta)
inline

Draw a Polya distributed random number.

Definition at line 109 of file Random.hh.

109 {
110 // Algorithm from Review of Particle Physics
111 // C. Amsler et al, Phys. Lett. B 667 (2008)
112 if (theta <= 0.) return -log(RndmUniformPos());
113 const double c = 3 * (theta + 1.) - 0.75;
114 double u1, u2, v1, v2, v3;
115 double x;
116 while (1) {
117 u1 = RndmUniformPos();
118 v1 = u1 * (1. - u1);
119 if (v1 == 0.) continue;
120 v2 = (u1 - 0.5) * sqrt(c / v1);
121 x = theta + v2;
122 if (x <= 0.) continue;
123 u2 = RndmUniformPos();
124 v3 = 64 * u2 * u2 * pow(v1, 3);
125 if (v3 <= 1. - 2 * v2 * v2 / x ||
126 log(v3) <= 2 * (theta * log(x / theta) - v2)) {
127 return x / (theta + 1.);
128 }
129 }
130}
double RndmUniformPos()
Draw a random number uniformly distributed in the range (0, 1).
Definition Random.hh:29

◆ RndmUniform()

double Garfield::RndmUniform ( )
inline

Draw a random number uniformly distributed in the range [0, 1).

Definition at line 26 of file Random.hh.

26{ return Random::Draw(); }
static double Draw() noexcept
Definition Random.hh:19

◆ RndmUniformPos()

double Garfield::RndmUniformPos ( )
inline

Draw a random number uniformly distributed in the range (0, 1).

Definition at line 29 of file Random.hh.

29 {
30 double r = RndmUniform();
31 while (r <= 0.) r = RndmUniform();
32 return r;
33}

◆ RndmVavilov()

double Garfield::RndmVavilov ( const double rkappa,
const double beta2 )

Draw a random number from a Vavilov distribution.

◆ RndmVoigt()

double Garfield::RndmVoigt ( const double mu,
const double sigma,
const double gamma )
inline

Draw a random number according to a Voigt function with mean mu.

The Voigt function is a convolution of a Gaussian (standard deviation sigma) and a Lorentzian (half width gamma).

Definition at line 80 of file Random.hh.

81 {
82 if (sigma <= 0.) return RndmLorentzian(mu, gamma);
83 const double a = gamma / (Sqrt2 * sigma);
84 const double x = RndmLorentzian(0., a) + RndmGaussian(0., 1. / Sqrt2);
85 return mu + x * Sqrt2 * sigma;
86}
double RndmLorentzian(const double mu, const double gamma)
Draw a Lorentzian random variate with mean mu and half-width at half maximum gamma.
Definition Random.hh:72

◆ RndmYuleFurry()

unsigned int Garfield::RndmYuleFurry ( const double mean)
inline

Draw a random number from a geometric distribution.

Definition at line 89 of file Random.hh.

89 {
90 if (mean <= 0.) return 0;
91 return 1 + static_cast<unsigned int>(std::log(RndmUniformPos()) /
92 std::log1p(-1. / mean));
93 /*
94 const double u = RndmUniform();
95 double p = 1. / mean;
96 const double q = 1. - p;
97 double sum = p;
98 unsigned int k = 1;
99 while (sum < u) {
100 ++k;
101 p *= q;
102 sum += p;
103 }
104 return k;
105 */
106}

◆ rtrim()

void Garfield::rtrim ( std::string & line)
inline

Definition at line 17 of file Utilities.hh.

17 {
18 line.erase(std::find_if(line.rbegin(), line.rend(),
19 [](int ch) { return !std::isspace(ch); })
20 .base(),
21 line.end());
22}

◆ startsWith()

bool Garfield::startsWith ( const std::string & line,
const std::string & s )
inline

Definition at line 33 of file Utilities.hh.

33 {
34 return (line.rfind(s, 0) == 0);
35}

◆ tokenize()

std::vector< std::string > Garfield::tokenize ( const std::string & line)
inline

Definition at line 24 of file Utilities.hh.

24 {
25 std::vector<std::string> words;
26 std::istringstream ss(line);
27 for (std::string word; ss >> word;) {
28 words.push_back(word);
29 }
30 return words;
31}

Variable Documentation

◆ gComponentNeBem3d

ComponentNeBem3d* Garfield::gComponentNeBem3d
extern