| title | Oscillator |
|---|---|
| permalink | tutorials-oscillator.html |
| keywords | Python, ODE |
| summary | We solve an oscillator with two masses in a partitioned fashion. Each mass is solved by an independent ODE. |
{% note %} Get the case files of this tutorial. Read how in the tutorials introduction. {% endnote %}
This tutorial solves a simple mass-spring oscillator with two masses and three springs. The system is cut at the middle spring and solved in a partitioned fashion:
Note that this case applies a Schwarz-type coupling method and not (like most other tutorials in this repository) a Dirichlet-Neumann coupling. This results in a symmetric setup of the solvers. We will refer to the solver computing the trajectory of Mass-Left and to the solver computing the trajectory of Mass-Right. For more information, please refer to [1].
This tutorial is only available in Python. You need to have preCICE and the Python bindings installed on your system.
- Python: An example solver using the preCICE Python bindings. This solver also depends on the Python libraries
numpy, which you can get from your system package manager or withpip3 install --user <package>.
Open two separate terminals and start both participants by calling:
cd python
./run.sh -land
cd python
./run.sh -rEach simulation run creates two files containing position and velocity of the two masses over time. These files are called trajectory-Mass-Left.csv and trajectory-Mass-Right.csv. You can use the script plot-trajectory.py for post-processing. Type python3 plot-trajectory --help to see available options. You can, for example plot the trajectory by running
python3 plot-trajectory.py python/output/trajectory-Mass-Left.csv TRAJECTORYThis allows you to study the effect of different time stepping schemes on energy conservation. Newmark beta conserves energy:
Generalized alpha does not conserve energy:
For details, refer to [1].
[1] V. Schüller, B. Rodenberg, B. Uekermann and H. Bungartz, A Simple Test Case for Convergence Order in Time and Energy Conservation of Black-Box Coupling Schemes, in: WCCM-APCOM2022. URL


