diff --git a/doc/Programs/IsingModel/IsingModel.cpp b/doc/Programs/IsingModel/IsingModel.cpp new file mode 100755 index 000000000..1dd758e45 --- /dev/null +++ b/doc/Programs/IsingModel/IsingModel.cpp @@ -0,0 +1,168 @@ +/* + Program to solve the two-dimensional Ising model + with zero external field and no parallelization + The coupling constant J is set to J = 1 + Boltzmann's constant = 1, temperature has thus dimension energy + Metropolis aolgorithm is used as well as periodic boundary conditions. + The code needs an output file on the command line and the variables mcs, nspins, + initial temp, final temp and temp step. + Run as + ./executable Outputfile numberof spins number of MC cycles initial temp final temp tempstep + ./test.x Lattice 100 10000000 2.1 2.4 0.01 + Compile and link as + c++ -O3 -std=c++11 -Rpass=loop-vectorize -o Ising.x IsingModel.cpp -larmadillo +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +using namespace arma; +// output file +ofstream ofile; + +// inline function for PeriodicBoundary boundary conditions +inline int PeriodicBoundary(int i, int limit, int add) { + return (i+limit+add) % (limit); +} +// Function to initialise energy and magnetization +void InitializeLattice(int, mat &, double&, double&); +// The metropolis algorithm including the loop over Monte Carlo cycles +void MetropolisSampling(int, int, double, vec &); +// prints to file the results of the calculations +void WriteResultstoFile(int, int, double, vec); + +// Main program begins here + +int main(int argc, char* argv[]) +{ + string filename; + int NSpins, MCcycles; + double InitialTemp, FinalTemp, TempStep; + if (argc <= 5) { + cout << "Bad Usage: " << argv[0] << + " read output file, Number of spins, MC cycles, initial and final temperature and tempurate step" << endl; + exit(1); + } + if (argc > 1) { + filename=argv[1]; + NSpins = atoi(argv[2]); + MCcycles = atoi(argv[3]); + InitialTemp = atof(argv[4]); + FinalTemp = atof(argv[5]); + TempStep = atof(argv[6]); + } + // Declare new file name and add lattice size to file name + string fileout = filename; + string argument = to_string(NSpins); + fileout.append(argument); + ofile.open(fileout); + // Start Monte Carlo sampling by looping over the selcted Temperatures + for (double Temperature = InitialTemp; Temperature <= FinalTemp; Temperature+=TempStep){ + vec ExpectationValues = zeros(5); + // Start Monte Carlo computation and get expectation values + MetropolisSampling(NSpins, MCcycles, Temperature, ExpectationValues); + // + WriteResultstoFile(NSpins, MCcycles, Temperature, ExpectationValues); + } + ofile.close(); // close output file + return 0; +} + + + +// The Monte Carlo part with the Metropolis algo with sweeps over the lattice +void MetropolisSampling(int NSpins, int MCcycles, double Temperature, vec &ExpectationValues) +{ + // Initialize the seed and call the Mersienne algo + std::random_device rd; + std::mt19937_64 gen(rd()); + // Set up the uniform distribution for x \in [[0, 1] + std::uniform_real_distribution RandomNumberGenerator(0.0,1.0); + // Initialize the lattice spin values + mat SpinMatrix = zeros(NSpins,NSpins); + // initialize energy and magnetization + double Energy = 0.; double MagneticMoment = 0.; + // initialize array for expectation values + InitializeLattice(NSpins, SpinMatrix, Energy, MagneticMoment); + // setup array for possible energy changes + vec EnergyDifference = zeros(17); + for( int de =-8; de <= 8; de+=4) EnergyDifference(de+8) = exp(-de/Temperature); + // Start Monte Carlo cycles + for (int cycles = 1; cycles <= MCcycles; cycles++){ + // The sweep over the lattice, looping over all spin sites + for(int x =0; x < NSpins; x++) { + for (int y= 0; y < NSpins; y++){ + int ix = (int) (RandomNumberGenerator(gen)*(double)NSpins); + int iy = (int) (RandomNumberGenerator(gen)*(double)NSpins); + int deltaE = 2*SpinMatrix(ix,iy)* + (SpinMatrix(ix,PeriodicBoundary(iy,NSpins,-1))+ + SpinMatrix(PeriodicBoundary(ix,NSpins,-1),iy) + + SpinMatrix(ix,PeriodicBoundary(iy,NSpins,1)) + + SpinMatrix(PeriodicBoundary(ix,NSpins,1),iy)); + if ( RandomNumberGenerator(gen) <= EnergyDifference(deltaE+8) ) { + SpinMatrix(ix,iy) *= -1.0; // flip one spin and accept new spin config + MagneticMoment += (double) 2*SpinMatrix(ix,iy); + Energy += (double) deltaE; + } + } + } + // update expectation values for local node + ExpectationValues(0) += Energy; ExpectationValues(1) += Energy*Energy; + ExpectationValues(2) += MagneticMoment; + ExpectationValues(3) += MagneticMoment*MagneticMoment; + ExpectationValues(4) += fabs(MagneticMoment); + } +} // end of Metropolis sampling over spins + +// function to initialise energy, spin matrix and magnetization +void InitializeLattice(int NSpins, mat &SpinMatrix, double& Energy, double& MagneticMoment) +{ + // setup spin matrix and initial magnetization + for(int x =0; x < NSpins; x++) { + for (int y= 0; y < NSpins; y++){ + SpinMatrix(x,y) = 1.0; // spin orientation for the ground state + MagneticMoment += (double) SpinMatrix(x,y); + } + } + // setup initial energy + for(int x =0; x < NSpins; x++) { + for (int y= 0; y < NSpins; y++){ + Energy -= (double) SpinMatrix(x,y)* + (SpinMatrix(PeriodicBoundary(x,NSpins,-1),y) + + SpinMatrix(x,PeriodicBoundary(y,NSpins,-1))); + } + } +}// end function initialise + + + +void WriteResultstoFile(int NSpins, int MCcycles, double temperature, vec ExpectationValues) +{ + double norm = 1.0/((double) (MCcycles)); // divided by number of cycles + double E_ExpectationValues = ExpectationValues(0)*norm; + double E2_ExpectationValues = ExpectationValues(1)*norm; + double M_ExpectationValues = ExpectationValues(2)*norm; + double M2_ExpectationValues = ExpectationValues(3)*norm; + double Mabs_ExpectationValues = ExpectationValues(4)*norm; + // all expectation values are per spin, divide by 1/NSpins/NSpins + double Evariance = (E2_ExpectationValues- E_ExpectationValues*E_ExpectationValues)/NSpins/NSpins; + double Mvariance = (M2_ExpectationValues - Mabs_ExpectationValues*Mabs_ExpectationValues)/NSpins/NSpins; + ofile << setiosflags(ios::showpoint | ios::uppercase); + ofile << setw(15) << setprecision(8) << temperature; + ofile << setw(15) << setprecision(8) << E_ExpectationValues/NSpins/NSpins; + ofile << setw(15) << setprecision(8) << Evariance/temperature/temperature; + ofile << setw(15) << setprecision(8) << M_ExpectationValues/NSpins/NSpins; + ofile << setw(15) << setprecision(8) << Mvariance/temperature; + ofile << setw(15) << setprecision(8) << Mabs_ExpectationValues/NSpins/NSpins << endl; +} // end output function + + + + + diff --git a/doc/Programs/IsingModel/input.dat b/doc/Programs/IsingModel/input.dat new file mode 100644 index 000000000..efc0628b7 --- /dev/null +++ b/doc/Programs/IsingModel/input.dat @@ -0,0 +1 @@ +100000 20 2.1 2.4 0.01 \ No newline at end of file diff --git a/doc/Programs/Sampling/README.md b/doc/Programs/Sampling/README.md new file mode 100644 index 000000000..b2078e441 --- /dev/null +++ b/doc/Programs/Sampling/README.md @@ -0,0 +1,15 @@ +# ResamplingAnalysisScripts + +## Sample Scripts for data Analysis +So far this is a simple python script (should be made parallel...) to perform resampling of a data set. Methods used are __Bootstrapping__, __Jackknife__ and __Blocking__. + +## Usage +Simply run `python analysis.py FILENAME.xxx [NLINES]` + +Where `FILENAME` is expected to have a 3 charachter extension `NLINES` (optional) is the number of lines in the file to read and process (default is the whole file, but it gets very slow above 2-3 hundred thousand entries) + +Ouput is located into the `FILENAME/` folder. + +If more than 10⁵ lines are specified the autocorrelation function won't be computed, as it would take too long. + +The `gaussian.dat` dataset has been generated with numpy, as a proof of concept. It represents a normally distributed set of 5x10⁵ elements with `std = 0.05`. One will notice that the estimate on the error of the central value is greatly improved by all resampling methods. diff --git a/doc/Programs/Sampling/analysis.py b/doc/Programs/Sampling/analysis.py new file mode 100644 index 000000000..84b8eaca5 --- /dev/null +++ b/doc/Programs/Sampling/analysis.py @@ -0,0 +1,206 @@ +from sys import argv +from os import mkdir, path +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.ticker import FormatStrFormatter +from matplotlib.font_manager import FontProperties + +class dataAnalysisClass: + # General Init functions + def __init__(self, fileName, size=0): + self.inputFileName = fileName + self.loadData(size) + self.createOutputFolder() + self.avg = np.average(self.data) + self.var = np.var(self.data) + self.std = np.std(self.data) + + def loadData(self, size=0): + if size != 0: + self.data = np.loadtxt(self.inputFileName)[0:size] + else: + self.data = np.loadtxt(self.inputFileName) + + # Statistical Analysis with Multiple Methods + def runAllAnalyses(self): + if len(self.data) <= 100000: + print "Autocorrelation..." + self.autocorrelation() + print "Bootstrap..." + self.bootstrap() + print "Jackknife..." + self.jackknife() + print "Blocking..." + self.blocking() + + # Standard Autocorrelation + def autocorrelation(self): + self.acf = np.zeros(len(self.data)/2) + for k in range(0, len(self.data)/2): + self.acf[k] = np.corrcoef(np.array([self.data[0:len(self.data)-k], \ + self.data[k:len(self.data)]]))[0,1] + + # Bootstrap + def bootstrap(self, nBoots = 1000): + bootVec = np.zeros(nBoots) + for k in range(0,nBoots): + bootVec[k] = np.average(np.random.choice(self.data, len(self.data))) + self.bootAvg = np.average(bootVec) + self.bootVar = np.var(bootVec) + self.bootStd = np.std(bootVec) + + # Jackknife + def jackknife(self): + jackknVec = np.zeros(len(self.data)) + for k in range(0,len(self.data)): + jackknVec[k] = np.average(np.delete(self.data, k)) + self.jackknAvg = self.avg - (len(self.data) - 1) * (np.average(jackknVec) - self.avg) + self.jackknVar = float(len(self.data) - 1) * np.var(jackknVec) + self.jackknStd = np.sqrt(self.jackknVar) + + + def blocking(self, nPoints=500): + blockSizeMin = 1 + blockSizeMax = len(self.data)/2 + + self.blockSizes = [] + self.meanVec = [] + self.varVec = [] + + blockList = np.linspace(blockSizeMin, blockSizeMax, nPoints) + for i in range(0, nPoints): + blockSize = int(blockList[i]) + meanTempVec = [] + varTempVec = [] + startPoint = 0 + endPoint = blockSize + + while endPoint <= len(self.data): + meanTempVec.append(np.average(self.data[startPoint:endPoint])) + startPoint = endPoint + endPoint += blockSize + mean, var = np.average(meanTempVec), np.var(meanTempVec) + self.meanVec.append(mean) + self.varVec.append(var) + self.blockSizes.append(blockSize) + + self.blockingAvg = np.average(self.meanVec[-3:]) + self.blockingVar = (np.average(self.varVec[-3:])) + self.blockingStd = np.sqrt(self.blockingVar) + + + + + + # Plot of Data, Autocorrelation Function and Histogram + def plotAll(self): + self.createOutputFolder() + if len(self.data) <= 100000: + self.plotAutocorrelation() + self.plotData() + self.plotHistogram() + self.plotBlocking() + + # Create Output Plots Folder + def createOutputFolder(self): + self.outName = self.inputFileName[:-4] + if not path.exists(self.outName): + mkdir(self.outName) + + # Plot the Dataset, Mean and Std + def plotData(self): + # Far away plot + font = {'fontname':'serif'} + plt.plot(range(0, len(self.data)), self.data, 'r-', linewidth=1) + plt.plot([0, len(self.data)], [self.avg, self.avg], 'b-', linewidth=1) + plt.plot([0, len(self.data)], [self.avg + self.std, self.avg + self.std], 'g--', linewidth=1) + plt.plot([0, len(self.data)], [self.avg - self.std, self.avg - self.std], 'g--', linewidth=1) + plt.ylim(self.avg - 5*self.std, self.avg + 5*self.std) + plt.gca().yaxis.set_major_formatter(FormatStrFormatter('%.4f')) + plt.xlim(0, len(self.data)) + plt.ylabel(self.outName.title() + ' Monte Carlo Evolution', **font) + plt.xlabel('MonteCarlo History', **font) + plt.title(self.outName.title(), **font) + plt.savefig(self.outName + "/data.eps") + plt.savefig(self.outName + "/data.png") + plt.clf() + + # Plot Histogram of Dataset and Gaussian around it + def plotHistogram(self): + binNumber = 50 + font = {'fontname':'serif'} + count, bins, ignore = plt.hist(self.data, bins=np.linspace(self.avg - 5*self.std, self.avg + 5*self.std, binNumber)) + plt.plot([self.avg, self.avg], [0,np.max(count)+10], 'b-', linewidth=1) + plt.ylim(0,np.max(count)+10) + plt.ylabel(self.outName.title() + ' Histogram', **font) + plt.xlabel(self.outName.title() , **font) + plt.title('Counts', **font) + + #gaussian + norm = 0 + for i in range(0,len(bins)-1): + norm += (bins[i+1]-bins[i])*count[i] + plt.plot(bins, norm/(self.std * np.sqrt(2 * np.pi)) * np.exp( - (bins - self.avg)**2 / (2 * self.std**2) ), linewidth=1, color='r') + plt.savefig(self.outName + "/hist.eps") + plt.savefig(self.outName + "/hist.png") + plt.clf() + + # Plot the Autocorrelation Function + def plotAutocorrelation(self): + font = {'fontname':'serif'} + plt.plot(range(1, len(self.data)/2), self.acf[1:], 'r-') + plt.ylim(-1, 1) + plt.xlim(0, len(self.data)/2) + plt.ylabel('Autocorrelation Function', **font) + plt.xlabel('Lag', **font) + plt.title('Autocorrelation', **font) + plt.savefig(self.outName + "/autocorrelation.eps") + plt.savefig(self.outName + "/autocorrelation.png") + plt.clf() + + def plotBlocking(self): + font = {'fontname':'serif'} + plt.plot(self.blockSizes, self.varVec, 'r-') + plt.ylabel('Variance', **font) + plt.xlabel('Block Size', **font) + plt.title('Blocking', **font) + plt.savefig(self.outName + "/blocking.eps") + plt.savefig(self.outName + "/blocking.png") + plt.clf() + + # Print Stuff to the Terminal + def printOutput(self): + print "\nSample Size: \t", len(self.data) + print "\n=========================================\n" + print "Sample Average: \t", self.avg + print "Sample Variance:\t", self.var + print "Sample Std: \t", self.std + print "\n=========================================\n" + print "Bootstrap Average: \t", self.bootAvg + print "Bootstrap Variance:\t", self.bootVar + print "Bootstrap Error: \t", self.bootStd + print "\n=========================================\n" + print "Jackknife Average: \t", self.jackknAvg + print "Jackknife Variance:\t", self.jackknVar + print "Jackknife Error: \t", self.jackknStd + print "\n=========================================\n" + print "Blocking Average: \t", self.blockingAvg + print "Blocking Variance:\t", self.blockingVar + print "Blocking Error: \t", self.blockingStd, "\n" + + + +# Initialize the class +if len(argv) > 2: + dataAnalysis = dataAnalysisClass(argv[1], int(argv[2])) +else: + dataAnalysis = dataAnalysisClass(argv[1]) + +# Run Analyses +dataAnalysis.runAllAnalyses() + +# Plot the data +dataAnalysis.plotAll() + +# Print Some Output +dataAnalysis.printOutput() diff --git a/doc/Programs/Sampling/gaussian.dat.gz b/doc/Programs/Sampling/gaussian.dat.gz new file mode 100644 index 000000000..68fe13910 Binary files /dev/null and b/doc/Programs/Sampling/gaussian.dat.gz differ diff --git a/doc/Programs/VMC2Electrons/MPIvmcqdot.cpp b/doc/Programs/VMC2Electrons/MPIvmcqdot.cpp new file mode 100755 index 000000000..e3643c7e3 --- /dev/null +++ b/doc/Programs/VMC2Electrons/MPIvmcqdot.cpp @@ -0,0 +1,461 @@ +// Variational Monte Carlo for atoms with importance sampling, slater det +// Test case for 2-electron quantum dot, no classes using Mersenne-Twister RNG +#include "mpi.h" +#include +#include +#include +#include +#include +#include +#include "vectormatrixclass.h" + +using namespace std; +// output file as global variable +ofstream ofile; +// the step length and its squared inverse for the second derivative +// Here we define global variables used in various functions +// These can be changed by using classes +int Dimension = 2; +int NumberParticles = 2; // we fix also the number of electrons to be 2 + +// declaration of functions + +// The Mc sampling for the variational Monte Carlo +void MonteCarloSampling(int, double &, double &, Vector &); + +// The variational wave function +double WaveFunction(Matrix &, Vector &); + +// The local energy +double LocalEnergy(Matrix &, Vector &); + +// The quantum force +void QuantumForce(Matrix &, Matrix &, Vector &); + + +// inline function for single-particle wave function +inline double SPwavefunction(double r, double alpha) { + return exp(-alpha*r*0.5); +} + +// inline function for derivative of single-particle wave function +inline double DerivativeSPwavefunction(double r, double alpha) { + return -r*alpha; +} + +// function for absolute value of relative distance +double RelativeDistance(Matrix &r, int i, int j) { + double r_ij = 0; + for (int k = 0; k < Dimension; k++) { + r_ij += (r(i,k)-r(j,k))*(r(i,k)-r(j,k)); + } + return sqrt(r_ij); +} + +// inline function for derivative of Jastrow factor +inline double JastrowDerivative(Matrix &r, double beta, int i, int j, int k){ + return (r(i,k)-r(j,k))/(RelativeDistance(r, i, j)*pow(1.0+beta*RelativeDistance(r, i, j),2)); +} + +// function for square of position of single particle +double singleparticle_pos2(Matrix &r, int i) { + double r_single_particle = 0; + for (int j = 0; j < Dimension; j++) { + r_single_particle += r(i,j)*r(i,j); + } + return r_single_particle; +} + +void lnsrch(int n, Vector &xold, double fold, Vector &g, Vector &p, Vector &x, + double *f, double stpmax, int *check, double (*func)(Vector &p)); + +void dfpmin(Vector &p, int n, double gtol, int *iter, double *fret, + double(*func)(Vector &p), void (*dfunc)(Vector &p, Vector &g)); + +static double sqrarg; +#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg) + + +static double maxarg1,maxarg2; +#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\ + (maxarg1) : (maxarg2)) + + +// Begin of main program + +int main(int argc, char* argv[]) +{ + + // MPI initializations + int NumberProcesses, MyRank, NumberMCsamples; + MPI_Init (&argc, &argv); + MPI_Comm_size (MPI_COMM_WORLD, &NumberProcesses); + MPI_Comm_rank (MPI_COMM_WORLD, &MyRank); + double StartTime = MPI_Wtime(); + if (MyRank == 0 && argc <= 1) { + cout << "Bad Usage: " << argv[0] << + " Read also output file on same line and number of Monte Carlo cycles" << endl; + } + // Read filename and number of Monte Carlo cycles from the command line + if (MyRank == 0 && argc > 2) { + string filename = argv[1]; // first command line argument after name of program + NumberMCsamples = atoi(argv[2]); + string fileout = filename; + string argument = to_string(NumberMCsamples); + // Final filename as filename+NumberMCsamples + fileout.append(argument); + ofile.open(fileout); + } + // broadcast the number of Monte Carlo samples + MPI_Bcast (&NumberMCsamples, 1, MPI_INT, 0, MPI_COMM_WORLD); + // Two variational parameters only + Vector VariationalParameters(2); + int TotalNumberMCsamples = NumberMCsamples*NumberProcesses; + // Loop over variational parameters + for (double alpha = 0.5; alpha <= 1.5; alpha +=0.1){ + for (double beta = 0.1; beta <= 0.5; beta +=0.05){ + VariationalParameters(0) = alpha; // value of alpha + VariationalParameters(1) = beta; // value of beta + // Do the mc sampling and accumulate data with MPI_Reduce + double TotalEnergy, TotalEnergySquared, LocalProcessEnergy, LocalProcessEnergy2; + LocalProcessEnergy = LocalProcessEnergy2 = 0.0; + MonteCarloSampling(NumberMCsamples, LocalProcessEnergy, LocalProcessEnergy2, VariationalParameters); + // Collect data in total averages + MPI_Reduce(&LocalProcessEnergy, &TotalEnergy, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Reduce(&LocalProcessEnergy2, &TotalEnergySquared, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); + // Print out results in case of Master node, set to MyRank = 0 + if ( MyRank == 0) { + double Energy = TotalEnergy/( (double)NumberProcesses); + double Variance = TotalEnergySquared/( (double)NumberProcesses)-Energy*Energy; + double StandardDeviation = sqrt(Variance/((double)TotalNumberMCsamples)); // over optimistic error + ofile << setiosflags(ios::showpoint | ios::uppercase); + ofile << setw(15) << setprecision(8) << VariationalParameters(0); + ofile << setw(15) << setprecision(8) << VariationalParameters(1); + ofile << setw(15) << setprecision(8) << Energy; + ofile << setw(15) << setprecision(8) << Variance; + ofile << setw(15) << setprecision(8) << StandardDeviation << endl; + } + } + } + double EndTime = MPI_Wtime(); + double TotalTime = EndTime-StartTime; + if ( MyRank == 0 ) cout << "Time = " << TotalTime << " on number of processors: " << NumberProcesses << endl; + if (MyRank == 0) ofile.close(); // close output file + // End MPI + MPI_Finalize (); + return 0; +} // end of main function + + +// Monte Carlo sampling with the Metropolis algorithm + +void MonteCarloSampling(int NumberMCsamples, double &cumulative_e, double &cumulative_e2, Vector &VariationalParameters) +{ + + // Initialize the seed and call the Mersienne algo + std::random_device rd; + std::mt19937_64 gen(rd()); + // Set up the uniform distribution for x \in [[0, 1] + std::uniform_real_distribution UniformNumberGenerator(0.0,1.0); + std::normal_distribution Normaldistribution(0.0,1.0); + // diffusion constant from Schroedinger equation + double D = 0.5; + double timestep = 0.05; // we fix the time step for the gaussian deviate + // allocate matrices which contain the position of the particles + Matrix OldPosition( NumberParticles, Dimension), NewPosition( NumberParticles, Dimension); + Matrix OldQuantumForce(NumberParticles, Dimension), NewQuantumForce(NumberParticles, Dimension); + double Energy = 0.0; double EnergySquared = 0.0; double DeltaE = 0.0; + // initial trial positions + for (int i = 0; i < NumberParticles; i++) { + for (int j = 0; j < Dimension; j++) { + OldPosition(i,j) = Normaldistribution(gen)*sqrt(timestep); + } + } + double OldWaveFunction = WaveFunction(OldPosition, VariationalParameters); + QuantumForce(OldPosition, OldQuantumForce, VariationalParameters); + // loop over monte carlo cycles + for (int cycles = 1; cycles <= NumberMCsamples; cycles++){ + // new position + for (int i = 0; i < NumberParticles; i++) { + for (int j = 0; j < Dimension; j++) { + // gaussian deviate to compute new positions using a given timestep + NewPosition(i,j) = OldPosition(i,j) + Normaldistribution(gen)*sqrt(timestep)+OldQuantumForce(i,j)*timestep*D; + } + // for the other particles we need to set the position to the old position since + // we move only one particle at the time + for (int k = 0; k < NumberParticles; k++) { + if ( k != i) { + for (int j = 0; j < Dimension; j++) { + NewPosition(k,j) = OldPosition(k,j); + } + } + } + double NewWaveFunction = WaveFunction(NewPosition, VariationalParameters); + QuantumForce(NewPosition, NewQuantumForce, VariationalParameters); + // we compute the log of the ratio of the greens functions to be used in the + // Metropolis-Hastings algorithm + double GreensFunction = 0.0; + for (int j = 0; j < Dimension; j++) { + GreensFunction += 0.5*(OldQuantumForce(i,j)+NewQuantumForce(i,j))* + (D*timestep*0.5*(OldQuantumForce(i,j)-NewQuantumForce(i,j))-NewPosition(i,j)+OldPosition(i,j)); + } + GreensFunction = exp(GreensFunction); + // The Metropolis test is performed by moving one particle at the time + if(UniformNumberGenerator(gen) <= GreensFunction*NewWaveFunction*NewWaveFunction/OldWaveFunction/OldWaveFunction ) { + for (int j = 0; j < Dimension; j++) { + OldPosition(i,j) = NewPosition(i,j); + OldQuantumForce(i,j) = NewQuantumForce(i,j); + } + OldWaveFunction = NewWaveFunction; + } + } // end of loop over particles + // compute local energy + double DeltaE = LocalEnergy(OldPosition, VariationalParameters); + // update energies + Energy += DeltaE; + EnergySquared += DeltaE*DeltaE; + } // end of loop over MC trials + // update the energy average and its squared + cumulative_e = Energy/NumberMCsamples; + cumulative_e2 = EnergySquared/NumberMCsamples; +} // end MonteCarloSampling function + + +// Function to compute the squared wave function and the quantum force + +double WaveFunction(Matrix &r, Vector &VariationalParameters) +{ + double wf = 0.0; + // full Slater determinant for two particles, replace with Slater det for more particles + wf = SPwavefunction(singleparticle_pos2(r, 0), VariationalParameters(0))*SPwavefunction(singleparticle_pos2(r, 1),VariationalParameters(0)); + // contribution from Jastrow factor + for (int i = 0; i < NumberParticles-1; i++) { + for (int j = i+1; j < NumberParticles; j++) { + // wf *= exp(RelativeDistance(r, i, j)/((1.0+VariationalParameters(1)*RelativeDistance(r, i, j)))); + } + } + return wf; +} + +// Function to calculate the local energy without numerical derivation of kinetic energy + +double LocalEnergy(Matrix &r, Vector &VariationalParameters) +{ + + // compute the kinetic and potential energy from the single-particle part + // for a many-electron system this has to be replaced by a Slater determinant + // The absolute value of the interparticle length + Matrix length( NumberParticles, NumberParticles); + // Set up interparticle distance + for (int i = 0; i < NumberParticles-1; i++) { + for(int j = i+1; j < NumberParticles; j++){ + length(i,j) = RelativeDistance(r, i, j); + length(j,i) = length(i,j); + } + } + double KineticEnergy = 0.0; + // Set up kinetic energy from Slater and Jastrow terms + for (int i = 0; i < NumberParticles; i++) { + for (int k = 0; k < Dimension; k++) { + double sum1 = 0.0; + for(int j = 0; j < NumberParticles; j++){ + if ( j != i) { + //sum1 += JastrowDerivative(r, VariationalParameters(1), i, j, k); + } + } + KineticEnergy += (sum1+DerivativeSPwavefunction(r(i,k),VariationalParameters(0)))*(sum1+DerivativeSPwavefunction(r(i,k),VariationalParameters(0))); + } + } + KineticEnergy += -2*VariationalParameters(0)*NumberParticles; + for (int i = 0; i < NumberParticles-1; i++) { + for (int j = i+1; j < NumberParticles; j++) { + // KineticEnergy += 2.0/(pow(1.0 + VariationalParameters(1)*length(i,j),2))*(1.0/length(i,j)-2*VariationalParameters(1)/(1+VariationalParameters(1)*length(i,j)) ); + } + } + KineticEnergy *= -0.5; + // Set up potential energy, external potential + eventual electron-electron repulsion + double PotentialEnergy = 0; + for (int i = 0; i < NumberParticles; i++) { + double DistanceSquared = singleparticle_pos2(r, i); + PotentialEnergy += 0.5*DistanceSquared; // sp energy HO part, note it has the oscillator frequency set to 1! + } + // Add the electron-electron repulsion + for (int i = 0; i < NumberParticles-1; i++) { + for (int j = i+1; j < NumberParticles; j++) { + //PotentialEnergy += 1.0/length(i,j); + } + } + double LocalE = KineticEnergy+PotentialEnergy; + return LocalE; +} + +// Compute the analytical expression for the quantum force +void QuantumForce(Matrix &r, Matrix &qforce, Vector &VariationalParameters) +{ + // compute the first derivative + for (int i = 0; i < NumberParticles; i++) { + for (int k = 0; k < Dimension; k++) { + // single-particle part, replace with Slater det for larger systems + double sppart = DerivativeSPwavefunction(r(i,k),VariationalParameters(0)); + // Jastrow factor contribution + double Jsum = 0.0; + for (int j = 0; j < NumberParticles; j++) { + if ( j != i) { + Jsum += JastrowDerivative(r, VariationalParameters(1), i, j, k); + } + } + qforce(i,k) = 2.0*(Jsum+sppart); + } + } +} // end of QuantumForce function + + +#define ITMAX 200 +#define EPS 3.0e-8 +#define TOLX (4*EPS) +#define STPMX 100.0 + +void dfpmin(Vector &p, int n, double gtol, int *iter, double *fret, + double(*func)(Vector &p), void (*dfunc)(Vector &p, Vector &g)) +{ + + int check,i,its,j; + double den,fac,fad,fae,fp,stpmax,sum=0.0,sumdg,sumxi,temp,test; + Vector dg(n), g(n), hdg(n), pnew(n), xi(n); + Matrix hessian(n,n); + + fp=(*func)(p); + (*dfunc)(p,g); + for (i = 0;i < n;i++) { + for (j = 0; j< n;j++) hessian(i,j)=0.0; + hessian(i,i)=1.0; + xi(i) = -g(i); + sum += p(i)*p(i); + } + stpmax=STPMX*FMAX(sqrt(sum),(double)n); + for (its=1;its<=ITMAX;its++) { + *iter=its; + lnsrch(n,p,fp,g,xi,pnew,fret,stpmax,&check,func); + fp = *fret; + for (i = 0; i< n;i++) { + xi(i)=pnew(i)-p(i); + p(i)=pnew(i); + } + test=0.0; + for (i = 0;i< n;i++) { + temp=fabs(xi(i))/FMAX(fabs(p(i)),1.0); + if (temp > test) test=temp; + } + if (test < TOLX) { + return; + } + for (i=0;i test) test=temp; + } + if (test < gtol) { + return; + } + for (i=0;i EPS*sumdg*sumxi) { + fac=1.0/fac; + fad=1.0/fae; + for (i=0;i stpmax) + for (i=0;i test) test=temp; + } + alamin=TOLX/test; + alam=1.0; + for (;;) { + for (i=0;i0.5*alam) + tmplam=0.5*alam; + } + } + alam2=alam; + f2 = *f; + fold2=fold; + alam=FMAX(tmplam,0.1*alam); + } +} +#undef ALF +#undef TOLX + + + + + + diff --git a/doc/Programs/VMC2Electrons/vectormatrixclass.cpp b/doc/Programs/VMC2Electrons/vectormatrixclass.cpp new file mode 100755 index 000000000..b608779ae --- /dev/null +++ b/doc/Programs/VMC2Electrons/vectormatrixclass.cpp @@ -0,0 +1,726 @@ + +#include "vectormatrixclass.h" + +Point::Point(int dim){ + dimension = dim; + data = new double[dimension]; + + for(int i=0;i=0 && i=0 && i0) + cout << data[0]; + for(int i=1;i=0 && i=0 && i0) + cout << data[0]; + for(int i=1;i tmp)?maxval:tmp; + } + return(maxval); +} + +double Vector::MaxMod(){ + double maxm = -1.0e+10; + + for(int i=0; i fabs(data[i]))?maxm:fabs(data[i]); + + return maxm; +} + +double Vector::ElementofMaxMod(){ + return(data[MaxModindex()]); +} + + +int Vector::MaxModindex(){ + double maxm = -1.0e+10; + int maxmindex = 0; + + for(int i=0; i sum)?maxval:sum; + } + return(maxval); +} + + +double Matrix::Norm_l1(){ + double maxval = 0.0,sum; + + for(int j=0;j sum)?maxval:sum; + } + return(maxval); +} + + + +Matrix& Matrix::operator=(const Matrix &m){ + if( (rows == m.rows) && (columns == m.columns)){ + for(int i=0; i=0) && (j>=0) && (i=0) && (j>=0) && (imaxv)?fabs(data[row][i]):maxv; + + return maxv; +} + +double Matrix::MaxModInRow(int row, int starting_column){ + double maxv = -1.0e+10; + for(int i=starting_column;imaxv)?fabs(data[row][i]):maxv; + + return maxv; +} + +int Matrix::MaxModInRowindex(int row){ + int maxvindex = 0; + double maxv = -1.0e+10; + + for(int i=0;imaxv)?fabs(data[i][column]):maxv; + + return maxv; +} + +double Matrix::MaxModInColumn(int column, int starting_row){ + double maxv = -1.0e+10; + for(int i=starting_row;imaxv)?fabs(data[i][column]):maxv; + + return maxv; +} + +int Matrix::MaxModInColumnindex(int column){ + int maxvindex = 0; + double maxv = -1.0e+10; + + for(int i=0;i=0.0)?1.0:-1.0; + + return xs; +} + +//GammaF function valid for x integer, or x (integer+0.5) +double GammaF(double x){ + double gamma = 1.0; + + if (x == -0.5) + gamma = -2.0*sqrt(M_PI); + else if (!x) return gamma; + else if ((x-(int)x) == 0.5){ + int n = (int) x; + double tmp = x; + + gamma = sqrt(M_PI); + while(n--){ + tmp -= 1.0; + gamma *= tmp; + } + } + else if ((x-(int)x) == 0.0){ + int n = (int) x; + double tmp = x; + + while(--n){ + tmp -= 1.0; + gamma *= tmp; + } + } + + return gamma; +} + + +int Factorial(int n){ + int value=1; + for(int i=n;i>0;i--) + value = value*i; + + return value; +} + +double ** CreateMatrix(int m, int n){ + double ** mat; + mat = new double*[m]; + for(int i=0;i +#include +using namespace std; + + + +class Point; +class Vector; +class Matrix; + + +/********************************/ +/* Point Class */ +/********************************/ + +class Point{ + private: + int dimension; + double *data; + + public: + Point(int dim); + Point(const Point& v); + ~Point(); + + int Dimension() const; + + //************************ + // User Defined Operators + //************************ + int operator==(const Point& v) const; + int operator!=(const Point& v) const; + Point & operator=(const Point& v); + + double operator()(const int i) const; + double& operator()(const int i); + + void Print() const; +}; + + + +/********************************/ +/* Vector Class */ +/********************************/ + +class Vector{ + private: + int dimension; + double *data; + + public: + Vector(); + Vector(int dim); + Vector(const Vector& v); + Vector(int col, const Matrix &A); + ~Vector(); + + void Initialize(int dim); + int Dimension() const; + double Length(); /* Euclidean Norm of the Vector */ + void Normalize(); + + double Norm_l1(); + double Norm_l2(); + double Norm_linf(); + double MaxMod(); + double ElementofMaxMod(); + int MaxModindex(); + + //************************ + // User Defined Operators + //************************ + int operator==(const Vector& v) const; + int operator!=(const Vector& v) const; + Vector & operator=(const Vector& v); + + double operator()(const int i) const; + double& operator()(const int i); + + void Print() const; + void Initialize(double a); + void Initialize(double *v); +}; + + + +/********************************/ +/* Matrix Class */ +/********************************/ + +class Matrix { +private: + int rows, columns; + double **data; + +public: + + Matrix(int dim); + Matrix(int rows1, int columns1); + Matrix(const Matrix& m); + Matrix(int num_vectors, const Vector * q); + Matrix(int rows1, int columns1, double **rowptrs); + ~Matrix(); + + int Rows() const; + int Columns() const; + double ** GetPointer(); + void GetColumn(int col, Vector &x); + void GetColumn(int col, Vector &x, int rowoffset); + void PutColumn(int col, const Vector &x); + double Norm_l1(); + double Norm_linf(); + + //************************ + // User Defined Operators + //************************ + Matrix& operator=(const Matrix& m); + double operator()(const int i, const int j) const; + double& operator()(const int i, const int j); + + double MaxModInRow(int row); + double MaxModInRow(int row, int starting_column); + int MaxModInRowindex(int row); + int MaxModInRowindex(int row, int starting_column); + + double MaxModInColumn(int column); + double MaxModInColumn(int column, int starting_row); + int MaxModInColumnindex(int column); + int MaxModInColumnindex(int column, int starting_row); + + void RowSwap(int row1, int row2); + + void Print() const; + +}; + + +/********************************/ +/* Operator Declarations */ +/********************************/ + +// Unitary operator - +Vector operator-(const Vector& v); + +// Binary operator +,- +Vector operator+(const Vector& v1, const Vector& v2); +Vector operator-(const Vector& v1, const Vector& v2); + +// Vector Scaling (multiplication by a scaler : defined commutatively) +Vector operator*(const double s, const Vector& v); +Vector operator*(const Vector& v, const double s); + +// Vector Scaling (division by a scaler) +Vector operator/(const Vector& v, const double s); + +Vector operator*(const Matrix& A, const Vector& x); + + +/********************************/ +/* Function Declarations */ +/********************************/ + +int min_dimension(const Vector& u, const Vector& v); +double dot(const Vector& u, const Vector& v); +double dot(int N, double *a, double *b); +double dot(int N, const Vector &u, const Vector &v); +void Swap(double &a, double &b); +double Sign(double x); + +/* Misc. useful functions to have */ +double log2(double x); +double GammaF(double x); +int Factorial(int n); +double ** CreateMatrix(int m, int n); +void DestroyMatrix(double ** mat, int m, int n); + +int ** ICreateMatrix(int m, int n); +void IDestroyMatrix(int ** mat, int m, int n); + +#endif + + diff --git a/doc/Projects/2017/Project/html/._Project-bs000.html b/doc/Projects/2017/Project/html/._Project-bs000.html new file mode 100644 index 000000000..12aab079e --- /dev/null +++ b/doc/Projects/2017/Project/html/._Project-bs000.html @@ -0,0 +1,250 @@ + + + + + + + +Project on Machine Learning + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Project on Machine Learning

+ +

+ + +

+Data Analysis and Machine Learning FYS-MAT3155/FYS4155 +
+ +

+ + +

Department of Physics, University of Oslo, Norway
+
+

+

Fall semester 2017

+
+

+

+ +

Using results from Monte Carlo models for machine learning

+ +

Introduction

+ +

+The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +

+In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +$$ +E=-J\sum_{< kl >}^{N}s_ks_l +$$ + +with +\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol \( < kl> \) indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz \( J> 0 \). We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +

Part a): Producing the data

+ +

+\( \langle E\rangle \) and \( \langle \vert M\vert \rangle \), the specific heat +\( C_V \) and the susceptibility \( \chi \) as functions of \( T \) for \( L=40 \), +\( L=60 \), \( L=100 \) and \( L=140 \) for \( T\in [2.0,2.3] \) with a step in +temperature \( \Delta T=0.05 \) or smaller. You may find it convenient narrow the domain for \( T \). + +

+Plot \( \langle E\rangle \), +\( \langle \vert M\vert\rangle \), \( C_V \) and \( \chi \) as functions of \( T \). + +

Part b): Fitting the data using regression analysis and other methods

+ +

+More text to come + +

Part c): Introducing Bayesian statistics

+ +More text to come + +

Part d): Studying the Ising model or the VMC results with Neural networks

+ +More text to come + +

Background literature

+ +

+If you wish to read more about the Ising model and statistical physics here are three suggestions. + +

+ +

Introduction to numerical projects

+ +

+Here follows a brief recipe and recommendation on how to write a report for each +project. + +

    +
  • Give a short description of the nature of the problem and the eventual numerical methods you have used.
  • +
  • Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
  • +
  • Include the source code of your program. Comment your program properly.
  • +
  • If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
  • +
  • Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
  • +
  • Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
  • +
  • Try to give an interpretation of you results in your answers to the problems.
  • +
  • Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
  • +
  • Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
  • +
+ + +

+ +

    +
  • 1
  • +
+ + +
+ + + + + + + +
+ © 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/Projects/2017/Project/html/Project-bs.html b/doc/Projects/2017/Project/html/Project-bs.html new file mode 100644 index 000000000..12aab079e --- /dev/null +++ b/doc/Projects/2017/Project/html/Project-bs.html @@ -0,0 +1,250 @@ + + + + + + + +Project on Machine Learning + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Project on Machine Learning

+ +

+ + +

+Data Analysis and Machine Learning FYS-MAT3155/FYS4155 +
+ +

+ + +

Department of Physics, University of Oslo, Norway
+
+

+

Fall semester 2017

+
+

+

+ +

Using results from Monte Carlo models for machine learning

+ +

Introduction

+ +

+The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +

+In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +$$ +E=-J\sum_{< kl >}^{N}s_ks_l +$$ + +with +\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol \( < kl> \) indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz \( J> 0 \). We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +

Part a): Producing the data

+ +

+\( \langle E\rangle \) and \( \langle \vert M\vert \rangle \), the specific heat +\( C_V \) and the susceptibility \( \chi \) as functions of \( T \) for \( L=40 \), +\( L=60 \), \( L=100 \) and \( L=140 \) for \( T\in [2.0,2.3] \) with a step in +temperature \( \Delta T=0.05 \) or smaller. You may find it convenient narrow the domain for \( T \). + +

+Plot \( \langle E\rangle \), +\( \langle \vert M\vert\rangle \), \( C_V \) and \( \chi \) as functions of \( T \). + +

Part b): Fitting the data using regression analysis and other methods

+ +

+More text to come + +

Part c): Introducing Bayesian statistics

+ +More text to come + +

Part d): Studying the Ising model or the VMC results with Neural networks

+ +More text to come + +

Background literature

+ +

+If you wish to read more about the Ising model and statistical physics here are three suggestions. + +

+ +

Introduction to numerical projects

+ +

+Here follows a brief recipe and recommendation on how to write a report for each +project. + +

    +
  • Give a short description of the nature of the problem and the eventual numerical methods you have used.
  • +
  • Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
  • +
  • Include the source code of your program. Comment your program properly.
  • +
  • If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
  • +
  • Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
  • +
  • Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
  • +
  • Try to give an interpretation of you results in your answers to the problems.
  • +
  • Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
  • +
  • Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
  • +
+ + +

+ +

    +
  • 1
  • +
+ + +
+ + + + + + + +
+ © 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/Projects/2017/Project/html/Project.html b/doc/Projects/2017/Project/html/Project.html new file mode 100644 index 000000000..634532fda --- /dev/null +++ b/doc/Projects/2017/Project/html/Project.html @@ -0,0 +1,193 @@ + + + + + + + +Project on Machine Learning + + + + + + + + + + + + + + + + + + + + + + + +

Project on Machine Learning

+ +

+ + +

+Data Analysis and Machine Learning FYS-MAT3155/FYS4155 +
+ +

+ + +

Department of Physics, University of Oslo, Norway
+
+

+

Fall semester 2017

+
+ +

Using results from Monte Carlo models for machine learning

+ +

Introduction

+ +

+The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +

+In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +$$ +E=-J\sum_{< kl >}^{N}s_ks_l +$$ + +with +\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol \( < kl> \) indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz \( J> 0 \). We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +

Part a): Producing the data

+ +

+\( \langle E\rangle \) and \( \langle \vert M\vert \rangle \), the specific heat +\( C_V \) and the susceptibility \( \chi \) as functions of \( T \) for \( L=40 \), +\( L=60 \), \( L=100 \) and \( L=140 \) for \( T\in [2.0,2.3] \) with a step in +temperature \( \Delta T=0.05 \) or smaller. You may find it convenient narrow the domain for \( T \). + +

+Plot \( \langle E\rangle \), +\( \langle \vert M\vert\rangle \), \( C_V \) and \( \chi \) as functions of \( T \). + +

Part b): Fitting the data using regression analysis and other methods

+ +

+More text to come + +

Part c): Introducing Bayesian statistics

+ +More text to come + +

Part d): Studying the Ising model or the VMC results with Neural networks

+ +More text to come + +

Background literature

+ +

+If you wish to read more about the Ising model and statistical physics here are three suggestions. + +

+ +

Introduction to numerical projects

+ +

+Here follows a brief recipe and recommendation on how to write a report for each +project. + +

    +
  • Give a short description of the nature of the problem and the eventual numerical methods you have used.
  • +
  • Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
  • +
  • Include the source code of your program. Comment your program properly.
  • +
  • If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
  • +
  • Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
  • +
  • Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
  • +
  • Try to give an interpretation of you results in your answers to the problems.
  • +
  • Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
  • +
  • Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
  • +
+ + + + + +
+ © 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/Projects/2017/Project/ipynb b/doc/Projects/2017/Project/ipynb new file mode 100644 index 000000000..02d8b804e Binary files /dev/null and b/doc/Projects/2017/Project/ipynb differ diff --git a/doc/Projects/2017/Project/pdf/Project.p.tex b/doc/Projects/2017/Project/pdf/Project.p.tex new file mode 100644 index 000000000..eab505f2f --- /dev/null +++ b/doc/Projects/2017/Project/pdf/Project.p.tex @@ -0,0 +1,239 @@ +%% +%% Automatically generated file from DocOnce source +%% (https://github.com/hplgit/doconce/) +%% +%% +% #ifdef PTEX2TEX_EXPLANATION +%% +%% The file follows the ptex2tex extended LaTeX format, see +%% ptex2tex: http://code.google.com/p/ptex2tex/ +%% +%% Run +%% ptex2tex myfile +%% or +%% doconce ptex2tex myfile +%% +%% to turn myfile.p.tex into an ordinary LaTeX file myfile.tex. +%% (The ptex2tex program: http://code.google.com/p/ptex2tex) +%% Many preprocess options can be added to ptex2tex or doconce ptex2tex +%% +%% ptex2tex -DMINTED myfile +%% doconce ptex2tex myfile envir=minted +%% +%% ptex2tex will typeset code environments according to a global or local +%% .ptex2tex.cfg configure file. doconce ptex2tex will typeset code +%% according to options on the command line (just type doconce ptex2tex to +%% see examples). If doconce ptex2tex has envir=minted, it enables the +%% minted style without needing -DMINTED. +% #endif + +% #define PREAMBLE + +% #ifdef PREAMBLE +%-------------------- begin preamble ---------------------- + +\documentclass[% +oneside, % oneside: electronic viewing, twoside: printing +final, % draft: marks overfull hboxes, figures with paths +10pt]{article} + +\listfiles % print all files needed to compile this document + +\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb} +\usepackage[table]{xcolor} +\usepackage{bm,ltablex,microtype} + +\usepackage[pdftex]{graphicx} + +\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} +\usepackage{ucs} +\usepackage[utf8x]{inputenc} + +\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern + +% Hyperlinks in PDF: +\definecolor{linkcolor}{rgb}{0,0,0.4} +\usepackage{hyperref} +\hypersetup{ + breaklinks=true, + colorlinks=true, + linkcolor=linkcolor, + urlcolor=linkcolor, + citecolor=black, + filecolor=black, + %filecolor=blue, + pdfmenubar=true, + pdftoolbar=true, + bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC + } +%\hyperbaseurl{} % hyperlinks are relative to this root + +\setcounter{tocdepth}{2} % levels in table of contents + +% --- fancyhdr package for fancy headers --- +\usepackage{fancyhdr} +\fancyhf{} % sets both header and footer to nothing +\renewcommand{\headrulewidth}{0pt} +\fancyfoot[LE,RO]{\thepage} +% Ensure copyright on titlepage (article style) and chapter pages (book style) +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} +% \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} +% Ensure copyright on titlepages with \thispagestyle{empty} +\fancypagestyle{empty}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} + \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} + +\pagestyle{fancy} + + +% prevent orhpans and widows +\clubpenalty = 10000 +\widowpenalty = 10000 + +% --- end of standard preamble for documents --- + + +% insert custom LaTeX commands... + +\raggedbottom +\makeindex +\usepackage[totoc]{idxlayout} % for index in the toc +\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc + +%-------------------- end preamble ---------------------- + +\begin{document} + +% matching end for #ifdef PREAMBLE +% #endif + +\newcommand{\exercisesection}[1]{\subsection*{#1}} + + +% ------------------- main content ---------------------- + + + +% ----------------- title ------------------------- + +\thispagestyle{empty} + +\begin{center} +{\LARGE\bf +\begin{spacing}{1.25} +Project on Machine Learning +\end{spacing} +} +\end{center} + +% ----------------- author(s) ------------------------- + +\begin{center} +{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-MAT3155/FYS4155}} +\end{center} + + \begin{center} +% List of all institutions: +\centerline{{\small Department of Physics, University of Oslo, Norway}} +\end{center} + +% ----------------- end author(s) ------------------------- + +% --- begin date --- +\begin{center} +Fall semester 2017 +\end{center} +% --- end date --- + +\vspace{1cm} + + +\subsection{Using results from Monte Carlo models for machine learning} + +\paragraph{Introduction.} +The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +\[ +E=-J\sum_{< kl >}^{N}s_ks_l +\] +with +$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol $$ indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz $J> 0$. We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +\paragraph{Part a): Producing the data.} +$\langle E\rangle$ and $\langle \vert M\vert \rangle$, the specific heat +$C_V$ and the susceptibility $\chi$ as functions of $T$ for $L=40$, +$L=60$, $L=100$ and $L=140$ for $T\in [2.0,2.3]$ with a step in +temperature $\Delta T=0.05$ or smaller. You may find it convenient narrow the domain for $T$. + +Plot $\langle E\rangle$, +$\langle \vert M\vert\rangle$, $C_V$ and $\chi$ as functions of $T$. + +\paragraph{Part b): Fitting the data using regression analysis and other methods.} +More text to come +\paragraph{Part c): Introducing Bayesian statistics.} +More text to come + +\paragraph{Part d): Studying the Ising model or the VMC results with Neural networks.} +More text to come + +\subsection{Background literature} + +If you wish to read more about the Ising model and statistical physics here are three suggestions. + +\begin{itemize} + \item \href{{http://www.worldscientific.com/worldscibooks/10.1142/5660}}{M. Plischke and B. Bergersen}, \emph{Equilibrium Statistical Physics}, World Scientific, see chapters 5 and 6. + + \item \href{{http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB}}{D. P. Landau and K. Binder}, \emph{A Guide to Monte Carlo Simulations in Statistical Physics}, Cambridge, see chapters 2,3 and 4. + + \item \href{{https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&}}{M. E. J. Newman and T. Barkema}, \emph{Monte Carlo Methods in Statistical Physics}, Oxford, see chapters 3 and 4. +\end{itemize} + +\noindent +\subsection{Introduction to numerical projects} + +Here follows a brief recipe and recommendation on how to write a report for each +project. + +\begin{itemize} + \item Give a short description of the nature of the problem and the eventual numerical methods you have used. + + \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + \item Include the source code of your program. Comment your program properly. + + \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + \item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + \item Try to give an interpretation of you results in your answers to the problems. + + \item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + \item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. +\end{itemize} + +\noindent + +% ------------------- end of main content --------------- + +% #ifdef PREAMBLE +\end{document} +% #endif + diff --git a/doc/Projects/2017/Project/pdf/Project.pdf b/doc/Projects/2017/Project/pdf/Project.pdf new file mode 100644 index 000000000..d44f7c710 Binary files /dev/null and b/doc/Projects/2017/Project/pdf/Project.pdf differ diff --git a/doc/Projects/2017/Project/pdf/Project.tex b/doc/Projects/2017/Project/pdf/Project.tex new file mode 100644 index 000000000..d6b8d47ca --- /dev/null +++ b/doc/Projects/2017/Project/pdf/Project.tex @@ -0,0 +1,211 @@ +%% +%% Automatically generated file from DocOnce source +%% (https://github.com/hplgit/doconce/) +%% +%% + + +%-------------------- begin preamble ---------------------- + +\documentclass[% +oneside, % oneside: electronic viewing, twoside: printing +final, % draft: marks overfull hboxes, figures with paths +10pt]{article} + +\listfiles % print all files needed to compile this document + +\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb} +\usepackage[table]{xcolor} +\usepackage{bm,ltablex,microtype} + +\usepackage[pdftex]{graphicx} + +\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} +\usepackage{ucs} +\usepackage[utf8x]{inputenc} + +\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern + +% Hyperlinks in PDF: +\definecolor{linkcolor}{rgb}{0,0,0.4} +\usepackage{hyperref} +\hypersetup{ + breaklinks=true, + colorlinks=true, + linkcolor=linkcolor, + urlcolor=linkcolor, + citecolor=black, + filecolor=black, + %filecolor=blue, + pdfmenubar=true, + pdftoolbar=true, + bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC + } +%\hyperbaseurl{} % hyperlinks are relative to this root + +\setcounter{tocdepth}{2} % levels in table of contents + +% --- fancyhdr package for fancy headers --- +\usepackage{fancyhdr} +\fancyhf{} % sets both header and footer to nothing +\renewcommand{\headrulewidth}{0pt} +\fancyfoot[LE,RO]{\thepage} +% Ensure copyright on titlepage (article style) and chapter pages (book style) +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} +% \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} +% Ensure copyright on titlepages with \thispagestyle{empty} +\fancypagestyle{empty}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} + \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} + +\pagestyle{fancy} + + +% prevent orhpans and widows +\clubpenalty = 10000 +\widowpenalty = 10000 + +% --- end of standard preamble for documents --- + + +% insert custom LaTeX commands... + +\raggedbottom +\makeindex +\usepackage[totoc]{idxlayout} % for index in the toc +\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc + +%-------------------- end preamble ---------------------- + +\begin{document} + +% matching end for #ifdef PREAMBLE + +\newcommand{\exercisesection}[1]{\subsection*{#1}} + + +% ------------------- main content ---------------------- + + + +% ----------------- title ------------------------- + +\thispagestyle{empty} + +\begin{center} +{\LARGE\bf +\begin{spacing}{1.25} +Project on Machine Learning +\end{spacing} +} +\end{center} + +% ----------------- author(s) ------------------------- + +\begin{center} +{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-MAT3155/FYS4155}} +\end{center} + + \begin{center} +% List of all institutions: +\centerline{{\small Department of Physics, University of Oslo, Norway}} +\end{center} + +% ----------------- end author(s) ------------------------- + +% --- begin date --- +\begin{center} +Fall semester 2017 +\end{center} +% --- end date --- + +\vspace{1cm} + + +\subsection*{Using results from Monte Carlo models for machine learning} + +\paragraph{Introduction.} +The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +\[ +E=-J\sum_{< kl >}^{N}s_ks_l +\] +with +$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol $$ indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz $J> 0$. We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +\paragraph{Part a): Producing the data.} +$\langle E\rangle$ and $\langle \vert M\vert \rangle$, the specific heat +$C_V$ and the susceptibility $\chi$ as functions of $T$ for $L=40$, +$L=60$, $L=100$ and $L=140$ for $T\in [2.0,2.3]$ with a step in +temperature $\Delta T=0.05$ or smaller. You may find it convenient narrow the domain for $T$. + +Plot $\langle E\rangle$, +$\langle \vert M\vert\rangle$, $C_V$ and $\chi$ as functions of $T$. + +\paragraph{Part b): Fitting the data using regression analysis and other methods.} +More text to come +\paragraph{Part c): Introducing Bayesian statistics.} +More text to come + +\paragraph{Part d): Studying the Ising model or the VMC results with Neural networks.} +More text to come + +\subsection*{Background literature} + +If you wish to read more about the Ising model and statistical physics here are three suggestions. + +\begin{itemize} + \item \href{{http://www.worldscientific.com/worldscibooks/10.1142/5660}}{M. Plischke and B. Bergersen}, \emph{Equilibrium Statistical Physics}, World Scientific, see chapters 5 and 6. + + \item \href{{http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB}}{D. P. Landau and K. Binder}, \emph{A Guide to Monte Carlo Simulations in Statistical Physics}, Cambridge, see chapters 2,3 and 4. + + \item \href{{https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&}}{M. E. J. Newman and T. Barkema}, \emph{Monte Carlo Methods in Statistical Physics}, Oxford, see chapters 3 and 4. +\end{itemize} + +\noindent +\subsection*{Introduction to numerical projects} + +Here follows a brief recipe and recommendation on how to write a report for each +project. + +\begin{itemize} + \item Give a short description of the nature of the problem and the eventual numerical methods you have used. + + \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + \item Include the source code of your program. Comment your program properly. + + \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + \item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + \item Try to give an interpretation of you results in your answers to the problems. + + \item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + \item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. +\end{itemize} + +\noindent + +% ------------------- end of main content --------------- + +\end{document} + diff --git a/doc/src/Projects/2017/Project/Project-bs.html b/doc/src/Projects/2017/Project/Project-bs.html new file mode 100644 index 000000000..12aab079e --- /dev/null +++ b/doc/src/Projects/2017/Project/Project-bs.html @@ -0,0 +1,250 @@ + + + + + + + +Project on Machine Learning + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Project on Machine Learning

+ +

+ + +

+Data Analysis and Machine Learning FYS-MAT3155/FYS4155 +
+ +

+ + +

Department of Physics, University of Oslo, Norway
+
+

+

Fall semester 2017

+
+

+

+ +

Using results from Monte Carlo models for machine learning

+ +

Introduction

+ +

+The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +

+In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +$$ +E=-J\sum_{< kl >}^{N}s_ks_l +$$ + +with +\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol \( < kl> \) indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz \( J> 0 \). We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +

Part a): Producing the data

+ +

+\( \langle E\rangle \) and \( \langle \vert M\vert \rangle \), the specific heat +\( C_V \) and the susceptibility \( \chi \) as functions of \( T \) for \( L=40 \), +\( L=60 \), \( L=100 \) and \( L=140 \) for \( T\in [2.0,2.3] \) with a step in +temperature \( \Delta T=0.05 \) or smaller. You may find it convenient narrow the domain for \( T \). + +

+Plot \( \langle E\rangle \), +\( \langle \vert M\vert\rangle \), \( C_V \) and \( \chi \) as functions of \( T \). + +

Part b): Fitting the data using regression analysis and other methods

+ +

+More text to come + +

Part c): Introducing Bayesian statistics

+ +More text to come + +

Part d): Studying the Ising model or the VMC results with Neural networks

+ +More text to come + +

Background literature

+ +

+If you wish to read more about the Ising model and statistical physics here are three suggestions. + +

+ +

Introduction to numerical projects

+ +

+Here follows a brief recipe and recommendation on how to write a report for each +project. + +

    +
  • Give a short description of the nature of the problem and the eventual numerical methods you have used.
  • +
  • Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
  • +
  • Include the source code of your program. Comment your program properly.
  • +
  • If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
  • +
  • Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
  • +
  • Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
  • +
  • Try to give an interpretation of you results in your answers to the problems.
  • +
  • Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
  • +
  • Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
  • +
+ + +

+ +

    +
  • 1
  • +
+ + +
+ + + + + + + +
+ © 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/src/Projects/2017/Project/Project.do.txt b/doc/src/Projects/2017/Project/Project.do.txt new file mode 100644 index 000000000..525efc842 --- /dev/null +++ b/doc/src/Projects/2017/Project/Project.do.txt @@ -0,0 +1,88 @@ +TITLE: Project on Machine Learning +AUTHOR: "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html" {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo, Norway +DATE: Fall semester 2017 + + +===== Using results from Monte Carlo models for machine learning ===== + +=== Introduction === + +The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +!bt +\[ +E=-J\sum_{< kl >}^{N}s_ks_l +\] +!et +with +$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol $$ indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz $J> 0$. We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +=== Part a): Producing the data === + + +$\langle E\rangle$ and $\langle \vert M\vert \rangle$, the specific heat +$C_V$ and the susceptibility $\chi$ as functions of $T$ for $L=40$, +$L=60$, $L=100$ and $L=140$ for $T\in [2.0,2.3]$ with a step in +temperature $\Delta T=0.05$ or smaller. You may find it convenient narrow the domain for $T$. + +Plot $\langle E\rangle$, +$\langle \vert M\vert\rangle$, $C_V$ and $\chi$ as functions of $T$. + +=== Part b): Fitting the data using regression analysis and other methods === + +More text to come +=== Part c): Introducing Bayesian statistics === +More text to come + +=== Part d): Studying the Ising model or the VMC results with Neural networks === +More text to come + +===== Background literature ===== + +If you wish to read more about the Ising model and statistical physics here are three suggestions. + + * "M. Plischke and B. Bergersen":"http://www.worldscientific.com/worldscibooks/10.1142/5660", *Equilibrium Statistical Physics*, World Scientific, see chapters 5 and 6. + + * "D. P. Landau and K. Binder":"http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB", *A Guide to Monte Carlo Simulations in Statistical Physics*, Cambridge, see chapters 2,3 and 4. + + * "M. E. J. Newman and T. Barkema":"https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&", *Monte Carlo Methods in Statistical Physics*, Oxford, see chapters 3 and 4. + + +===== Introduction to numerical projects ===== + +Here follows a brief recipe and recommendation on how to write a report for each +project. + + * Give a short description of the nature of the problem and the eventual numerical methods you have used. + + * Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + * Include the source code of your program. Comment your program properly. + + * If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + * Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + * Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + * Try to give an interpretation of you results in your answers to the problems. + + * Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + * Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. + + + + + + + + + diff --git a/doc/src/Projects/2017/Project/Project.html b/doc/src/Projects/2017/Project/Project.html new file mode 100644 index 000000000..634532fda --- /dev/null +++ b/doc/src/Projects/2017/Project/Project.html @@ -0,0 +1,193 @@ + + + + + + + +Project on Machine Learning + + + + + + + + + + + + + + + + + + + + + + + +

Project on Machine Learning

+ +

+ + +

+Data Analysis and Machine Learning FYS-MAT3155/FYS4155 +
+ +

+ + +

Department of Physics, University of Oslo, Norway
+
+

+

Fall semester 2017

+
+ +

Using results from Monte Carlo models for machine learning

+ +

Introduction

+ +

+The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +

+In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +$$ +E=-J\sum_{< kl >}^{N}s_ks_l +$$ + +with +\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol \( < kl> \) indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz \( J> 0 \). We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +

Part a): Producing the data

+ +

+\( \langle E\rangle \) and \( \langle \vert M\vert \rangle \), the specific heat +\( C_V \) and the susceptibility \( \chi \) as functions of \( T \) for \( L=40 \), +\( L=60 \), \( L=100 \) and \( L=140 \) for \( T\in [2.0,2.3] \) with a step in +temperature \( \Delta T=0.05 \) or smaller. You may find it convenient narrow the domain for \( T \). + +

+Plot \( \langle E\rangle \), +\( \langle \vert M\vert\rangle \), \( C_V \) and \( \chi \) as functions of \( T \). + +

Part b): Fitting the data using regression analysis and other methods

+ +

+More text to come + +

Part c): Introducing Bayesian statistics

+ +More text to come + +

Part d): Studying the Ising model or the VMC results with Neural networks

+ +More text to come + +

Background literature

+ +

+If you wish to read more about the Ising model and statistical physics here are three suggestions. + +

+ +

Introduction to numerical projects

+ +

+Here follows a brief recipe and recommendation on how to write a report for each +project. + +

    +
  • Give a short description of the nature of the problem and the eventual numerical methods you have used.
  • +
  • Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
  • +
  • Include the source code of your program. Comment your program properly.
  • +
  • If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
  • +
  • Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
  • +
  • Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
  • +
  • Try to give an interpretation of you results in your answers to the problems.
  • +
  • Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
  • +
  • Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
  • +
+ + + + + +
+ © 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/src/Projects/2017/Project/Project.ipynb b/doc/src/Projects/2017/Project/Project.ipynb new file mode 100644 index 000000000..6fb226086 --- /dev/null +++ b/doc/src/Projects/2017/Project/Project.ipynb @@ -0,0 +1,104 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "# Project on Machine Learning\n", + "\n", + " **[Data Analysis and Machine Learning FYS-MAT3155/FYS4155](http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html)**, Department of Physics, University of Oslo, Norway\n", + "\n", + "Date: **Fall semester 2017**\n", + "\n", + "## Using results from Monte Carlo models for machine learning\n", + "\n", + "### Introduction\n", + "\n", + "The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters.\n", + "\n", + "In its simplest form\n", + "the energy of the Ising model is expressed as, without an externally applied magnetic field," + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "E=-J\\sum_{< kl >}^{N}s_ks_l\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "with\n", + "$s_k=\\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling\n", + "constant expressing the strength of the interaction between\n", + "neighboring spins. The symbol $$ indicates that we sum over\n", + "nearest neighbors only. We will assume that we have a ferromagnetic\n", + "ordering, viz $J> 0$. We will use periodic boundary conditions and\n", + "the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. \n", + "\n", + "### Part a): Producing the data\n", + "\n", + "$\\langle E\\rangle$ and $\\langle \\vert M\\vert \\rangle$, the specific heat\n", + "$C_V$ and the susceptibility $\\chi$ as functions of $T$ for $L=40$,\n", + "$L=60$, $L=100$ and $L=140$ for $T\\in [2.0,2.3]$ with a step in\n", + "temperature $\\Delta T=0.05$ or smaller. You may find it convenient narrow the domain for $T$. \n", + "\n", + "Plot $\\langle E\\rangle$,\n", + "$\\langle \\vert M\\vert\\rangle$, $C_V$ and $\\chi$ as functions of $T$.\n", + "\n", + "### Part b): Fitting the data using regression analysis and other methods\n", + "\n", + "More text to come\n", + "### Part c): Introducing Bayesian statistics\n", + "\n", + "More text to come\n", + "\n", + "### Part d): Studying the Ising model or the VMC results with Neural networks\n", + "\n", + "More text to come\n", + "\n", + "## Background literature\n", + "\n", + "If you wish to read more about the Ising model and statistical physics here are three suggestions.\n", + "\n", + " * [M. Plischke and B. Bergersen](http://www.worldscientific.com/worldscibooks/10.1142/5660), *Equilibrium Statistical Physics*, World Scientific, see chapters 5 and 6.\n", + "\n", + " * [D. P. Landau and K. Binder](http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB), *A Guide to Monte Carlo Simulations in Statistical Physics*, Cambridge, see chapters 2,3 and 4.\n", + "\n", + " * [M. E. J. Newman and T. Barkema](https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&), *Monte Carlo Methods in Statistical Physics*, Oxford, see chapters 3 and 4.\n", + "\n", + "## Introduction to numerical projects\n", + "\n", + "Here follows a brief recipe and recommendation on how to write a report for each\n", + "project.\n", + "\n", + " * Give a short description of the nature of the problem and the eventual numerical methods you have used.\n", + "\n", + " * Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.\n", + "\n", + " * Include the source code of your program. Comment your program properly.\n", + "\n", + " * If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.\n", + "\n", + " * Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.\n", + "\n", + " * Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.\n", + "\n", + " * Try to give an interpretation of you results in your answers to the problems.\n", + "\n", + " * Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.\n", + "\n", + " * Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning." + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/doc/src/Projects/2017/Project/Project.p.tex b/doc/src/Projects/2017/Project/Project.p.tex new file mode 100644 index 000000000..eab505f2f --- /dev/null +++ b/doc/src/Projects/2017/Project/Project.p.tex @@ -0,0 +1,239 @@ +%% +%% Automatically generated file from DocOnce source +%% (https://github.com/hplgit/doconce/) +%% +%% +% #ifdef PTEX2TEX_EXPLANATION +%% +%% The file follows the ptex2tex extended LaTeX format, see +%% ptex2tex: http://code.google.com/p/ptex2tex/ +%% +%% Run +%% ptex2tex myfile +%% or +%% doconce ptex2tex myfile +%% +%% to turn myfile.p.tex into an ordinary LaTeX file myfile.tex. +%% (The ptex2tex program: http://code.google.com/p/ptex2tex) +%% Many preprocess options can be added to ptex2tex or doconce ptex2tex +%% +%% ptex2tex -DMINTED myfile +%% doconce ptex2tex myfile envir=minted +%% +%% ptex2tex will typeset code environments according to a global or local +%% .ptex2tex.cfg configure file. doconce ptex2tex will typeset code +%% according to options on the command line (just type doconce ptex2tex to +%% see examples). If doconce ptex2tex has envir=minted, it enables the +%% minted style without needing -DMINTED. +% #endif + +% #define PREAMBLE + +% #ifdef PREAMBLE +%-------------------- begin preamble ---------------------- + +\documentclass[% +oneside, % oneside: electronic viewing, twoside: printing +final, % draft: marks overfull hboxes, figures with paths +10pt]{article} + +\listfiles % print all files needed to compile this document + +\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb} +\usepackage[table]{xcolor} +\usepackage{bm,ltablex,microtype} + +\usepackage[pdftex]{graphicx} + +\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} +\usepackage{ucs} +\usepackage[utf8x]{inputenc} + +\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern + +% Hyperlinks in PDF: +\definecolor{linkcolor}{rgb}{0,0,0.4} +\usepackage{hyperref} +\hypersetup{ + breaklinks=true, + colorlinks=true, + linkcolor=linkcolor, + urlcolor=linkcolor, + citecolor=black, + filecolor=black, + %filecolor=blue, + pdfmenubar=true, + pdftoolbar=true, + bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC + } +%\hyperbaseurl{} % hyperlinks are relative to this root + +\setcounter{tocdepth}{2} % levels in table of contents + +% --- fancyhdr package for fancy headers --- +\usepackage{fancyhdr} +\fancyhf{} % sets both header and footer to nothing +\renewcommand{\headrulewidth}{0pt} +\fancyfoot[LE,RO]{\thepage} +% Ensure copyright on titlepage (article style) and chapter pages (book style) +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} +% \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} +% Ensure copyright on titlepages with \thispagestyle{empty} +\fancypagestyle{empty}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} + \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} + +\pagestyle{fancy} + + +% prevent orhpans and widows +\clubpenalty = 10000 +\widowpenalty = 10000 + +% --- end of standard preamble for documents --- + + +% insert custom LaTeX commands... + +\raggedbottom +\makeindex +\usepackage[totoc]{idxlayout} % for index in the toc +\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc + +%-------------------- end preamble ---------------------- + +\begin{document} + +% matching end for #ifdef PREAMBLE +% #endif + +\newcommand{\exercisesection}[1]{\subsection*{#1}} + + +% ------------------- main content ---------------------- + + + +% ----------------- title ------------------------- + +\thispagestyle{empty} + +\begin{center} +{\LARGE\bf +\begin{spacing}{1.25} +Project on Machine Learning +\end{spacing} +} +\end{center} + +% ----------------- author(s) ------------------------- + +\begin{center} +{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-MAT3155/FYS4155}} +\end{center} + + \begin{center} +% List of all institutions: +\centerline{{\small Department of Physics, University of Oslo, Norway}} +\end{center} + +% ----------------- end author(s) ------------------------- + +% --- begin date --- +\begin{center} +Fall semester 2017 +\end{center} +% --- end date --- + +\vspace{1cm} + + +\subsection{Using results from Monte Carlo models for machine learning} + +\paragraph{Introduction.} +The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +\[ +E=-J\sum_{< kl >}^{N}s_ks_l +\] +with +$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol $$ indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz $J> 0$. We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +\paragraph{Part a): Producing the data.} +$\langle E\rangle$ and $\langle \vert M\vert \rangle$, the specific heat +$C_V$ and the susceptibility $\chi$ as functions of $T$ for $L=40$, +$L=60$, $L=100$ and $L=140$ for $T\in [2.0,2.3]$ with a step in +temperature $\Delta T=0.05$ or smaller. You may find it convenient narrow the domain for $T$. + +Plot $\langle E\rangle$, +$\langle \vert M\vert\rangle$, $C_V$ and $\chi$ as functions of $T$. + +\paragraph{Part b): Fitting the data using regression analysis and other methods.} +More text to come +\paragraph{Part c): Introducing Bayesian statistics.} +More text to come + +\paragraph{Part d): Studying the Ising model or the VMC results with Neural networks.} +More text to come + +\subsection{Background literature} + +If you wish to read more about the Ising model and statistical physics here are three suggestions. + +\begin{itemize} + \item \href{{http://www.worldscientific.com/worldscibooks/10.1142/5660}}{M. Plischke and B. Bergersen}, \emph{Equilibrium Statistical Physics}, World Scientific, see chapters 5 and 6. + + \item \href{{http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB}}{D. P. Landau and K. Binder}, \emph{A Guide to Monte Carlo Simulations in Statistical Physics}, Cambridge, see chapters 2,3 and 4. + + \item \href{{https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&}}{M. E. J. Newman and T. Barkema}, \emph{Monte Carlo Methods in Statistical Physics}, Oxford, see chapters 3 and 4. +\end{itemize} + +\noindent +\subsection{Introduction to numerical projects} + +Here follows a brief recipe and recommendation on how to write a report for each +project. + +\begin{itemize} + \item Give a short description of the nature of the problem and the eventual numerical methods you have used. + + \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + \item Include the source code of your program. Comment your program properly. + + \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + \item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + \item Try to give an interpretation of you results in your answers to the problems. + + \item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + \item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. +\end{itemize} + +\noindent + +% ------------------- end of main content --------------- + +% #ifdef PREAMBLE +\end{document} +% #endif + diff --git a/doc/src/Projects/2017/Project/Project.pdf b/doc/src/Projects/2017/Project/Project.pdf new file mode 100644 index 000000000..d44f7c710 Binary files /dev/null and b/doc/src/Projects/2017/Project/Project.pdf differ diff --git a/doc/src/Projects/2017/Project/Project.tex b/doc/src/Projects/2017/Project/Project.tex new file mode 100644 index 000000000..d6b8d47ca --- /dev/null +++ b/doc/src/Projects/2017/Project/Project.tex @@ -0,0 +1,211 @@ +%% +%% Automatically generated file from DocOnce source +%% (https://github.com/hplgit/doconce/) +%% +%% + + +%-------------------- begin preamble ---------------------- + +\documentclass[% +oneside, % oneside: electronic viewing, twoside: printing +final, % draft: marks overfull hboxes, figures with paths +10pt]{article} + +\listfiles % print all files needed to compile this document + +\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb} +\usepackage[table]{xcolor} +\usepackage{bm,ltablex,microtype} + +\usepackage[pdftex]{graphicx} + +\usepackage[T1]{fontenc} +%\usepackage[latin1]{inputenc} +\usepackage{ucs} +\usepackage[utf8x]{inputenc} + +\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern + +% Hyperlinks in PDF: +\definecolor{linkcolor}{rgb}{0,0,0.4} +\usepackage{hyperref} +\hypersetup{ + breaklinks=true, + colorlinks=true, + linkcolor=linkcolor, + urlcolor=linkcolor, + citecolor=black, + filecolor=black, + %filecolor=blue, + pdfmenubar=true, + pdftoolbar=true, + bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC + } +%\hyperbaseurl{} % hyperlinks are relative to this root + +\setcounter{tocdepth}{2} % levels in table of contents + +% --- fancyhdr package for fancy headers --- +\usepackage{fancyhdr} +\fancyhf{} % sets both header and footer to nothing +\renewcommand{\headrulewidth}{0pt} +\fancyfoot[LE,RO]{\thepage} +% Ensure copyright on titlepage (article style) and chapter pages (book style) +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} +% \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} +% Ensure copyright on titlepages with \thispagestyle{empty} +\fancypagestyle{empty}{ + \fancyhf{} + \fancyfoot[C]{{\footnotesize \copyright\ 1999-2017, "Data Analysis and Machine Learning FYS-MAT3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license}} + \renewcommand{\footrulewidth}{0mm} + \renewcommand{\headrulewidth}{0mm} +} + +\pagestyle{fancy} + + +% prevent orhpans and widows +\clubpenalty = 10000 +\widowpenalty = 10000 + +% --- end of standard preamble for documents --- + + +% insert custom LaTeX commands... + +\raggedbottom +\makeindex +\usepackage[totoc]{idxlayout} % for index in the toc +\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc + +%-------------------- end preamble ---------------------- + +\begin{document} + +% matching end for #ifdef PREAMBLE + +\newcommand{\exercisesection}[1]{\subsection*{#1}} + + +% ------------------- main content ---------------------- + + + +% ----------------- title ------------------------- + +\thispagestyle{empty} + +\begin{center} +{\LARGE\bf +\begin{spacing}{1.25} +Project on Machine Learning +\end{spacing} +} +\end{center} + +% ----------------- author(s) ------------------------- + +\begin{center} +{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-MAT3155/FYS4155}} +\end{center} + + \begin{center} +% List of all institutions: +\centerline{{\small Department of Physics, University of Oslo, Norway}} +\end{center} + +% ----------------- end author(s) ------------------------- + +% --- begin date --- +\begin{center} +Fall semester 2017 +\end{center} +% --- end date --- + +\vspace{1cm} + + +\subsection*{Using results from Monte Carlo models for machine learning} + +\paragraph{Introduction.} +The aim of this project is to use an already developed Monte Carlo program (either the ising Model or a variational Monte Carlo code) to produce, in case of the Ising model, the energy as function of temperature. For the variational Monte carlo calculation of interacting electrons in an oscilaltor trap, the data are represented by the ground state energies as functions of the variational parameters. + +In its simplest form +the energy of the Ising model is expressed as, without an externally applied magnetic field, +\[ +E=-J\sum_{< kl >}^{N}s_ks_l +\] +with +$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling +constant expressing the strength of the interaction between +neighboring spins. The symbol $$ indicates that we sum over +nearest neighbors only. We will assume that we have a ferromagnetic +ordering, viz $J> 0$. We will use periodic boundary conditions and +the Metropolis algorithm only. Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the course under programs. + +\paragraph{Part a): Producing the data.} +$\langle E\rangle$ and $\langle \vert M\vert \rangle$, the specific heat +$C_V$ and the susceptibility $\chi$ as functions of $T$ for $L=40$, +$L=60$, $L=100$ and $L=140$ for $T\in [2.0,2.3]$ with a step in +temperature $\Delta T=0.05$ or smaller. You may find it convenient narrow the domain for $T$. + +Plot $\langle E\rangle$, +$\langle \vert M\vert\rangle$, $C_V$ and $\chi$ as functions of $T$. + +\paragraph{Part b): Fitting the data using regression analysis and other methods.} +More text to come +\paragraph{Part c): Introducing Bayesian statistics.} +More text to come + +\paragraph{Part d): Studying the Ising model or the VMC results with Neural networks.} +More text to come + +\subsection*{Background literature} + +If you wish to read more about the Ising model and statistical physics here are three suggestions. + +\begin{itemize} + \item \href{{http://www.worldscientific.com/worldscibooks/10.1142/5660}}{M. Plischke and B. Bergersen}, \emph{Equilibrium Statistical Physics}, World Scientific, see chapters 5 and 6. + + \item \href{{http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB}}{D. P. Landau and K. Binder}, \emph{A Guide to Monte Carlo Simulations in Statistical Physics}, Cambridge, see chapters 2,3 and 4. + + \item \href{{https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&}}{M. E. J. Newman and T. Barkema}, \emph{Monte Carlo Methods in Statistical Physics}, Oxford, see chapters 3 and 4. +\end{itemize} + +\noindent +\subsection*{Introduction to numerical projects} + +Here follows a brief recipe and recommendation on how to write a report for each +project. + +\begin{itemize} + \item Give a short description of the nature of the problem and the eventual numerical methods you have used. + + \item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself. + + \item Include the source code of your program. Comment your program properly. + + \item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code. + + \item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes. + + \item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc. + + \item Try to give an interpretation of you results in your answers to the problems. + + \item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it. + + \item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning. +\end{itemize} + +\noindent + +% ------------------- end of main content --------------- + +\end{document} + diff --git a/doc/src/Projects/2017/Project/README.txt b/doc/src/Projects/2017/Project/README.txt new file mode 100644 index 000000000..1655b776a --- /dev/null +++ b/doc/src/Projects/2017/Project/README.txt @@ -0,0 +1,2 @@ +This IPython notebook Project.ipynb does not require any additional +programs. diff --git a/doc/src/Projects/2017/Project/clean.sh b/doc/src/Projects/2017/Project/clean.sh new file mode 100644 index 000000000..2e5da2c72 --- /dev/null +++ b/doc/src/Projects/2017/Project/clean.sh @@ -0,0 +1,3 @@ +#!/bin/sh +doconce clean +rm -rf *.pdf *.tex ipynb*.tar.gz *.html ._*.html *~ reveal.js Trash README.txt diff --git a/doc/src/Projects/2017/Project/ipynb-Project-src.tar.gz b/doc/src/Projects/2017/Project/ipynb-Project-src.tar.gz new file mode 100644 index 000000000..02d8b804e Binary files /dev/null and b/doc/src/Projects/2017/Project/ipynb-Project-src.tar.gz differ diff --git a/doc/src/Projects/2017/Project/make.sh b/doc/src/Projects/2017/Project/make.sh new file mode 100755 index 000000000..35e5d2f6d --- /dev/null +++ b/doc/src/Projects/2017/Project/make.sh @@ -0,0 +1,81 @@ +#!/bin/sh +set -x + +function system { + "$@" + if [ $? -ne 0 ]; then + echo "make.sh: unsuccessful command $@" + echo "abort!" + exit 1 + fi +} + +if [ $# -eq 0 ]; then +echo 'bash make.sh slides1|slides2' +exit 1 +fi + +name=$1 +rm -f *.tar.gz + +opt="--encoding=utf-8" +opt= + +rm -f *.aux + + + +# Plain HTML documents +html=${name} +system doconce format html $name --pygments_html_style=default --html_style=bloodish --html_links_in_new_window --html_output=$html $opt +system doconce split_html $html.html --method=space10 + +# Bootstrap style +html=${name}-bs +system doconce format html $name --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=$html $opt +system doconce split_html $html.html --method=split --pagination --nav_button=bottom + +# IPython notebook +system doconce format ipynb $name $opt + +# Ordinary plain LaTeX document +system doconce format pdflatex $name --print_latex_style=trac --latex_admon=paragraph $opt +system doconce ptex2tex $name envir=print +# Add special packages +doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex +doconce replace 'section{' 'section*{' $name.tex +pdflatex -shell-escape $name +pdflatex -shell-escape $name +mv -f $name.pdf ${name}.pdf +cp $name.tex ${name}.tex + +# Publish +dest=../../../../Projects/2017 +if [ ! -d $dest/$name ]; then +mkdir $dest/$name +mkdir $dest/$name/pdf +mkdir $dest/$name/html +mkdir $dest/$name/ipynb +fi +cp ${name}*.tex $dest/$name/pdf +cp ${name}*.pdf $dest/$name/pdf +cp -r ${name}*.html ._${name}*.html $dest/$name/html + +# Figures: cannot just copy link, need to physically copy the files +if [ -d fig-${name} ]; then +if [ ! -d $dest/$name/html/fig-$name ]; then +mkdir $dest/$name/html/fig-$name +fi +cp -r fig-${name}/* $dest/$name/html/fig-$name +fi + +cp ${name}.ipynb $dest/$name/ipynb +ipynb_tarfile=ipynb-${name}-src.tar.gz +if [ ! -f ${ipynb_tarfile} ]; then +cat > README.txt < + + + + + + + @@ -287,48 +314,122 @@ formulas in HTML or ipython notebook files.

Projects Fall 2017

-

Project 1

+

Project

+ +

Course content

+ +

+Probability theory and statistical methods play a central role in science. Nowadays we are +surrounded by huge amounts of data. For example, there are about one trillion web pages; more than one +hour of video is uploaded to YouTube every second, amounting to 10 years of content every +day; the genomes of 1000s of people, each of which has a length of \( 3.8\times 10^9 \) base pairs, have +been sequenced by various labs and so on. +This deluge of data calls for automated methods of data analysis, +which is exactly what machine +learning provides. In this course the approach is to define machine learning as a set of methods that can +automatically detect patterns in data, and then use the uncovered patterns to predict future +data, or to perform other kinds of decision making under uncertainty. Since many of these problems can be studied using +tools of probability theory, the aim of this course is to expose you to central methods in probability theory linked with machine learning. + +

+This course covers thus topics like Monte Carlo methods and Markov chains, Bayesian statistics, error estimates, various linear methods, optimization of data and error analysis and central algorithms in machine learning. +The course has several numerical projects and numerical exercises that are meant to illustrate the theory. + +

Learning outcomes

+ +

+The course introduces a variety of central algorithms and methods +essential for studies of data analysis and machine learning. The course is project based and through the various projects, normally three, the students will be exposed to fundamental research problems in these fields, with the aim to reproduce state of the art scientific results. The students will learn to develop and structure large codes for studying these systems, get acquainted with computing facilities and learn to handle large scientific projects. A good scientific and ethical conduct is emphasized throughout the course. More specifically, after this course you will

    -
  • ipynb file
  • +
  • Learn about basic data analysis, Bayesian statistics, Monte Carlo methods, data optimization and machine learning;
  • +
  • Be capable of extending the acquired knowledge to other systems and cases;
  • +
  • Have an understanding of central algorithms used in data analysis and machine learning;
  • +
  • Have a basic knowledge of Bayesian statistics and learning and common distributions;
  • +
  • Gain knowledge of central aspects of Monte Carlo methods, Markov chains, Gibbs samplers and their possible applications, from numerical integration to simulation of stock markets;
  • +
  • Understand linear methods for regression and classification;
  • +
  • Learn about neural network, genetic algorithms and Boltzmann machines;
  • +
  • Work on numerical projects to illustrate the theory. The projects play a central role and students are expected to know modern programming languages like Python or C++.
+

Prerequisites

+ +

+Basic knowledge in programming and numerics. Required courses are the equivalents to the University of Oslo mathematics courses MAT1100, MAT1110, MAT1120 and at least one of the corresponding computing and programming courses INF1000/INF1110 or MAT-INF1100/MAT-INF1100L/BIOS1100/KJM-INF1xxx. + +

The course has two central parts

+ +
    +
  1. Statistical analysis and optimization of data
  2. +
  3. Machine learning
  4. +
+ +

Statistical analysis and optimization of data

+ +

+The following topics will be covered + +

    +
  • Basic concepts, expectation values, variance, covariance, correlation functions and errors;
  • +
  • Simpler models, binomial distribution, the Poisson distribution, simple and multivariate normal distributions;
  • +
  • Central elements of Bayesian statistics and modeling;
  • +
  • Monte Carlo methods, Markov chains, Metropolis-Hastings algorithm, ergodicity;
  • +
  • Linear methods for regression and classification;
  • +
  • Estimation of errors using blocking, bootstrapping and jackknife methods;
  • +
  • Practical optimization using Singular-value decomposition and least squares for parameterizing data.
-

Basic Syllabus

-
- -

-To be filled in -

- - -

Additional literature

-
- -

-More to come -

- +

Machine learning

+The following topics will be covered + +

    +
  • Gaussian and Dirichlet processes;
  • +
  • Boltzmann machines;
  • +
  • Neural networks;
  • +
  • Genetic algorithms.
  • +
+ +All the above topics will be supported by examples, hands-on exercises and project work. + +

Possible textbooks

+ +

+General learning book on statistical analysis: + +

    +
  • Christian Robert and George Casella, Monte Carlo Statistical Methods, Springer
  • +
  • Peter Hoff, A first course in Bayesian statistical models, Springer
  • +
+ +General Machine Learning Books: + +
    +
  • Kevin Murphy, Machine Learning: A Probabilistic Perspective, MIT Press
  • +
  • Christopher M. Bishop, Pattern Recognition and Machine Learning, Springer
  • +
  • David J.C. MacKay, Information Theory, Inference, and Learning Algorithms, Cambridge University Press
  • +
  • Trevor Hastie, Robert Tibshirani, and Jerome Friedman, The Elements of Statistical Learning, Springer
  • +
  • David Barber, Bayesian Reasoning and Machine Learning, Cambridge University Press
  • +
+