# Loose coupling (synchronisation after time window) with pypreCICE

**URL:** <https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599>\
**Category:** Is preCICE for me?\
**Tags:** python\
**Created:** [May 18, 2021, 2:21pm UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599 "2021-05-18T14:21:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulianSchl](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/julianschl/32/692_2.png) [@JulianSchl](https://precice.discourse.group/u/JulianSchl)\
**Post date:** [May 18, 2021, 2:21pm UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/1 "2021-05-18T14:21:50Z")

</div>

Hi,

I am wondering wether there is a guide to realize a loose coupling with the python interface pypreCICE .  
With loose coupling I mean the autonomous iteration of the solvers for every time window.  
After the compleation of every time window, the solvers should synchronize and check for convergence.

My guess to realize this constellation was to lookup the function `is_time_window_complete()` every iteration and then either exchange data or just advance to the next time step.  
Do you think this concept would work?  
And can I even advance in time steps without exchanging data?

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 18, 2021, 3:34pm UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/2 "2021-05-18T15:34:43Z")

</div>

> [@JulianSchl](#):
>
> And can I even advance in time steps without exchanging data?

Certainly yes, if you choose smaller time steps in the solvers than you use for the time windows used by preCICE. There is a nice description [in the documentation](https://precice.org/couple-your-code-timestep-sizes.html#fixed-time-window).

However, I am not sure what you mean with

> [@JulianSchl](#):
>
> With loose coupling I mean the autonomous iteration of the solvers for every time window.

What do you mean with “autonomous iteration of the solvers”? Do you mean time steps of solvers per time window? Do mean other iterations (Newton solver, solver for linear system of equations…)? “Loose coupling” is, as mentioned on Gitter by @uekerman, usually refers to “explicit” coupling that can be configured out-of-the-box changing the preCICE configuration.

Maybe you could elaborate on what you want to achieve.

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [May 18, 2021, 3:39pm UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/3 "2021-05-18T15:39:51Z")

</div>

This video could also help: [High-order and multi-rate time stepping with preCICE (Benjamin Rüth, preCICE Workshop 2020) - YouTube](https://www.youtube.com/watch?v=7NhBmcx_MmI)

---

<div class="post-metadata">

**Author:** ![JulianSchl](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/julianschl/32/692_2.png) [@JulianSchl](https://precice.discourse.group/u/JulianSchl)\
**Post date:** [May 18, 2021, 4:32pm UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/4 "2021-05-18T16:32:03Z")

</div>

Thank you for your reply!

> [@ajaust](#):
>
> What do you mean with “autonomous iteration of the solvers”? Do you mean time steps of solvers per time window? Do mean other iterations (Newton solver, solver for linear system of equations…)? “Loose coupling” is, as mentioned on Gitter by @uekerman, usually refers to “explicit” coupling that can be configured out-of-the-box changing the preCICE configuration.

I am sorry for the misunderstanding, I meant that the e.g. solid or fluid solver calculate their time window without exchanging data.  
I think preCICE provides a solution for this case with implicit [first participant](https://precice.org/couple-your-code-timestep-sizes.html#first-participant-prescribes-timestep-size) time stepping. If I understand it correctly, (for example) the solid solver could do 1 timestep, while the fluid solver is making 5 timesteps. After one time window, the solvers can exchange their results and maybe do the time window again (in case of divergence).

> [@uekerman](#):
>
> This video could also help: [High-order and multi-rate time stepping with preCICE (Benjamin Rüth, preCICE Workshop 2020) - YouTube](https://www.youtube.com/watch?v=7NhBmcx_MmI)

Nice video, I think now I better understand the reason for the change to preCICE 2!

---

<div class="post-metadata">

**Author:** ![Makis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/makis/32/25_2.png) [@Makis](https://precice.discourse.group/u/Makis)\
**Post date:** [May 18, 2021, 8:06pm UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/5 "2021-05-18T20:06:00Z")

</div>

> [@JulianSchl](#):
>
> I meant that the e.g. solid or fluid solver calculate their time window without exchanging data.

You probably already found everything you need, but maybe for the future reader: in our terms, what you describe we call “subcycling” and it currently works with any of the supporting coupling schemes. The participants can do as many uncoupled time steps as they need, while they have to synchronize at the end of every (arbitrary large) “coupling time window”. To do this, you simply set the solver’s timestep size as `dt = min(precice_dt, dt)` after an `advance()`.

---

<div class="post-metadata">

**Author:** ![JulianSchl](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/julianschl/32/692_2.png) [@JulianSchl](https://precice.discourse.group/u/JulianSchl)\
**Post date:** [May 19, 2021, 10:10am UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/6 "2021-05-19T10:10:35Z")

</div>

After overthinking the case again, I am not sure if I can realize this case of loose coupling with subcycling.  
I have tried to illustrate my intention below. My idea was to let the both solvers calculate their timesteps in one timewindow individually and exchange / compare their solutions after the end of every time window. Therefore I am wondering if it is possible exchange data (e.g. forces and displacement) for one time window in advance (prediction of potential data).

 ![Screenshot 2021-05-19 12.04.23](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/378583ee0d08f954a98348345b1a0963ff7249ea.png)

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [May 19, 2021, 10:50am UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/7 "2021-05-19T10:50:39Z")

</div>

The arrows you crossed out only mean that the solvers tell preCICE what timestep sizes they used, such that preCICE can track the time of both. No data is communicated here. Data is only communicated at the end of each time window.  
If I understand your case correctly, preCICE already does what you want.

> Therefore I am wondering if it is possible exchange data (e.g. forces and displacement) for one time window in advance (prediction of potential data).

You mean sth like an explicit coupling (every time window only computed once), but combined with some predictor-corrector method? This is not yet possible (but could be something @BenjaminRodenberg will add to preCICE in the future).

What you can do already now, however, is to use an implicit scheme. Then you have your predictor in the second iteration. And you could also restrict the amount of iterations to 2. Then you are pretty close to such a predictor-corrector scheme already.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [May 22, 2021, 10:51am UTC](https://precice.discourse.group/t/loose-coupling-synchronisation-after-time-window-with-pyprecice/599/8 "2021-05-22T10:51:25Z")

</div>

Closed on May 22, 2021, 10:51am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
