From 8d4d28fa848c2fbf24fa0289f05fc6342a6b6589 Mon Sep 17 00:00:00 2001 From: Kishore Nori Date: Sun, 17 Nov 2024 22:57:39 +1100 Subject: [PATCH] adding more rigorous tests for product rule of hessian of two fields --- test/FieldsTests/FieldInterfacesTests.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/FieldsTests/FieldInterfacesTests.jl b/test/FieldsTests/FieldInterfacesTests.jl index fdef98b93..b24c10a8e 100644 --- a/test/FieldsTests/FieldInterfacesTests.jl +++ b/test/FieldsTests/FieldInterfacesTests.jl @@ -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) @@ -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