Skip to content

Commit

Permalink
adding more rigorous tests for product rule of hessian of two fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kishore-nori committed Nov 17, 2024
1 parent 757af98 commit 8d4d28f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/FieldsTests/FieldInterfacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ b = GenericField(bfun)
c = GenericField(cfun)

f = Operation(+)(Operation(*)(a,b), c)
∇f = (a)*b + (b)*a + (c)
cp = afun(p) * bfun(p) + cfun(p)
∇cp = (afun)(p)*bfun(p) + (bfun)(p)*afun(p) + (cfun)(p)
∇∇cp = ∇∇(afun)(p) * bfun(p) + afun(p) * ∇∇(bfun)(p) + 2*(afun)(p)(bfun)(p) + ∇∇(cfun)(p)
∇∇cp = ∇∇(afun)(p) * bfun(p) + afun(p) * ∇∇(bfun)(p) + (afun)(p)(bfun)(p) + (bfun)(p)(afun)(p) + ∇∇(cfun)(p)
test_field(f,p,cp)
test_field(f,p,cp, grad=∇cp, gradgrad=∇∇cp)

Expand All @@ -398,4 +399,9 @@ test_field(f,x,f.(x),grad=∇(f).(x),gradgrad=∇∇(f).(x))
test_field(f,z,f.(z))
test_field(f,z,f.(z),grad=(f).(z),gradgrad=∇∇(f).(z))

# this one checks by taking ∇ of ∇f to see if matches with rule for ∇∇(f)
test_field(∇f, p, ∇cp, grad=∇∇cp)
test_field(∇f, x, (f).(x), grad=∇∇(f).(x))
test_field(∇f, z, (f).(z), grad=∇∇(f).(z))

end # module

0 comments on commit 8d4d28f

Please sign in to comment.