Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove kinetic energy contribution from virtual sites #4839

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/sphinx/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,15 @@ General features
- ``THERMOSTAT_PER_PARTICLE`` Allows setting a per-particle friction
coefficient for the Langevin and Brownian thermostats.

- ``ROTATIONAL_INERTIA`` Allows to set the eigenvalues for rotational inertia matrix of particles
- ``ROTATIONAL_INERTIA`` Allows particles to have individual rotational inertia matrix eigenvalues.
When not built in, all eigenvalues are unity in simulation units.

- ``EXTERNAL_FORCES`` Allows to define an arbitrary constant force for each particle
individually. Also allows to fix individual coordinates of particles,
keep them at a fixed position or within a plane.

- ``MASS`` Allows particles to have individual masses. Note that some analysis
procedures have not yet been adapted to take the masses into account
correctly.
- ``MASS`` Allows particles to have individual masses.
When not built in, all masses are unity in simulation units.

.. seealso:: :attr:`espressomd.particle_data.ParticleHandle.mass`

Expand Down
2 changes: 1 addition & 1 deletion src/core/energy_inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ inline double translational_kinetic_energy(Particle const &p) {
*/
inline double rotational_kinetic_energy(Particle const &p) {
#ifdef ROTATION
return p.can_rotate()
return (p.can_rotate() and not p.is_virtual())
? 0.5 * (hadamard_product(p.omega(), p.omega()) * p.rinertia())
: 0.0;
#else
Expand Down
19 changes: 18 additions & 1 deletion src/core/unit_tests/energy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define BOOST_TEST_MODULE tests
#define BOOST_TEST_MODULE energy calculation
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

Expand Down Expand Up @@ -69,6 +69,23 @@ BOOST_AUTO_TEST_CASE(rotational_kinetic_energy_) {
0.5 * (hadamard_product(p.omega(), p.omega()) * p.rinertia());
BOOST_CHECK_EQUAL(rotational_kinetic_energy(p), expected);
}

// virtual particle
{
#ifdef VIRTUAL_SITES

Particle p;
#ifdef ROTATIONAL_INERTIA
p.rinertia() = {1., 2., 3.};
#endif
p.set_virtual(true);
p.omega() = {3., 4., 5.};
p.set_can_rotate_all_axes();

auto const expected = 0.;
BOOST_CHECK_EQUAL(rotational_kinetic_energy(p), expected);
#endif
}
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/python/espressomd/particle_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class ParticleHandle(ScriptInterfaceHelper):
rinertia: (3,) array_like of :obj:`float`
The particle rotational inertia.

Sets the diagonal elements of this particles rotational inertia
Sets the diagonal elements of this particle's rotational inertia
tensor. These correspond with the inertial moments along the
coordinate axes in the particle's co-rotating coordinate system.
When the particle's quaternions are set to ``[1, 0, 0, 0,]``, the
Expand Down