Python API - polyhedral_gravity#

Module Overview#

Polyhedron#

Enums to specify Mesh(-checks)#

GravityModel#

Single Function#

Cached Evaluation#

Embedded Information#

The module also provides several attributes that define key metadata about the build configuration, versioning, and runtime behavior of the polyhedral_gravity module which are set at compile time. Below is the list of the available attributes:

__version__#

Specifies the version of the polyhedral_gravity module at compile time.

This corresponds to the value of the POLYHEDRAL_GRAVITY_VERSION C++ variable.

__parallelization__#

Specifies the parallelization of the polyhedral_gravity module at compile time (One of CPP, OMP, TBB)

This attribute corresponds to the value of the POLYHEDRAL_GRAVITY_PARALLELIZATION C++ variable.

__commit__#

Specifies the Git commit hash of the source code at compile time.

It is assigned the value of the POLYHEDRAL_GRAVITY_COMMIT_HASH C++ variable.

__logging__#

Specifies the logging level fixed at compile time.

This corresponds to the value defined by the POLYHEDRAL_GRAVITY_LOGGING_LEVEL C++ variable.

PyTorch Interface (Differentiable)#

The optional polyhedral_gravity.torch submodule provides a pure-PyTorch, autograd-differentiable re-implementation of evaluate(..). It is not imported by default and requires PyTorch to be installed separately (pip install torch). See Examples Python for a usage example, and the PyTorch interface notebook and benchmark notebook for further details.

polyhedral_gravity.torch.evaluate(vertices, faces, density, computation_points, gravitational_constant=6.67430e-11)#

Gravitational potential, acceleration, and gradient tensor for a polyhedron, differentiable w.r.t. vertex positions and density.

Parameters:
  • vertices – (N, 3) vertex positions [m] (torch.Tensor).

  • faces – (F, 3) triangle vertex indices, integer dtype (torch.Tensor).

  • density – Constant density [kg/m^3].

  • computation_points – (Q, 3) evaluation positions [m] (torch.Tensor).

  • gravitational_constant – Gravitational constant, defaults to 6.67430e-11.

Returns:

Tuple of potential (Q,), acceleration (Q, 3), and gradient tensor (Q, 6) (ordered as [Vxx, Vyy, Vzz, Vxy, Vxz, Vyz]).