diff --git a/src/dynamo/jamfile b/src/dynamo/jamfile index 926d3d64d..ba37d84b2 100644 --- a/src/dynamo/jamfile +++ b/src/dynamo/jamfile @@ -89,4 +89,6 @@ unit-test infmass_spheres_test : tests/infmass_spheres_test.cpp dynamo_core/no /system//boost_unit_test_framework : no no:no @tags.exe-naming ; -alias test : scheduler_sorter_test hardsphere_test binaryhardsphere_test squarewell_test 2dstepped_potential_test infmass_spheres_test lines_test ; \ No newline at end of file +unit-test static_spheres_test : tests/static_spheres_test.cpp dynamo_core/no /system//boost_unit_test_framework : no no:no @tags.exe-naming ; + +alias test : scheduler_sorter_test hardsphere_test binaryhardsphere_test squarewell_test 2dstepped_potential_test infmass_spheres_test lines_test static_spheres_test ; \ No newline at end of file diff --git a/src/dynamo/tests/static_spheres_test.cpp b/src/dynamo/tests/static_spheres_test.cpp new file mode 100644 index 000000000..502df6c51 --- /dev/null +++ b/src/dynamo/tests/static_spheres_test.cpp @@ -0,0 +1,88 @@ +#define BOOST_TEST_MODULE Static_Spheres_test +#define BOOST_TEST_DYN_LINK +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +std::mt19937 RNG; + +dynamo::Vector getRandVelVec() +{ + //See http://mathworld.wolfram.com/SpherePointPicking.html + std::normal_distribution<> normal_dist(0.0, (1.0 / sqrt(double(NDIM)))); + + dynamo::Vector tmpVec; + for (size_t iDim = 0; iDim < NDIM; iDim++) + tmpVec[iDim] = normal_dist(RNG); + + return tmpVec; +} + +void init(dynamo::Simulation& Sim, const double density) +{ + RNG.seed(std::random_device()()); + Sim.ranGenerator.seed(std::random_device()()); + Sim.dynamics = dynamo::shared_ptr(new dynamo::DynGravity(&Sim, dynamo::Vector(0,-1,0))); + Sim.BCs = dynamo::shared_ptr(new dynamo::BCNone(&Sim)); + Sim.ptrScheduler = dynamo::shared_ptr(new dynamo::SNeighbourList(&Sim, new dynamo::FELCBT())); + Sim.primaryCellSize = dynamo::Vector(52,52,52); + + Sim.addSpecies(dynamo::shared_ptr(new dynamo::SpPoint(&Sim, new dynamo::IDRangeRange(0, 0), 1.0, "Bulk", 0))); + Sim.addSpecies(dynamo::shared_ptr(new dynamo::SpFixedCollider(&Sim, new dynamo::IDRangeRange(1, 8), "FixedColliders", 1))); + + Sim.interactions.push_back(dynamo::shared_ptr(new dynamo::IHardSphere(&Sim, 1.0, 1, new dynamo::IDPairRangeAll(), "Bulk"))); + + Sim.locals.push_back(dynamo::shared_ptr(new dynamo::LWall(&Sim, 1.0, 1.0, dynamo::Vector(0,1,0), dynamo::Vector(0,-2.67753263802375e+01,0), "GroundPlate", new dynamo::IDRangeAll(&Sim)))); + + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(0, 4, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(0.6, 1, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(-1.51, 1, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(-2.51, 1.5, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(-3.51, 2, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(-3.51, 3.5, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(1.6, 2, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(2, 3.5, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + Sim.particles.push_back(dynamo::Particle(dynamo::Vector(-0.75, 0.5, 0), dynamo::Vector(0,0,0), Sim.particles.size())); + + Sim.ensemble = dynamo::Ensemble::loadEnsemble(Sim); +} + +BOOST_AUTO_TEST_CASE( Test_Simulation ) +{ + { + dynamo::Simulation Sim; + init(Sim, 0.5); + Sim.initialise(); + Sim.writeXMLfile("staticsphere.xml"); + } + + dynamo::Simulation Sim; + Sim.loadXMLfile("staticsphere.xml"); + + Sim.endEventCount = 500000; + Sim.addOutputPlugin("Misc"); + Sim.initialise(); + while (Sim.runSimulationStep()) {} + + const double expectedMFT = 7.81945252098576; + dynamo::OPMisc& opMisc = *Sim.getOutputPlugin(); + //Check the mean free time is roughly what is expected + double MFT = opMisc.getMFT(); + BOOST_CHECK_CLOSE(MFT, expectedMFT, 0.1); + BOOST_CHECK_MESSAGE(Sim.checkSystem() <= 1, "There are more than two invalid states in the final configuration"); +} diff --git a/test/static-spheres.xml b/test/static-spheres.xml deleted file mode 100644 index c4a7a320c..000000000 --- a/test/static-spheres.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - - -

- - - - diff --git a/test/test_dynarun.sh b/test/test_dynarun.sh index d645da4eb..ee06e0d2e 100755 --- a/test/test_dynarun.sh +++ b/test/test_dynarun.sh @@ -353,30 +353,6 @@ function GravityPlateTest { tmp.xml.bz2 run.log } -function StaticSpheresTest { - > run.log - - ./dynarun -c 500000 static-spheres.xml >> run.log 2>&1 - - if [ -e output.xml.bz2 ]; then - if [ $(bzcat output.xml.bz2 \ - | $Xml sel -t -v '/OutputData/Misc/totMeanFreeTime/@val' \ - | gawk '{mft=7.81945252098576; var=($1-mft)/mft; print ((var < 0.02) && (var > -0.02))}') != "1" ]; then - echo "StaticSpheresTest -: FAILED" - exit 1 - else - echo "StaticSpheresTest -: PASSED" - fi - else - echo "Error, no output.0.xml.bz2 in StaticSpheresTest" - exit 1 - fi - -#Cleanup - rm -Rf config.end.xml.bz2 config.out.xml.bz2 output.xml.bz2 \ - tmp.xml.bz2 run.log -} - function SwingSpheresTest { > run.log @@ -424,9 +400,6 @@ function BinaryThermalisedGranulate { rm -Rf output.xml.bz2 config.out.xml.bz2 run.log } -echo "INTERACTIONS+Dynamod Systems" -echo "Testing static spheres in gravity, NeighbourLists and BoundedPQ's" -StaticSpheresTest #######THIS TEST IS GOOD, BUT A RECENT PATCH CHANGED THE cubic root finder, altering the result##### PLEASE RECALIBRATE #echo "Testing static and bonded spheres in gravity, NeighbourLists and BoundedPQ's" #SwingSpheresTest