87 lines
1.9 KiB
C++
87 lines
1.9 KiB
C++
/**
|
|
* @file System.hpp
|
|
* @author jun <jun@firmwarejun.net>
|
|
* @brief System declarations
|
|
* @version 0.1
|
|
* @date 2023-07-25
|
|
*
|
|
* Copyright (c) 2023 jun <https://git.firmwarejun.net/jun/MolecularDynamics2>
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
#include "Atom.hpp"
|
|
|
|
typedef std::function<double(double)> PotentialFunction;
|
|
typedef std::function<double(double)> ForceFunction;
|
|
|
|
class System {
|
|
private:
|
|
std::vector<Atom> atoms; ///< Atoms in the system
|
|
std::vector<Atom> atomsOld; ///< Atoms in the system in the previous step
|
|
|
|
std::vector<double> forceTable; ///< Force table
|
|
std::vector<double> forceTableOld; ///< Force table in the previous step
|
|
std::vector<double> potentialTable; ///< Potential table
|
|
|
|
ForceFunction forceGenerator; ///< Force generator
|
|
PotentialFunction potentialGenerator; ///< Potential generator
|
|
|
|
double rcut; ///< Cutoff radius
|
|
double rcut2; ///< Cutoff radius squared
|
|
|
|
std::size_t tableResolution = 1000; ///< Resolution of the force table
|
|
|
|
double timeDelta = 0; ///< Time delta between steps
|
|
|
|
/**
|
|
* @brief Initialize the force and potential tables
|
|
*
|
|
*/
|
|
void initTables();
|
|
|
|
/**
|
|
* @brief Evaluate interaction forces between atoms
|
|
*
|
|
*/
|
|
void evaulateForces();
|
|
|
|
public:
|
|
explicit System(double timeDelta,
|
|
double rcut,
|
|
PotentialFunction potentialFunction,
|
|
ForceFunction forceFunction,
|
|
std::size_t tableResolution = 1000);
|
|
|
|
void step();
|
|
|
|
/**
|
|
* @brief Step the system to the first step using euler method
|
|
*
|
|
*/
|
|
void stepFirst();
|
|
|
|
/**
|
|
* @brief Add an atom to the system
|
|
*
|
|
* @param atom
|
|
*/
|
|
void addAtom(Atom atom);
|
|
|
|
/**
|
|
* @brief Add a vector of atoms to the system
|
|
*
|
|
* @param atoms
|
|
*/
|
|
void addAtom(std::vector<Atom> atoms);
|
|
|
|
/**
|
|
* @brief Print atoms
|
|
*
|
|
*/
|
|
void printAtoms();
|
|
}; |