Skip to content

an objective approach to molecular dynamics (Argon Gas simulation)

Notifications You must be signed in to change notification settings

nort3x/Objective-Molecular-dynamics

Repository files navigation

Objective-Molecular-dynamics

an objective approach to molecular dynamics (Argon Gas simulation)

OOP practice in MolecularDynamics - partially compeleted - any pull will be accpeted \

#include <iostream>
#include <fstream>
#include <iomanip>

#include "MDLib/MDLib.h"

int main() {
    using namespace std;

    ArgonGasWorld agw(200,10);  // a box containing 200 argon atoms with side length of 10
    auto integrator = new VerletIntegrator<ArgonAtom,double>(&agw,0.01); // making an integrator
    auto constraint = new RigidBoxConstraint<ArgonAtom,double>(10);  // making a Constraint
    //auto constraint = new PeriodicBoundaryConditionBox<ArgonAtom,double>(10);
    //auto constraint  = new FreeSpace<ArgonAtom>();
    agw.RandomizePosition();
    agw.RandomizeVelocity(100);

    cout<<"Intited....\n";

    // golabi means peach :D (please let it be like this in memory of my dear professor)
    fstream  golabi; 
    golabi.open("/root/Desktop/d.dat",ios::out);
    agw.setDynamics(0.01,integrator,constraint);
    for (int i = 1; i < 1000000; ++i) {
        agw.ElapseInTime(0.1,0.0001);
        //cout<<agw.getTotalKineticEnergy()+agw.getTotalPotentialEnergy()<<"\n";
        //golabi<<std::setprecision(15)<<agw.getTime()<<"\t"<<agw.getTotalKineticEnergy()+agw.getTotalPotentialEnergy()<<endl;
        golabi<<agw[1].Position<<endl;
    }

    return 0;
}