From a78bb6dfb820781eb01724c1a8850c0f30a78367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dion=20H=C3=A4fner?= Date: Thu, 19 Jun 2025 11:07:32 +0200 Subject: [PATCH] doc: fix equation rendering in shapeopt demo --- examples/fem-shapeopt/demo.ipynb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/fem-shapeopt/demo.ipynb b/examples/fem-shapeopt/demo.ipynb index c921a74..2b8b47d 100644 --- a/examples/fem-shapeopt/demo.ipynb +++ b/examples/fem-shapeopt/demo.ipynb @@ -29,9 +29,11 @@ "\n", "We denote the design space as a function $g$ that maps the design variables to a signed distance field. Then, we can then define the density field $\\rho(\\mathbf{x})$ as a function of a signed distance field (SDF) value $g(\\mathbf{x})$. Finally we denote the differentiable finite element method (FEM) solver as $f$, which takes the density field as input and returns the structure's compliance. Therefore, the optimization problem can be formulated as follows:\n", "\n", + "$$\n", "\\begin{equation}\n", "\\min_{\\theta} f(\\rho(g(\\theta))).\n", "\\end{equation}\n", + "$$\n", "\n", "Here, $\\theta$ is the vector of design variables (the $y$-coordinates of the vertices)." ] @@ -47,9 +49,11 @@ "\n", "Since we want use a gradient based optimizer, we need to compute the gradient of the compliance with respect to the design variables. Hence we are interested in the following derivative:\n", "\n", + "$$\n", "\\begin{equation}\n", "\\frac{\\partial f}{\\partial\\theta} = \\frac{\\partial f}{\\partial \\rho} \\cdot \\frac{\\partial \\rho}{\\partial g} \\cdot \\frac{\\partial g}{\\partial\\theta}\n", "\\end{equation}\n", + "$$\n", "\n", "Note that each term is a (Jacobian) matrix. With modern AD libraries such as [JAX](https://github.com/jax-ml/jax), backpropagation uses the vector-Jacobian-product to pull back the gradients over the entire pipeline, without ever materializing Jacobian matrices. This is a powerful feature, but it typically requires that the entire pipeline is implemented in a single monolithic application – which can be cumbersome and error-prone, and does not scale well to large applications or compute needs.\n", "\n", @@ -362,9 +366,11 @@ "\n", "Now that we have the signed distance field (SDF) from the design space, we can proceed to compute the *density field*, which is what the FEM solver expects. That is, we need to define a function $\\rho$ that maps the SDF to a density value. This function needs to be smooth and differentiable to ensure that the optimization process can effectively navigate the design space. We use a parametrized sigmoid function, which ensures that the density values are bounded between 0 and 1. Here, $s$ is the slope of the sigmoid and $\\varepsilon$ is the offset. The parameters $s$ and $\\varepsilon$ can be adjusted to control the steepness and position of the transition between 0 and 1 in the density field.\n", "\n", + "$$\n", "\\begin{equation}\n", " \\rho(\\text{SDF}) = \\frac{1}{1 + e^{s \\cdot \\text{SDF} - \\varepsilon}}\n", "\\end{equation}\n", + "$$\n", "\n", "Since this function is straightforward to implement, we can directly use the JAX library to define it." ]