# Exporting and plotting derived quantities in time-dependent problem

**URL:** <https://fenicsproject.discourse.group/t/exporting-and-plotting-derived-quantities-in-time-dependent-problem/10878>\
**Category:** General\
**Created:** [April 8, 2023, 1:45am UTC](https://fenicsproject.discourse.group/t/exporting-and-plotting-derived-quantities-in-time-dependent-problem/10878 "2023-04-08T01:45:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [April 8, 2023, 9:22am UTC](https://fenicsproject.discourse.group/t/exporting-and-plotting-derived-quantities-in-time-dependent-problem/10878/2 "2023-04-08T09:22:10Z")

</div>

There are multiple things you should do to improve your code.  
First,

> [@Bao](#):
>
> \_fm = project(\_f1\*\* 2 + \_f2\*\* 2,W)

You should use `_fm.rename("fm","")` after projection to make time dependent visualization work.

Secondly, one should avoid calling

> [@Bao](#):
>
> solve(F == 0, f)

and

> [@Bao](#):
>
> \_fm = project(\_f1\*\* 2 + \_f2\*\* 2,W)

Inside loops, as these calls does not cache expensive calls to matrix creation, solver creation, and in the case of projection a reassembly of a time independent matrix (and subsequent LU factorization).

You should instead use  
`LUSolver`  
for projections, and  
`NonlinearVariationalSolver` for nonlinear problems.

In general, if you are new to Dolfin, it is recommended to use Dolfinx, see:

> [@The new DOLFINx solver is now recommended over DOLFIN](https://fenicsproject.discourse.group/t/the-new-dolfinx-solver-is-now-recommended-over-dolfin/8249):
>
> In April 2022 we released versions of the new FEniCS Project components; DOLFINx (v0.4.1) , FFCx (v0.4.2), Basix (v0.4.1) and UFL (2022.1.0.post0). These projects are hosted under our GitHub account at [FEniCS Project · GitHub](https://github.com/fenics) We now recommend that all new projects begin in the new DOLFINx problem solving environment, rather than the old DOLFIN problem solving environment. We consider DOLFINx to be superior to the old DOLFIN, particularly in terms of performance, scalability, API consistency and…

---

_[View the full topic](https://fenicsproject.discourse.group/t/exporting-and-plotting-derived-quantities-in-time-dependent-problem/10878)._
