← Back to team overview

ffc team mailing list archive

square root of a sum

 

Hi,

Given the following form

   DG09 = VectorElement("Discontinuous Lagrange", "tetrahedron", 0, 9)

   V  = TestFunction(DG09)
   Hp = TrialFunction(DG09)

   chi = 0.1

   # definitions
   def Mat(A):
       return ( [A[0], A[3], A[8]],
                [A[6], A[1], A[4]],
                [A[5], A[7], A[2]] )

   def sym(A):
       return 0.5*(A + transp(A))

   def skw(A):
       return 0.5*(A - transp(A))

   def denom(A):
        return 1/sqrt(dot(2*sym(A),2*sym(A)) + chi*dot(2*skw(A),2*skw(A)))

   a = denom(Mat(Hp))*dot(Mat(V),Mat(Hp))*dx

I get an error stating:

       a = denom(Mat(Hp))*dot(Mat(V),Mat(Hp))*dx
     File "invsqrtsum.py", line 30, in denom
       return 1/sqrt(dot(2*sym(A),2*sym(A)) + chi*dot(2*skw(A),2*skw(A)))
     File
   "/home/jtostie/builds/lib/python/ffc/compiler/language/operators.py",
   line 231, in sqrt
       return Form(v).sqrt()
     File
   "/home/jtostie/builds/lib/python/ffc/compiler/language/algebra.py",
   line 628, in sqrt
       raise FormError, (self, "Cannot take square root of sum.")

I can see that there is a check for len(self.monomials) > 1. Is there a fundamental reason why this can't be relaxed given a (guaranteed) positive sum? Is there another way around this restriction?
Thanks,
Jake


Follow ups