Scientific ML Studio
Learn/ Studio Tour/ 3.3
3.3 · The blocks, one at a time

Set the boundary and initial conditions

One BC block per boundary, one IC block for the start. Without conditions the equation has many solutions and the network may find any of them.

A PDE on its own does not have a unique solution. The conditions pick one out. In the Lab they are two blocks.

  • Boundary condition (BC): what holds on one edge of the domain.
  • Initial condition (IC): what holds at the start, for problems that change in time.

Boundary conditions

Place one BC block for each boundary the Domain exposes. A rectangle has four, so you place four.

Wiring. Each BC block has one input, Boundary, and one output, the condition. Connect a Domain boundary port to the BC's Boundary input: BC1 to the first block, BC2 to the second, and so on. Then connect each BC's output to the Loss block's BC / IC input. Many wires may go into that one input.

On the canvas the outputs are named BC 1, BC 2, … in the order you placed the blocks. These are block numbers. They need not match the Domain's boundary names, and hovering over a BC's output tells you which Domain boundary it is attached to.

Your screenshot · a Domain with four boundary ports wired to four BC blocks, each wired on to the Loss block.

The four kinds

Choose Condition type on the block.

Type You enter What it enforces on that edge
Dirichlet (value) u = a formula $u$ equals the formula
Neumann (normal flux) du/dn = a formula the outward normal derivative equals the formula. 0.0 means insulated, or no flux
Robin numbers $a$, $b$, and g = a formula $a\,u + b\,\partial u/\partial n = g$
Periodic nothing $u$ and its normal derivative match those on the opposite edge

The formulas are written in the Domain's coordinates, and in t as well when the problem is time-dependent. A value that changes in time is fine: sin(pi*t) on a boundary. The rules for writing formulas are on Read and change a block's settings.

Which way is "outward"? Look at the arrows in the geometry figure on Define the domain. On the left edge of a rectangle the outward normal points left, so a positive flux there means the field increases to the left. If a Neumann result looks mirrored, check the sign against the outward normal.

Periodic edges pair up with the opposite edge: BC1 with BC2 on a line, and on a rectangle BC1 with BC2 and BC3 with BC4. A circle has no opposite edge, and the Graph check says so. Put a periodic block on both edges of a pair. The tie only has to be stated once, but the Graph check counts an edge as covered only when it has a block of its own.

Applies to network output matters only if your network has several outputs.

Initial condition

Only a time-dependent problem needs an IC. Tick Time dimension on the Domain first. That gives the Domain an Initial output.

  1. Place an IC block.
  2. Connect the Domain's Initial output to the IC's Initial input.
  3. Connect the IC's output to the Loss block's BC / IC input.
  4. Enter u(x, t_init) = as a formula in the spatial coordinates, for example sin(pi*x). The label reminds you that time is fixed here, so t is not available in this formula.

For an equation that is second order in time, like the wave equation, tick Initial velocity and enter u_t(x, t_init) = as well. The wave equation needs both a starting shape and a starting speed; 0.0 means released from rest.

What the Graph check says about conditions

Note What to do
No boundary conditions are wired in. The problem is under-determined. Add BC blocks and wire the Domain's boundaries into them.
No condition on BC2. Those boundaries are left free. That boundary has no BC block. Add one, or leave it free on purpose.
A Boundary condition block is not wired to any boundary port on the Domain. It is ignored. Wire the Domain's BC port into the block's Boundary input.
A time-evolving equation is an initial-value problem, but no Initial condition block is wired in. Add an IC block.
An Initial condition is wired in but the Domain has no time dimension… Either tick Time dimension or remove the IC.
An elliptic equation is steady: an initial condition does not apply to it. Remove the IC.
A second-order time equation needs an initial velocity as well as an initial value. Tick Initial velocity on the IC block.
A periodic condition on BC1 has no opposite edge on this geometry. A circle has no opposite edge; use another type.

How many conditions does a problem need?

Roughly: every boundary of the domain needs one condition, and a problem that changes in time needs an initial condition on top of that (two for the wave equation). Fewer than that and the problem is under-determined, so the network may converge to a solution that is not your solution. The Graph check is checking this for you, but it can only count; it cannot tell whether the values you chose make physical sense.

Next: building the network.