← Blog

[Phys-sim] Ch.2 Optimization Framework

· Phys-sim

2.1 Optimization Time Integrator

Recall that implicit methods like Backward Euler required solving a linear system of equations. This is equivalent to solving an optimization problem:

xn+1=arg min⁡xE(x)where E(x)=12∣∣x−x~n∣∣M2+Δt2P(x).\begin{gathered} x^{n+1}=\argmin_{x} E(x)\\ where\ E(x)=\frac{1}{2}||x-\tilde x^n||_M^2 + \Delta t^2 P(x). \end{gathered}

Here, x~n=xn+Δtvn\tilde x^n = x^n + \Delta t v^n, the first term of E(x)E(x) is the inertia term. P(x),E(x)P(x), E(x) are the potential energy and incremental potential. The “incremental” part comes from the fact that E(x)E(x) depends on values from the previous time step, as can be seen in the inertia term.

Conservative Forces

For forces whose derivative of the potential energy is equal to the negative force, they are classified as conservative forces. This means that the total work done in a moving particle is independent of the path taken.

dP(x)dx=−f(x)\frac{dP(x)}{dx} = -f(x)

Examples include gravity and elasticity.

2.2 Dirichlet Boundary Conditions

Dirichlet boundary conditions (BC) are constraints on the values of parameters. For example, points that cannot move during simulation can be set as linear equality constraints, which are BC. The optimization problem now looks like:

min⁡xE(x) s.t. Ax=b,\min_x E(x)\ s.t.\ Ax=b,

where A∈Rm×dn,b∈RmA\in\R^{m\times dn}, b\in \R^{m}.

How does the added equality constraints change how we solve the optimization problem? For unconstrained problems, finding the minimum is equivalent to finding where the gradient is zero. For constrained problems, we use the KKT condition.

At the local minimum, the following KKT condition must be met:

∇E(x)−ATλ=0Ax=b.\begin{gathered} \nabla E(x) - A^T\lambda = 0 \\Ax = b. \end{gathered}

Here, λ∈Rm\lambda\in\R^m represents the Lagrange multiplier vector.

2.3 Contact

For MPM methods, a common approach to prevent interpenetration is by enforcing the Courant-Friedrichs-lewy(CFL) upper limit when choosing timestep sizes. For FEM methods, we need to exactly model contact forces, which is tricky because of its non-smooth nature. There isn’t a potential energy formulation for it.

Contact can be modeled by assessing the proximity of points. Since we want to avoid collision, we can ensure that the distance between different points never reduces to zero. The optimization problem with boundary conditions can be formulated as follows:

min⁡xE(x)s.t.Ax=b,∀k,ck(x)≥ϵ.\min_x E(x) s.t. Ax=b, \forall k, c_k(x) \geq \epsilon.

Here, ckc_k measures the distance between pairs of points on the surface, and ϵ→0\epsilon \rightarrow 0 is a tiny positive value to ensure no penetration is happening.

Formulating the optimization problem with contact constraints using KKT conditions, we get

∇E(x)−ATλ−Σkγk∇ck(x)=0,Ax=b,∀k,ck(x)−ϵ≥0,γk≥0,γk(ck(x)−ϵ)=0\begin{gathered} \nabla E(x) - A^T\lambda - \Sigma_k \gamma_k \nabla c_k(x) = 0,\\Ax=b,\\\forall k, c_k(x)-\epsilon \geq0,\gamma_k\geq 0, \gamma_k(c_k(x)-\epsilon)= 0 \end{gathered}

Here, ∇ck(x)\nabla c_k(x) points in the direction of the contact force for the contacting pair kk. The last condition, γk(ck(x)−ϵ)=0\gamma_k (c_k(x)-\epsilon) = 0, is the complementary slackness contition, which states that contact forces should be zero when not in contact or non-zero when in contact.

There are many methods available for solving optimization problems with inequality constraints.

  • Primal-Dual Methods: Solve the primal and dual problem simultaneously.
  • Projected Steepest Descent Methods: Modifies the classic steepest descent method (for unconstrained problems) by adding projection to enforce constraints. May struggle with ill-conditioned problems.
  • Interior-point methods (Barrier Methods): Introduces a “barrier function” to penalize infeasible solutions. This effectively transforms a constrained problem to an unconstrained one.

This book focuses on Incremental Potential Contact (IPC), a robust contact modeling method. It approximates contact with a smooth potential energy term. (I think this can be classified as barrier methods?)

2.4 Friction

Friction is another tricky force to model. Here are some reasons why. Friction acts very differently depending on whether the object is moving or static. In addition to that, the transition between static and moving friction is instantaneous, creating a non-smooth jump. It is not a conservative force, meaning it is state/path-dependent. It dissipates kinetic energy into heat, which is irreversible.

The Coulomb Friction model is the most widely used model. It is based on the maximal dissipation principal (MDP), and is capable of modeling the non-smooth transition between static and dynamic frictions.

  • Static Friction
    • is a reactive force that resists initial movement of the object.
  • Dynamic Friction
    • is a constant force that opposes the motion of a moving object.

MPM methods can inherently model friction using their grids, but is not as accurate as FEM methods in general. For FEMs, we can use their IPC model to incorporate an approximated potential energy term for friction.