.. _sec_tut_bosehubbard_statics: Example: Static Bose Hubbard Model ---------------------------------- Next we handle the more difficult task of exploring the two parameter phase space of the Bose-Hubbard Hamiltonian. In one spatial dimension the Bose-Hubbard Hamiltonian takes the form shown in Eq. :eq:`eq_bosehubbard`. The first term, whose magnitude is controlled by :math:`t`, is known as the tunneling term of the model, a large :math:`t` promotes particles tunneling between nearest neighbor sites. The second term, whose magnitude is controlled by :math:`U`, describes repulsive on site interaction, finally the last term in the sum accounts for the energy associated with the chemical potential of the system. .. math:: :label: eq_bosehubbard \hat{H} = -t \sum_{i=1}^{L-1} (\hat{\mathrm{b}}^{\dagger}_i \hat{\mathrm{b}}_{i+1} + \hat{\mathrm{b}}_i \hat{\mathrm{b}}^{\dagger}_{i+1}) + \frac{1}{2} U \sum_{i=1}^{L} \hat{\mathrm{n}}_i (\hat{\mathrm{n}}_i-\hat{I}) - \mu\sum_{i=1}^{L} \hat{\mathrm{n}}_i\,, As usual we begin my importing necessary libraries. There are a couple new libraries in the lines below. From ``matplotlib`` we import ``cm``, this allows us to use color maps in our plots. This of course requires the installation of ``matplotlib``. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 1-6 :lineno-start: 1 Towards the end of the script we define a function for plotting the results of our simulations, The function is useful because its sets the limits of plots using the data provided to it, but not that defining it requires ``matplotlib`` to be installed. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 120-147 :lineno-start: 120 The first time we run the file, we set the post process flag to ``False`` via the command line argument ``--PostProcess=False`` which is passed to the main function: .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 10-10 :lineno-start: 10 Inside the main function, we set an initial time, this is stored in seconds. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 26-26 :lineno-start: 26 We build the appropriate operators and construct the interaction operator using the built in linear algebra of python. Note that computationally it is not necessary to compute the term involving :math:`\mu`, since in the canonical ensemble this only introduces an overall shift in the energy of the system, the :math:`\frac{\mu}{U}` term is computed by subtracting the ground state energy ``Output['energy']`` across simulations with different numbers of particles. .. term in Fig. numreffigbosedepletion (not supported by this sphinx version) .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 28-44 :lineno-start: 28 We let OSMPS set the maximum bond dimension using default criteria, see Sec. :ref:`sec_vmps` or :py:class:`convergence.MPSConvParam` for details. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 46-46 :lineno-start: 46 We set ``U=1``, and generate lists for parameters we will change across simulations. The first is the list of values our tunneling parameter will range over, ``tlist``, we will sample 20 points from the interval :math:`0 \leq t \leq 0.4`. The system size is set to ``L=10`` and the number of particles is set to range from ``1`` to ``11``, with 11 sampling points. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 48-52 :lineno-start: 48 Using these lists of numbers we generate all of the necessary parameter lists for our simulation. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 54-76 :lineno-start: 54 If ``PostProcess=False`` we run the simulations, check the time in seconds, and subtract our original time to measure the amount of time ``mps.runMPS`` took to run. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 81-88 :lineno-start: 81 After the simulation data is computed, the ``Outputs`` are stored in the local process, and NumPy arrays are initialized to store the pertinent data. Namely, a ``for`` loop construction is used to build the ``depletion``, ``energies``, ``tinternal`` (time), and ``chempotmu`` (chemical potential). See below. .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 93-113 :lineno-start: 93 The plot should then look like .. _figbosedepletion: .. image:: ./../images/Tut2_BoseHubbard_Depletion.* :width: 600px The actual function for the plot looks like .. literalinclude:: ../../../Examples/02_BoseHubbardStatics.py :lines: 121-148 :lineno-start: 121 Now we can continue in the next example with a real time evolution.