{ "cells": [ { "cell_type": "markdown", "id": "brakke_strings-0", "metadata": {}, "source": [ "# Brakke's samples: strings, metrics and other dimensions\n", "\n", "\n", "One-dimensional \"surfaces\" (strings) in the plane and in space, a background metric,\n", "and a three-dimensional bubble in four-dimensional space. For strings, `relax()`\n", "averages vertices but can't equiangulate.\n", "\n", "Each sample is run twice from its datafile: once with the recipe Brakke wrote into\n", "it (its `gogo` command, or the usage its comments describe), once with a default\n", "`ev.relax()` given as many refinements as the recipe does (`levels`). The table\n", "shows the energy each ends with, the residual (how far from equilibrium, see\n", "[Relaxing a surface](relaxing.md)), the facet count, the time, and what `relax()`\n", "reports: converged, stable, and any health issues. A lower energy on the same mesh\n", "is not always the better answer: a coarse mesh can lower its energy in ways the\n", "smooth surface can't, so where an exact value is known, the error against it is\n", "the measure. Times are from the documentation build and vary.\n", "\n", "This gallery assumes [Getting started](getting_started.md) and\n", "[Relaxing a surface](relaxing.md); its pages can be read in any order." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-1", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pyvista as pv\n", "import pysurfaceevolver as pyse\n", "import brakke_helpers as bh\n", "\n", "pv.set_jupyter_backend(\"static\")" ] }, { "cell_type": "markdown", "id": "brakke_strings-2", "metadata": {}, "source": [ "## `popstr.fe`: popping a string junction\n", "\n", "Four strings meeting at a point. For strings, Plateau's rule is three at a point, at\n", "120 degrees: the recipe pops the junction into two triple points (`o`), and so does\n", "`relax()` after converging." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-3", "metadata": {}, "outputs": [], "source": [ "print(bh.recipe(\"popstr.fe\"))\n", "runs = bh.compare(\"popstr.fe\")\n", "bh.show(runs, view=\"xy\")" ] }, { "cell_type": "markdown", "id": "brakke_strings-4", "metadata": {}, "source": [ "## `slidestr.fe`: a drop held in a corner\n", "\n", "A drop (in two dimensions: an area bounded by a string) on a hyperbolic slide, gravity\n", "pulling it down into the corner that holds it." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-5", "metadata": {}, "outputs": [], "source": [ "print(bh.recipe(\"slidestr.fe\"))\n", "runs = bh.compare(\"slidestr.fe\")\n", "bh.show(runs, view=\"xy\")" ] }, { "cell_type": "markdown", "id": "brakke_strings-6", "metadata": {}, "source": [ "## `100grain.fe`: a two-dimensional foam coarsening\n", "\n", "A Voronoi diagram of 100 cells in a periodic square, with automatic popping and\n", "chopping (`autopop`, `autochop`): edges that shrink away are deleted and the junctions\n", "popped as the foam coarsens. The cells have no fixed areas, so there is no equilibrium\n", "to reach; the file says to \"just do 'g' steps in big chunks\". Here 1000 of them,\n", "against a default `relax()`, which reports the foam unconverged." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-7", "metadata": {}, "outputs": [], "source": [ "runs = bh.compare(\"100grain.fe\", \"g 1000\")\n", "bh.show(runs, view=\"xy\")" ] }, { "cell_type": "markdown", "id": "brakke_strings-8", "metadata": {}, "source": [ "## `metric.fe`: a string in a curved metric\n", "\n", "A background metric that turns the punctured plane into a catenoid: the string loop\n", "shrinks onto the catenoid's throat (drawn in the plane's coordinates)." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-9", "metadata": {}, "outputs": [], "source": [ "print(bh.recipe(\"metric.fe\"))\n", "runs = bh.compare(\"metric.fe\")\n", "bh.show(runs, view=\"xy\")" ] }, { "cell_type": "markdown", "id": "brakke_strings-10", "metadata": {}, "source": [ "## `knotty.fe`: a trefoil knot\n", "\n", "A trefoil (3,2 torus knot) with a knot energy that keeps the string from crossing\n", "itself. The file defines several energies and length constraints; this is its default\n", "combination. Knot energies have many local minima: the recipe uses conjugate gradients\n", "(`U`) and may end in a different one." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-11", "metadata": {}, "outputs": [], "source": [ "print(bh.recipe(\"knotty.fe\"))\n", "runs = bh.compare(\"knotty.fe\")\n", "bh.show(runs)" ] }, { "cell_type": "markdown", "id": "brakke_strings-12", "metadata": {}, "source": [ "## `quadm.fe`: a film in a metric\n", "\n", "A soap film on a quadrilateral wire, in a background metric." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-13", "metadata": {}, "outputs": [], "source": [ "print(bh.recipe(\"quadm.fe\"))\n", "runs = bh.compare(\"quadm.fe\")\n", "bh.show(runs)" ] }, { "cell_type": "markdown", "id": "brakke_strings-14", "metadata": {}, "source": [ "## `simplex3.fe`: a bubble in four dimensions\n", "\n", "A three-dimensional bubble in four-dimensional space, starting as a simplex and\n", "becoming a 3-sphere, in Evolver's simplex representation. Evolver has no Hessian for\n", "bodies there (outside the Lagrange model), so `relax()` takes gradient steps only, and\n", "there is nothing to draw in three dimensions." ] }, { "cell_type": "code", "execution_count": null, "id": "brakke_strings-15", "metadata": {}, "outputs": [], "source": [ "print(bh.recipe(\"simplex3.fe\"))\n", "runs = bh.compare(\"simplex3.fe\")" ] }, { "cell_type": "markdown", "id": "brakke_strings-16", "metadata": {}, "source": [ "## Next\n", "\n", "Curved elements: [Brakke's samples: quadratic and Lagrange\n", "elements](brakke_lagrange.ipynb)." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }