# RuntimeError: Use 'Function.copy(deepcopy=True)' for copying

**URL:** <https://fenicsproject.discourse.group/t/runtimeerror-use-function-copy-deepcopy-true-for-copying/3721>\
**Category:** Linear Algebra\
**Created:** [July 8, 2020, 7:41am UTC](https://fenicsproject.discourse.group/t/runtimeerror-use-function-copy-deepcopy-true-for-copying/3721 "2020-07-08T07:41:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lschm53](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/lschm53/32/1385_2.png) [@lschm53](https://fenicsproject.discourse.group/u/lschm53)\
**Post date:** [July 8, 2020, 7:41am UTC](https://fenicsproject.discourse.group/t/runtimeerror-use-function-copy-deepcopy-true-for-copying/3721/1 "2020-07-08T07:41:08Z")

</div>

Hi,

i am trying to compute a program to identify the orientation of fibers at any time in tensor form of form 3x3 on a cubic mesh.  
So am trying to define a TensorFunctionSpace for the fiber orientation and a VectorFunctionSpace one for the Matrix (Material). I have the following beginning of my code:

```python
from fenics import *
from mshr import *
import numpy as np

T = 5.0 # final time
num_steps = 100 # number of time steps
dt = T / num_steps # time step size
eps = 0.01 # diffusion coefficient

# Read mesh 
mesh = UnitSquareMesh(8, 8, "left/right")

# Define function spaces
W = VectorFunctionSpace(mesh, 'P', 2)
V = Function(TensorFunctionSpace(mesh, "Lagrange", 1, shape = (3,3)))

#Define boundaries
inflow = 'near(x[0], 0)'
walls = 'near(x[1], 0) || near(x[1], 1)'

#Define boundary conditions
bco_inflow = DirichletBC(W, Constant((0,0)), inflow)     
bco_noslip = DirichletBC(W, Constant((0, 0)), walls) 
bco = [bco_noslip]

#Define Test-function
v = TestFunction(W)

# Define functions for velocity and orientations
u = Function(W) #velocity
o = Function(V) #orientation
o_n = Function(V) #orientation at next time step

'''
I get following Error Message:

RuntimeError: Use 'Function.copy(deepcopy=True)' for copying

What does that mean? I am in advance sorry for bad coding, really a newbie to FEniCs and programming.

Thanks in advance.
'''
```

---

<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:** [July 8, 2020, 8:10am UTC](https://fenicsproject.discourse.group/t/runtimeerror-use-function-copy-deepcopy-true-for-copying/3721/2 "2020-07-08T08:10:48Z")

</div>

> [@lschm53](#):
>
> `V = Function(TensorFunctionSpace(mesh, "Lagrange", 1, shape = (3,3)))`

If you remove the function-wrapper here, everything should work nicely.

---

<div class="post-metadata">

**Author:** ![lschm53](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/lschm53/32/1385_2.png) [@lschm53](https://fenicsproject.discourse.group/u/lschm53)\
**Post date:** [July 8, 2020, 8:12am UTC](https://fenicsproject.discourse.group/t/runtimeerror-use-function-copy-deepcopy-true-for-copying/3721/3 "2020-07-08T08:12:55Z")

</div>

Thanks, it worked out.
