Skip to content

Commit a2f5a91

Browse files
authored
doc: Fix equation rendering in shapeopt demo (#46)
Verified manually by building docs locally.
1 parent 7150049 commit a2f5a91

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/fem-shapeopt/demo.ipynb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
"\n",
3030
"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",
3131
"\n",
32+
"$$\n",
3233
"\\begin{equation}\n",
3334
"\\min_{\\theta} f(\\rho(g(\\theta))).\n",
3435
"\\end{equation}\n",
36+
"$$\n",
3537
"\n",
3638
"Here, $\\theta$ is the vector of design variables (the $y$-coordinates of the vertices)."
3739
]
@@ -47,9 +49,11 @@
4749
"\n",
4850
"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",
4951
"\n",
52+
"$$\n",
5053
"\\begin{equation}\n",
5154
"\\frac{\\partial f}{\\partial\\theta} = \\frac{\\partial f}{\\partial \\rho} \\cdot \\frac{\\partial \\rho}{\\partial g} \\cdot \\frac{\\partial g}{\\partial\\theta}\n",
5255
"\\end{equation}\n",
56+
"$$\n",
5357
"\n",
5458
"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",
5559
"\n",
@@ -362,9 +366,11 @@
362366
"\n",
363367
"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",
364368
"\n",
369+
"$$\n",
365370
"\\begin{equation}\n",
366371
" \\rho(\\text{SDF}) = \\frac{1}{1 + e^{s \\cdot \\text{SDF} - \\varepsilon}}\n",
367372
"\\end{equation}\n",
373+
"$$\n",
368374
"\n",
369375
"Since this function is straightforward to implement, we can directly use the JAX library to define it."
370376
]

0 commit comments

Comments
 (0)