Skip to content

Commit 880fc7c

Browse files
committed
adding some more documentation
1 parent c69815d commit 880fc7c

File tree

14 files changed

+217
-514
lines changed

14 files changed

+217
-514
lines changed

docs/conf.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys
16-
import os
17-
import sphinx.ext.autodoc
1815

1916
# If extensions (or modules to document with autodoc) are in another directory,
2017
# add these directories to sys.path here. If the directory is relative to the
2118
# documentation root, use os.path.abspath to make it absolute, like shown here.
22-
sys.path.insert(0, os.path.abspath('..'))
23-
sys.path.append(os.path.abspath('sphinxext'))
24-
sys.path.insert(0,os.path.abspath('../../texext'))
2519

2620
# -- General configuration ------------------------------------------------
2721

@@ -33,12 +27,8 @@
3327
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3428
# ones.
3529
extensions = [
36-
'sphinx.ext.autodoc',
37-
'sphinx.ext.todo',
38-
'sphinx.ext.napoleon',
3930
'sphinx.ext.mathjax',
40-
'texext',
41-
# 'sphinxcontrib.bibtex',
31+
'sphinx_math_dollar'
4232
]
4333

4434
# Add any paths that contain templates here, relative to this directory.
@@ -74,7 +64,7 @@
7464
#
7565
# This is also used if you do content translation via gettext catalogs.
7666
# Usually you set "language" from the command line for these cases.
77-
language = None
67+
language = 'en' 'en' 'en' 'en'
7868

7969
# There are two options for replacing |today|: either, you set today to some
8070
# non-false value, then it is used:

docs/install.rst

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ For the basic libraries
1818
* GNU make
1919

2020

21+
Optional:
22+
23+
* for building Python wrappers you will need ``python3``, ``pip3`` and ``numpy``.
24+
* for building standard MATLAB wrappers: MATLAB
25+
* for modifying MATLAB wrappers (experts only): ``mwrap``
26+
27+
2128
Quick install instructions
2229
*********************************************
2330

@@ -52,12 +59,25 @@ You may then link to the FMM library using the ``-lfmm2d`` option.
5259
To verify successful compilation of the program, run ``make test``
5360
which compiles some fortran test drivers in ``test/`` linked against
5461
the static library, after which it
55-
runs the test programs. The last 4 lines of the terminal output should be::
62+
runs the test programs. The last 17 lines of the terminal output should be::
5663

5764
cat print_testreshelm.txt
5865
Successfully completed 27 out of 27 tests in hfmm2d testing suite
66+
Successfully completed 27 out of 27 tests in hf-hfmm2d testing suite
5967
Successfully completed 27 out of 27 tests in hfmm2d vec testing suite
68+
Successfully completed 1 out of 1 tests in helm2d_mps testing suite
69+
cat print_testreslap.txt
70+
Successfully completed 9 out of 9 tests in cfmm2d testing suite
71+
Successfully completed 9 out of 9 tests in cfmm2d vec testing suite
72+
Successfully completed 9 out of 9 tests in lfmm2d testing suite
73+
Successfully completed 9 out of 9 tests in lfmm2d vec testing suite
74+
Successfully completed 9 out of 9 tests in rfmm2d testing suite
75+
Successfully completed 9 out of 9 tests in rfmm2d vec testing suite
76+
cat print_testresbh.txt
77+
Successfully completed 1 out of 1 tests in bhfmm2d testing suite
6078
rm print_testreshelm.txt
79+
rm print_testreslap.txt
80+
rm print_testresbh.txt
6181

6282

6383
To verify successful installation of the program, and the correct
@@ -118,6 +138,78 @@ The corresponding makefiles are ``hfmm2d_example.make``,
118138
``hfmm2d_vec_example.make``, and ``hfmm2d_legacy_example.make``.
119139

120140

141+
Building Python wrappers
142+
****************************
143+
144+
First make sure you have python (version 3 or higher), pip and numpy installed.
145+
146+
You may then execute ``make python`` (after copying over the
147+
operating system specific make.inc.* file to make.inc) which calls
148+
pip for the install and then runs some tests.
149+
150+
To rerun the tests, you may run ``pytest`` in ``python/``
151+
or alternatively run ``python python/test_hfmm.py`` and
152+
``python python/test_lfmm.py``.
153+
154+
See ``python/hfmmexample.py`` and ``python/lfmmexample.py`` to see
155+
usage examples for the Python wrappers.
156+
157+
.. note::
158+
On windows, you will need to update ``distutils.cfg`` located in
159+
``(PYTHON_INSTALL_DIR)\Lib\distutils`` and set it to::
160+
161+
[build]
162+
compiler=mingw32
163+
164+
[build_ext]
165+
compiler=mingw32
166+
167+
which forces python to use the mingw compiler for building its
168+
modules. In case you wish to revert to using VC/C++ for building python
169+
modules, make sure to update distutils.cfg appropriately.
170+
171+
172+
A few words about Python environments
173+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174+
175+
There can be confusion and conflicts between various versions of Python and installed packages. It is therefore a very good idea to use virtual environments. Here's a simple way to do it (after installing python-virtualenv)::
176+
177+
Open a terminal
178+
virtualenv -p /usr/bin/python3 env1
179+
. env1/bin/activate
180+
181+
Now you are in a virtual environment that starts from scratch. All pip installed packages will go inside the env1 directory. (You can get out of the environment by typing ``deactivate``)
182+
183+
It's advisable to install numpy into a virtual environment using pip as.
184+
185+
virtualenv -p /usr/bin/python3 env1
186+
. env1/bin/activate
187+
pip install numpy
188+
189+
190+
Building the MATLAB wrappers
191+
****************************
192+
193+
First make sure you have MATLAB installed.
194+
195+
Then run ``make matlab`` (after copying over the operating
196+
system specific make.inc.* file to make.inc) which links the .m files to
197+
the .c file in the matlab folder.
198+
199+
To run tests, you can run ``matlab test_hfmm3d.m`` and
200+
``matlab test_lfmm3d.m`` and it should return with $0$ crashes.
201+
202+
Example codes for demonstrating the Helmholtz and Laplace
203+
interfaces are ``hfmm3d_example.m`` and ``lfmm3d_example.m``.
204+
205+
In order to build the MATLAB routines with the optimized direct kernel
206+
evaluation routines on a Mac, we recommend building mex with gcc
207+
instead of clang. The relevant xml files for configuring mex to use
208+
gcc can be found at https://github.com/danfortunato/matlab-gcc.
209+
Follow the instructions there to configure mex with gcc, and set
210+
CC = ``gcc-<version number>`` in your make.inc file.
211+
212+
121213
Tips for installing dependencies
122214
**********************************
123215

@@ -170,3 +262,66 @@ Download and install ``git`` for windows
170262
(Available `here <https://git-scm.com/download/win>`_).
171263

172264

265+
Tips for installing optional dependencies
266+
******************************************
267+
268+
Installing python and pip
269+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270+
271+
On Ubuntu linux
272+
##################
273+
274+
::
275+
276+
sudo apt-get install python3 python3-pip
277+
278+
279+
On Mac OSX
280+
############
281+
282+
Make sure you have homebrew installed. See `Tips for installing dependencies -> On Mac OSX <install.html#mac-inst>`__
283+
284+
::
285+
286+
brew install python3
287+
288+
289+
On Windows
290+
###########
291+
292+
Download and install python3.7 from python.org.
293+
294+
Configuring MATLAB
295+
~~~~~~~~~~~~~~~~~~~
296+
297+
On Windows
298+
############
299+
300+
Update ``MINGW_LPATH`` in ``make.inc.windows.mingw`` to point to the
301+
appropriate installation directory (it should be the one within the
302+
``gcc`` folder).
303+
304+
To setup mingw as the C compiler on MATLAB run ``configuremingw.p``
305+
(which can be downloaded from
306+
`here <https://www.mathworks.com/matlabcentral/answers/uploaded_files/88639/configuremingw.p>`_)
307+
and choose the mingw directory. To verify successful setup run ``mex
308+
-setup`` from matlab and it should be configured to compile with mingw.
309+
310+
311+
Installing MWrap
312+
~~~~~~~~~~~~~~~~~~
313+
314+
If you make any changes to the
315+
fortran code, you will need to regenerate the .c files
316+
from the .mw files for which mwrap is required.
317+
This is not needed for most users.
318+
`MWrap <http://www.cs.cornell.edu/~bindel/sw/mwrap>`_
319+
is a very useful MEX interface generator by Dave Bindel.
320+
321+
Make sure you have ``flex`` and ``bison`` installed.
322+
Download version 0.33.5 or later from https://github.com/zgimbutas/mwrap, un-tar the package, cd into it, then::
323+
324+
make
325+
sudo cp mwrap /usr/local/bin/
326+
327+

docs/math.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ given by
3535
.. math::
3636
:label: rlap_nbody
3737
38-
u(x) = \sum_{j=1}^{N} c_{j} \log{(\|x-x_{j}\|)} - v_{j} d_{j}\cdot \nabla \log{(\|x-x_{j}\|)} \, ,
38+
u(x) = -\frac{1}{2\pi}\left(\sum_{j=1}^{N} c_{j} \log{(\|x-x_{j}\|)} - v_{j} d_{j}\cdot \nabla \log{(\|x-x_{j}\|)}\right) \, ,
3939
4040
and its gradient $\nabla u(x) \in \mathbb{R}^{2}$
4141
at the source and target locations. When $x=x_{j}$, the term
@@ -51,14 +51,14 @@ $j=1,2,\ldots N$,
5151
denote a collection of dipole strengths, and let $d_{j} \in \mathbb{R}^{2}$,
5252
$j=1,2,\ldots N$, denote the corresponding dipole orientation vectors.
5353

54-
The Laplace FMM (rfmm2d) computes
54+
The Laplace FMM (lfmm2d) computes
5555
the potential $u(x) \in \mathbb{C}$
5656
given by
5757

5858
.. math::
5959
:label: llap_nbody
6060
61-
u(x) = \sum_{j=1}^{N} c_{j} \log{(\|x-x_{j}\|)} - v_{j} d_{j}\cdot \nabla \log{(\|x-x_{j}\|)} \, ,
61+
u(x) = -\frac{1}{2\pi} \left(\sum_{j=1}^{N} c_{j} \log{(\|x-x_{j}\|)} - v_{j} d_{j}\cdot \nabla \log{(\|x-x_{j}\|)}\right) \, ,
6262
6363
and its gradient $\nabla u(x) \in \mathbb{C}^{2}$
6464
at the source and target locations. (The outputs are complex-valued in this case because
@@ -83,7 +83,7 @@ given by
8383
.. math::
8484
:label: clap_nbody
8585
86-
u(z) = \sum_{j=1}^{N} c_{j} \log{(\|z-\xi_{j}\|)} - \frac{v_{j}}{z-\xi_{j}} \, ,
86+
u(z) = -\frac{1}{2\pi}\left(\sum_{j=1}^{N} c_{j} \log{(\|z-\xi_{j}\|)} - \frac{v_{j}}{z-\xi_{j}}\right) \, ,
8787
8888
and its
8989
derivatives $u'(z), u''(z) \in
@@ -111,7 +111,7 @@ given by
111111
.. math::
112112
:label: helm_nbody
113113
114-
u(x) = \sum_{j=1}^{N} c_{j} H_{0}^{(1)}(k\|x-x_{j}\|) - v_{j} d_{j}\cdot \nabla H_{0}^{(1)}(k\|x-x_{j}\|) \, ,
114+
u(x) = \frac{i}{4}\left(\sum_{j=1}^{N} c_{j} H_{0}^{(1)}(k\|x-x_{j}\|) - v_{j} d_{j}\cdot \nabla H_{0}^{(1)}(k\|x-x_{j}\|)\right) \, ,
115115
116116
and its gradient $\nabla u(x) \in \mathbb{C}^{2}$
117117
at the source and target locations, where $H_{0}^{(1)}$ is the Hankel function
@@ -136,21 +136,21 @@ given by
136136
.. math::
137137
:label: biharm_nbody
138138
139-
u(z) &= \sum_{j=1}^{N} 2 \, c_{j,1} \log{\|z - \xi_{j}\|} +
139+
u(z) &= \frac{1}{2\pi} \left(\sum_{j=1}^{N} 2 \, c_{j,1} \log{\|z - \xi_{j}\|} +
140140
c_{j,2} \frac{z-\xi_{j}}{\overline{z-\xi_{j}}} + \frac{v_{j,1}}{z - \xi_{j}} +
141141
\frac{v_{j,3}}{\overline{z-\xi_{j}}} +
142-
v_{j,2} \frac{z - \xi_{j}}{(\overline{z-\xi_{j}})^2} \, , \\
143-
P_{z} \frac{\mathrm{d}}{\mathrm{d} z}u(z) &= \sum_{j=1}^{N} \frac{c_{j,1}}{z-\xi_{j}} -
144-
\frac{v_{j,1}}{(z-\xi_{j})^2} \, \\
142+
v_{j,2} \frac{z - \xi_{j}}{(\overline{z-\xi_{j}})^2} \right) \, , \\
143+
P_{z} \frac{\mathrm{d}}{\mathrm{d} z}u(z) &= \frac{1}{2\pi} \left(\sum_{j=1}^{N} \frac{c_{j,1}}{z-\xi_{j}} -
144+
\frac{v_{j,1}}{(z-\xi_{j})^2} \right) \, \\
145145
P_{\overline{z}} \frac{\mathrm{d}}{\mathrm{d} z} u(z) &=
146-
\sum_{j=1}^{N} \frac{c_{j,2}}{\overline{z-\xi_{j}}} +
147-
\frac{v_{j,2}}{(\overline{z-\xi_{j}})^2} \,
146+
\frac{1}{2\pi} \left(\sum_{j=1}^{N} \frac{c_{j,2}}{\overline{z-\xi_{j}}} +
147+
\frac{v_{j,2}}{(\overline{z-\xi_{j}})^2} \right) \,
148148
,\\
149149
\frac{\mathrm{d}}{\mathrm{d}\overline{z}} u(z) &=
150-
\sum_{j=1}^{N} \frac{c_{j,1}}{\overline{z-\xi_{j}}} -
150+
\frac{1}{2\pi}\left(\sum_{j=1}^{N} \frac{c_{j,1}}{\overline{z-\xi_{j}}} -
151151
c_{j,2} \frac{z-\xi_{j}}{(\overline{z-\xi_{j}})^2} -
152152
\frac{v_{j,3}}{(\overline{z-\xi_{j}})^2} -
153-
2v_{j,2} \frac{z - \xi_{j}}{(\overline{z-\xi_{j}})^3} \, , \\
153+
2v_{j,2} \frac{z - \xi_{j}}{(\overline{z-\xi_{j}})^3}\right) \, , \\
154154
155155
at the source and target locations.
156156
When $z=\xi_{j}$, the term
@@ -216,7 +216,7 @@ Stokes FMM
216216
Let $G^{\textrm{stok}}(x,y)$ denote the Stokeslet given by
217217

218218
.. math::
219-
G^{\textrm{stok}}(x,y) = \frac{1}{2}
219+
G^{\textrm{stok}}(x,y) = \frac{1}{4\pi}
220220
\begin{bmatrix}
221221
-\log{\|x-y \|} + \frac{(x_{1}-y_{1})^2}{\|x-y\|^2} & \frac{(x_{1}-y_{1})
222222
(x_{2}-y_{2})}{\|x-y \|^2} \\
@@ -294,7 +294,7 @@ given by
294294
.. math::
295295
:label: helm_nbody_vec
296296
297-
u_{\ell}(x) = \sum_{j=1}^{N} c_{\ell,j} H_{0}^{(1)}(k\|x-x_{j}\|) - v_{\ell,j} d_{\ell,j}\cdot \nabla H_{0}^{(1)}(k\|x-x_{j}\|) \, ,
297+
u_{\ell}(x) = \frac{i}{4}\left(\sum_{j=1}^{N} c_{\ell,j} H_{0}^{(1)}(k\|x-x_{j}\|) - v_{\ell,j} d_{\ell,j}\cdot \nabla H_{0}^{(1)}(k\|x-x_{j}\|)\right) \, ,
298298
299299
and its gradients $\nabla u_{\ell}(x) \in \mathbb{C}^{2}$
300300
at the source and target locations.

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
texext
21
sphinxcontrib.bibtex
2+
sphinx-math-dollar

0 commit comments

Comments
 (0)