# Reuse Factorized Simulation Problem

**URL:** <https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546>\
**Category:** Uncategorized\
**Created:** [March 17, 2023, 1:48pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546 "2023-03-17T13:48:13Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmcclellan](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cmcclellan](https://calculix.discourse.group/u/cmcclellan)\
**Post date:** [March 17, 2023, 1:48pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/1 "2023-03-17T13:48:13Z")

</div>

Hi All,

I need to preform 100s of linear thermal simulations on a single mesh where all I do between different steps is change the boundary temperatures. I was wondering if there is a way to use one of the direct solvers to factor the matrix once and then use the factored matrix for all of the simulations, instead of refactored the matrix for every simulation.

Thanks!

---

<div class="post-metadata">

**Author:** ![Calc\_em](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Calc\_em](https://calculix.discourse.group/u/Calc_em)\
**Post date:** [March 17, 2023, 2:18pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/2 "2023-03-17T14:18:59Z")

</div>

The CalculiX functionality closest to what you want to achieve is restart capability. It allows you to run the first step of the analysis once and then run more steps with different settings without having to recalculate that first step. So you could even solve an empty step (e.g. with initial temperature only) and then follow it with multiple versions of the second step. All of them would continue from the first one, with conductivity matrix already calculated.

---

<div class="post-metadata">

**Author:** ![Disla](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/disla/32/3548_2.png) [@Disla](https://calculix.discourse.group/u/Disla)\
**Post date:** [March 17, 2023, 3:30pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/3 "2023-03-17T15:30:40Z")

</div>

I’m courious about this question.  
¿Wouldn’t it be the same to set up a time varing temperature BC and run a transient?.

---

<div class="post-metadata">

**Author:** ![Calc\_em](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Calc\_em](https://calculix.discourse.group/u/Calc_em)\
**Post date:** [March 17, 2023, 3:46pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/4 "2023-03-17T15:46:08Z")

</div>

It seems that the OP wants independent load cases with different thermal conditions, not a continuous analysis just with BCs changing over time. If not then amplitude could indeed help.

---

<div class="post-metadata">

**Author:** ![cmcclellan](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cmcclellan](https://calculix.discourse.group/u/cmcclellan)\
**Post date:** [March 17, 2023, 4:01pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/5 "2023-03-17T16:01:30Z")

</div>

Thank you all for the advice. Yes, I’m looking for independent static simulations, not transient analysis.

I tried using restart, but it doesn’t seem to store the decomposed matrix as SPOOLES factors it again for the 2nd step. Here are examples:  
First file step

```auto
*initial conditions, type=temperature
Nall,0.0

*STEP
*RESTART,WRITE

*HEAT TRANSFER, STEADY STATE,
1.0,1.0

*END STEP

```

I then copy the rout to rin for the second file:

```auto
*STEP
*RESTART,READ,STEP=1
***********************************************************
*HEAT TRANSFER, STEADY STATE,
1.0,1.0

*BOUNDARY
BC1,11,11,1.0

*BOUNDARY
BC2,11,11,0.0

*END STEP

```

---

<div class="post-metadata">

**Author:** ![Calc\_em](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Calc\_em](https://calculix.discourse.group/u/Calc_em)\
**Post date:** [March 17, 2023, 5:20pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/6 "2023-03-17T17:20:22Z")

</div>

This functionality is supposed to significantly speed up analyses by avoiding the need to recalculate common steps. Another application is to continue analyses that were stopped for some reason.

I don’t know exactly how it works internally but it’s possible that CalculiX repeats some stages of calculations. It doesn’t repeat that whole step for sure though.

Does it work with \*RESTART, READ placed between \*STEP and \*HEAT TRANSFER ? Normally, it’s placed before the \*STEP keyword.

---

<div class="post-metadata">

**Author:** ![cmcclellan](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cmcclellan](https://calculix.discourse.group/u/cmcclellan)\
**Post date:** [March 17, 2023, 7:53pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/7 "2023-03-17T19:53:15Z")

</div>

I see, thanks for the info. I did not see a change when moving the RESTART after HEAT TRANSFER.

I’ll mess around with it more today with different structures. It’s also possible I could do something like Disla suggested with large time steps to converge to steady-state quickly (I’ve never done transient in Calculix though so I’m not sure).

Thank you both for the advice! I’ll reply back here if I make more progress.

---

<div class="post-metadata">

**Author:** ![fgr](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@fgr](https://calculix.discourse.group/u/fgr)\
**Post date:** [March 17, 2023, 8:04pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/8 "2023-03-17T20:04:59Z")

</div>

According to the manual section 7.104 “restart, read” should be the very first non-comment line in the data set.  
I have never tested it on a thermal calculation but static linear/nonlinear it works this way.

---

<div class="post-metadata">

**Author:** ![vicmw](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@vicmw](https://calculix.discourse.group/u/vicmw)\
**Post date:** [March 18, 2023, 9:58am UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/9 "2023-03-18T09:58:52Z")

</div>

I didn’t think it was possible to reuse a matrix factorization when you’re changing the values of the constraints. Temperature constraints affect the matrix, not just the load vector.

---

<div class="post-metadata">

**Author:** ![jbr](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jbr](https://calculix.discourse.group/u/jbr)\
**Post date:** [March 18, 2023, 4:37pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/10 "2023-03-18T16:37:02Z")

</div>

Could you use `*STEP, PERTURBATION`? I’m assuming these are all small perturbations in the temperature field and no changes in the boundary conditions, right?

---

<div class="post-metadata">

**Author:** ![cmcclellan](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cmcclellan](https://calculix.discourse.group/u/cmcclellan)\
**Post date:** [March 20, 2023, 8:15pm UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/11 "2023-03-20T20:15:47Z")

</div>

Thanks all for the advice. These are changes in the boundary conditions, not small perturbations, so it seems it is not possible to reuse the factorized matrix for different temperature BCs.

---

<div class="post-metadata">

**Author:** ![vicmw](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@vicmw](https://calculix.discourse.group/u/vicmw)\
**Post date:** [May 5, 2023, 9:22am UTC](https://calculix.discourse.group/t/reuse-factorized-simulation-problem/1546/12 "2023-05-05T09:22:10Z")

</div>

If CCX does reuse the factorization, there is still a way. You can approximate a fixed temperature BC using a heat flow rate through a constant thermal resistance to a constant fixed temperature sink. Then you set the heat flow rate to control the temperature at the boundary of your actual model. It’s analogous to a Norton equivalent circuit in electronics.
