# Optimize a big model containing modules with different stiffness

**URL:** <https://discourse.julialang.org/t/optimize-a-big-model-containing-modules-with-different-stiffness/83530>\
**Category:** Modelling & Simulations\
**Tags:** diffeq, performance\
**Created:** [June 29, 2022, 5:54pm UTC](https://discourse.julialang.org/t/optimize-a-big-model-containing-modules-with-different-stiffness/83530 "2022-06-29T17:54:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amarantine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amarantine/32/28222_2.png) [@Amarantine](https://discourse.julialang.org/u/Amarantine)\
**Post date:** [June 29, 2022, 5:54pm UTC](https://discourse.julialang.org/t/optimize-a-big-model-containing-modules-with-different-stiffness/83530/1 "2022-06-29T17:54:00Z")

</div>

Hello people! I have a few modules that I connected together as a big model. The modules have different stiffness. For example, module A is not stiff but runs very slowly for each time step (it has a delay component), but module B is very stiff but runs relatively fast for each time step. I am wondering if there’s anyway to solve them together in a fast way (like computing module A every 50 time steps of B?). By the way, module A only feeds into B and does not get feedback from B, but there is need to connect them together instead of running them separately. Attached are the computational time / time step metrics for each module, and the number of time steps each module needs.

 ![computational time](https://global.discourse-cdn.com/julialang/original/3X/7/3/7354765b80e4452dbdcec2c4dc45099b9d787bc7.png)  
 ![time steps](https://global.discourse-cdn.com/julialang/original/3X/2/1/214b3177a4b3b72f9783f55e7710d22fdfc12ce5.png)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 29, 2022, 5:55pm UTC](https://discourse.julialang.org/t/optimize-a-big-model-containing-modules-with-different-stiffness/83530/2 "2022-06-29T17:55:12Z")

</div>

> [@Amarantine](#):
>
> By the way, module A only feeds into B and does not get feedback from B, but there is need to connect them together instead of running them separately

Then just solve model A first, and then use its continuous solution in model B.

---

<div class="post-metadata">

**Author:** ![Amarantine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amarantine/32/28222_2.png) [@Amarantine](https://discourse.julialang.org/u/Amarantine)\
**Post date:** [July 8, 2022, 11:22pm UTC](https://discourse.julialang.org/t/optimize-a-big-model-containing-modules-with-different-stiffness/83530/3 "2022-07-08T23:22:57Z")

</div>

What’s the most efficient way to use model A’s continuous solution in model B? Do I do something like `modelAsolution(time, idxs=1)` for the different indices at each time-step?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 9, 2022, 4:21am UTC](https://discourse.julialang.org/t/optimize-a-big-model-containing-modules-with-different-stiffness/83530/4 "2022-07-09T04:21:59Z")

</div>

yes
