GCMC Simulation
A C++ and Python-based Monte Carlo simulation framework for interacting particles.
Loading...
Searching...
No Matches
initial.h
Go to the documentation of this file.
1#ifndef INITIAL_H
2#define INITIAL_H
3
4#include <vector>
5#include <cmath>
6
10class Particle {
11public:
12 double x, y;
13
19 Particle(double x_init = 0.0, double y_init = 0.0);
20
26 void updatePosition(double dx, double dy);
27};
32private:
33 double Lx;
34 double Ly;
35 double invLx;
36 double invLy;
37 double volume;
38
39public:
45 SimulationBox(double Lx, double Ly);
46
51 void applyPBC(Particle &p) const;
52
59 double minimumImageDistance(const Particle &p1, const Particle &p2) const;
60
67 double minimumImageDistanceSquared(const Particle &p1, const Particle &p2) const;
68
73 double getLx() const;
74
79 double getLy() const;
80
85 double getV() const;
86};
87
95void initializeParticles(std::vector<Particle> &particles, const SimulationBox &box, int N, bool random = true, unsigned int seed = 0);
96
97
98#endif // INITIAL_H
Represents a particle in the 2D simulation box.
Definition initial.h:10
Particle(double x_init=0.0, double y_init=0.0)
Constructs a Particle with the given initial position.
Definition initial.cpp:7
double x
Definition initial.h:12
double y
Position of the particle.
Definition initial.h:12
void updatePosition(double dx, double dy)
Updates the position of the particle.
Definition initial.cpp:10
Manages the 2D simulation box, including periodic boundary conditions.
Definition initial.h:31
double getLy() const
Gets the length of the simulation box in the y-direction.
Definition initial.cpp:53
SimulationBox(double Lx, double Ly)
Constructs a SimulationBox with the given dimensions.
Definition initial.cpp:16
double minimumImageDistanceSquared(const Particle &p1, const Particle &p2) const
Calculates the minimum image distance squared between two particles considering PBC.
Definition initial.cpp:37
double getV() const
Gets the simulation box volume.
Definition initial.cpp:58
void applyPBC(Particle &p) const
Applies periodic boundary conditions to a particle.
Definition initial.cpp:20
double getLx() const
Gets the length of the simulation box in the x-direction.
Definition initial.cpp:48
double minimumImageDistance(const Particle &p1, const Particle &p2) const
Calculates the minimum image distance between two particles considering PBC.
Definition initial.cpp:26
void initializeParticles(std::vector< Particle > &particles, const SimulationBox &box, int N, bool random=true, unsigned int seed=0)
Initializes N particles in the simulation box.
Definition initial.cpp:64