int main(int argc, char* argv[]){ /* **************************************************************** * the first part looks exactly like in the last example. * ***************************************************************/ //first set up the random number generator RandomNumberGenerators randomNumbers; randomNumbers.seedAll(); //now set up the system typedef LOKI_TYPELIST_3(FeatureMoleculesIO,FeatureBox,FeatureBondset<>) Features; typedef ConfigureSystem<VectorInt3,Features> Config; typedef Ingredients<Config> MyIngredients; MyIngredients mySystem; mySystem.setBoxX(64); mySystem.setBoxY(64); mySystem.setBoxZ(64); mySystem.setPeriodicX(true); mySystem.setPeriodicY(true); mySystem.setPeriodicZ(true); mySystem.modifyBondset().addBFMclassicBondset(); mySystem.synchronize(mySystem); /* **************************************************************** * as compared to the previous example, we now don't create the * particles by hand, but we use an updater for this in the * task manager. the advantage of this approach is that you can * reuse this updater in different programs, so you don't have to * write the code for creating particles every time. * * we want the particles to be created once before the simulation. * so we have to tell the task manager this when adding the * updater. this is done by giving the number 0 as execution * frequency, as shown below. * the largest part of the code below is exactly the same as in the * previous example. * ***************************************************************/ //create the task manager TaskManager taskmanager; //add the ex5updater, which creates the particles //again, the addUpdater function takes two arguments. The first one //is a pointer to the updater, and the second one is the execution //frequency. here we use 0 as frequency, because we want the updater //to be executed only once at the beginning. //what would happen, if you set a number different from 0? uint32_t numberOfParticles=100; taskmanager.addUpdater(new Ex5Updater<MyIngredients>(mySystem,numberOfParticles),0); //add the simulator //here we set the frequency to one, because we want to execute it in every //circle taskmanager.addUpdater(new UpdaterSimpleSimulator<MyIngredients,MoveLocalSc>(mySystem,1000),1); //the following two analyzers are the same as in the last example: //on top of this, we add a third one, which is the ex5analyzer //written for this example. //add the file output, the trajectory file name will be "polymer.bfm" taskmanager.addAnalyzer(new AnalyzerWriteBfmFile<MyIngredients>("polymer.bfm",mySystem),1); //add the radius of gyration calculation. we execute this only //every 10th time taskmanager.addAnalyzer(new AnalyzerRadiusOfGyration<MyIngredients>(mySystem,"polymer"),10); //now add the ex5analyzer. execute it every second circle std::string outputFilename("ex5output.dat"); taskmanager.addAnalyzer(new Ex5Analyzer<MyIngredients>(mySystem,outputFilename),2); //as before, we initialize and run the task manager, and cleanup afterwards taskmanager.initialize(); taskmanager.run(10000); taskmanager.cleanup(); return 0; }