> For the complete documentation index, see [llms.txt](https://tlcfem.gitbook.io/suanpan-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tlcfem.gitbook.io/suanpan-manual/integrator/implicit/bathetwostep.md).

# BatheTwoStep

Starting from version 2.7, customisation of spectral radius ($$\rho\_\infty$$) and sub-step size ($$\gamma$$) is supported.

The algorithm is known to be able to conserve energy and momentum.

References:

1. [10.1016/j.compstruc.2006.09.004](https://doi.org/10.1016/j.compstruc.2006.09.004)
2. [10.1016/j.compstruc.2018.11.001](https://doi.org/10.1016/j.compstruc.2018.11.001)

The implementation follows the original algorithm. The only difference is the step size defined in `suanPan` is the mean step size of two sub-step sizes, that is $$\Delta{}t/2$$ in the references.

For further discussions on this type of algorithm, one can check the following references.

1. [10.1007/s11071-023-09065-7](https://doi.org/10.1007/s11071-023-09065-7)

## Syntax

```
integrator BatheTwoStep (1) [2] [3]
# (1) int, unique integrator tag
# [2] double, spectral radius, \rho_\infty, default: 0
# [2] double, sub-step size, gamma, default: 0.5
```

Using `integrator BatheTwoStep (1)` with two optional parameters omitted gives the same results as in versions prior to version 2.7.

The spectral radius $$\rho\_\infty$$ ranges from 0 to 1, both ends **inclusive**.

The sub-step size $$\gamma$$ ranges from 0 to 1, both ends **exclusive**.

## Theory

### The First Sub-step

For trapezoidal rule,

$$
v\_{n+1}=v\_n+\dfrac{\gamma\Delta{}t}{2}\left(a\_n+a\_{n+1}\right),
$$

$$
u\_{n+1}=u\_n+\dfrac{\gamma\Delta{}t}{2}\left(v\_n+v\_{n+1}\right).
$$

Then,

$$
u\_{n+1}=u\_n+\dfrac{\gamma\Delta{}t}{2}\left(v\_n+v\_n+\dfrac{\gamma\Delta{}t}{2}\left(a\_n+a\_{n+1}\right)\right),
$$

$$
\Delta{}u=\gamma\Delta{}tv\_n+\dfrac{\gamma^2\Delta{}t^2}{4}a\_n+\dfrac{\gamma^2\Delta{}t^2}{4}a\_{n+1}.
$$

One could obtain

$$
a\_{n+1}=\dfrac{4}{\gamma^2\Delta{}t^2}\Delta{}u-\dfrac{4}{\gamma\Delta{}t}v\_n-a\_n,\qquad
\Delta{}a=\dfrac{4}{\gamma^2\Delta{}t^2}\Delta{}u-\dfrac{4}{\gamma\Delta{}t}v\_n-2a\_n,
$$

$$
v\_{n+1}=\dfrac{2}{\gamma\Delta{}t}\Delta{}u-v\_n,\qquad
\Delta{}v=\dfrac{2}{\gamma\Delta{}t}\Delta{}u-2v\_n.
$$

The effective stiffness is then

$$
\bar{K}=K+\dfrac{2}{\gamma\Delta{}t}C+\dfrac{4}{\gamma^2\Delta{}t^2}M.
$$

### The Second Sub-step

The second step is computed by

$$
v\_{n+2}=v\_n+\Delta{}t\left(q\_0a\_n+q\_1a\_{n+1}+q\_2a\_{n+2}\right),
$$

$$
u\_{n+2}=u\_n+\Delta{}t\left(q\_0v\_n+q\_1v\_{n+1}+q\_2v\_{n+2}\right).
$$

The parameters satisfy $$q\_0+q\_1+q\_2=1$$, and

$$
q\_1=\dfrac{\rho\_\infty+1}{2\gamma\left(\rho\_\infty-1\right)+4},\qquad
q\_2=0.5-\gamma{}q\_1.
$$

Hence,

$$
a\_{n+2}=\dfrac{v\_{n+2}-v\_n}{q\_2\Delta{}t}-\dfrac{q\_0}{q\_2}a\_n-\dfrac{q\_1}{q\_2}a\_{n+1},
$$

$$
v\_{n+2}=\dfrac{u\_{n+2}-u\_n}{q\_2\Delta{}t}-\dfrac{q\_0}{q\_2}v\_n-\dfrac{q\_1}{q\_2}v\_{n+1}.
$$

The effective stiffness is then

$$
\bar{K}=K+\dfrac{1}{q\_2\Delta{}t}C+\dfrac{1}{q\_2^2\Delta{}t^2}M.
$$

## Accuracy Analysis

![bathetwostep-0.0](https://1124082496-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEquxr3H9WpPg4iPvT2mB%2Fuploads%2Fgit-blob-a7a2353ba7b5f8612538c84275b6939a2f6029de%2Fbathetwostep-0.0.svg?alt=media) ![bathetwostep-0.5](https://1124082496-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEquxr3H9WpPg4iPvT2mB%2Fuploads%2Fgit-blob-3ea8997ecdcdcf234e520532f0143b6c5f7007f6%2Fbathetwostep-0.5.svg?alt=media) ![bathetwostep-1.0](https://1124082496-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEquxr3H9WpPg4iPvT2mB%2Fuploads%2Fgit-blob-9859c7c280019d889b9dbab4f37ac5bd80b92602%2Fbathetwostep-1.0.svg?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tlcfem.gitbook.io/suanpan-manual/integrator/implicit/bathetwostep.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
