Skip to content

Commit

Permalink
Improved documentation (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zwicker authored Aug 22, 2024
1 parent e243936 commit 2acb835
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
8 changes: 4 additions & 4 deletions docs/source/manual/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A crucial aspect of partial differential equations are boundary conditions, whic
to be specified at the domain boundaries. For the simple domains contained in `py-pde`,
all boundaries are orthogonal to one of the axes in the domain, so boundary conditions
need to be applied to both sides of each axis. Here, the lower side of an axis can have
a differnt condition than the upper side. For instance, one can enforce the value of a
a different condition than the upper side. For instance, one can enforce the value of a
field to be `4` at the lower side and its derivative (in the outward direction) to be
`2` on the upper side using the following code:

Expand Down Expand Up @@ -171,7 +171,7 @@ defined in this package. Note that operators need to be specified with their ful
i.e., `laplace` for a scalar Laplacian and `vector_laplace` for a Laplacian operating on
a vector field. Moreover, the dot product between two vector fields can be denoted by
using :code:`dot(field1, field2)` in the expression, and :code:`outer(field1, field2)`
calculates an outer product. In this case, boundary conditons for the operators can be
calculates an outer product. In this case, boundary conditions for the operators can be
specified using the `bc` argument, in which case the same boundary conditions are
applied to all operators. The additional argument `bc_ops` provides a more fine-grained
control, where conditions for each individual operator can be specified.
Expand All @@ -182,9 +182,9 @@ field is defined on a two-dimensional Cartesian grid, the variables :code:`x` an
:math:`x`-direction, one can use either :code:`(x > 5)` or :code:`heaviside(x - 5, 0.5)`,
where the second argument denotes the returned value in case the first argument is `0`.
For convenience, Cartesian coordinates are also available when using curvilinear grids.
The respective coordinate values at a point can be acccessed using :code:`cartesian[i]`,
The respective coordinate values at a point can be accessed using :code:`cartesian[i]`,
where :code:`i` is an index, e.g., `i=0` for the first axis (normally the x-axis).
Finally, expressions for equations in :class:`~pde.pdes.pde.PDE` can explicitely depend
Finally, expressions for equations in :class:`~pde.pdes.pde.PDE` can explicitly depend
on time, which is denoted by the variable :code:`t`.

Expressions also support user-defined functions via the `user_funcs` argument, which is
Expand Down
6 changes: 3 additions & 3 deletions docs/source/manual/basic_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ and the operators defined by the package.

Running the simulation
""""""""""""""""""""""
To solve the PDE, we first need to generate an initial condition, i.e., the initial
values of the fields that are evolved forward in time by the PDE.
To solve the PDE, we use the generated initial condition, i.e., the initial
field :code:`field`, which are evolved forward in time by the PDE.
This field also defined the geometry on which the PDE is solved.
In the simplest case, the solution is then obtain by running

Expand Down Expand Up @@ -135,6 +135,6 @@ subsequently:
for time, field in storage.items():
print(f"t={time}, field={field.magnitude}")
Moreover, a movie of the simulation can be created using
Moreover, a movie of the simulation can be created using :func:`~pde.visualization.movies.movie`, i.e., by calling
:code:`pde.movie(storage, filename=FILE)`, where `FILE` determines where the movie is
written.
7 changes: 4 additions & 3 deletions docs/source/manual/mathematical_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ methods as described below.

Curvilinear coordinates
"""""""""""""""""""""""
The package supports multiple curvilinear coordinate systems. They allow to exploit
The package supports multiple curvilinear coordinate systems through :mod:`pde.grids.coordinates`.
They allow to exploit
symmetries present in physical systems. Consequently, many grids implemented in
`py-pde` inherently assume symmetry of the described fields. However, a drawback of
curvilinear coordinates are the fact that the basis vectors now depend on position,
which makes tensor fields less intuitive and complicates the expression of differential
operators. To avoid confusion, we here specify the used coordinate systems explictely:
operators. To avoid confusion, we here specify the used coordinate systems explicitly:

Polar coordinates
-----------------
Expand Down Expand Up @@ -131,7 +132,7 @@ which is also indicated in the inset.

Differential operators are implemented using the usual second-order central
differences.
This requires the introducing of virtual support points at :math:`x_{-1}` and
This requires introducing virtual support points at :math:`x_{-1}` and
:math:`x_N`, which can be determined from the boundary conditions at
:math:`x=x_\mathrm{min}` and :math:`x=x_\mathrm{max}`, respectively.
The field classes automate this transparently.
Expand Down
15 changes: 4 additions & 11 deletions docs/source/manual/performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ To enable those, it's best to specify an initial time step, like so
eq.solve(t_range=10, dt=1e-3, adaptive=True)
An additional advantage of this choice is that it selects
:class:`~pde.solvers.explicit.ExplicitSolver`, which is also compiled with :mod:`numba`
for speed.
Alternatively, if only `t_range` is specified, the generic scipy-solver
:class:`~pde.solvers.scipy.ScipySolver`, which can be significantly slower.


Additional factors influencing the performance of the package include the compiler used
for :mod:`numpy`, :mod:`scipy`, and of course :mod:`numba`.
Moreover, the BLAS and LAPACK libraries might make a difference.
Expand All @@ -79,9 +72,9 @@ of typical packages

.. code-block:: bash
port install py37-numpy +gcc8+openblas
port install py37-scipy +gcc8+openblas
port install py37-numba +tbb
port install py312-numpy +gcc14+openblas
port install py312-scipy +gcc14+openblas
port install py312-numba +tbb
Note that you can disable the automatic multithreading via :ref:`configuration`.

Expand Down Expand Up @@ -139,7 +132,7 @@ To avoid confusion, trackers will only be used on one process and also the resul
only returned in one process to avoid problems where multiple process write data
simultaneously.
Consequently, the example above checked whether `result is None` (in which case the
corresponnding process is a child process) and only resumes analysis when the result is
corresponding process is a child process) and only resumes analysis when the result is
actually present.

The automatic treatment tries to use sensible default values, so typical simulations
Expand Down
2 changes: 1 addition & 1 deletion pde/grids/coordinates/cylindrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class CylindricalCoordinates(CoordinatesBase):
"""N-dimensional Cartesian coordinates."""
"""3-dimensional cylindrical coordinates."""

_singleton: CylindricalCoordinates | None = None
dim = 3
Expand Down

0 comments on commit 2acb835

Please sign in to comment.