Skip to content

Commit

Permalink
Fix calls to Mersenne Twister for CBMC functions
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed Jul 12, 2024
1 parent ff3f67a commit 3c7b0bb
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
12 changes: 10 additions & 2 deletions src/cbmc/DCFreeCycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ void DCFreeCycle::BuildNew(TrialMol &newMol, uint molIndex) {
positions[hed.NumBond()].Set(0, newMol.RawRectCoords(anchorBond, 0, 0));

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 0;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down Expand Up @@ -217,9 +221,13 @@ void DCFreeCycle::BuildOld(TrialMol &oldMol, uint molIndex) {
positions[hed.NumBond()].Add(0, -center);

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 1;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down
12 changes: 10 additions & 2 deletions src/cbmc/DCFreeCycleSeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ void DCFreeCycleSeed::BuildNew(TrialMol &newMol, uint molIndex) {
positions[hed.NumBond()].Set(0, newMol.RawRectCoords(anchorBond, 0, 0));

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 0;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down Expand Up @@ -216,9 +220,13 @@ void DCFreeCycleSeed::BuildOld(TrialMol &oldMol, uint molIndex) {
positions[hed.NumBond()].Add(0, -center);

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 1;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down
12 changes: 10 additions & 2 deletions src/cbmc/DCFreeHedron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ void DCFreeHedron::BuildNew(TrialMol &newMol, uint molIndex) {
positions[hed.NumBond()].Set(0, newMol.RawRectCoords(anchorBond, 0, 0));

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 0;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down Expand Up @@ -196,9 +200,13 @@ void DCFreeHedron::BuildOld(TrialMol &oldMol, uint molIndex) {
positions[hed.NumBond()].Add(0, -center);

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 1;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down
12 changes: 10 additions & 2 deletions src/cbmc/DCFreeHedronSeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ void DCFreeHedronSeed::BuildNew(TrialMol &newMol, uint molIndex) {
positions[hed.NumBond()].Set(0, newMol.RawRectCoords(anchorBond, 0, 0));

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 0;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down Expand Up @@ -195,9 +199,13 @@ void DCFreeHedronSeed::BuildOld(TrialMol &oldMol, uint molIndex) {
positions[hed.NumBond()].Add(0, -center);

// counting backward to preserve prototype
double u1, u2, u3;
for (uint lj = nLJTrials; lj-- > 1;) {
// convert chosen torsion to 3D positions
RotationMatrix spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
u1 = prng();
u2 = prng();
u3 = prng();
RotationMatrix spin = RotationMatrix::UniformRandom(u1, u2, u3);
for (uint b = 0; b < hed.NumBond() + 1; ++b) {
// find positions
positions[b].Set(lj, spin.Apply(positions[b][0]));
Expand Down
12 changes: 10 additions & 2 deletions src/cbmc/DCRotateCOM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ void DCRotateCOM::BuildNew(TrialMol &newMol, uint molIndex) {
RandRotateZ();
} else {
// convert chosen torsion to 3D positions
spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
double u1, u2, u3;
u1 = prng();
u2 = prng();
u3 = prng();
spin = RotationMatrix::UniformRandom(u1, u2, u3);
}

for (uint a = 0; a < atomNumber; ++a) {
Expand Down Expand Up @@ -287,7 +291,11 @@ void DCRotateCOM::BuildOld(TrialMol &oldMol, uint molIndex) {
RandRotateZ();
} else {
// convert chosen torsion to 3D positions
spin = RotationMatrix::UniformRandom(prng(), prng(), prng());
double u1, u2, u3;
u1 = prng();
u2 = prng();
u3 = prng();
spin = RotationMatrix::UniformRandom(u1, u2, u3);
}

for (uint a = 0; a < atomNumber; ++a) {
Expand Down

0 comments on commit 3c7b0bb

Please sign in to comment.