Introduction Numerical method Implementation Validation and Results Conclusions and further work Efficient object orientation for many-body physics problems Islen Vallejo Henao Department of physics University of Oslo November 2009 Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Physical problem Mathematical model Why computational physics? Advantages Better understanding of the processes. Cheaper and less dangerous than experiments. Allow experiments impossible practically. Computation Need to routinely predict processes. Theory Experiment What are the difficulties? Numerical method: which one? efficiency?,... . Programming: style? ... Hardware: Speed, memory (storage)? Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Physical problem Mathematical model Methodology in computational physics Physical problem Mathematical model Numerical model Computer code Simulation (hardware) Figure: Simulation chart flow Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Physical problem Mathematical model The many-body problem in quantum mechanics Goal Solve the many-electron Schrödinger equation to obtain the ground state energy in quantum mechanical systems with the so-called closed shell model. Time-independent Schrödinger eq. For a system of N-particles: Physical systems b = EΨ HΨ (1) Quantum dots. Hamiltonian: Total energy b = K(x) b b H + V(x) Atoms: helium and beryllium. (2) Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Physical problem Mathematical model How to define our Hamiltonian...for atoms? Assumptions 1 Assume non-relativistic energies. 2 Use Born-Oppenheimer approximation: Nuclei are much more massive than electrons (∼ 2000 : 1 or more). Electron motions much faster than nuclear motions. Assume that electrons move instantly compared to nuclei. 3 Go from a molecular to an electronic Schrödinger equation. Hamiltonian for hydrogen-like atoms. z Potential energy }| { N N N X N 2 X 2 2 X X h̄ 1 Ze 1 e b =− H ∇2 − + 2m i=1 ri 4π0 i=1 |ri − R| 4π0 i=1 j=i+1 |ri − rj | | {z } | {z } | {z } Electronic kinetic energy Attraction of electron i by nucleus Islen Vallejo Henao Repulsion between electrons i and j Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Physical problem Mathematical model How to define our Hamiltonian...for quantum dots? Assumptions 1 Assume non-relativistic energies. 2 Confining potential modelled by an harmonic oscillator potential. 3 Use the electronic Schröndinger equation. Hamiltonian for quantum dots. b = H N X i=1 | N X N X e2 h̄2 1 ∗ 2 2 2 1 2 ∇ m ω (x +y )] + + i i i 2m∗ 2 4π |r − rj | r 0 i | {z } i=1 j=i+1 {z } | {z } Confining [− Electronic kinetic energy potential Islen Vallejo Henao Repulsion Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Table of contents Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Why is it a hard problem to solve? P.A.M. Dirac: The fundamental laws necessary for the mathematical treatment of a large part of physics and the whole of chemistry are thus completely known, and the difficulty lies only in the fact that application of these laws leads to equations that are too complex to be solved. Hamiltonian term Quantum nature Kinetic energy Nuclei-electron Electron-electron One-body One-body Two-body (hard) Table: Nature of the terms in the Hamiltonian. The wave function contains explicit correlations that leads to non-factoring multi-dimensional integrals. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Quantum Variational Monte Carlo Variational principle b given a (parametrized) trial The expectation value of the energy computed for a Hamiltonian H wave function ΨT is an upper bound to the ground state energy E0 . R b = EVMC = hHi b T dR b Ti Ψ∗T HΨ hΨT |H|Ψ R 2 = ≥ E0 hΨT |ΨT i ΨT dR How to compute high dimensional integrals efficiently? Solution: Translate the problem into a Monte Carlo language. R Evmc = T Ψ∗T ΨT HΨ dR Ψ R 2 T = ΨT dR b R hb i T Z |ΨT |2 HΨ dR Ψ R 2 T = P(R)EL dR ΨT dR Sample configurations, R, stochastically. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function ...How to compute high dimensional integrals efficiently? [continued] Average of the local energy EL over the probability distribution function P(R). Z hEi = P(R)EL dR ≈ M 1 X EL (Ri ), M i=1 where M is the number of Monte Carlo samples. Statistical variance (assuming uncorrelated data set) var(E) = hE2 i − hEi2 Zero variance principle. The optimization of the trial wave function has as goal to find the optimal set of parameters that gives the minimum energy/variance. BUT: We just need a (parametric) trial wave function...! Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Trial wave function: ΨT = ΨD ΨJ (Slater-Jastrow) Slater determinant ˛ ˛ φ1 (r1 ) ˛ ˛ φ1 (r2 ) ˛ ΨD ∝ ˛ . ˛ .. ˛ ˛ φ1 (rN ) φ2 (r1 ) φ2 (r2 ) .. . φ2 (rN ) ··· ··· .. . ··· ˛ φN (r1 ) ˛ ˛ φN (r2 ) ˛ ˛ ˛ .. ˛ . ˛ ˛ φN (rN ) Pauli exclusion principle. Spin-independent Hamiltonian? ΨD = |D|↑ |D|↓ . Electron-nucleus cusp conditions. Linear Padé-Jastrow correlation function 0 ΨJ = exp @ X j<i aij rij 1 + βij rij 1 Linear correlation. A Two-body correlation. Fullfils electron-electron cusp conditions. rij = |rj − ri | Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Initialize: Set R, α and ΨT−α (R) Suggest a move Require: nel, nmc, nes, δt, R and Ψα (R). Ensure: hEα i. for c = 1 to nmc do for p = 1 to nel do cur xnew = xcur p p + χ + DF(xp )δt Generate an uniformly distributed variable r Compute acceptance ratio Is R ≥ r? no Reject move: xnew = xold i i yes T Compute F(xnew ) = ∇Ψ ΨT Accept trial move with probability h i ω(xcur ,xnew ) |Ψ(xnew )|2 min 1, ω(xnew ,xcur ) |Ψ(xcur )|2 end for 2 b T Compute EL = HΨ = − 12 ∇ΨΨT + V. ΨT T end for 1 Pnmc Compute hEi = nmc c=1 EL and σ2 = hEi2 − hE2 i. Accept move: xold = xnew i i Last move? yes Get local energy EL no Last MC step? yes Collect samples End Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Wave function optimization, why and how? Goal Find an optimal set of parameters α in ΨT to minimized the estimated energy. Approaches 1 Minimization of the variance of the local energy. 2 Minimization of the energy. 3 A combination of both. Examples of optimization algorithms 1 Stochastic gradient approximation (SGA). 2 Quasi-Newton method. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Minimization of energy with quasi-Newton method Objective function and its derivative Expectation value of the energy: » – R Evmc = |ΨT |2 R b HΨ T ΨT dR Ψ2T dR Derivative of the expectation value of the energy: 2 * ∂ΨT +3 * ∂ΨT + ∂E ∂cm = 2 4 EL cm ∂cm ΨTc −E m cm ∂cm ΨTc m 5 Strategies for computing the derivative Direct analytical differentiation: i h ∂ΨTc Q QN m = ∂c∂ |D|↑ |D|↓ N i=1 i=j+1 J(rij ) = ...? ∂c m m Enjoy it! Numerical derivative: central differences: Just for ΨSD we have to do dΨSD dαm = ΨSD (αm +∆αm )−ΨSD (αm −∆αm ) 2∆αm + O(∆α2m ) (...to be done per parameter). Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Why numerical methods? Trial wave function QVMC algorithm Optimization of the trial wave function Minimization of energy with quasi-Newton method Trick to compute the derivative of the energy Goal: ∂E ∂cm 2* = 2 4 EL ∂ΨT cm ∂cm ΨTc m + * −E ∂ΨT cm ∂cm ΨTc m +3 5=2 »fi fl fi fl– ∂ ln ΨT ∂ ln ΨTc m EL ∂c cm − E ∂c m m 1 Split the trial wave function: ΨTcm = ΨSDcm ΨJcm = ΨSDc ↑ ΨSDc ↓ ΨJcm . m m 2 Rewrite the derivatives as: 3 4 ∂ ln ΨTc m ∂cm = ∂ ln(ΨSD cm ↑ ∂cm ) + ∂ ln(ΨSD cm ↓ ) ∂cm + ∂ ln(ΨJc ) m ∂cm « „ d Divide the standard expression dt (det A) = (det A) tr A−1 dA by det A to get: dt “ ” P P N N d dA −1 ln det A(t) = tr A−1 dt = i=1 j=1 Aij Ȧji dt This expression inserted in step (??) gives: ∂ ln ΨTcm ∂cm =( N X N X D−1 ij Ḋji )↑ + ( i=1 j=1 Islen Vallejo Henao N X N X i=1 j=1 D−1 ij Ḋji )↓ + ∂ ln(ΨJcm ) ∂cm Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Table of contents Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Quick design of a QVMC simulator in Python Main parts of a QVMC simulator: VMC, Energy, PsiTrial and Particle. #Import some packages ... class VMC(): def init ( self , _dim, _np, _charge, ...,_parameters): ... particle = Particle(_dim, _np, _step) psi = Psi(_np, _dim, _parameters) energy = Energy(..., particle, psi, _charge) self . mc = MonteCarlo(psi, _ncycles, particle, energy,...) def doVariationalLoop(self): ... for var in xrange(nVar): self . mc.doMonteCarloImportanceSampling() self . mc.psi.updateVariationalParameters() Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Easy creation/manipulation of matrices in Python ... class Particle () : def init ( self , _dim, _np, _step): # Initialize matrices for configuration space r_old = zeros((_np, _dim)) ... def acceptMove(self, i): self . r_old[i,0:dim] = self.r_new[i,0:dim] ... def setTrialPositionsBF ( self ) : dt = self . step r_old = dt*random.uniform(−0.5,0.5,size=np*dim) r_old.reshape(np,dim) ... Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Calling the code from VMC import * # Set parameters of simulation nsd = 3 # Number of spatial dimensions nVar= 10 # Number of variations (optimization method) nmc = 10000 # Number of monte Carlo cycles nel = 2 # Number of electrons Z = 2.0 # Nuclear charge ... vmc = VMC(nsd, nel, Z,... , nmc, dt, nVar, varPar) vmc.doVariationalLoop() vmc.mc.energy.printResults() Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ How well does Python perform? High level language? Clear and compact syntax. Support all the major program styles. Runs on all major platforms. Free, open source (e.g. vs Matlab). Comprehensive standard library. Huge collection of free modules on the web. Good support for scientific computing. However... How well performs Python with respect to C++? Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Comparing Python to C++ computing VMC 2.5 180 160 2 Execution time, s Execution time, s 140 120 100 80 60 40 1.5 1 0.5 20 0 20000 40000 60000 80000 Monte Carlo cycles 100000 0 20000 40000 60000 80000 Monte Carlo cycles 100000 Figure: Execution time as a function of the number of Monte Carlo cycles for a Python (blue) and C++ (green) simulators implementing the QVMC method with importance sampling for the He atom. CONCLUSION: Python is SLOW, except when it is not running! Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Detecting bottlenecks in Python # calls Total time Cum. time 1 1 1910014 100001 1910014 50000 1910014 50000 6180049 900002 300010 50000 9.153 0.000 23.794 12.473 58.956 0.864 57.476 8.153 21.489 4.968 2.072 2.272 207.061 207.061 159.910 117.223 71.704 66.208 64.412 62.548 21.489 4.968 2.072 2.796 Class:function MonteCarlo.py:(doMCISampling) VMC.py:(doVariationalLoop) Psi.py:(getPsiTrial) Psi.py:(getQuantumForce) Psi.py:(getModelWaveFunctionHe) Energy.py:(getLocalEnergy) Psi.py:(getCorrelationFactor) Energy.py:(getKineticEnergy) :0(sqrt) :0(copy) :0(zeros) Energy.py:(getPotentialEnergy) Table: Profile of a QVMC simulator with importance sampling for the He atom implemented in Python. The run was done with 50000 Monte Carlo cycles. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Can ”Python” do better?: Extending Python with C++ sys.path.insert(0, './extensions') # Set the path to the extensions import ext_QVMC # Extension module class Vmc(): def init ( self , _Parameters): # Create an object of the ' conversion class ' self . convert = ext_QVMC.Convert() # Get the paramters of the currrent simulation simParameters = _Parameters.getParameters() alpha = simParameters[6] self . varpar = array([alpha, beta]) # Convert a Python array to a MyArray object self . v_p = self . convert.py2my_copy(self.varpar) # Create objects to be extended in C++ self . psi = ext_QVMC.Psi(self.v_p, self.nel, self.nsd) ... Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Calling code for the mixed Python/C++ simulator from SimParameters import * # Class encapsulating the \ # parameters of simulation from Vmc import * # Import the simulator box. # Create an object containing the # parameters of the current simulation simpar = SimParameters('Be.data') # Create a Variational Monte Carlo simulation vmc = Vmc(simpar) vmc.doVariationalLoop() vmc.energy.doStatistics(”resultsBe.data”, 1.0) Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Comparing Python to C++ 30 Execution time, s 25 20 Mixed -O1 C++ -O1 Mixed -O2 C++ -O2 Mixed -O3 C++ -O3 15 10 5 0 500000 1e+06 1.5e+06 Monte Carlo cycles 2e+06 Figure: Execution time as a function of the number of Monte Carlo cycles for mixed Python/C++ and pure C++ simulators implementing the QVMC method with importance sampling for He atom. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ 5 steps for structuring a simulator in OOP Defining classes 1 From the mathematical model and the algorithms, identify the main components of the problem (classes). Vmc simulation: VmcSimulation.h Parameters in simulation: Parameters.h Monte Carlo method: MonteCarlo.h Energy: Energy.h Potential:Potential.h Trial wave function: PsiTrial ... 2 Identify the mathematical and algorithmic parts changing from problem to problem (superclasses). Potential:Potential.h Trial wave function: PsiTrial Monte Carlo method: MonteCarlo.h ... Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Enhance flexibility 3 List what each of these classes should do, IN GENERAL (member functions), e.g., for PsiTrial.h: Compute the acceptance ratio: getPsiPsiRatio(). Compute the quantum force: getQuantumForce(). ... #include "SomeClass.h" class PsiTrial{ public: virtual double getAcceptanceRatio()=0; virtual MyArray<double> getQuantumForce()=0; virtual getLapPsiRatio()=0; } Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Inheritance (specializing behaviours): “is a”-relationship 4 Be specific with the behaviour , i.e., create subclases by finding ”is a” -relationships.(subclasses) For example: Slater-Jastrow (SlaterJastrow.h) is a (kind of) trial wave function (PsiTrial.h). Slater alone (SlaterAlone.h) is a (kind of) trial wave function (PsiTrial.h). ... Coulomb one-body (OneBodyCoulomb.h) is a (kind of) potential (Potential.h). PsiTrial *s = new SlaterJastrow(sd, pj); or PsiTrial *sj = new SlaterAlone(sd); Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Implementation in Python Implementation in mixed Python/C++ Implementation in C++ Composition: has a-relationship 5 Connect the whole structure with relatonships of type has a (composition). ΨT = |D|↑ |D|↓ |J(rij) For example: Slater-Jastrow wave function (SlaterJastrow.h) has a Slater determinant (SlaterDeterminant.h) and a correlation function (CorrelationFnc.h). #include "SlaterDeterminant.h" #include "CorrelationFnc.h" class SlaterJastrow: public PsiTrial{ private: SlaterDeterminant *slater; CorrelationFnc *correlation; public: ... }; Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Table of contents Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Analytical GS for atoms (without correlation) −3 −15.2 −16 Energy, 〈 E 〉 (au) Energy, 〈 E 〉 (au) −3.2 −3.4 −3.6 −3.8 −17.6 −18.4 −19.2 −4 −4.2 1 −16.8 1.5 2 α 2.5 3 −20 2 3 4 α 5 6 Figure: Dependence of the energy on α for He(left) and Be(right) atoms. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Analytical GS for quantum dots (without correlation) 3 14 Energy, 〈 E 〉 (au) Energy, 〈 E 〉 (au) 2.75 2.5 2.25 12.4 11.6 10.8 10 2 0.4 13.2 0.6 0.8 1 1.2 α 1.4 1.6 1.8 2 0.4 0.6 0.8 1 1.2 α 1.4 1.6 1.8 2 Figure: Dependence of the energy on α for a 2D quantum dot with 2-and 6-electron without interactions. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Graphical estimation of the GS energy for atoms −14 Mean energy, E (au) Mean energy, E (au) −1.5 −2 −2.5 −3 1 −14.1 −14.2 −14.3 −14.4 −14.5 −14.6 0.8 3 2.5 0.5 2 4.4 0.6 0 1 α 4 0.2 1.5 β 4.2 0.4 β 3.8 0 3.6 α Figure: Energy as a function of α and β for He (left) and Be (right) atoms. Experimental set up: 107 Monte Carlo cycles, 10% equilibration steps and dt = 0.01. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Graphical estimation of the GS energy for QD Figure: Energy as a function of α and β for 2D quantum dots with two (left) and six electrons (right). Experimental set up: 107 Monte Carlo cycles, 10% equilibration steps and dt = 0.01. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Graphical estimation of the GS energy for helium −1.4 −1.6 −2.886 Mean energy, E (au) Mean energy, E (au) −1.8 −2 −2.2 −2.4 −2.888 −2.6 −2.89 −2.8 −3 1 1.5 2 α 2.5 3 0.18 0.26 0.34 β 0.42 0.5 0.58 Figure: Dependence of the energy on α (left) along the value of β (right) that gives the minimum variational energy for a He atom. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Graphical estimation of the GS energy for beryllium −14.485 −14 −14.1 Mean energy, E (au) Mean energy, E (au) −14.49 −14.2 −14.3 −14.4 −14.495 −14.5 −14.5 −14.6 3.6 3.7 3.8 3.9 α 4 4.1 4.2 0.06 0.07 0.08 0.09 β 0.1 0.11 0.12 Figure: Dependence of the energy on α (left) along the value of β (right) that gives the minimum variational energy for a Be atom. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Graphical estimation of the GS energy for 2-e− QD 3.6 3.25 3.2 Mean energy, E (au) Mean energy, E (au) 3.5 3.4 3.3 3.2 3.15 3.1 3.05 3.1 3 3 0.8 0.9 1 1.1 α 1.2 1.3 0 0.1 0.2 0.3 β 0.4 0.5 Figure: Dependence of the energy on α (left) along the value of β (right) that gives the minimum variational energy for a 2D quantum dot with two electrons. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Graphical estimation of the GS energy for 6-e− QD 23 20.45 22 20.4 Mean energy, E (au) Mean energy, E (au) 22.5 21.5 21 20.35 20.3 20.25 20.5 20.2 20 0.5 1 α 1.5 20.15 0.35 0.4 0.45 0.5 0.55 β 0.6 0.65 0.7 0.75 Figure: Dependence of the energy on α (left) along the value of β (right) that gives the minimum variational energy for a 2D quantum dot with six electrons. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Summary of the results with graphical estimation System He Be 2DQDot2e (ω = 1.0) 2DQDot6e (ω = 1.0) αoptimal βoptimal Energy, hEi (au) 1.85 3.96 0.98 0.9 0.35 0.09 0.41 0.6 −2.8901 ± 1.0 × 10−4 −14.5043 ± 4.0 × 10−4 3.0003 ± 1.2 × 10−5 20.19 ± 1.2 × 10−4 Table: Ground state energy and corresponding variational parameters α and β estimated graphically. (2DQDot2e = 2D quantum dot with two electrons). Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Optimization with Quasi-Newton method System He Be α0 β0 αopt βopt 1.564 3.85 0.134 0.08 1.838 3.983 0.370 0.104 Energy, (au) -2.891 -14.503 Table: Optimized variational parameters and corresponding energy minimization using a quasi-Newton method. Simulation parameters: 107 Monte Carlo cycles with 10 % equilibration steps, dt = 0.01. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Convergence to the optimal parameters for helium 2.3 0.8 α0 = 1.564, αopt = 1.8378900818459 2.2 Variational parameter, β Variational parameter, α 2.1 2 1.9 1.8 1.7 0.6 0.5 0.4 0.3 0.2 1.6 1.5 0 β0 = 0.1342, βopt = 0.3703844012544 0.7 2 4 6 8 Number of iterations 10 12 0.1 0 2 4 6 8 Number of iterations 10 12 Figure: Evolution of α (left) and β (right) with the number of iterations for He atom. Experimental set up: 107 Monte Carlo cycles, 10% equilibration steps in four nodes. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Convergence to the minimal energy for helium −2.65 α0 = 1.564, β0 = 0.1342, α = 1.8378900818459, opt βopt = 0.3703844012544, Emin = −2.8908185137222 Mean energy, E (au) −2.7 −2.75 −2.8 −2.85 −2.9 0 2 4 6 8 Number of iterations 10 12 Figure: Evolution of the energy with the number of iterations for He atom. Experimental set up: 107 Monte Carlo cycles and 10% equilibration steps in four nodes. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Convergence to the optimized parameters for Be 4.25 0.8 α0 = 3.85, α = 3.9826281304910 opt 4.2 0.6 Variational parameter, β Variational parameter, α 4.15 4.1 4.05 4 0.5 0.4 0.3 3.95 0.2 3.9 0.1 3.85 0 β0 = 0.08, βopt = 0.1039459074823 0.7 5 10 15 Number of iterations 20 25 0 0 5 10 15 Number of iterations 20 25 Figure: Evolution of α (left) and β (right) with the number of iterations for Be atom. Experimental set up: 107 Monte Carlo cycles and 10% equilibration steps in four nodes. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Convergence to the minimal energy for Be −13.9 α0 = 3.85, β0 = 0.08, α = 3.9826281304910, opt βopt = 0.1039459074823, Emin = −14.5034420665939 Mean energy, E (au) −14 −14.1 −14.2 −14.3 −14.4 −14.5 −14.6 0 5 10 15 Number of iterations 20 25 Figure: Evolution of the energy with the number of iterations for Be atom. Experimental set up: 107 Monte Carlo cycles and 10% equilibration steps in four nodes. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for He Time step Energy, (au) Error Accepted moves, (%) 0.002 0.003 0.004 0.005 0.006 0.007 0.008 -2.891412637854 -2.890797649433 -2.890386198895 -2.890078440930 -2.890463490951 -2.890100432462 -2.889659923905 5.5e-4 4.5e-4 4.0e-4 3.5e-4 3.2e-4 2.8e-4 2.7e-4 99.97 99.94 99.91 99.88 99.84 99.81 99.77 Table: Energy computed for the He atom and the error associated as a function of the time step. Experimental set up: 107 Monte Carlo cycles with 10 % equilibration steps, α = 1.8379 and β = 0.3704. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for He −4 −2.8885 3 x 10 −2.889 2 −2.89 Error Mean energy, E (au) 2.5 −2.8895 −2.8905 1.5 −2.891 1 −2.8915 −2.892 1 2 3 4 5 6 Time step, dt 7 8 9 −3 x 10 0.5 0 0.5 1 Number of blocks 1.5 2 4 x 10 Figure: Extrapolation (left) of the energy to zero-dt and blocking (right) at dt = 0.01 where the energy −2.89039 ± 2.5 × 10−4 au. Parameters: α = 1.8379, β = 0.3704. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for Be Time step Energy, (au) Error Accepted moves, (%) 0.004 0.005 0.006 0.007 0.008 0.009 0.01 -14.50321303316 -14.50266236227 -14.50136820967 -14.50314292468 -14.50206184582 -14.50164368104 -14.50145748870 1.3e-3 1.2e-3 1.1e-3 1.0e-3 9.5e-4 8.5e-4 8.0e-4 99.61 99.47 99.32 99.17 99.01 98.85 98.68 Table: Energy computed for the Be atom and the error associated as a function of the time step. Parameters: α = 3.983 and β = 0.103. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for Be −4 −14.499 10 x 10 9 −14.5 7 Error Mean energy, E(au) 8 −14.501 −14.502 6 5 −14.503 4 −14.504 3 −14.505 0 0.002 0.004 0.006 Time step, dt 0.008 0.01 2 0 0.5 1 Number of blocks 1.5 2 4 x 10 Figure: Extrapolation (left) of the energy to dt−zero and blocking (right) at dt = 0.01 for the Be atom where the energy E = −14.50146 ± 8.5 × 10−4 au. Parameters: α = 3.983 and β = 0.103. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for 2-e− electron QD Time step Energy, (au) Error Accepted moves, (%) 0.01 0.02 0.03 0.04 0.05 0.06 0.07 3.000340072477 3.000357900850 3.000364180564 3.000384908560 3.000370330692 3.000380980039 3.000402836533 4.5e-5 3.2e-5 2.6e-5 2.2e-5 2.0e-5 1.8e-5 1.7e-5 99.95 99.87 99.77 99.65 99.52 99.37 99.21 Table: Dependence of the energy on dt for a 2D quantum dot with two electrons. Parameters: α = 0.99044, β = 0.39994 taken from Albrigtsen(2009). Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for 2-e− electron QD −5 2 3,00044 x 10 1.8 1.6 3,0004 1.4 3,00038 Error Mean energy, E (au) 3,00042 3,00036 1.2 3,00034 1 3,00032 0.8 3,0003 0 0.01 0.02 0.03 0.04 0.05 Time step, dt 0.06 0.07 0.08 0.6 0 0.5 1 Number of blocks 1.5 2 4 x 10 Figure: Extrapolation (left) of the energy to zero-dt for a 2D quantum dot with 2e− (left) and blocking (right)(Emin = 3.000381 ± 1.8 × 10−5 au) at dt = 0.06. Parameters: α = 0.99044 and β = 0.39994. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for 6-e− electron QD Time step Energy, (au) Error Accepted moves, (%) 0.01 0.02 0.03 0.04 0.05 0.06 0.07 20.19048030567 20.19059799459 20.19045049792 20.19069748408 20.19066469178 20.19064491561 20.19078449010 4.0e-4 2.8e-4 2.4e-4 2.0e-4 1.8e-4 1.7e-4 1.6e-4 99.90 99.75 99.55 99.34 99.10 98.85 98.58 Table: Energy as a function of the time step for a 2D-quantum dot with six electrons. Parameters: ω = 1.0, α = 0.926273 and β = 0.561221 taken from Albrigtsen (2009). Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolation of energy to zero dt for 6-e− electron QD −4 20.1912 1.8 1.6 20.191 1.4 20.1908 1.2 Error Mean energy, E (au) x 10 20.1906 1 20.1904 0.8 20.1902 20.19 0 0.6 0.01 0.02 0.03 0.04 0.05 Time step, dt 0.06 0.07 0.08 0.4 0 0.5 1 Number of blocks 1.5 2 4 x 10 Figure: Extrapolation (left) of the energy to zero−dt 2D quantum dot with 6e− (left) and blocking (right)(Emin = 20.190645 ± 1.7 × 10−4 au) at dt = 0.06 . Parameters of simulation: 107 Monte Carlo steps with 10 % equilibration steps, α = 0.926273 and β = 0.561221 running with four nodes. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Extrapolated energy to zero dt for atoms and QD System He Be 2DQDot2e 2DQDot6e Evmc , (au), EHF Eexact -2.8913 -14.5039 3.0003 20.1904 -2.862 -14.573 - -2.904 -14.667 3.000 - Table: Energies estimated using zero-dt extrapolation. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Validation Optimization of the trial wave function Extrapolation to zero dt Influence of the # MC cycles Influence of the # MC cycles on the statistical error −3 8 x 10 7 6 Error 5 4 3 2 1 0 0 1 2 3 4 5 Monte Carlo cycles 6 7 8 7 x 10 Figure: Error in the energy as a function of the number of Monte Carlo cycles for a Be atom. Parameters:dt = 0.01, α = 3.981, β = 0.09271, 10 % equilibration steps and four processors per run. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Table of contents Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Conclusion: main results What has be done? Prototyping of a QVMC simulator with Python. Extension of the Python simulator with C++. Development of a applied to atoms and quantum dots within the so-called closed shell model. Proposal of an efficient algorithm to compute the analytical derivative of the energy in QVMC. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Conclusion: discussion Some reflections Potential use of Python in scientific computing (prototyping, testing and limitations) vs C++. Parametric optimization of ΨT (α, β). Graphical method (manual optimization of parameters). Quasi-Newton method (automatic optimization of parameters). Choice of dt in QVMC. Expensive extrapolation of the energy to zero − dt. Importance of locating the region with quasilinear energy − dt plot. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Conclusion: Future work and perspectives Improve SWIG (Simplified Wrapper Interface Generator) to enhance compatibility Python/C++. Make Python faster (Google-Python at SIMULA). Try alternative algorithms. Updating the inverse of the Slater matrix. Evaluation of quantum force and kinetic energy. Sampling of core and valence electrons with different δt. Methods adapted for handling stochastic noise: Stochastic Newton-based methods. Stochastic gradient approximation (SGA). Improve flexibility using functors and templates. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Acknowledgements Morten Hjorth-Jensen. Rune Algbritsen. Johannes Rekkedal. Patrick Merlot. Magnus Pedersen. Audience. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Figure: Patrick and Johannes ”drinking coffee”. Islen Vallejo Henao Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Cusp conditions For the exact solution of the Schrödinger equation the local energy EL = HΨ Ψ must be constant (finite). The electronic Hamiltonian has singularities at points where two particles collidate, i.e., ri → 0 and/or rij → 0. For helium atom: b b = − 1 ∇2 − 1 ∇2 − 2 − 2 + 1 H 2 1 2 2 r1 r2 r12 The infinite potential terms must be cancelled by infinite kinetic terms. The first derivatives must be discontinuous at the singularities. Nuclear cusp conditions “ ” 1 ∂Ψ = −Z, l = 0. ΨSD ∂ri r =0 “ ”i 1 ∂Ψ Z = − l+1 , l > 0. Ψ ∂r SD i ri =0 Islen Vallejo Henao Electronic cusp conditions (2D and 3D) “ ” 1 ulike-spin ∂ΨC 1 = 1 ΨC ∂rij like-spin. rij =0 3 1 “ ” ulike-spin ∂Ψ 1 C = 21 ΨC ∂rij like-spin. rij =0 4 Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Implementation of a QVMC simulator in C++ QVMC algorithm with drift diffusion Requirements 1 Numerical efficiency. 2 Flexibility. Extensibility. Independent of the nsd. 3 Readability. How? 1 Alternative algorithms. 2 Object oriented programming. Classes, inheritance, templates, etc. 3 Operator overloading, functors, etc. Islen Vallejo Henao Require: nel, nmc, nes, δt, R and Ψα (R). Ensure: hEα i. for c = 1 to nmc do for p = 1 to nel do cur xnew = xcur p p + χ + DF(xp )δt T Compute F(xnew ) = 2.0 ∇Ψ ΨT Accept trial move with probability h i ω(xcur ,xnew ) |Ψ(xnew )|2 min 1, ω(xnew ,xcur ) |Ψ(xcur )|2 end for Compute 2 T = − 12 ∇ΨΨT + V. EL = HΨ ΨT T end for P nmc 1 Compute hEi = nmc c=1 EL and σ2 = hEi2 − hE2 i. b Efficient object orientation for many-body physics problems Introduction Numerical method Implementation Validation and Results Conclusions and further work Main results Discussion Future work and perspectives Algorithm analysis and performance improvement No optimization Ψnew T Ψcur T Optimization new = |D|↑ new |D|↓ cur cur Ψnew C Ψcur C |D|↑ |D|↓ | {z } | {z } RC RSD ∇Ψnew T Ψnew T ∇2 Ψnew T Ψnew T = . ∇(|D|↑ |D|↓ ΨC ) |D|↑ |D|↓ ΨC 2 = ∇ (|D|↑ |D|↓ ΨC ) |D|↑ |D|↓ ΨC R ≡ RSD PRC new )D−1 (xcur ). RSD = N j=1 φj (xi ji RC = · · · ? ∇Ψ Ψ = ∇(|D|↑ ) ∇i |D(x)| |D(x)| ∇i |D(y)| |D(y)| ... |D|↑ = = PN 1 R + ∇(|D|↓ ) |D|↓ + ∇ΨC . ΨC −1 j=1 ∇i φj (xi )Dji (x) PN −1 j=1 ∇i φj (yi )Dji (x). Inverse updating −1 cur D−1 (xcur ) − Dki (x ) PN D (xnew )D−1 (xcur ) if j 6= i l=1 il kj lj R new ) = D−1 (x −1 cur P kj Dki (x ) N Dil (xcur )D−1 (xcur ) if j = i l=1 lj R Islen Vallejo Henao Efficient object orientation for many-body physics problems