-
Notifications
You must be signed in to change notification settings - Fork 38
New integration schemes - new doc ! #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bakpaul
wants to merge
10
commits into
sofa-framework:master
Choose a base branch
from
bakpaul:27_07_start_doc_changes_for_new_integration_schemes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f75950a
start generic changes for main principles
bakpaul c7cfaeb
Add some equations
bakpaul 55b9c77
Add all genberal equations
bakpaul 53d4484
Finalize the main principles
bakpaul 952d7ff
Rename folder/files
bakpaul 07cecc3
Minimal renaming in IS files
bakpaul d858bf2
Remove flowcharts as they are really quickly outdated
bakpaul 458f8c1
Add some insights on the API
bakpaul ddf4efe
Add components rewritting
bakpaul f2bd981
Remove TODO link as they can be guessed
bakpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
426 changes: 371 additions & 55 deletions
426
20_Simulation_Principles/40_System_Resolution/10_Integration_Scheme.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...omponents/40_IntegrationScheme/20_Backward/20_EulerImplicitIntegrationScheme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| EulerImplicitIntegrationScheme | ||
| =================== | ||
|
|
||
| This component belongs to the category of [integration schemes](../../../../simulation-principles/system-resolution/integration-scheme/). This scheme builds the system following an implicit scheme: forces are considered based on the state information at the next time step $x(t+dt)$, unknown at the current time step. | ||
|
|
||
| This is the most broadly used integration scheme thank's to its unconditional stability and simplicity. | ||
|
|
||
| It is recommended to read the theoretical part of the [integration schemes](../../../../simulation-principles/system-resolution/integration-scheme/) page to understand the following. | ||
|
|
||
| The EulerImplicitIntegrationScheme inherits from VelocityBaseIntegrationScheme because its integration scheme in velocity is invertible. Its equations are the following : | ||
|
|
||
| $$ | ||
| \begin{aligned} | ||
| g_{\boldsymbol{x}}^{(t,h)} &: \boldsymbol{v}, \boldsymbol{a} \mapsto \boldsymbol{x}_t + h \boldsymbol{v} \\ | ||
| g_{\boldsymbol{v}}^{(t,h)} &: \boldsymbol{a} \mapsto \boldsymbol{v}_t + h \boldsymbol{a} | ||
| \end{aligned} | ||
| $$ | ||
|
|
||
|
|
||
| #### API specialization | ||
|
|
||
| As explained in the [IntegrationScheme](../../../../simulation-principles/system-resolution/integration-scheme/) documentation, the specilization consist in implementing 4 methods that requires the knowledge of four terms/expressions. for Euler implicit they are the following : | ||
| $$ | ||
| \begin{aligned} | ||
| &\tilde{g}_{\boldsymbol{x}}^{(t,h)} \equiv g_{\boldsymbol{x}}^{(t,h)} \\ | ||
| &g_{\boldsymbol{v}}^{(t,h)-1} : \boldsymbol{v} \mapsto \frac{1}{h}(\boldsymbol{v} - \boldsymbol{v}_t) | ||
| \end{aligned} | ||
| \qquad \qquad \qquad | ||
| \begin{aligned} | ||
| &\frac{\mathrm{d} \tilde{g}_{\boldsymbol{x}}^{(t,h)}}{\mathrm{d} \boldsymbol{v}} = h \\ | ||
| &\frac{\mathrm{d} g_{\boldsymbol{v}}^{(t,h)-1}}{\mathrm{d} \boldsymbol{v}} = \frac{1}{h} | ||
| \end{aligned} | ||
| $$ | ||
|
|
||
|
|
||
| #### Trapezoidal rule | ||
|
|
||
| Activating the trapezoidalScheme option of the Euler implicit scheme will make the scheme less dissipative. This will apply the [trapezoidal rule](https://en.wikipedia.org/wiki/Trapezoidal_rule) to the velocity integration, and thus will increase the order of the time integration, which is known to be less dissipative. | ||
| It is also known to increase robustness and stability to the time integration due to the order 2 in time of this trapezoidal scheme. The modified scheme is the following: | ||
|
|
||
| $$ | ||
| \begin{aligned} | ||
| g_{\boldsymbol{x}}^{(t,h)} &: \boldsymbol{v}, \boldsymbol{a} \mapsto \boldsymbol{x}_t + \frac{h}{2} \boldsymbol{v_t} + \frac{h}{2} \boldsymbol{v} \\ | ||
| g_{\boldsymbol{v}}^{(t,h)} &: \boldsymbol{a} \mapsto \boldsymbol{v}_t + h \boldsymbol{a} | ||
| \end{aligned} | ||
| $$ | ||
|
|
||
| This results in the updated term: | ||
|
|
||
| $$ | ||
|
|
||
| \frac{\mathrm{d} \tilde{g}_{\boldsymbol{x}}^{(t,h)}}{\mathrm{d} \boldsymbol{v}} = h/2 | ||
| $$ | ||
|
|
||
| To activate this trapezoidal rule, you need to use the data `trapezoidalScheme=true`. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| The EulerImplicitIntegrationScheme **requires**: | ||
|
|
||
| - a [LinearSolver](../../../../simulation-principles/system-resolution/linear-solver/) to solve the linear system | ||
| - and a MechanicalObject to store the state vectors. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ponents/40_IntegrationScheme/20_Backward/60_NewmarkImplicitIntegrationScheme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| NewmarkIntegrationScheme | ||
| ===================== | ||
|
|
||
| This component belongs to the category of [integration schemes](../../../../simulation-principles/system-resolution/integration-scheme/). This scheme builds the system following an implicit scheme: forces are considered based on the state information at the next time step $x(t+dt)$, unknown at the current time step. | ||
|
|
||
| It is recommended to read the theoretical part of the [integration schemes](../../../../simulation-principles/system-resolution/integration-scheme/) page to understand the following. | ||
|
|
||
| The Newmark-$\beta$ integration scheme is a parametrized integration scheme. It presents a set of two parameters $\zeta = (\beta, \gamma)$, balancing the 'implicitness' of the solver: | ||
| 1. With $\zeta =(0,0.5)$, the scheme is an explicit central difference scheme | ||
| 2. With $\zeta =(0.25,0.5)$ it behaves like an average constant acceleration scheme | ||
| 3. With $\zeta =(1/6,0.5)$ it behaves like a linear accelerations scheme | ||
| 4. If $2 \beta \geq \gamma \geq 1/2$, then the Newmark-$\beta$ method is stable regardless of the size of the time-step | ||
|
|
||
| It inherits from AccelerationBAsedIntegrationScheme as only the acceleration integration is implicit. Its equations are the following : | ||
|
|
||
| $$ | ||
| \begin{aligned} | ||
| g_{\boldsymbol{x}}^{(t,h)} &: \boldsymbol{v}, \boldsymbol{a} \mapsto \boldsymbol{x}_t + h \boldsymbol{v}_t + h^2\left[\left(\frac{1}{2} - \beta\right)\boldsymbol{a}_t + \beta \boldsymbol{a}\right] \\ | ||
| g_{\boldsymbol{v}}^{(t,h)} &: \boldsymbol{a} \mapsto \boldsymbol{v}_t + h \left[(1-\gamma)\boldsymbol{a}_t + \gamma \boldsymbol{a}\right] | ||
| \end{aligned} | ||
| $$ | ||
|
|
||
|
|
||
| #### API specialization | ||
|
|
||
| As explained in the [IntegrationScheme](../../../../simulation-principles/system-resolution/integration-scheme/) documentation, the specialization consist in implementing 5 methods that requires the knowledge of four terms/expressions. For Newmark-$\beta$ they are the following : | ||
| $$ | ||
| \frac{\mathrm{d} g_{\boldsymbol{x}}^{(t,h)}}{\mathrm{d} \boldsymbol{v}} = 0 | ||
| \qquad \qquad \qquad | ||
| \frac{\mathrm{d} g_{\boldsymbol{x}}^{(t,h)}}{\mathrm{d} \boldsymbol{a}} = h^2\beta | ||
| \qquad \qquad \qquad | ||
| \frac{\mathrm{d} g_{\boldsymbol{v}}^{(t,h)}}{\mathrm{d} \boldsymbol{a}} = h \gamma | ||
| $$ | ||
|
|
||
|
|
||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| At each simulation step and each Newton Raphson iteration, the NewmarkIntegrationScheme **requires**: | ||
|
|
||
| - a [LinearSolver](../../../../simulation-principles/system-resolution/linear-solver/) to solve the linear system | ||
| - and a MechanicalObject to store the state vectors. |
69 changes: 69 additions & 0 deletions
69
30_Components/40_IntegrationScheme/20_Backward/BDFIntegrationScheme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| BDFIntegrationScheme | ||
| ============ | ||
|
|
||
| This component belongs to the category of [integration schemes](../../../../simulation-principles/system-resolution/integration-scheme/). | ||
| It is an implicit method for the numerical integration of the ODE resulting from Newton's second law of motion. | ||
|
|
||
| It is recommended to read the theoretical part of the [integration schemes](../../../../simulation-principles/system-resolution/integration-scheme/) page to understand the following. | ||
|
|
||
| The method relies on [Backward Differentiation Formula](https://en.wikipedia.org/wiki/Backward_differentiation_formula) (BDF). This is a special case of [linear multistep method](https://en.wikipedia.org/wiki/Linear_multistep_method). | ||
| To integrate the ODE in time, it uses information from the previous time steps to compute the next step. | ||
| It establishes a linear combination of the unknown states, the previous states and the values of the ODE function when applied on those states. | ||
|
|
||
| It the specific case of BDF, the coefficients of the linear combination come from the approximation of the function by a Lagrange interpolation polynomial. | ||
| The order of the BDF is the number of previous time steps required to approximate the interpolation polynomial. | ||
| The first-order BDF requires a single time step in the past to compute the next. | ||
| It corresponds to the [backward Euler method](EulerImplicitSolver.md). | ||
| The coefficients are unique for a given order, but can be influenced by a change of time step size. | ||
| The SOFA component supports any order, and any change of time step size. | ||
|
|
||
| In the following we are going to present the generic linear multistep method equations from which BFD derives. It has to be noted that we made the choice to only apply the linear multi step method to the position integration, not on the velocity. Using it to both decreases the stability margin of the integration scheme, leading to big instabilities in the scenes. | ||
|
|
||
| The LinearMultistepIntegrationScheme inherits from VelocityBaseIntegrationScheme because its integration scheme in velocity is invertible. Its equations are the following : | ||
|
|
||
| $$ | ||
| \begin{aligned} | ||
| g_{\boldsymbol{x}}^{(t,h)} &: \boldsymbol{v}, \boldsymbol{a} \mapsto - \sum_{j=1}^{n} \frac{\alpha_j}{\alpha_{n+1}} \boldsymbol{x}_{t-n+j} + h \frac{\beta_{n+1}}{\alpha_{n+1}} \boldsymbol{v} + h \sum_{j=1}^{n} \frac{\beta_j}{\alpha_{n+1}} \boldsymbol{v}_{t-n+j} \\ | ||
| g_{\boldsymbol{v}}^{(t,h)} &: \boldsymbol{a} \mapsto \boldsymbol{v}_{t} + h \boldsymbol{a} | ||
| \end{aligned} | ||
| $$ | ||
|
|
||
| with $n$ the order of the integration scheme | ||
|
|
||
| #### API specialization | ||
|
|
||
| As explained in the [IntegrationScheme](../../../../simulation-principles/system-resolution/integration-scheme/) documentation, the specilization consist in implementing 4 methods that requires the knowledge of four terms/expressions. for Euler implicit they are the following : | ||
| $$ | ||
| \begin{aligned} | ||
| &\tilde{g}_{\boldsymbol{x}}^{(t,h)} \equiv g_{\boldsymbol{x}}^{(t,h)} \\ | ||
| &g_{\boldsymbol{v}}^{(t,h)-1} : \boldsymbol{v} \mapsto \frac{\boldsymbol{v} - \boldsymbol{v}_t}{h} | ||
| \end{aligned} | ||
| \qquad \qquad \qquad | ||
| \begin{aligned} | ||
| &\frac{\mathrm{d} \tilde{g}_{\boldsymbol{x}}^{(t,h)}}{\mathrm{d} \boldsymbol{v}} = h \frac{\beta_{n+1}}{\alpha_{n+1}} \\ | ||
| &\frac{\mathrm{d} g_{\boldsymbol{v}}^{(t,h)-1}}{\mathrm{d} \boldsymbol{v}} = \frac{1}{h} | ||
| \end{aligned} | ||
| $$ | ||
|
|
||
|
|
||
| #### BDF implementation | ||
|
|
||
| The generic implementation of LinearMultistepIntegrationScheme requires to overide only one virtual funciton being : | ||
|
|
||
| ```cpp | ||
| // Method that will compute the $\alpha$ and $\beta factors$ | ||
| virtual void computeFactors() = 0; | ||
| ``` | ||
|
|
||
| The the implementation of BDFIntegrationScheme only computes those terms using the previously cited Lagrange polynomial interpolation. | ||
|
|
||
|
|
||
| ----- | ||
|
|
||
| The BDFIntegrationScheme **requires**: | ||
|
|
||
| - a [LinearSolver](../../../../simulation-principles/system-resolution/linear-solver/) to solve the linear system | ||
| - and a MechanicalObject to store the state vectors. | ||
|
|
||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me rethink that we could have kept only "StaticEquilibrium" as a class name, don't you think (for later PR) ?