101 lines
2.1 KiB
C++
101 lines
2.1 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"
|
|
#include "Potentials.hpp"
|
|
|
|
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
|
|
|
|
Potential *potential; ///< Potential function
|
|
|
|
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
|
|
|
|
double lx, ly, lz; ///< Box size, if periodic boundary conditions are used
|
|
|
|
/**
|
|
* @brief Initialize the force and potential tables
|
|
*
|
|
*/
|
|
void initTables();
|
|
|
|
/**
|
|
* @brief Evaluate interaction forces between atoms
|
|
*
|
|
*/
|
|
void evaulateForces();
|
|
|
|
/**
|
|
* @brief Build the grid based on the cutoff radius.
|
|
*
|
|
* This function partitions the space into cells of size rcut x rcut x rcut.
|
|
*/
|
|
void buildGrid();
|
|
|
|
public:
|
|
explicit System(double timeDelta,
|
|
double rcut,
|
|
Potential *potential,
|
|
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();
|
|
|
|
/**
|
|
* @brief Set the simulation box size
|
|
*
|
|
* @param lx
|
|
* @param ly
|
|
* @param lz
|
|
*/
|
|
void setBoxSize(double lx, double ly, double lz);
|
|
}; |