Skip to content

Commit

Permalink
translational atom move now uses unit sphere
Browse files Browse the repository at this point in the history
  • Loading branch information
mlund committed Nov 21, 2017
1 parent cbdb480 commit 8a8e02a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions include/faunus/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<class Trandombase>
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 );
Expand Down
2 changes: 1 addition & 1 deletion src/examples/water2.test
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8a8e02a

Please sign in to comment.