From e69201ce24e4f366726b9324586f4a49adf37ce5 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 10 Dec 2019 01:52:07 -0800 Subject: [PATCH] work on grid text --- meanas/fdmath/__init__.py | 252 +++++++++++++++++++++----------------- 1 file changed, 137 insertions(+), 115 deletions(-) diff --git a/meanas/fdmath/__init__.py b/meanas/fdmath/__init__.py index 742081e..71a1e6e 100644 --- a/meanas/fdmath/__init__.py +++ b/meanas/fdmath/__init__.py @@ -376,10 +376,143 @@ $$ Grid description ================ -As described in the section on scalar discrete derivatives above, cell widths along -each axis can be arbitrary and independently defined. Moreover, all field components -are defined at "derived" or "dual" positions, in-between the "base" grid points on -one or more axes. +As described in the section on scalar discrete derivatives above, cell widths +(`dx[i]`, `dy[j]`, `dz[k]`) along each axis can be arbitrary and independently +defined. Moreover, all field components are actually defined at "derived" or "dual" +positions, in-between the "base" grid points on one or more axes. + +To get a better sense of how this works, let's start by drawing a grid with uniform +`dy` and `dz` and nonuniform `dx`. We will only draw one cell in the y and z dimensions +to make the illustration simpler; we need at least two cells in the x dimension to +demonstrate how nonuniform `dx` affects the various components. + +Place the E fore-vectors at integer indices \\( r = (m, n, p) \\) and the H back-vectors +at fractional indices \\( r + \\frac{1}{2} = (m + \\frac{1}{2}, n + \\frac{1}{2}, p + \\frac{1}{2}. +Remember that these are indices and not coordinates; they can coorespond to arbitrary +(monotonically increasing) coordinates depending on the cell widths. + +Draw lines to denote the planes on which the H components and back-vectors are defined. +For simplicity, don't draw the equivalent planes for the E components and fore-vectors, +except as necessary to show their locations -- it's easiest to just connect them to their +associated H-equivalents. The result looks something like this: + + [figure: Component centers] + p= + [H]__________Hx___________[H]______Hx______[H] __ +1/2 + z y /: /: /: /: /| | | + |/_x / : / : / : / : / | | | + / : / : / : / : / | | | + Hy : Ez...........Hy : Ez......Hy | | | + /: : : : /: : : : /| | | | + / : Hz : Ey....../.:..Hz : Ey./.|..Hz __ 0 | dz[0] + / : /: : / / : /: : / / | /| | | + /_________________________/________________/ | / | | | + | :/ : :/ | :/ : :/ | |/ | | | + | Ex : [E].......|..Ex : [E]..|..Ex | | | + | : | : | | | | + | [H]..........Hx....|......[H].....Hx|......[H] __ --------- (m=+1/2, p=-1/2) + | / | / | / / / + | / | / | / / / + Hz / Hz / Hz / / / + | Hy | Hy | Hy __ 0 / dy[0] + | / | / | / / / + | / | / | / / / + |/ |/ |/ / / + [H]__________Hx___________[H]______Hx______[H] __ -1/2 / + =n + |------------|------------|--------|------| + -1/2 0 +1/2 +1 +3/2 = m + + ------------------------- ---------------- + dx[0] dx[1] + + Part of a nonuniform "base grid", with labels specifying + positions of the various field components. [E] fore-vectors + are at the cell centers, and [H] back-vectors are at the + vertices. H components along the near (-y) top (+z) edge + have been omitted to make the insides of the cubes easier + to visualize. + +This figure shows where all the components are located; however, it is also useful to show +what volumes those components are responsible for representing. Consider the Ex component: +two of its nearest neighbors are E fore-vectors, labeled `[E]` in the figure. + + [figure: Ex volumes] + <__________________________________________> + z y << /: / /: >> | + |/_x < < / : / / : > > | + < < / : / / : > > | + < < / : / / : > > | + <: < / : : / : >: > | + < : < / : : / : > : > | dz[0] + < : < / : : / : > : > | + <____________/_____________________________> : > | + < : < | : :| : > : > | + < Ex < | : Ex| : > Ex > | + < : < | : :| : > : > | + < : <....|.......:........:|.......:...>...:...> + < : < | / :| / / > : > / + < : < | / :| / / > : > / + < :< | / :|/ / > :> / + < < | / :| / > > / + < < | / | / > > / dy[0] + < < | / | / > > / + << |/ |/ >> / + <____________|_________________|___________> / + + ~------------ ----------------- -----------~ + dx'[-1] dx'[0] dx'[1] + + The Ex values are positioned on the x-faces of the base + grid. They represent the Ex field in volumes shifted by + a half-cell in the x-dimension, as shown here. Only the + center cell is fully shown; the other two are truncated + (shown using >< markers). + + Note that the Ex positions are the in the same positions + as the previous figure; only the cell boundaries have moved. + Also note that the points at which Ex is defined are not + necessarily centered in the volumes they represent; non- + uniform cell sizes result in off-center volumes like the + center cell here. + + [figure: Hy volumes] + z y mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm s + |/_x << m: m: >> | + < < m : m : > > | dz'[1] + Hy............m...........Hy........m......Hy > | + < < m : m : > > | + < < m : m : > > | + < _______m_____:_______________m_____:_>______ + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm > | + < < | / : | / :> > | + < < | / : | / :> > | dz'[0] + < < | / : | / :> > | + < wwwwww|w/wwwwwwwwwwwwwwwwwww|w/wwwww>wwwwwww s + < < |/ w |/ w > > / + _____________|_____________________|________ > / + < Hy........|...w...........Hy....|...w...>..Hy / + < < | w | w > > / dy[0] + < < | w | w > > / + << |w |w >> / + wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww + + ~------------ --------------------- -------~ + dx'[-1] dx'[0] dx'[1] + + The Hy values are positioned on the y-edges of the base + grid. Again here, the 'Hy' labels represent the same points + as in the basic grid figure above; the edges have shifted + by a half-cell along the x- and z-axes. + + The grid lines _|:/ are edges of the area represented by + each Hy value, and the lines drawn using .w represent + edges where a cell's faces extend beyond the drawn area + (i.e. where the drawing is truncated in the x- or z- + directions). + + +TODO: explain dxes [figure: 3D base and derived grids] _____________________________ _____________________________ @@ -432,117 +565,6 @@ one or more axes. later figures for a better representation. -Nevertheless, while the spacing - - - [figure: Component centers] - [H]__________Hx___________[H]______Hx______[H] - z y /: /: /: /: /| | - |/_x / : / : / : / : / | | - / : / : / : / : / | | - Hy : Ez...........Hy : Ez......Hy | | - /: : : : /: : : : /| | | - / : Hz : Ey....../.:..Hz : Ey./.|..Hz | dz[0] - / : /: : / / : /: : / / | /| | - /_________________________/________________/ | / | | - | :/ : :/ | :/ : :/ | |/ | | - | Ex : [E].......|..Ex : [E]..|..Ex | | - | : | : | | | - | [H]..........Hx....|......[H].....Hx|......[H] - | / | / | / / - | / | / | / / - Hz / Hz / Hz / / - | Hy | Hy | Hy / - | / | / | / / dy[0] - | / | / | / / - |/ |/ |/ / - [H]__________Hx___________[H]______Hx______[H] / - - ------------------------- ---------------- - dx[0] dx[1] - - Part of a nonuniform "base grid", with labels specifying - positions of the various field components. [E] fore-vectors - are at the cell centers, and [H] back-vectors are at the - vertices. H components along the near (-y) top (+z) edge - have been omitted to make the insides of the cubes easier - to visualize. - - <__________________________________________> - z y << /: / /: >> | - |/_x < < / : / / : > > | - < < / : / / : > > | - < < / : / / : > > | - <: < / : : / : >: > | - < : < / : : / : > : > | dz[0] - < : < / : : / : > : > | - <____________/_____________________________> : > | - < : < | : :| : > : > | - < Ex < | : Ex| : > Ex > | - < : < | : :| : > : > | - < : <....|.......:........:|.......:...>...:...> - < : < | / :| / / > : > / - < : < | / :| / / > : > / - < :< | / :|/ / > :> / - < < | / :| / > > / - < < | / | / > > / dy[0] - < < | / | / > > / - << |/ |/ >> / - <____________|_________________|___________> / - - ~------------ ----------------- -----------~ - dx'[-1] dx'[0] dx'[1] - - The Ex values are positioned on the x-faces of the base - grid. They represent the Ex field in volumes shifted by - a half-cell in the x-dimension, as shown here. Only the - center cell is fully shown; the other two are truncated - (shown using >< markers). - - Note that the Ex positions are the in the same positions - as the previous figure; only the cell boundaries have moved. - Also note that the points at which Ex is defined are not - necessarily centered in the volumes they represent; non- - uniform cell sizes result in off-center volumes like the - center cell here. - - z y mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm s - |/_x << m: m: >> | - < < m : m : > > | dz'[1] - Hy............m...........Hy........m......Hy > | - < < m : m : > > | - < < m : m : > > | - < _______m_____:_______________m_____:_>______ - mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm > | - < < | / : | / :> > | - < < | / : | / :> > | dz'[0] - < < | / : | / :> > | - < wwwwww|w/wwwwwwwwwwwwwwwwwww|w/wwwww>wwwwwww s - < < |/ w |/ w > > / - _____________|_____________________|________ > / - < Hy........|...w...........Hy....|...w...>..Hy / - < < | w | w > > / dy[0] - < < | w | w > > / - << |w |w >> / - wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww - - ~------------ --------------------- -------~ - dx'[-1] dx'[0] dx'[1] - - The Hy values are positioned on the y-edges of the base - grid. Again here, the 'Hy' labels represent the same points - as in the basic grid figure above; the edges have shifted - by a half-cell along the x- and z-axes. - - The grid lines _|:/ are edges of the area represented by - each Hy value, and the lines drawn using .w represent - edges where a cell's faces extend beyond the drawn area - (i.e. where the drawing is truncated in the x- or z- - directions). - - -TODO: explain dxes - """ from .types import fdfield_t, vfdfield_t, dx_lists_t, fdfield_updater_t