From 8a8e02a2a9cdb80d5def427d8d19b230b02dc802 Mon Sep 17 00:00:00 2001 From: Mikael Lund Date: Tue, 21 Nov 2017 16:54:19 +0100 Subject: [PATCH] translational atom move now uses unit sphere --- include/faunus/point.h | 6 ++++-- src/examples/water2.test | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/faunus/point.h b/include/faunus/point.h index 37317af79..7e7be1672 100644 --- a/include/faunus/point.h +++ b/include/faunus/point.h @@ -68,15 +68,17 @@ namespace Faunus * * @param ran Function that takes no arguments and returns a random * float uniformly distributed in the range `[0:1[`. + * @param dir Directions. Sphere=1,1,1 (default), XY circle=1,1,0 etc. */ template - PointBase &ranunit( Trandombase &ran ) + PointBase &ranunit( Trandombase &ran, const PointBase& dir={1,1,1} ) { + assert( dir.size() == 3 ); Tcoord r2; do { for ( size_t i = 0; i < 3; ++i ) - this->operator[](i) = 2 * ran() - 1; + operator[](i) = (2 * ran() - 1) * dir[i]; r2 = squaredNorm(); } while ( r2 > 1 ); diff --git a/src/examples/water2.test b/src/examples/water2.test index c8a56ef41..ecbcf3d4a 100644 --- a/src/examples/water2.test +++ b/src/examples/water2.test @@ -4,7 +4,7 @@ GroupRotation/Translation_water_acceptance 34.0539 GroupRotation/Translation_water_dRot 3.64838 GroupRotation/Translation_water_dTrans 0.107132 IsobaricVolumeFluctuations_MSQDisplacement 4.45178 -IsobaricVolumeFluctuations_acceptance 35.6863 +IsobaricVolumeFluctuations_acceptance 30.1158 IsobaricVolumeFluctuations_averageSideLength 31.0922 energyAverage -367908 relativeEnergyDrift 5.37773e-15