grid
Note
Functions for performing calculations on grids.
Module author: Adam Gagorik <adam.gagorik@gmail.com>
-
class grid.Grid(xsize, ysize, zsize)[source]
A class to represent the Langmuir simulation lattice. Alternate
contructors exist.
Parameters: |
- xsize (int) – x points
- ysize (int) – y points
- zsize (int) – z points
|
-
classmethod from_checkpoint(chk)[source]
Create grid instance from checkpoint file.
Parameters: | chk – checkpoint filename or object |
>>> grid = lm.grid.Grid.from_checkpoint('out.chk')
-
create_zeros()[source]
Compute a grid of zeros.
-
parameters()[source]
Return a langmuir.parameters.Parameters.
-
refine(factor=0)[source]
Refines the mesh. If factor=0 or dx/factor > 1.0, the mesh is reset
to the default spacing of 1.0.
Parameters: | factor (float) – zoom factor; > 0 refines the mesh, < 0 zooms out. |
-
class grid.IndexMapper(grid)[source]
A class that maps between site indicies the Langmuir way.
>>> grid = lm.grid.Grid(10, 10, 10)
>>> imap = lm.grid.IndexMapper(grid)
-
indexS(x_index, y_index, z_index)[source]
Compute (Langmuir’s) site index from x, y, and z index
Parameters: |
- x_index (int) – x-site
- y_index (int) – y-site
- z_index (int) – z-site
|
>>> grid = lm.grid.Grid(10, 10, 10)
>>> imap = lm.grid.IndexMapper(grid)
>>> s = imap.indexS(0, 0, 0)
-
indexX(s_index)[source]
Compute (Langmuir’s) x index from site index
Parameters: | s_index (int) – site index |
>>> grid = lm.grid.Grid(10, 10, 10)
>>> imap = lm.grid.IndexMapper(grid)
>>> x = imap.indexX(10)
-
indexY(s_index)[source]
Compute (Langmuir’s) y index from site index
Parameters: | s_index (int) – site index |
>>> grid = lm.grid.Grid(10, 10, 10)
>>> imap = lm.grid.IndexMapper(grid)
>>> y = imap.indexX(10)
-
indexZ(s_index)[source]
Compute (Langmuir’s) z index from site index
Parameters: | s_index (int) – site index |
>>> grid = lm.grid.Grid(10, 10, 10)
>>> imap = lm.grid.IndexMapper(grid)
>>> z = imap.indexX(10)
-
class grid.XYZV(grid, s, v=None)[source]
Put site values on a mesh using site ids.
Parameters: |
- grid (Grid) – grid object
- s (list) – site indcies
- v (list or scalar) – site values
|
>>> chk = lm.checkpoint.load('out.chk')
>>> grid = lm.grid.Grid.from_checkpoint(chk)
>>> xyzv = lm.grid.XYZV(grid, chk.electrons, -1)
-
class grid.PrecalculatedMesh(grid)[source]
Perform fast computation of Coulomb interactions and distances with a
precomputed mesh.
Parameters: | grid (Grid) – grid object |
>>> grid = lm.grid.Grid(5, 5, 5)
>>> mesh = lm.grid.PrecalculatedMesh(grid)
-
coulomb(xi_ids, yi_ids, zi_ids, xj_ids=None, yj_ids=None, zj_ids=None, q=1)[source]
Compute coulomb interaction at j’s due to charges at i’s. If no
j’s are passed, then the answer will be computed at every mesh
point (expensive!)’
Parameters: |
- xi_ids (list, int) – charge x-position(s)
- yi_ids (list, int) – charge y-position(s)
- zi_ids (list, int) – charge z-position(s)
- xj_ids – energy x-position(s)
- yj_ids – energy y-position(s)
- zj_ids – energy z-position(s)
- q (int, float) – charge
|
>>> grid = lm.grid.Grid(10, 10, 10)
>>> mesh = lm.grid.PrecalculatedMesh(grid)
>>> coul = mesh.coulomb(0, 0, 0, 1, 1, 1, -1)
-
distances(xi_ids, yi_ids, zi_ids, xj_ids=None, yj_ids=None, zj_ids=None)[source]
Compute all distances between i’s, or compute all distances between
i’s and j’s
Parameters: |
- xi_ids (list, int) – initial x-position(s)
- yi_ids (list, int) – initial y-position(s)
- zi_ids (list, int) – initial z-position(s)
- xj_ids – final x-position(s)
- yj_ids – final y-position(s)
- zj_ids – final z-position(s)
|
>>> grid = lm.grid.Grid(10, 10, 10)
>>> mesh = lm.grid.PrecalculatedMesh(grid)
>>> dist = mesh.distances(0, 0, 0, 1, 1, 1)