Difference between revisions of "ALPS 2 Tutorials:DWA-02 Density Profile"

From ALPS
Jump to: navigation, search
(Evaluating the simulation and preparing plots using Python)
m
 
(29 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Languages|ALPS_2_Tutorials:DWA-02_Density_Profile}}
 +
 
= Density profile =
 
= Density profile =
  
Line 9: Line 11:
 
=== Preparing and running the simulation from the command line ===
 
=== Preparing and running the simulation from the command line ===
  
The parameter file [http://alps.comp-phys.org/static/tutorials2.1.0/dwa-02-density-profile/parm2a parm2a] sets up Monte Carlo simulation of a 120<sup>3</sup> optical lattice trap that mimicks the experiment:
+
The parameter file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/parm2a parm2a] sets up Monte Carlo simulation of a 120<sup>3</sup> optical lattice trap that mimicks the experiment:
  
 
  LATTICE="inhomogeneous simple cubic lattice"
 
  LATTICE="inhomogeneous simple cubic lattice"
Line 38: Line 40:
 
=== Preparing and running the simulation from Python ===
 
=== Preparing and running the simulation from Python ===
  
To set up and run the simulation in Python we use the script  [http://alps.comp-phys.org/static/tutorials2.1.0/dwa-02-density-profile/tutorial2a.py tutorial2a.py]. The first parts of this script imports the required modules and then prepares the input files as a list of Python dictionaries:
+
To set up and run the simulation in Python we use the script  [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/tutorial2a.py 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
 
  import pyalps
Line 75: Line 77:
 
=== Evaluating the simulation and preparing plots using Python ===
 
=== Evaluating the simulation and preparing plots using Python ===
  
To load the results and prepare the plot for density profile we load the results from the output files from all output files starting with <tt>parm2a</tt>. The script is again in [http://alps.comp-phys.org/static/tutorials2.1.0/dwa-02-density-profile/tutorial2a.py tutorial2a.py]
+
To load the results and prepare the plot for density profile we load the results from the output files from all output files starting with <tt>parm2a</tt>. The script is again in [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/tutorial2a.py tutorial2a.py]
  
 
  import pyalps
 
  import pyalps
  data     = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2a'), 'Local Density');
+
  data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2a'), 'Local Density');
  
 
To visualize the column integrated density:
 
To visualize the column integrated density:
Line 85: Line 87:
 
  aplt.plot3D(data, centeredAtOrigin=True)
 
  aplt.plot3D(data, centeredAtOrigin=True)
  
and the cross-section density at the center:
+
=== Setting up and running the simulation in Vistrails ===
 
 
import pyalps.plot as aplt;
 
aplt.plot3D(data, centeredAtOrigin=True, layer="center")
 
 
 
However, with only 100 measurements, we expect that the cross-section density to be noisy. This can be improved upon having more measurements.
 
  
=== Setting up and running the simulation in Vistrails ===
+
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/dwa-02-density-profile.vt dwa-02-density-profile.vt] and look at the workflow labeled "Column integrated density profile". Click on "Execute" to prepare the input file, run the simulation and create the output figure.
  
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/dwa-02-density-profile.vt dwa-02-density-profile.vt] and look at the workflow labeled "Column integrated density". Click on "Execute" to prepare the input file, run the simulation and create the output figure.
+
(The simulation takes roughly 3 hours from scratch.)
  
 
== Cross section density ==
 
== Cross section density ==
Line 102: Line 99:
 
=== Preparing and running the simulation from the command line ===
 
=== Preparing and running the simulation from the command line ===
  
The parameter file [http://alps.comp-phys.org/static/tutorials2.1.0/dwa-02-density-profile/parm2a parm2a] sets up Monte Carlo simulation of a 120<sup>3</sup> optical lattice trap that mimicks the Bloch experiment:
+
The parameter file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/parm2a parm2a] sets up Monte Carlo simulation of a 80<sup>3</sup> optical lattice trap that mimicks the Bloch experiment:
  
 
  LATTICE="inhomogeneous simple cubic lattice"
 
  LATTICE="inhomogeneous simple cubic lattice"
  L=120
+
  L=60
 
   
 
   
  MODEL='boson Hubbard"
+
  MODEL="boson Hubbard"
 
  Nmax=20
 
  Nmax=20
 +
 
 +
t=1.
 +
U=60.
 +
mu="40. - (0.09416*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.12955*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.11496*(z-(L-1)/2.)*(z-(L-1)/2.))"
 +
 +
THERMALIZATION=1000000
 +
SWEEPS=3000000
 +
SKIP=1000
 
   
 
   
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=100000
 
SKIP=50
 
 
 
 
  MEASURE[Local Density]=1
 
  MEASURE[Local Density]=1
 
   
 
   
Line 126: Line 123:
 
  parameter2xml parm2a
 
  parameter2xml parm2a
 
  dwa parm2a.in.xml
 
  dwa parm2a.in.xml
 
  
 
=== Preparing and running the simulation from Python ===
 
=== Preparing and running the simulation from Python ===
  
To set up and run the simulation in Python we use the script  [http://alps.comp-phys.org/static/tutorials2.1.0/dwa-02-density-profile/tutorial2b.py tutorial2b.py]. The first parts of this script imports the required modules and then prepares the input files as a list of Python dictionaries:
+
To set up and run the simulation in Python we use the script  [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/tutorial2b.py tutorial2b.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
 
  import pyalps
Line 137: Line 133:
 
   {
 
   {
 
     'LATTICE' : 'inhomogeneous simple cubic lattice' ,
 
     'LATTICE' : 'inhomogeneous simple cubic lattice' ,
     'L'      : 100 ,
+
     'L'      : 60 ,
 
   
 
   
 
     'MODEL'  : 'boson Hubbard' ,
 
     'MODEL'  : 'boson Hubbard' ,
Line 144: Line 140:
 
     't'  : 1. ,
 
     't'  : 1. ,
 
     'U'  : 60. ,
 
     'U'  : 60. ,
     'mu' : '74. - (0.09416*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.12955*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.11496*(z-(L-1)/2.)*(z-(L-1)/2.))' ,
+
     'mu' : '40. - (0.09416*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.12955*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.11496*(z-(L-1)/2.)*(z-(L-1)/2.))' ,
 
   
 
   
 
     'T'  : 1. ,
 
     'T'  : 1. ,
 
   
 
   
     'THERMALIZATION' : 1500000 ,
+
     'THERMALIZATION' : 1000000 ,
     'SWEEPS'        : 10000000 ,
+
     'SWEEPS'        : 3000000 ,
     'SKIP'          : 5000 ,  
+
     'SKIP'          : 1000 ,  
 
   
 
   
 
     'MEASURE[Local Density]': 1
 
     'MEASURE[Local Density]': 1
Line 165: Line 161:
 
=== Evaluating the simulation and preparing plots using Python ===
 
=== Evaluating the simulation and preparing plots using Python ===
  
To load the results and prepare the plot for density profile we load the results from the output files from all output files starting with <tt>parm2b</tt>. The script is again in [http://alps.comp-phys.org/static/tutorials2.1.0/dwa-02-density-profile/tutorial2b.py tutorial2b.py]
+
To load the results and prepare the plot for density profile we load the results from the output files from all output files starting with <tt>parm2b</tt>. The script is again in [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/tutorial2b.py tutorial2b.py]
  
 
  import pyalps
 
  import pyalps
  data     = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2b'), 'Local Density');
+
  data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2b'), 'Local Density');
  
To visualize the column integrated density:
+
To visualize the cross-section density at the center:
  
 
  import pyalps.plot as aplt;
 
  import pyalps.plot as aplt;
  aplt.plot3D(data, centeredAtOrigin=True)
+
  aplt.plot3D(data, centeredAtOrigin=True, layer="center")
 +
 
 +
=== Setting up and running the simulation in Vistrails ===
 +
 
 +
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/dwa-02-density-profile.vt dwa-02-density-profile.vt] and look at the workflow labeled "Cross-sectional density profile". Click on "Execute" to prepare the input file, run the simulation and create the output figure.
 +
 
 +
To run the next workflow "Advanced visualization of 3D density profiles", you have to first specify the directory '''archive_dir''' for archiving in the toolbox '''Archiving simulation'''.
  
and the cross-section density at the center:
+
== Advanced visualization: cross-sectional density profile ==
  
import pyalps.plot as aplt;
+
=== Enhancing with Vistrails VTK package ===
aplt.plot3D(data, centeredAtOrigin=True, layer="center")
 
  
However, with only 100 measurements, we expect that the cross-section density to be noisy. This can be improved upon having more measurements.
+
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/dwa-02-density-profile.vt dwa-02-density-profile.vt] and look at the workflow labeled "Advanced visualization". Click on "Execute" to prepare the input file, run the simulation and create the output figure.
  
=== Setting up and running the simulation in Vistrails ===
 
  
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.2.0/dwa-02-density-profile/dwa-02-density-profile.vt dwa-02-density-profile.vt] and look at the workflow labeled "Column integrated density". Click on "Execute" to prepare the input file, run the simulation and create the output figure.
+
&copy; 2013 by Matthias Troyer, Ping Nang Ma.

Latest revision as of 15:55, 1 October 2013

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.

Column integrated density

In this subsection, we want to mimick the experimental setup.

Preparing and running the simulation from the command line

The parameter file parm2a sets up Monte Carlo simulation of a 1203 optical lattice trap that mimicks the 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

(This simulation roughly takes 3 hours.)

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.

(This simulation roughly takes roughly 3 hours.)

Evaluating the simulation and preparing plots using Python

To load the results and prepare the plot for density profile we load the results from the output files from all output files starting with parm2a. The script is again in tutorial2a.py

import pyalps
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2a'), 'Local Density');

To visualize the column integrated density:

import pyalps.plot as aplt;
aplt.plot3D(data, centeredAtOrigin=True)

Setting up and running the simulation in Vistrails

To run the simulation in Vistrails open the file dwa-02-density-profile.vt and look at the workflow labeled "Column integrated density profile". Click on "Execute" to prepare the input file, run the simulation and create the output figure.

(The simulation takes roughly 3 hours from scratch.)

Cross section density

We want to observe a Mott plateau.

Preparing and running the simulation from the command line

The parameter file parm2a sets up Monte Carlo simulation of a 803 optical lattice trap that mimicks the Bloch experiment:

LATTICE="inhomogeneous simple cubic lattice"
L=60

MODEL="boson Hubbard"
Nmax=20
 
t=1.
U=60.
mu="40. - (0.09416*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.12955*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.11496*(z-(L-1)/2.)*(z-(L-1)/2.))"

THERMALIZATION=1000000
SWEEPS=3000000
SKIP=1000

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 tutorial2b.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'       : 60 ,

    'MODEL'   : 'boson Hubbard' ,
    'Nmax'    : 20 ,

    't'  : 1. ,
    'U'  : 60. ,
    'mu' : '40. - (0.09416*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.12955*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.11496*(z-(L-1)/2.)*(z-(L-1)/2.))' ,

    'T'  : 1. ,

    'THERMALIZATION' : 1000000 ,
    'SWEEPS'         : 3000000 ,
    'SKIP'           : 1000 , 

    'MEASURE[Local Density]': 1
  }
]

We next convert this into a job file in XML format and run the worm simulation:

input_file = pyalps.writeInputFiles('parm2b', 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 the plot for density profile we load the results from the output files from all output files starting with parm2b. The script is again in tutorial2b.py

import pyalps
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2b'), 'Local Density');

To visualize the cross-section density at the center:

import pyalps.plot as aplt;
aplt.plot3D(data, centeredAtOrigin=True, layer="center")

Setting up and running the simulation in Vistrails

To run the simulation in Vistrails open the file dwa-02-density-profile.vt and look at the workflow labeled "Cross-sectional density profile". Click on "Execute" to prepare the input file, run the simulation and create the output figure.

To run the next workflow "Advanced visualization of 3D density profiles", you have to first specify the directory archive_dir for archiving in the toolbox Archiving simulation.

Advanced visualization: cross-sectional density profile

Enhancing with Vistrails VTK package

To run the simulation in Vistrails open the file dwa-02-density-profile.vt and look at the workflow labeled "Advanced visualization". Click on "Execute" to prepare the input file, run the simulation and create the output figure.


© 2013 by Matthias Troyer, Ping Nang Ma.