From d636797d3e4539bbe0cfc037bae15d334a4d296f Mon Sep 17 00:00:00 2001 From: Giovanni Bordiga Date: Tue, 23 Jul 2024 20:18:47 -0400 Subject: [PATCH] Add angular momentum fn --- difflexmm/energy.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/difflexmm/energy.py b/difflexmm/energy.py index 7ec8bbc..feda7ca 100644 --- a/difflexmm/energy.py +++ b/difflexmm/energy.py @@ -598,6 +598,16 @@ def magnetic_energy_fn(block_displacements: jnp.ndarray, control_params: Control return magnetic_energy_fn +def angular_momentum(block_position, block_velocity, inertia, reference_point=jnp.array([0., 0.])): + """ + Computes the angular momentum of the blocks. + """ + momentum_centroids = jnp.cross(block_position[:, :2] - reference_point, + block_velocity[:, :2] * inertia[:, :2], axis=-1) + momentum_rotations = block_velocity[:, 2] * inertia[:, 2] + return momentum_centroids + momentum_rotations + + def compute_ligament_strains(block_displacement, centroid_node_vectors, bond_connectivity, reference_bond_vectors): node_displacements = block_to_node_kinematics( block_displacement,