# AssertionError: Mismatch of quadrature points!

**URL:** <https://fenicsproject.discourse.group/t/assertionerror-mismatch-of-quadrature-points/2486>\
**Category:** Uncategorized\
**Created:** [February 20, 2020, 8:35pm UTC](https://fenicsproject.discourse.group/t/assertionerror-mismatch-of-quadrature-points/2486 "2020-02-20T20:35:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djoums](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@djoums](https://fenicsproject.discourse.group/u/djoums)\
**Post date:** [February 20, 2020, 8:35pm UTC](https://fenicsproject.discourse.group/t/assertionerror-mismatch-of-quadrature-points/2486/1 "2020-02-20T20:35:00Z")

</div>

hello everyone  
I would like to model the growth phenomenon in the cardiac muscle according to the following equations below. the code I have written is the one where I calculate the growth tensor to form the elastic tensor.  
But I have a quadrature error.  
Has anyone ever modelled this phenomenon before? Please help.

![1](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/1X/94589544a09c28de0c2dc5b8564cf756068141f0.png) ![2](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/1X/94d1d41318ce165f03c167352c82b1ba73b83ca4.png) ![3](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/1X/7fde97956ac7aea4c58458a49d8d48ee8c744bf1.png) ![4](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/1X/26803b4c57cca6113e1b824a96b7f36c04bb7ada.png) ![5](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/1X/1320a986b79e9645739fc5af1b2dd9feba6b9267.png)  
where theta is the growth factor, lamda\_e the elastic stretch and the lamda\_h is the hydrostatic stretch.

here is the code function  
def growthfunction (f\_0, s\_0, n\_0, d,v):

t = np.linspace(0,1,4)  
dt=0.9  
N=len(t)  
O\_max=2  
O\_min=0  
gam=0.1  
lam=0.2  
lamda\_h=1  
I = Identity(d)  
F=I+v  
O\_0=1  
iterration=0  
err=1  
F\_g=O\_0\*I  
for j in range(N):

```
   F_gt=F_g.T
   FF_g=inner(f_0,(F_g.T*F_g)*f_0)
   lamda_g=sqrt(FF_g)
   #lamda_e=(1/lamda_g)*(f_0*(F.T/O_0)*(F/O_0)*f_0)^0.5
   O_1=O_0+dt*((1/gam)*(((O_max-O_0)/(O_max-O_min))**lam)*(lamda_g-lamda_h))
   F_g=O_1*I
   O_0=O_1
   
   print ('\n growth steps ' ,j)

```

return F\_g

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [February 21, 2020, 3:07pm UTC](https://fenicsproject.discourse.group/t/assertionerror-mismatch-of-quadrature-points/2486/2 "2020-02-21T15:07:23Z")

</div>

It’s not clear what’s going on from the given code, but the “Mismatch of quadrature points!” error usually occurs when a `Form`'s integrand involves a `Function` in a `"Quadrature"`-type `FunctionSpace`, but the `Form` is integrated with a different quadrature degree than that of the `"Quadrature"`-type `Function`. To clarify, here is an annotated snippet of code to illustrate:

```python
from dolfin import *
from ufl.algorithms.compute_form_data \
    import estimate_total_polynomial_degree

# Set up a quadrature function space:
mesh = UnitIntervalMesh(1)
q_deg = 3
print("Degree of quadrature element: "+str(q_deg))
Qe = FiniteElement("Quadrature", mesh.ufl_cell(),
                   degree=q_deg,
                   quad_scheme="default")
Q = FunctionSpace(mesh, Qe)

# Create a simple integrand for demonstration:
q_func = Function(Q)
q_func.interpolate(Expression("1",degree=0))
x = SpatialCoordinate(mesh)
f = x[0]*q_func

# Estimated degree is higher than the degree
# of the quadrature element; without forcing
# quadrature of forms to use a lower degree,
# this will result in an error.
f_deg = estimate_total_polynomial_degree(f)
print("Estimated degree of `f`: "+str(f_deg))

# Would cause "Mismatch of quadrature points",
# since `dx` defaults to using the estimated
# polynomial degree of the integrand:

#int_f = assemble(f*dx)

# Error avoided by manually setting quadrature
# degree for forms to match that of
# quadrature element:
dx = dx(metadata={"quadrature_degree":q_deg})
int_f = assemble(f*dx)

# Sanity check:
print("Result = " + str(int_f))

```

As shown in the code snippet, the usual way around this is to set the degree of the integration `Measure` to match the degree of the `"Quadrature"`-type `Function` needed in the integrand.

---

<div class="post-metadata">

**Author:** ![djoums](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@djoums](https://fenicsproject.discourse.group/u/djoums)\
**Post date:** [February 21, 2020, 3:38pm UTC](https://fenicsproject.discourse.group/t/assertionerror-mismatch-of-quadrature-points/2486/3 "2020-02-21T15:38:22Z")

</div>

Thank a lot kamensky I will try and give your a feedback. However I would like to know if there is a technic to found integrated degree quadratures manually.

Djoumessi René Thierry  
PhD student  
university of Dschang  
department of physics  
heart and complex system modelling.
