cashocs.verification.shape_gradient_test#
- cashocs.verification.shape_gradient_test(sop: shape_optimization.ShapeOptimizationProblem, h: list[fenics.Function] | None = None, rng: np.random.RandomState | None = None) float [source]#
Performs a Taylor test to verify that the computed shape gradient is correct.
- Parameters:
sop (shape_optimization.ShapeOptimizationProblem) – The underlying shape optimization problem.
h (list[fenics.Function] | None) – The direction used to compute the directional derivative. If this is
None
, then a random direction is used (default isNone
).rng (np.random.RandomState | None) – A numpy random state for calculating a random direction
- Returns:
The convergence order from the Taylor test. If this is (approximately) 2 or larger, everything works as expected.
- Return type:
float