# Domains The domain says where a problem lives, and with it what happens at its edge: nothing, a repetition, or a wall. This page names the families of domains and helps you choose one. Each family has a page of its own. ```python import sympy as sp import pdemagic as pm from pdemagic import curves x, y = sp.symbols("x y", real=True) u = sp.Function("u")(x, y) ``` ## The families - **Free space**, `pm.FreeSpace(x, y, z)`: all of space, in any number of dimensions, with no wall anywhere. See [Free space and periodic directions](free-space.md). - **Periodic directions**, `pm.Space(x, y, periodic={x: (0, 2)})`: the problem repeats along the coordinates that are named, and is free along the others. A slab, a wire, a crystal. On the same page. - **Boxes with walls**, `pm.Box({x: (0, 1), y: (0, 1)})`: an interval, a rectangle, a box in any number of dimensions, with a boundary condition on each face. It can be periodic along some of its coordinates. See [Boxes with walls](boxes.md). - **Round domains**, `pm.Disk`, `pm.Ball` and `pm.Cylinder`: in polar, spherical and cylindrical coordinates, with vacuum outside or with a condition on the surface. With an inner radius they are a ring, a shell and a hollow cylinder. See [Disks, rings, balls, shells and cylinders](round.md). - **Shapes in the plane**, `pm.Region(x, y, curve, ...)`: whatever closed curves of lines and arcs bound, with holes and corners, and a condition on each piece of the boundary. See [Shapes in the plane](regions.md). The equation is the same on all of them. Only the domain changes, and with it whether a `boundary` is given: ```python equation = sp.Eq(-pm.laplacian(u), sp.exp(-8 * (x**2 + y**2))) triangle = curves.Polygon((-1, -1), (1, -1), (0, 1)) problems = [ pm.Problem(equation, domain=pm.FreeSpace(x, y)), pm.Problem(equation, domain=pm.Box({x: (-1, 1), y: (-1, 1)}), boundary=sp.Eq(u, 0)), pm.Problem(equation, domain=pm.Region(x, y, triangle), boundary=sp.Eq(u, 0)), ] kinds = [pm.plan(problem).method.kind for problem in problems] assert kinds == ["fourier", "collocation", "spectral_elements"] ``` Each family has its own method, which [the planner](planner.md) chooses. ## Which domain for which situation | The situation | The domain | |---|---| | Sources with nothing around them: charges, antennas, a wave packet | `pm.FreeSpace` | | Something that repeats in every direction: a crystal, a pattern | `pm.Space` with every coordinate periodic | | A slab or a wire: repeating along some directions, open along the others | `pm.Space` with some coordinates periodic | | An interval, a rectangle or a box with walls: a rod, a plate, a room | `pm.Box` | | A channel: walls across, repeating along | `pm.Box` with `periodic=[x]` | | A disk, a ring, a ball, a shell or a cylinder with a condition on its surface | `pm.Disk`, `pm.Ball`, `pm.Cylinder` with a `boundary` | | A charge that fills a disk, a ball or a cylinder, with vacuum outside | the same, without a `boundary` | | Any other shape in the plane: an L, a plate with a hole, half a disk | `pm.Region` | | Conductors and dielectrics with sharp surfaces, in space | `pm.FreeSpace` with [bodies](bodies.md) | Two domains can describe one shape: a disk is a `Disk`, and a `Region` that a circle bounds. The two take different equations. As a round domain the disk takes $a\,\nabla^2 u + c\,u = f$, and as a region any elliptic equation of second order, such as one with a mixed derivative. [What is solved where](../ref/equations.md) has the table. ## What no boundary means in free space Free space has no wall, and you state no boundary condition. The solution is the one that its sources produce, with nothing coming in from far away: - For Poisson's equation in three dimensions that is the potential that vanishes at infinity, the vacuum condition. - In one and two dimensions no solution vanishes at infinity unless the source has zero net charge. There it is the convolution of the source with the free-space Green's function, $-|x|/2$ in one dimension and $-\ln(r)/(2\pi)$ in two. - For [waves of one frequency](helmholtz.md) it is the solution in which the sources send waves out and nothing comes in. - In [time](time.md) nothing is reflected: the box holds everything that a wave reaches by the end of the time span. The computer still needs a box. You do not choose it: the planner puts it around the sources and records it in the plan. The box is not a wall, and the solution inside it is the one of all of space: ```python plan = pm.plan(problems[0]) assert plan.grid.periodic == [False, False] assert plan.grid.lower[0] < -1.8 and plan.grid.upper[0] > 1.8 print(plan.notes[1]) ``` ```text Box: chosen so that the source falls to 1e-12 of the maximum at the faces. ``` A source must therefore die away. For one that does not, the planner finds no box, and says so. ## What does not work yet - Shapes in space, and boundaries in the plane that are not made of lines and of arcs of circles and ellipses. - Boxes that are bounded along some directions and free along others. - Sectors of a disk as round domains, and parts of a ball other than shells. In the plane a sector is drawn as a region. - Periodic cells that are not rectangular. - Periodic directions together with more than three free ones. ## See also - [The reference of the domains](../ref/domains.md) and of [regions and their curves](../ref/regions.md). - [What is solved where](../ref/equations.md): the table of equations and domains. - [Boundary conditions](boundary-conditions.md), for the domains that have walls. - [The known limits](../dev/limits.md#domains). - [A shape of your own](../intro/tutorial-5-shapes.md), the tutorial on regions.