Skip to content

Commit

Permalink
Add angular momentum fn
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanniBordiga committed Jul 24, 2024
1 parent 4abeb4d commit d636797
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions difflexmm/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d636797

Please sign in to comment.