Skip to main content

hoomd_interaction/external/
constant_torque.rs

1// Copyright (c) 2024-2026 The Regents of the University of Michigan.
2// Part of hoomd-rs, released under the BSD 3-Clause License.
3
4//! Implement [`ConstantTorque`]
5use serde::{Deserialize, Serialize};
6
7use hoomd_vector::{Outer, Wedge};
8
9use crate::SiteForceVirialAndTorque;
10
11/// Apply the same torque to every site, independent of the site's properties.
12#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
13pub struct ConstantTorque<V: Wedge> {
14    /// Torque $`[\mathrm{energy}]`$.
15    pub torque: V::Bivector,
16}
17
18impl<S, V> SiteForceVirialAndTorque<S> for ConstantTorque<V>
19where
20    V: Default + Wedge + Outer,
21    V::Bivector: Copy + Default,
22    V::Tensor: Default,
23{
24    type Force = V;
25
26    #[inline]
27    fn site_force_virial_and_torque(&self, _site_properties: &S) -> (V, V::Tensor, V::Bivector) {
28        (V::default(), V::Tensor::default(), self.torque)
29    }
30}