Y YASPS
Docs menu
Getting started Scene Mesh Primitive Primitive union Connectivity Attribute Minimizer Solver Differentiator Matrix Jacobian Hessian Gradient Examples Dropping in a container Cubify Inverse simulation

API reference · 12

Hessian

A symmetric block-sparse second derivative together with the symbolic terms needed to assemble its numeric values and gradient.

Hessians are normally returned by differentiator.diff2 when its two target lists match.

hessian

hessian(wrt, local_targets=[], dynamic_instances=False)

Create an empty hessian layout for a set of static target attributes. The differentiator fills the symbolic assembly data.

Parameter Type Default Description
wrt list[attribute] required Ordered, static differentiation targets.
local_targets list[attribute] [] Local targets associated with the first symbolic term.
dynamic_instances bool False Whether the initial symbolic term uses dynamic instances.

Returns: new hessian.

Raises: ValueError for dynamic targets or an empty total target layout.

compute

compute(local_gradient=None)

Assemble the numeric sparse blocks, diagonal data, and gradient using current attribute and connectivity values.

Parameter Type Default Description
local_gradient gradient or None None Optional existing gradient buffer with the same target layout.

Example

adjoint_hessian.compute()
right_hand_side = adjoint_hessian.gradient

Returns: this hessian.

Addition

left + right

Combine hessian terms with the same ordered wrt layout. Static and dynamic contributions remain separate until numeric assembly.

Example

adjoint_hessian = elastic_hessian + inertia_hessian

Returns: combined hessian.

Raises: ValueError when target layouts differ; TypeError when the other operand is not a hessian.

Properties

Property Type Description
rows int Hessian row count.
cols int Hessian column count; equal to rows.
wrt list[attribute] Ordered differentiation targets.
wrt_start_indices list[int] Cumulative offsets for the target segments.
local_targets list[list[attribute]] Local targets for each combined symbolic term.
dynamic_instances bool Whether the original term was marked dynamic.
gradient gradient or None Assembled gradient associated with this hessian.
diagonal pycuda.gpuarray.GPUArray Flat numeric hessian diagonal.
diagonal_blocks pycuda.gpuarray.GPUArray Flattened diagonal blocks used by the solver preconditioner.
diagonal_blocks_inverse pycuda.gpuarray.GPUArray Storage for inverted diagonal blocks.
gradient_segments_start_cpu list[int] CPU offsets delimiting gradient segments.
block_dimensions list[int] Static sparse block dimensions.
block_counts list[int] Static block count per dimension category.
block_dimensions_dynamic list[int] Dynamic sparse block dimensions.
block_counts_dynamic list[int] Dynamic block count per dimension category.
hash int Hash derived from the ordered wrt attributes.