Example class structure for the first VMC project of FYS4411 (spring 2023). You may, if you wish, fork this repository and make it the basis of your project. If you choose to do this, you will have to implement a lot of the crucial functions yourself. The relevant functions you need to implement are spread throughout the project, but they are all commented with a note saying what each function should do.
Please note that this is only a start, and when you have implemented all of these functions you will only have completed the first exercise. However, once this is done, you will have a very good basis for further work, and adding functionality will be easier with a good class structure.
If you want to write your own code from scratch, you are of course welcome to do so, and feel free to use this code as inspiration for your own class structure.
System
class functions. Consider also the base classes WaveFunction
, Hamiltonian
, MonteCarlo
and the function in initialstate.h
, and see which functions are virtual (i.e., functions that NEED to be implemented by any sub-class).Sampler
class and the entire Random
class in the beginning.The recommend way to compile this project is by using CMake to create a Makefile that you can then run. You can install CMake through one of the Linux package managers, e.g., apt install cmake
, pacman -S cmake
, etc. For Mac you can install using brew install cmake
. Other ways of installing are shown here: https://cmake.org/install/.
In a Linux/Mac terminal this can be done by the following commands
# Create build-directory
mkdir build
# Move into the build-directory
cd build
# Run CMake to create a Makefile
cmake ../
# Make the Makefile using two threads
make -j2
# Move the executable to the top-directory
mv vmc ..
Or, simply run the script compile_project
via
./compile_project
and the same set of commands are done for you. Now the project can be run by executing
./vmc
in the top-directory.
Run make clean
in the top-directory to remove the executable vmc
and the build
-directory.
Compilation of the project using Windows should work using CMake as it is OS-independent, but make
does not work on Windows so the compile_project
-script will not work.
Here follows a suggestion for how you can work to complete the missing parts of the code:
SimpleGaussian
wave function: Write the evaluate
function. Assume for now that the number of particles is always one, and the number of dimensions is always one. Next, compute the Laplacian analytically, and implement the computeDoubleDerivative
function.Random
class (or your own favorite random number generator, should you have one) to implement the missing part of the setupRandomUniformInitialState
function.Hamiltonian
sub-class HarmonicOscillator
. Here you will have to use the Laplacian you calculated for the wave function earlier.alpha
accordingly. What is the resulting energy?computeAverages
function in the Sampler
class. What is missing here?