Difference between revisions of "ALPS 2 Tutorials:MC-01 Equilibration"

From ALPS
Jump to: navigation, search
(A convenient tool: pyalps.checkNonSteadyState)
(A convenient tool: pyalps.checkNonSteadyState)
Line 80: Line 80:
 
to see how it works.
 
to see how it works.
  
Here is one example (observable: |Magnetization|, confidence interval = 95%):
+
Here is one example (observable: |Magnetization|):
  
  pyalps.checkSteadyState(files[0], '|Magnetization|', confidenceInterval=0.95)
+
  pyalps.checkNonSteadyState(files[0], '|Magnetization|')
  
and another one:
+
and another one (at 95% confidence interval):
  
  pyalps.checkSteadyState(files[0], ['|Magnetization|', 'Energy'], confidenceInterval=0.95)
+
  pyalps.checkNonSteadyState(files[0], ['|Magnetization|', 'Energy'], confidenceInterval=0.95)
  
<u>'''Description'''</u><br/>
+
and its complete log:
1. ''steady_state_check'' first performs a linear fit on the timeseries, and decides whether the measurement observable has reached steady state equilibrium based on the gradient/slope of the fitted line.
 
  
2. The optional arguments of ''steady_state_check'' are:
+
  pyalps.checkNonSteadyState(files[0], ['|Magnetization|', 'Energy'], confidenceInterval=0.95, includeLog=True)
 
 
{| border="1" cellpadding="5" cellspacing="0" align="center"
 
|| argument
 
|| default
 
|| remark
 
|-
 
||  confidenceInterval
 
|| 0.01
 
|| <math> \mathrm{tolerance} = \frac{X^\mathrm{(fit)} (t_\mathrm{final}) - X^\mathrm{(fit)} (t_\mathrm{initial})}{\bar{X}} </math>
 
|-
 
|| simplified
 
|| False
 
|| shall we combine the checks of all observables as 1 final boolean answer?
 
|-
 
|| includeLog
 
|| False
 
|| shall we print the detailed log?
 
|}
 
 
 
3. To see the complete log for instance:
 
 
 
  pyalps.checkSteadyState(files[0], ['|Magnetization|', 'Energy'], confidenceInterval=0.95, includeLog=True)
 
  
 
=== Using Vistrails ===
 
=== Using Vistrails ===
  
 
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.1.0/mc-01b-equilibration/mc-01b-equilibration.vt mc-01b-equilibration.vt].
 
To run the simulation in Vistrails open the file [http://alps.comp-phys.org/static/tutorials2.1.0/mc-01b-equilibration/mc-01b-equilibration.vt mc-01b-equilibration.vt].

Revision as of 16:16, 10 September 2013

Equilibration

Rule of thumb: All Monte Carlo simulations have to be equilibrated before taking measurements.

Example: Classical Monte Carlo (local updates) simulations

As an example, we will implement a classical Monte Carlo simulation implemented in the Ising model on a finite square lattice of size 482.

Using command line

The parameter file parm1a:

LATTICE="square lattice"
T=2.269186
J=1
THERMALIZATION=10000
SWEEPS=50000  
UPDATE="local"
MODEL="Ising"
{L=48;}

We first convert the input parameters to XML and then run the application spinmc:

parameter2xml parm1a
spinmc --Tmin 10 --write-xml parm1a.in.xml


Add in timeseries analysis here after Python

Based on the timeseries, the user will then judge for himself/herself whether the simulation has reached equilibration.

Using Python

The following describes what is going on within the script file tutorial1a.py.

The headers:

import pyalps

Set up a python list of parameters (python) dictionaries:

parms = [{
  'LATTICE'         : "square lattice",
  'MODEL'           : "Ising",
  'L'               : 48,
  'J'               : 1.,
  'T'               : 2.269186,
  'THERMALIZATION'  : 10000,
  'SWEEPS'          : 50000,
}]

Write into XML input file:

input_file = pyalps.writeInputFiles('parm1a',parms)

and run the application spinmc:

pyalps.runApplication('spinmc', input_file, Tmin=10, writexml=True)

We first get the list of all result files via:

files = pyalps.getResultFiles(prefix='parm1a')

and then extract, say the timeseries of the |Magnetization| measurements:

ts_M = pyalps.loadTimeSeries(files[0], '|Magnetization|');

We can then visualize graphically:

import matplotlib.pyplot as plt
plt.plot(ts_M)
plt.show()

Based on the timeseries, the user will then judge for himself/herself whether the simulation has reached equilibration.

A convenient tool: pyalps.checkNonSteadyState

ALPS Python provides a convenient tool to check whether a measurement observable(s) has (have) not reached steady state equilibrium. Read here to see how it works.

Here is one example (observable: |Magnetization|):

pyalps.checkNonSteadyState(files[0], '|Magnetization|')

and another one (at 95% confidence interval):

pyalps.checkNonSteadyState(files[0], ['|Magnetization|', 'Energy'], confidenceInterval=0.95)

and its complete log:

pyalps.checkNonSteadyState(files[0], ['|Magnetization|', 'Energy'], confidenceInterval=0.95, includeLog=True)

Using Vistrails

To run the simulation in Vistrails open the file mc-01b-equilibration.vt.