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

Two-dimensional implementation of the nearly exact Boundary Element Method. More...

#include <ComponentNeBem2d.hh>

Inheritance diagram for Garfield::ComponentNeBem2d:

Classes

struct  Element
struct  Region
struct  Segment
struct  SpaceCharge
struct  Wire

Public Member Functions

 ComponentNeBem2d ()
 Constructor.
 ~ComponentNeBem2d ()
 Destructor.
void SetMedium (Medium *medium)
 Set the "background" medium.
bool AddSegment (const double x0, const double y0, const double x1, const double y1, const double v, const int ndiv=-1)
 Add a conducting straight-line segment.
bool AddWire (const double x, const double y, const double d, const double v, const int ntrap=5)
 Add a wire.
bool AddRegion (const std::vector< double > &xp, const std::vector< double > &yp, Medium *medium, const unsigned int bctype=4, const double v=0., const int ndiv=-1)
 Add a region bounded by a polygon.
void AddChargeDistribution (const double x, const double y, const double a, const double b, const double rho)
void SetRangeZ (const double zmin, const double zmax)
 Set the extent of the drift region along z.
bool Initialise ()
 Discretise the geometry and compute the solution.
void SetNumberOfDivisions (const unsigned int ndiv)
 Set the default number of elements per segment.
void SetNumberOfCollocationPoints (const unsigned int ncoll)
void EnableAutoResizing (const bool on=true)
void EnableRandomCollocation (const bool on=true)
void SetMaxNumberOfIterations (const unsigned int niter)
unsigned int GetNumberOfRegions () const
 Return the number of regions.
bool GetRegion (const unsigned int i, std::vector< double > &xv, std::vector< double > &yv, Medium *&medium, unsigned int &bctype, double &v)
 Return the properties of a given region.
unsigned int GetNumberOfSegments () const
 Return the number of conducting straight-line segments.
bool GetSegment (const unsigned int i, double &x0, double &y0, double &x1, double &x2, double &v) const
 Return the coordinates and voltage of a given straight-line segment.
unsigned int GetNumberOfWires () const
 Return the number of wires.
bool GetWire (const unsigned int i, double &x, double &y, double &d, double &v, double &q) const
 Return the coordinates, diameter, potential and charge of a given wire.
size_t GetNumberOfElements () const override
 Return the number of boundary elements.
bool GetElement (const unsigned int i, double &x0, double &y0, double &x1, double &y1, double &q) const
 Return the coordinates and charge of a given boundary element.
Medium * GetMedium (const double x, const double y, const double z) override
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
bool GetVoltageRange (double &vmin, double &vmax) override
bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
bool GetElementaryCell (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
bool CrossedWire (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc, const bool centre, double &rc) override
bool InTrapRadius (const double q0, const double x0, const double y0, const double z0, double &xw, double &yx, double &rw) override

Private Types

enum  BC { Voltage = 1 , Charge , Floating , Dielectric }
 Boundary condition type. More...

Private Member Functions

void EliminateOverlaps (std::vector< Segment > &segments)
 Split/merge overlapping segments.
bool Discretise (const Segment &segment, std::vector< Element > &elements, const double lambda, const unsigned int ndiv)
 Create elements from a straight-line segment.
bool ComputeInfluenceMatrix (std::vector< std::vector< double > > &infmat) const
bool InvertMatrix (std::vector< std::vector< double > > &influenceMatrix, std::vector< std::vector< double > > &inverseMatrix) const
bool LUDecomposition (std::vector< std::vector< double > > &mat, std::vector< int > &index) const
void LUSubstitution (const std::vector< std::vector< double > > &mat, const std::vector< int > &index, std::vector< double > &col) const
bool Solve (const std::vector< std::vector< double > > &inverseMatrix, const std::vector< double > &bc)
bool CheckConvergence (const double tol, std::vector< bool > &ok)
void SplitElement (Element &oldElement, std::vector< Element > &elements)
double LinePotential (const double a, const double x, const double y) const
 Potential of a line segment (half-width a) in local coordinates.
double WirePotential (const double r0, const double x, const double y) const
 Potential of a thin wire with radius r0.
void LineField (const double a, const double x, const double y, double &ex, double &ey) const
 Field of a line segment (half-width a) in local coordinates.
void WireField (const double r0, const double x, const double y, double &ex, double &ey) const
 Field of a thin wire with radius r0.
double BoxPotential (const double a, const double b, const double x, const double y, const double v0) const
 Potential of a uniformly charged rectangle.
void BoxField (const double a, const double b, const double x, const double y, double &ex, double &ey) const
 Field of a uniformly charged rectangle.
void Reset () override
void UpdatePeriodicity () override
void ToLocal (const double xIn, const double yIn, const double cphi, const double sphi, double &xOut, double &yOut) const
 Rotation from global to local coordinates.
void ToGlobal (const double xIn, const double yIn, const double cphi, const double sphi, double &xOut, double &yOut) const
 Rotation from local to global coordinates.
int Field (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, const bool opt)
 Evaluation of the electric field (and optionally potential).

Private Attributes

unsigned int m_nDivisions = 5
 Default number elements per segment.
unsigned int m_nCollocationPoints = 1
bool m_autoSize = false
bool m_randomCollocation = false
unsigned int m_nMaxIterations = 3
Medium * m_medium = nullptr
 Background medium.
bool m_useRangeZ = false
 Flag whether a z-range has been defined by the user.
double m_zmin = -1.
 Lower z limit.
double m_zmax = 1.
 Upper z limit.
std::vector< Regionm_regions
 Regions.
std::vector< Segmentm_segments
 User-specified conducting straight-line segments.
std::vector< Wirem_wires
 Wires.
std::vector< Elementm_elements
 Straight-line boundary elements.
std::vector< SpaceChargem_spaceCharge

Static Private Attributes

static const double InvEpsilon0
static const double InvTwoPiEpsilon0

Detailed Description

Two-dimensional implementation of the nearly exact Boundary Element Method.

Definition at line 12 of file ComponentNeBem2d.hh.

Member Enumeration Documentation

◆ BC

Boundary condition type.

Enumerator
Voltage 

Fixed potential.

Charge 

Fixed charge density (not implemented).

Floating 

Floating conductor (not implemented).

Dielectric 

Dielectric-dielectric interface.

Definition at line 131 of file ComponentNeBem2d.hh.

131 {
132 Voltage = 1,
133 Charge,
134 Floating,
136 };
@ Floating
Floating conductor (not implemented).
@ Charge
Fixed charge density (not implemented).
@ Dielectric
Dielectric-dielectric interface.

Constructor & Destructor Documentation

◆ ComponentNeBem2d()

Garfield::ComponentNeBem2d::ComponentNeBem2d ( )

Constructor.

◆ ~ComponentNeBem2d()

Garfield::ComponentNeBem2d::~ComponentNeBem2d ( )
inline

Destructor.

Definition at line 17 of file ComponentNeBem2d.hh.

17{}

Member Function Documentation

◆ AddChargeDistribution()

void Garfield::ComponentNeBem2d::AddChargeDistribution ( const double x,
const double y,
const double a,
const double b,
const double rho )

◆ AddRegion()

bool Garfield::ComponentNeBem2d::AddRegion ( const std::vector< double > & xp,
const std::vector< double > & yp,
Medium * medium,
const unsigned int bctype = 4,
const double v = 0.,
const int ndiv = -1 )

Add a region bounded by a polygon.

Parameters
xp,ypx/y-coordinates of the vertices of the polygon.
mediumpointer to the medium associated to the region.
bctype1: fixed voltage, 4: dielectric-dielectric interface.
vapplied potential.
ndivnumber of elements on each edge segment.

◆ AddSegment()

bool Garfield::ComponentNeBem2d::AddSegment ( const double x0,
const double y0,
const double x1,
const double y1,
const double v,
const int ndiv = -1 )

Add a conducting straight-line segment.

Parameters
x0,y0,x1,y1coordinates of start and end point.
vapplied potential.
ndivnumber of elements in which to split the segment.

◆ AddWire()

bool Garfield::ComponentNeBem2d::AddWire ( const double x,
const double y,
const double d,
const double v,
const int ntrap = 5 )

Add a wire.

Parameters
x,ycentre of the wire.
dwire diameter.
vapplied potential.
ntrapmultiple of the wire radius within which a particle is considered to be trapped by the wire.

◆ BoxField()

void Garfield::ComponentNeBem2d::BoxField ( const double a,
const double b,
const double x,
const double y,
double & ex,
double & ey ) const
private

Field of a uniformly charged rectangle.

◆ BoxPotential()

double Garfield::ComponentNeBem2d::BoxPotential ( const double a,
const double b,
const double x,
const double y,
const double v0 ) const
private

Potential of a uniformly charged rectangle.

◆ CheckConvergence()

bool Garfield::ComponentNeBem2d::CheckConvergence ( const double tol,
std::vector< bool > & ok )
private

◆ ComputeInfluenceMatrix()

bool Garfield::ComponentNeBem2d::ComputeInfluenceMatrix ( std::vector< std::vector< double > > & infmat) const
private

◆ CrossedWire()

bool Garfield::ComponentNeBem2d::CrossedWire ( const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
double & xc,
double & yc,
double & zc,
const bool centre,
double & rc )
override

◆ Discretise()

bool Garfield::ComponentNeBem2d::Discretise ( const Segment & segment,
std::vector< Element > & elements,
const double lambda,
const unsigned int ndiv )
private

Create elements from a straight-line segment.

◆ ElectricField() [1/2]

void Garfield::ComponentNeBem2d::ElectricField ( const double x,
const double y,
const double z,
double & ex,
double & ey,
double & ez,
double & v,
Medium *& m,
int & status )
override

◆ ElectricField() [2/2]

void Garfield::ComponentNeBem2d::ElectricField ( const double x,
const double y,
const double z,
double & ex,
double & ey,
double & ez,
Medium *& m,
int & status )
override

◆ EliminateOverlaps()

void Garfield::ComponentNeBem2d::EliminateOverlaps ( std::vector< Segment > & segments)
private

Split/merge overlapping segments.

◆ EnableAutoResizing()

void Garfield::ComponentNeBem2d::EnableAutoResizing ( const bool on = true)
inline

Definition at line 60 of file ComponentNeBem2d.hh.

◆ EnableRandomCollocation()

void Garfield::ComponentNeBem2d::EnableRandomCollocation ( const bool on = true)
inline

Definition at line 61 of file ComponentNeBem2d.hh.

◆ Field()

int Garfield::ComponentNeBem2d::Field ( const double x,
const double y,
const double z,
double & ex,
double & ey,
double & ez,
double & v,
Medium *& m,
const bool opt )
private

Evaluation of the electric field (and optionally potential).

◆ GetBoundingBox()

bool Garfield::ComponentNeBem2d::GetBoundingBox ( double & xmin,
double & ymin,
double & zmin,
double & xmax,
double & ymax,
double & zmax )
override

◆ GetElement()

bool Garfield::ComponentNeBem2d::GetElement ( const unsigned int i,
double & x0,
double & y0,
double & x1,
double & y1,
double & q ) const

Return the coordinates and charge of a given boundary element.

◆ GetElementaryCell()

bool Garfield::ComponentNeBem2d::GetElementaryCell ( double & xmin,
double & ymin,
double & zmin,
double & xmax,
double & ymax,
double & zmax )
override

◆ GetMedium()

Medium * Garfield::ComponentNeBem2d::GetMedium ( const double x,
const double y,
const double z )
override

◆ GetNumberOfElements()

size_t Garfield::ComponentNeBem2d::GetNumberOfElements ( ) const
inlineoverride

Return the number of boundary elements.

Definition at line 83 of file ComponentNeBem2d.hh.

83{ return m_elements.size(); }
std::vector< Element > m_elements
Straight-line boundary elements.

◆ GetNumberOfRegions()

unsigned int Garfield::ComponentNeBem2d::GetNumberOfRegions ( ) const
inline

Return the number of regions.

Definition at line 67 of file ComponentNeBem2d.hh.

67{ return m_regions.size(); }
std::vector< Region > m_regions
Regions.

◆ GetNumberOfSegments()

unsigned int Garfield::ComponentNeBem2d::GetNumberOfSegments ( ) const
inline

Return the number of conducting straight-line segments.

Definition at line 73 of file ComponentNeBem2d.hh.

73{ return m_segments.size(); }
std::vector< Segment > m_segments
User-specified conducting straight-line segments.

◆ GetNumberOfWires()

unsigned int Garfield::ComponentNeBem2d::GetNumberOfWires ( ) const
inline

Return the number of wires.

Definition at line 78 of file ComponentNeBem2d.hh.

78{ return m_wires.size(); }
std::vector< Wire > m_wires
Wires.

◆ GetRegion()

bool Garfield::ComponentNeBem2d::GetRegion ( const unsigned int i,
std::vector< double > & xv,
std::vector< double > & yv,
Medium *& medium,
unsigned int & bctype,
double & v )

Return the properties of a given region.

◆ GetSegment()

bool Garfield::ComponentNeBem2d::GetSegment ( const unsigned int i,
double & x0,
double & y0,
double & x1,
double & x2,
double & v ) const

Return the coordinates and voltage of a given straight-line segment.

◆ GetVoltageRange()

bool Garfield::ComponentNeBem2d::GetVoltageRange ( double & vmin,
double & vmax )
override

◆ GetWire()

bool Garfield::ComponentNeBem2d::GetWire ( const unsigned int i,
double & x,
double & y,
double & d,
double & v,
double & q ) const

Return the coordinates, diameter, potential and charge of a given wire.

◆ Initialise()

bool Garfield::ComponentNeBem2d::Initialise ( )

Discretise the geometry and compute the solution.

◆ InTrapRadius()

bool Garfield::ComponentNeBem2d::InTrapRadius ( const double q0,
const double x0,
const double y0,
const double z0,
double & xw,
double & yx,
double & rw )
override

◆ InvertMatrix()

bool Garfield::ComponentNeBem2d::InvertMatrix ( std::vector< std::vector< double > > & influenceMatrix,
std::vector< std::vector< double > > & inverseMatrix ) const
private

◆ LineField()

void Garfield::ComponentNeBem2d::LineField ( const double a,
const double x,
const double y,
double & ex,
double & ey ) const
private

Field of a line segment (half-width a) in local coordinates.

◆ LinePotential()

double Garfield::ComponentNeBem2d::LinePotential ( const double a,
const double x,
const double y ) const
private

Potential of a line segment (half-width a) in local coordinates.

◆ LUDecomposition()

bool Garfield::ComponentNeBem2d::LUDecomposition ( std::vector< std::vector< double > > & mat,
std::vector< int > & index ) const
private

◆ LUSubstitution()

void Garfield::ComponentNeBem2d::LUSubstitution ( const std::vector< std::vector< double > > & mat,
const std::vector< int > & index,
std::vector< double > & col ) const
private

◆ Reset()

void Garfield::ComponentNeBem2d::Reset ( )
overrideprivate

◆ SetMaxNumberOfIterations()

void Garfield::ComponentNeBem2d::SetMaxNumberOfIterations ( const unsigned int niter)

◆ SetMedium()

void Garfield::ComponentNeBem2d::SetMedium ( Medium * medium)
inline

Set the "background" medium.

Definition at line 20 of file ComponentNeBem2d.hh.

20{ m_medium = medium; }
Medium * m_medium
Background medium.

◆ SetNumberOfCollocationPoints()

void Garfield::ComponentNeBem2d::SetNumberOfCollocationPoints ( const unsigned int ncoll)

◆ SetNumberOfDivisions()

void Garfield::ComponentNeBem2d::SetNumberOfDivisions ( const unsigned int ndiv)

Set the default number of elements per segment.

◆ SetRangeZ()

void Garfield::ComponentNeBem2d::SetRangeZ ( const double zmin,
const double zmax )

Set the extent of the drift region along z.

◆ Solve()

bool Garfield::ComponentNeBem2d::Solve ( const std::vector< std::vector< double > > & inverseMatrix,
const std::vector< double > & bc )
private

◆ SplitElement()

void Garfield::ComponentNeBem2d::SplitElement ( Element & oldElement,
std::vector< Element > & elements )
private

◆ ToGlobal()

void Garfield::ComponentNeBem2d::ToGlobal ( const double xIn,
const double yIn,
const double cphi,
const double sphi,
double & xOut,
double & yOut ) const
private

Rotation from local to global coordinates.

◆ ToLocal()

void Garfield::ComponentNeBem2d::ToLocal ( const double xIn,
const double yIn,
const double cphi,
const double sphi,
double & xOut,
double & yOut ) const
private

Rotation from global to local coordinates.

◆ UpdatePeriodicity()

void Garfield::ComponentNeBem2d::UpdatePeriodicity ( )
overrideprivate

◆ WireField()

void Garfield::ComponentNeBem2d::WireField ( const double r0,
const double x,
const double y,
double & ex,
double & ey ) const
private

Field of a thin wire with radius r0.

◆ WirePotential()

double Garfield::ComponentNeBem2d::WirePotential ( const double r0,
const double x,
const double y ) const
private

Potential of a thin wire with radius r0.

Member Data Documentation

◆ InvEpsilon0

const double Garfield::ComponentNeBem2d::InvEpsilon0
staticprivate

Definition at line 112 of file ComponentNeBem2d.hh.

◆ InvTwoPiEpsilon0

const double Garfield::ComponentNeBem2d::InvTwoPiEpsilon0
staticprivate

Definition at line 113 of file ComponentNeBem2d.hh.

◆ m_autoSize

bool Garfield::ComponentNeBem2d::m_autoSize = false
private

Definition at line 118 of file ComponentNeBem2d.hh.

◆ m_elements

std::vector<Element> Garfield::ComponentNeBem2d::m_elements
private

Straight-line boundary elements.

Definition at line 179 of file ComponentNeBem2d.hh.

◆ m_medium

Medium* Garfield::ComponentNeBem2d::m_medium = nullptr
private

Background medium.

Definition at line 123 of file ComponentNeBem2d.hh.

◆ m_nCollocationPoints

unsigned int Garfield::ComponentNeBem2d::m_nCollocationPoints = 1
private

Definition at line 117 of file ComponentNeBem2d.hh.

◆ m_nDivisions

unsigned int Garfield::ComponentNeBem2d::m_nDivisions = 5
private

Default number elements per segment.

Definition at line 116 of file ComponentNeBem2d.hh.

◆ m_nMaxIterations

unsigned int Garfield::ComponentNeBem2d::m_nMaxIterations = 3
private

Definition at line 120 of file ComponentNeBem2d.hh.

◆ m_randomCollocation

bool Garfield::ComponentNeBem2d::m_randomCollocation = false
private

Definition at line 119 of file ComponentNeBem2d.hh.

◆ m_regions

std::vector<Region> Garfield::ComponentNeBem2d::m_regions
private

Regions.

Definition at line 146 of file ComponentNeBem2d.hh.

◆ m_segments

std::vector<Segment> Garfield::ComponentNeBem2d::m_segments
private

User-specified conducting straight-line segments.

Definition at line 157 of file ComponentNeBem2d.hh.

◆ m_spaceCharge

std::vector<SpaceCharge> Garfield::ComponentNeBem2d::m_spaceCharge
private

Definition at line 187 of file ComponentNeBem2d.hh.

◆ m_useRangeZ

bool Garfield::ComponentNeBem2d::m_useRangeZ = false
private

Flag whether a z-range has been defined by the user.

Definition at line 125 of file ComponentNeBem2d.hh.

◆ m_wires

std::vector<Wire> Garfield::ComponentNeBem2d::m_wires
private

Wires.

Definition at line 167 of file ComponentNeBem2d.hh.

◆ m_zmax

double Garfield::ComponentNeBem2d::m_zmax = 1.
private

Upper z limit.

Definition at line 129 of file ComponentNeBem2d.hh.

◆ m_zmin

double Garfield::ComponentNeBem2d::m_zmin = -1.
private

Lower z limit.

Definition at line 127 of file ComponentNeBem2d.hh.


The documentation for this class was generated from the following file: