Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LangmuirCore::Grid Class Reference

A class to hold Agents, calculate their positions, and store the background potential. More...

#include <cubicgrid.h>

Public Types

enum  CubeFace {
  Left = 0, Right = 1, Top = 2, Bottom = 3,
  Front = 4, Back = 5, NoFace = 6
}
 A way to indicate the faces of a cube. More...
 

Public Member Functions

 Grid (World &world, QObject *parent=0)
 Create a grid. More...
 
 ~Grid ()
 Destroy the grid. More...
 
int xSize ()
 Get the number of sites along the x-direction. More...
 
int ySize ()
 Get the number of sites along the y-direction. More...
 
int zSize ()
 Get the number of sites along the z-direction. More...
 
int xyPlaneArea ()
 Get the number of sites in the xy-plane. More...
 
int volume ()
 Get the total number of sites. More...
 
double totalDistance (int site1, int site2)
 Get the distance between two sites. More...
 
double xDistance (int site1, int site2)
 Get the distance along the x-direction between two sites. More...
 
double yDistance (int site1, int site2)
 Get the distance along the y-direction between two sites. More...
 
double zDistance (int site1, int site2)
 Get the distance along the z-direction between two sites. More...
 
double xImageDistance (int site1, int site2)
 Get the image distance along the x-direction between two sites. More...
 
double yImageDistance (int site1, int site2)
 Get the image distance along the y-direction between two sites. More...
 
double zImageDistance (int site1, int site2)
 Get the image distance along the z-direction between two sites. More...
 
int xDistancei (int site1, int site2)
 Get the integer distance along the x-direction between two sites. More...
 
int yDistancei (int site1, int site2)
 Get the integer distance along the y-direction between two sites. More...
 
int zDistancei (int site1, int site2)
 Get the integer distance along the z-direction between two sites. More...
 
int xImageDistancei (int site1, int site2)
 Get the integer image distance along the x-direction between two sites. More...
 
int yImageDistancei (int site1, int site2)
 Get the integer image distance along the y-direction between two sites. More...
 
int zImageDistancei (int site1, int site2)
 Get the integer image distance along the z-direction between two sites. More...
 
int getIndexS (int xIndex, int yIndex, int zIndex=0)
 Get the serial site ID. More...
 
int getIndexY (int site)
 Get the "y-site ID" from the "s-site ID". More...
 
int getIndexX (int site)
 Get the "x-site ID" from the "s-site ID". More...
 
int getIndexZ (int site)
 Get the "z-site ID" from the "s-site ID". More...
 
double getPositionY (int site)
 Get the y-position from the "s-site ID". More...
 
double getPositionX (int site)
 Get the x-position from the "s-site ID". More...
 
double getPositionZ (int site)
 Get the z-position from the "s-site ID". More...
 
AgentagentAddress (int site)
 Get a pointer to the Agent at a site. More...
 
Agent::Type agentType (int site)
 Get the type of Agent at a site. More...
 
void addToPotential (int site, double potential)
 Add some value to the background potential at a site. More...
 
void setPotential (int site, double potential)
 Set the background potential at a site to some value. More...
 
double potential (int site)
 Get the background potential at some site. More...
 
QVector< int > neighborsSite (int site, int hoppingRange=1)
 Calculate the neighboring sites of a given site. More...
 
QVector< int > neighborsFace (Grid::CubeFace cubeFace)
 Calculate the neighboring sites of a given face of the Grid. More...
 
QVector< int > sliceIndex (int xi, int xf, int yi, int yf, int zi, int zf)
 Calculate the list of sites occupying a given range. More...
 
void registerAgent (Agent *agent)
 Assign an Agent to a site in the Grid. More...
 
void registerSpecialAgent (Agent *agent, Grid::CubeFace cubeFace)
 Assign an Agent to a special location. More...
 
void unregisterAgent (Agent *agent)
 Remove an Agent from the Grid. More...
 
void unregisterSpecialAgent (Agent *agent, Grid::CubeFace cubeFace)
 Remove an Agent from the special list of Agents in the Grid. More...
 
void unregisterDefect (int site)
 Remove a defect from the Grid. More...
 
void registerDefect (int site)
 Assign a site to be Agent::Defect. More...
 
int specialAgentCount ()
 The total number of special Agents. More...
 
QList< Agent * > & getSpecialAgentList (Grid::CubeFace cubeFace)
 Get a list of special Agents assigned to a specific Grid::CubeFace. More...
 

Static Public Member Functions

static QString toQString (const Grid::CubeFace e)
 

Protected Attributes

Worldm_world
 Reference to the World object. More...
 
QVector< Agent * > m_agents
 1D list of Agent pointers, the size of which is the volume of the Grid + the max number of special Agents. More...
 
QVector< double > m_potentials
 1D list of site potentials, the size of which is the volume of the Grid + the max number of special Agents. More...
 
QVector< Agent::Typem_agentType
 1D list of Agent types, the size of which is the volume of the Grid + the max number of special Agents. More...
 
QList< QList< Agent * > > m_specialAgents
 A list of lists of special agents, where each sub-list is for a different Grid::CubeFace. More...
 
int m_specialAgentReserve
 The max number of special Agents allowed. More...
 
int m_specialAgentCount
 The current number of special Agents registered with the Grid. More...
 
int m_xSize
 The number of sites along the x-direction. More...
 
int m_ySize
 The number of sites along the y-direction. More...
 
int m_zSize
 The number of sites along the z-direction. More...
 
int m_xyPlaneArea
 The number of sites in the xy-plane. More...
 
int m_yzPlaneArea
 The number of sites in the yz-plane. More...
 
int m_xzPlaneArea
 The number of sites in the xz-plane. More...
 
int m_volume
 The total number of sites. More...
 

Detailed Description

A class to hold Agents, calculate their positions, and store the background potential.

The x-direction

  • perpendicular to the electrodes
  • runs from left to right
  • corresponds to the dimension called length.

The y-direction

  • parallel to the electrodes
  • runs from bottom to top
  • corresponds to the dimension called width.

The z-direction

  • parallel to the electrodes
  • runs from back to front
  • corresponds to the dimension called height.

Member Enumeration Documentation

A way to indicate the faces of a cube.

Enumerator
Left 

x = 0, yz plane

Right 

x = lx, yz plane

Top 

z = 0, xy plane

Bottom 

z = lz, xy plane

Front 

y = 0, xz plane

Back 

y = ly, xz plane

NoFace 

undefined face

Constructor & Destructor Documentation

LangmuirCore::Grid::Grid ( World world,
QObject *  parent = 0 
)

Create a grid.

Parameters
worldreference to the world object
parentQObject this belongs to
LangmuirCore::Grid::~Grid ( )

Destroy the grid.

Member Function Documentation

void LangmuirCore::Grid::addToPotential ( int  site,
double  potential 
)

Add some value to the background potential at a site.

Parameters
sitethe "s-site ID"
potentialthe value to add
Agent* LangmuirCore::Grid::agentAddress ( int  site)

Get a pointer to the Agent at a site.

Parameters
sitethe "s-site ID"
Warning
may be NULL if there is no Agent
Agent::Type LangmuirCore::Grid::agentType ( int  site)

Get the type of Agent at a site.

Parameters
sitethe "s-site ID"
Warning
if there is no Agent, it should be Agent::Empty
int LangmuirCore::Grid::getIndexS ( int  xIndex,
int  yIndex,
int  zIndex = 0 
)

Get the serial site ID.

Parameters
xIndexx site ID
yIndexy site ID
zIndexz site ID

The position of a particle in the Grid can be thought of as a 3-tuple of (x, y, z) site IDs. However, this 3-tuple can be mapped/hashed into a single number using the dimension of the grid, called the "serial site ID", the "s-site ID", or just the "site".

int LangmuirCore::Grid::getIndexX ( int  site)

Get the "x-site ID" from the "s-site ID".

Parameters
sitethe "s-site ID"

The y-site ID can be thought of as the x-value of the cornor of a Grid site.

See also
getIndexS
int LangmuirCore::Grid::getIndexY ( int  site)

Get the "y-site ID" from the "s-site ID".

Parameters
sitethe "s-site ID"

The y-site ID can be thought of as the y-value of the cornor of a Grid site.

See also
getIndexS
int LangmuirCore::Grid::getIndexZ ( int  site)

Get the "z-site ID" from the "s-site ID".

Parameters
sitethe "s-site ID"

The y-site ID can be thought of as the z-value of the cornor of a Grid site.

See also
getIndexS
double LangmuirCore::Grid::getPositionX ( int  site)

Get the x-position from the "s-site ID".

Parameters
sitethe "s-site ID"

Particles are considered to reside in the "center" of Grid sites. The x-position is therefore the "x-site ID" plus 0.5 in reduced units.

double LangmuirCore::Grid::getPositionY ( int  site)

Get the y-position from the "s-site ID".

Parameters
sitethe "s-site ID"

Particles are considered to reside in the "center" of Grid sites. The y-position is therefore the "y-site ID" plus 0.5 in reduced units.

double LangmuirCore::Grid::getPositionZ ( int  site)

Get the z-position from the "s-site ID".

Parameters
sitethe "s-site ID"

Particles are considered to reside in the "center" of Grid sites. The z-position is therefore the "z-site ID" plus 0.5 in reduced units.

QList<Agent *>& LangmuirCore::Grid::getSpecialAgentList ( Grid::CubeFace  cubeFace)

Get a list of special Agents assigned to a specific Grid::CubeFace.

Parameters
cubeFacethe face of the Grid
QVector<int> LangmuirCore::Grid::neighborsFace ( Grid::CubeFace  cubeFace)

Calculate the neighboring sites of a given face of the Grid.

Parameters
cubeFacethe face of the Grid to consider
QVector<int> LangmuirCore::Grid::neighborsSite ( int  site,
int  hoppingRange = 1 
)

Calculate the neighboring sites of a given site.

Parameters
sitethe "s-site ID"
hoppingRangethe number of adjacent sites to consider in the calculation
double LangmuirCore::Grid::potential ( int  site)

Get the background potential at some site.

Parameters
sitethe "s-site ID"
void LangmuirCore::Grid::registerAgent ( Agent agent)

Assign an Agent to a site in the Grid.

Parameters
agenta pointer to the Agent
Warning
uses Agent::getCurrentSite()
site must be Agent::Empty

Makes sure the site is empty first. After assigning the Agent to the site, calculates and assigns the neighbors to the Agent.

void LangmuirCore::Grid::registerDefect ( int  site)

Assign a site to be Agent::Defect.

Parameters
site
void LangmuirCore::Grid::registerSpecialAgent ( Agent agent,
Grid::CubeFace  cubeFace 
)

Assign an Agent to a special location.

Parameters
agenta pointer to the Agent
cubeFacethe face of the Grid

Agents such as Sources and Drains do not occupy a site in the Grid, and so must be stored in a special location.

void LangmuirCore::Grid::setPotential ( int  site,
double  potential 
)

Set the background potential at a site to some value.

Parameters
sitethe "s-site ID"
potentialthe value to set
QVector<int> LangmuirCore::Grid::sliceIndex ( int  xi,
int  xf,
int  yi,
int  yf,
int  zi,
int  zf 
)

Calculate the list of sites occupying a given range.

Parameters
xistarting x-site ID
xfstopping x-site ID
yistarting y-site ID
yfstopping y-site ID
zistarting z-site ID
zfstopping z-site ID
int LangmuirCore::Grid::specialAgentCount ( )

The total number of special Agents.

static QString LangmuirCore::Grid::toQString ( const Grid::CubeFace  e)
static
double LangmuirCore::Grid::totalDistance ( int  site1,
int  site2 
)

Get the distance between two sites.

Parameters
site1the first site
site2the second site
void LangmuirCore::Grid::unregisterAgent ( Agent agent)

Remove an Agent from the Grid.

Parameters
agenta pointer to the Agent
void LangmuirCore::Grid::unregisterDefect ( int  site)

Remove a defect from the Grid.

Parameters
sitethe "s-site ID"
void LangmuirCore::Grid::unregisterSpecialAgent ( Agent agent,
Grid::CubeFace  cubeFace 
)

Remove an Agent from the special list of Agents in the Grid.

Parameters
agenta pointer to the Agent
cubeFacethe face of the Grid
int LangmuirCore::Grid::volume ( )

Get the total number of sites.

double LangmuirCore::Grid::xDistance ( int  site1,
int  site2 
)

Get the distance along the x-direction between two sites.

Parameters
site1the first site
site2the second site
int LangmuirCore::Grid::xDistancei ( int  site1,
int  site2 
)

Get the integer distance along the x-direction between two sites.

Parameters
site1the first site
site2the second site
double LangmuirCore::Grid::xImageDistance ( int  site1,
int  site2 
)

Get the image distance along the x-direction between two sites.

Parameters
site1the first site
site2the second site (reflected)

The second site's x-position is taken to be the negative of its x-value (i.e., the particle is reflected through the yz-plane).

int LangmuirCore::Grid::xImageDistancei ( int  site1,
int  site2 
)

Get the integer image distance along the x-direction between two sites.

Parameters
site1the first site
site2the second site (reflected)

The second site's x-position is taken to be the negative of its x-value (i.e., the particle is reflected through the yz-plane).

int LangmuirCore::Grid::xSize ( )

Get the number of sites along the x-direction.

int LangmuirCore::Grid::xyPlaneArea ( )

Get the number of sites in the xy-plane.

double LangmuirCore::Grid::yDistance ( int  site1,
int  site2 
)

Get the distance along the y-direction between two sites.

Parameters
site1the first site
site2the second site
int LangmuirCore::Grid::yDistancei ( int  site1,
int  site2 
)

Get the integer distance along the y-direction between two sites.

Parameters
site1the first site
site2the second site
double LangmuirCore::Grid::yImageDistance ( int  site1,
int  site2 
)

Get the image distance along the y-direction between two sites.

Parameters
site1the first site
site2the second site (reflected)

The second site's y-position is taken to be the negative of its y-value (i.e., the particle is reflected through the xz-plane).

int LangmuirCore::Grid::yImageDistancei ( int  site1,
int  site2 
)

Get the integer image distance along the y-direction between two sites.

Parameters
site1the first site
site2the second site (reflected)

The second site's y-position is taken to be the negative of its y-value (i.e., the particle is reflected through the xz-plane).

int LangmuirCore::Grid::ySize ( )

Get the number of sites along the y-direction.

double LangmuirCore::Grid::zDistance ( int  site1,
int  site2 
)

Get the distance along the z-direction between two sites.

Parameters
site1the first site
site2the second site
int LangmuirCore::Grid::zDistancei ( int  site1,
int  site2 
)

Get the integer distance along the z-direction between two sites.

Parameters
site1the first site
site2the second site
double LangmuirCore::Grid::zImageDistance ( int  site1,
int  site2 
)

Get the image distance along the z-direction between two sites.

Parameters
site1the first site
site2the second site (reflected)

The second site's z-position is taken to be the negative of its z-value (i.e., the particle is reflected through the xy-plane).

int LangmuirCore::Grid::zImageDistancei ( int  site1,
int  site2 
)

Get the integer image distance along the z-direction between two sites.

Parameters
site1the first site
site2the second site (reflected)

The second site's z-position is taken to be the negative of its z-value (i.e., the particle is reflected through the xy-plane).

int LangmuirCore::Grid::zSize ( )

Get the number of sites along the z-direction.

Member Data Documentation

QVector<Agent *> LangmuirCore::Grid::m_agents
protected

1D list of Agent pointers, the size of which is the volume of the Grid + the max number of special Agents.

Warning
some of these may be NULL

Each position in the list is mapped to a position in the Grid. Use getIndexS() to calculate the serial site ID needed to index this list.

QVector<Agent::Type> LangmuirCore::Grid::m_agentType
protected

1D list of Agent types, the size of which is the volume of the Grid + the max number of special Agents.

Warning
some of these may be Agent::Empty

Each position in the list is mapped to a position in the Grid. Use getIndexS() to calculate the serial site ID needed to index this list.

QVector<double> LangmuirCore::Grid::m_potentials
protected

1D list of site potentials, the size of which is the volume of the Grid + the max number of special Agents.

Each position in the list is mapped to a position in the Grid. Use getIndexS() to calculate the serial site ID needed to index this list.

int LangmuirCore::Grid::m_specialAgentCount
protected

The current number of special Agents registered with the Grid.

int LangmuirCore::Grid::m_specialAgentReserve
protected

The max number of special Agents allowed.

QList< QList<Agent *> > LangmuirCore::Grid::m_specialAgents
protected

A list of lists of special agents, where each sub-list is for a different Grid::CubeFace.

int LangmuirCore::Grid::m_volume
protected

The total number of sites.

World& LangmuirCore::Grid::m_world
protected

Reference to the World object.

int LangmuirCore::Grid::m_xSize
protected

The number of sites along the x-direction.

int LangmuirCore::Grid::m_xyPlaneArea
protected

The number of sites in the xy-plane.

int LangmuirCore::Grid::m_xzPlaneArea
protected

The number of sites in the xz-plane.

int LangmuirCore::Grid::m_ySize
protected

The number of sites along the y-direction.

int LangmuirCore::Grid::m_yzPlaneArea
protected

The number of sites in the yz-plane.

int LangmuirCore::Grid::m_zSize
protected

The number of sites along the z-direction.


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