# How to store time-dependent solution for every time-step

**URL:** <https://fenicsproject.discourse.group/t/how-to-store-time-dependent-solution-for-every-time-step/1498>\
**Category:** Uncategorized\
**Created:** [September 9, 2019, 7:37am UTC](https://fenicsproject.discourse.group/t/how-to-store-time-dependent-solution-for-every-time-step/1498 "2019-09-09T07:37:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yannik](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yannik](https://fenicsproject.discourse.group/u/Yannik)\
**Post date:** [September 9, 2019, 7:37am UTC](https://fenicsproject.discourse.group/t/how-to-store-time-dependent-solution-for-every-time-step/1498/1 "2019-09-09T07:37:58Z")

</div>

Hi everyone,

I’m using macOS Mojave (10.14.6), miniconda, and FEniCS 2018 with Python.  
I’m solving the wave equation (which does not matter here, it can be an arbitrary time-dependent PDE). This works, everything is fine. But I want to save the solution for every time-step in a variable, or something else, such that I can use it later and pass it to other subroutines. The TimeSeries won’t work here for me, so I tried to save it in a Python list as follows:

```
solution = []
compute solution y0 for time t = 0
solution(append(y0))
compute solution y1 for time t += dt
solution.append(y1)
loop over each time-step:
    compute new solution y
    solution.append(y)

```

But somehow this won’t work and I don’t know why. So is there a better way to store the solution of a time-dependent PDE?

---

<div class="post-metadata">

**Author:** ![Kart](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@Kart](https://fenicsproject.discourse.group/u/Kart)\
**Post date:** [September 9, 2019, 10:11am UTC](https://fenicsproject.discourse.group/t/how-to-store-time-dependent-solution-for-every-time-step/1498/2 "2019-09-09T10:11:17Z")

</div>

Hi Yannik,

I am assuming y is your trial function? If so, you could try:  
`solution.append(y.vector())`  
instead of:  
`solution.append(y)`  
So your solution will be a matrix containing a set of vectors for each time step.  
Hope this helps

---

<div class="post-metadata">

**Author:** ![Yannik](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yannik](https://fenicsproject.discourse.group/u/Yannik)\
**Post date:** [September 10, 2019, 8:43am UTC](https://fenicsproject.discourse.group/t/how-to-store-time-dependent-solution-for-every-time-step/1498/3 "2019-09-10T08:43:12Z")

</div>

Thank you very much. This has not solved it (I think the problem here is with the python-lists), but you lead me to the right way. I created a Matrix of the size dof \times \text{time-steps} and saved the nodal values `u.vector()[:]` for each time in the columns of the Matrix.
