Computational Physics - Department of Physics

(Axel Boer) #1

482 14 Quantum Monte Carlo Methods


// the step length and its squared inverse for the second derivative
#defineh 0.001
#defineh2 1000000


// declaraton of functions


// Function to read in data from screen, note call by reference
voidinitialise(int&,int&,int&,int&,int&,int&,double&) ;


// The Mc sampling for the variational Monte Carlo
voidmc_sampling(int,int,int,int,int,int,double,double ,double);


// The variational wave function
doublewave_function(double **,double,int,int);


// The local energy
doublelocal_energy(double**,double,double,int,int,int);


// prints to screen the results of the calculations
voidoutput(int,int,int,double,double);


// Begin of main program


//int main()
intmain(intargc,charargv[])
{
char
outfilename;
intnumber_cycles, max_variations, thermalization, charge;
intdimension, number_particles;
doublestep_length;
doublecumulative_e,cumulative_e2;
// Read in output file, abort if there are too few command-line arguments
if( argc <= 1 ){
cout <<"Bad Usage: "<< argv[0] <<
" read also output file on same line"<< endl;
exit(1);
}
else{
outfilename=argv[1];
}
ofile.open(outfilename);
// Read in data
initialise(dimension, number_particles, charge,
max_variations, number_cycles,
thermalization, step_length) ;
cumulative_e =new double[max_variations+1];
cumulative_e2 =new double[max_variations+1];
// Do the mc sampling
mc_sampling(dimension, number_particles, charge,
max_variations, thermalization,
number_cycles, step_length, cumulative_e, cumulative_e2);
// Print out results
output(max_variations, number_cycles, charge, cumulative_e, cumulative_e2);
delete[] cumulative_e;delete[] cumulative_e;
ofile.close();// close output file
return0;
}

Free download pdf