Category : Science and Education
Archive : LAPLACE.ZIP
Filename : LAPLACE.DOC
laplace  solve Laplace's equation in two dimensions.
SYNOPSIS
laplace data [ options ]
DESCRIPTION
LAPLACE solves Laplace's equation in two dimensions, with Dirichlet
boundary conditions on arbitrary boundaries. In other words, it
solves the partial differential equation
2 2
d d
(  +  ) V(x,y) = 0
2 2
dx dy
where V(x,y) has specified constant values along each of one or
more fixed curves. In electrical terms, it will calculate the
potential at various points on a cross section of a
transmission line where the voltages and shapes of the
perfectly conducting electrodes may be specified.
METHOD
LAPLACE calculates the potentials on a rectangular equally
spaced grid of W * H points ranging from XMIN to XMAX and from
YMIN to YMAX. The user may use switch options to initialize
these six parameters. By default, W=H=25 and the grid spacing
is large enough to just include the input file points. LAPLACE
will enlarge W or H, and then adjust XMIN, XMAX, YMIN, and/or
YMAX to ensure that the grid spacing E is the same in both
directions.
If H1 and W1 are even, LAPLACE will first calculate
potentials on a coarse grid and use those values to initialize
the fine grid. If H1 and W1 include several powers of 2,
LAPLACE will recursively repeat this procedure.
The density of points along the specified boundaries makes little
difference. In other words, defining a circle with 200 points
instead of 50 will not significantly slow the calculation or
improve its accuracy. That is because both the accuracy and
time are dominated by the size of the grid. The setup time for each
pass is determined by the number of times the boundary curves cross
grid lines. Calculation time is approximately proportional to
W*H*N. I/O time is also significant even with a ramdisk, due
to the floating point operations involved.
The calculated potentials are accurate to within a few percent for
a set of boundaries within one grid spacing of the specified
boundaries. Suppose you tried one set of boundary conditions in
which a particular boundary line just barely intersected a grid
line, and a second set in which that boundary fell just short of
the grid line. The potential contours in the second case would be
moved in by just about the grid spacing, possibly passing through
the boundary. To check for this, use the program GRID.
LAPLACE calculates the potentials by means of relaxation using
integer arithmetic and the formula
V(x,y) = ( V(x+e,y) + V(xe,y) + V(x,y+e) + V(x,ye) )/4
with suitable adjustments where the boundary falls between grid
points and on the edge of the grid to avoid referencing nonexistent
grid points. This process will always converge. However, if the
corners of the grid are not part of a specified boundary the
convergence will be slow. If one boundary encloses the others (a
closed transmission line) the region outside that boundary is at a
uniform potential and the convergence can be improved by adding to
that outer boundary. In other words, convergence will be slower
with
00 than with 0000000000000000
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 00 0 0 0 00 0 0
0 0000 0 0 0 0000 0 0
0 0 00 00
0000000000000000 0000000000000000
However, the convergence at the interesting points (between the two
boundaries) is not affected. Adding an explicit rectangular
boundary will also slow the calculation. One alternative is to set
the outer boundary at potential zero and use the g switch (below).
INPUT DATA
The data file is an ASCII list of X,Y pairs specifying the shape
of the boundaries. The given points are assumed to be connected
by straight line segments. The last point along each segment of the
boundary is followed by the potential along that segment, which may
be in quotes.
Blank input lines are ignored. Input lines beginning with a
semicolon are echoed to the display but otherwise ignored.
For example, the data file:
3 5
7 5 "3"
4 2
6 2 "6"
specifies this configuration:
< 4 >
3 volts > ****************************** 
^


3


V
6 volts > *************** 
< 2 >
...two parallel plates, of widths 4 units and 2 units,
separated by 3 units, one at 3 V and the other at 6 V. (Note
that the potentials, charge densities, and other calculated
values are unchanged if the entire structure is enlarged by
some factor.)
The input data file format is the same as for GRAPH, which can be
used to display the file for debugging. It is also the same format
used by SPLINE, which can be helpful in preparing curved
boundaries.
OUTPUT DATA
The calculated potentials are written to a file with the same
name as the data file, but the extension ".POT". The first two
lines specify the grid, and the remaining lines give the
potentials at the grid points. It has the following format:
2g10.4i5
2g10.4i5
8g10.4
8g10.4
...
8g10.4
For example,
0 1 8 minimum and maximum x values, width
0 1 8 minimum and maximum y values, height
0 2.1999E1 3.5502E1 4.5513E1 5.4547E1 6.4558E1 7.8036E1 1
2.1999E1 3.0496E1 3.8981E1 4.6490E1 5.3583E1 6.1079E1 6.9551E1 7.8024E1
3.5502E1 3.8981E1 4.3425E1 4.7857E1 5.2203E1 5.6635E1 6.1067E1 6.4534E1
4.5513E1 4.6490E1 4.7857E1 4.9310E1 5.0750E1 5.2191E1 5.3558E1 5.4523E1
5.4547E1 5.3583E1 5.2203E1 5.0750E1 4.9298E1 4.7833E1 4.6453E1 4.5476E1
6.4558E1 6.1079E1 5.6635E1 5.2191E1 4.7833E1 4.3389E1 3.8933E1 3.5453E1
7.8036E1 6.9551E1 6.1067E1 5.3558E1 4.6453E1 3.8933E1 3.0448E1 2.1963E1
1 7.8024E1 6.4534E1 5.4523E1 4.5476E1 3.5453E1 2.1963E1 0
The points are written in the following order:
for (y=YMIN; y<=YMAX; y=y+EDGE)
for (x=XMIN; x<=XMAX; x=x+EDGE)
printf("%g10.4 ",V(x,y));
...with newlines as needed to limit the output to 8 points per
line. The output file format is appropriate for CONTOUR, which can
be used to calculate equipotentials.
OPTIONS
b Displays a printer plot with zeros along the specified
boundaries.
g The edge of the grid is grounded (potential is 0).
m num Margin. Extend the grid by the distance
same units as the x and y locations, beyond the given
boundaries on all sides. For open boundaries (for
example, an isolated cylinder) it is more convenient to
use the g and m switches than generating a box of the
required size explicitly. The resulting model will
also be faster (because the boundary doesn't fall
between grid points).
p Displays a matrix of the calculated potentials, with
XMIN,YMIN at the top left corner.
r Periodically calculates and displays the number of times
each grid point has been updated and the root mean
square value of the quantity
V(x)  (V(x+e,y) + V(xe,y) + V(x,y+e) + V(x,ye))/4
which indicates the error remaining.
n
Sets the number of relaxation cycles N (default 75).
It should be approximately twice the larger of W and H.
w
h
Set the number of grid points in the x and y direction
(default 25). Convergence is improved if W1 and H1
both have several factors of 2, allowing LAPLACE to
initialize by recursively calculating on a coarser
grid. Internal table space limits the grid size to
approximately W*H <= 10000.
x min [max]
y min [max]
Specify the data range covered by the grid. These are
necessary, for example, for an open transmission line.
The m switch is an alternative.
xs The boundary conditions are symmetric across the line
x=xmin, which means the gradient there has no
xcomponent and that contours of potential are
horizontal there.
ys Similarly for the line y=ymin.
xp The boundary conditions are symmetric across both the
lines x=xmin and x=xmax.
yp Similarly for the line y=ymin and y=ymax.
? Print a help message, such as the following:
laplace version 0.2
usage: laplace [file][options]
options are:
b display boundaries
g edge of grid is grounded (potential 0)
p display calculated potentials
q quiet: no comments during calculation
r calculate and display residuals
m margin distance to expand grid beyond given boundaries (default 0)
n num number of relaxation cycles (default 75)
h num height of grid in cells (default 25)
w num width of grid in cells (default 25)
x [min [max]] specify x range
y [min [max]] specify y range
xs symmetric across the line x=xmin
ys symmetric across the line y=ymin
xp periodic: symmetric across lines x=xmin and x=xmax
yp periodic: symmetric across lines y=ymin and y=ymax
BUGS
Subject to descretization errors.
Should handle axisymmetric 3D problems.
CONTOUR will find equipotentials, but there's no corresponding
way to find gradients (electric field lines).
AUTHOR
James R. Van Zandt
6038882272. Resale forbidden, distribution encouraged, comments
welcome.
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/