forked from mortele/variational-monte-carlo-fys4411
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
58 lines (48 loc) · 1.92 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <vector>
#include <memory>
#include "system.h"
#include "WaveFunctions/simplegaussian.h"
#include "Hamiltonians/harmonicoscillator.h"
#include "InitialStates/initialstate.h"
#include "Solvers/metropolis.h"
#include "Math/random.h"
#include "particle.h"
#include "sampler.h"
using namespace std;
int main() {
// Seed for the random number generator
int seed = 2023;
unsigned int numberOfDimensions = 1;
unsigned int numberOfParticles = 1;
unsigned int numberOfMetropolisSteps = (unsigned int) 1e6;
unsigned int numberOfEquilibrationSteps = (unsigned int) 1e5;
double omega = 1.0; // Oscillator frequency.
double alpha = 0.5; // Variational parameter.
double stepLength = 0.1; // Metropolis step length.
// The random engine can also be built without a seed
auto rng = std::make_unique<Random>(seed);
// Initialize particles
auto particles = setupRandomUniformInitialState(stepLength, numberOfDimensions, numberOfParticles, *rng);
// Construct a unique pointer to a new System
auto system = std::make_unique<System>(
// Construct unique_ptr to Hamiltonian
std::make_unique<HarmonicOscillator>(omega),
// Construct unique_ptr to wave function
std::make_unique<SimpleGaussian>(alpha),
// Construct unique_ptr to solver, and move rng
std::make_unique<Metropolis>(std::move(rng)),
// Move the vector of particles to system
std::move(particles));
// Run steps to equilibrate particles
auto acceptedEquilibrationSteps = system->runEquilibrationSteps(
stepLength,
numberOfEquilibrationSteps);
// Run the Metropolis algorithm
auto sampler = system->runMetropolisSteps(
stepLength,
numberOfMetropolisSteps);
// Output information from the simulation
sampler->printOutputToTerminal(*system);
return 0;
}