Difference between revisions of "ALPS 2 Tutorials:DWA-02 Density Profile"
(→Evaluating the simulation and preparing plots using Python) |
(→Preparing and running the simulation from the command line) |
||
Line 10: | Line 10: | ||
LATTICE="inhomogeneous simple cubic lattice" | LATTICE="inhomogeneous simple cubic lattice" | ||
− | L= | + | L=120 |
MODEL='boson Hubbard" | MODEL='boson Hubbard" | ||
Line 19: | Line 19: | ||
mu="4.05 - (0.0073752*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.0036849*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.0039068155*(z-(L-1)/2.)*(z-(L-1)/2.))" | mu="4.05 - (0.0073752*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.0036849*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.0039068155*(z-(L-1)/2.)*(z-(L-1)/2.))" | ||
− | THERMALIZATION= | + | THERMALIZATION=1500 |
− | SWEEPS= | + | SWEEPS=7000 |
− | SKIP= | + | SKIP=50 |
MEASURE[Local Density]=1 | MEASURE[Local Density]=1 |
Revision as of 06:53, 17 September 2013
Contents
Density profile
As a second example of the dwa QMC code, we will study the density profile of an optical lattice in an harmonic trap which resembles the experiment
Column integrated density
Preparing and running the simulation from the command line
The parameter file parm2a sets up Monte Carlo simulation of a 1003 optical lattice trap that mimicks the Bloch experiment:
LATTICE="inhomogeneous simple cubic lattice" L=120 MODEL='boson Hubbard" Nmax=20 t=1. U=8.11 mu="4.05 - (0.0073752*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.0036849*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.0039068155*(z-(L-1)/2.)*(z-(L-1)/2.))" THERMALIZATION=1500 SWEEPS=7000 SKIP=50 MEASURE[Local Density]=1 { T=1. }
Using the standard sequence of commands you can run the simulation using the quantum dwa code
parameter2xml parm2a dwa parm2a.in.xml
Preparing and running the simulation from Python
To set up and run the simulation in Python we use the script tutorial2a.py. The first parts of this script imports the required modules and then prepares the input files as a list of Python dictionaries:
import pyalps parms = [ { 'LATTICE' : 'inhomogeneous simple cubic lattice' , 'L' : 120 , 'MODEL' : 'boson Hubbard' , 'Nmax' : 20 , 't' : 1. , 'U' : 8.11 , 'mu' : '4.05 - (0.0073752*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.0036849*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.0039068155*(z-(L-1)/2.)*(z-(L-1)/2.))' , 'T' : 1. , 'THERMALIZATION' : 1500 , 'SWEEPS' : 7000 , 'SKIP' : 50 , 'MEASURE[Local Density]': 1 } ]
We next convert this into a job file in XML format and run the worm simulation:
input_file = pyalps.writeInputFiles('parm2a', parms) res = pyalps.runApplication('dwa', input_file)
We now have the same output files as in the command line version.
Evaluating the simulation and preparing plots using Python
To load the results and prepare plots we load the results from the output files and collect the magntization density as a function of magnetic field from all output files starting with parm2a. The script is again in tutorial2a.py
import numpy import pyalps import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.axes3d import Axes3D; L = int(pyalps.getParameters('parm2a.task1.out.h5')[0]['L']); density = pyalps.getMeasurements('parm2a.task1.out.h5', observable='Local Density')[0]['mean']['value'].reshape([L,L,L]); #cross_section_density = density[:,:,L/2]; column_integrated_density = numpy.sum(density, axis=2); x = numpy.array([range(L)] * L, float) - (L-1)/2.; y = numpy.transpose(x); fig = plt.figure(); ax = fig.add_subplot(1, 1, 1, projection='3d') surf = ax.plot_surface( x, y, column_integrated_density, rstride=1, cstride=1, cmap=matplotlib.cm.coolwarm, linewidth=0, antialiased=False) fig.colorbar(surf, shrink=0.5, aspect=10); fig.show();