In [1]:
# Now we are going to run a basic simulation
from copy import deepcopy as dc
from ase import Atoms
from pyiid.experiments.elasticscatter import ElasticScatter
from pyiid.calc.calc_1d import Calc1D
from pyiid.sim.nuts_hmc import NUTSCanonicalEnsemble
from ase.cluster import Octahedron
import matplotlib.pyplot as plt
from ase.visualize import view

In [2]:
atoms = Octahedron('Au', 2)

In [6]:
# We can examine the configuration we made
atoms.edit()


/home/christopher/mc/envs/sim_dev2/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py:127: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
  set_interactive(1)

In [3]:
scat = ElasticScatter()
pdf = scat.get_pdf(atoms)
r = scat.get_r()

In [7]:
# Now lets dilate the atoms so that they don't match the pdf
atoms2 = dc(atoms)
atoms2.positions *= 1.03
pdf2 = scat.get_pdf(atoms2)
r = scat.get_r()

In [8]:
calc = Calc1D(
    target_data=pdf,  # The target or experimental data
    exp_function=scat.get_pdf,
    # The function which takes in atoms and produces
    # data like the experiment
    exp_grad_function=scat.get_grad_pdf,  # the function which produces the
    #  gradient of the calculated data
    conv=100,  # conversion from the unitless goodness of fit to eV
    potential='rw' # use the rw PES over chi squared
)

In [9]:
# Now we attach the calculator to our displaced atoms
atoms2.set_calculator(calc)
# Now we can get back the potential energy
print atoms2.get_potential_energy()
# And the forces
print atoms2.get_forces()


92.551192825
[[ 52.77273718  -0.          -0.        ]
 [ -0.          52.77273756  -0.        ]
 [ -0.          -0.          52.77273732]
 [ -0.          -0.         -52.77273732]
 [ -0.         -52.77273729  -0.        ]
 [-52.77273729  -0.          -0.        ]]

In [10]:
# Now we need to make the ensemble
ensemble = NUTSCanonicalEnsemble(atoms2, temperature=1000,
                                 verbose=True, escape_level=8)


[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]
trajectory file None
trying step size 1.0
optimal step size 1.0
thermal_nrg 0.0861738569226
kinetic energy 0.775564712303

In [11]:
# Now run the simulation
traj, metadata = ensemble.run(20)


iteration number 0
	time step size 10.1805069739 fs
	 	depth 1 samples 2
	 	depth 2 samples 4
iteration number 1
	time step size 101.805069739 fs
	 	depth 1 samples 2
iteration number 2
	time step size 24.1632408217 fs
	 	depth 1 samples 2
	 	depth 2 samples 4
	 	depth 3 samples 8
iteration number 3
	time step size 3.40938267521 fs
			New Potential Energy: 77.1178931441 eV
			New Kinetic Energy: 11.4945074096 eV
			New Temperature: 14820.8231076 K
accepted configuration at  77.1178931441
	 	depth 1 samples 2
			New Potential Energy: 81.0621260014 eV
			New Kinetic Energy: 8.70906708994 eV
			New Temperature: 11229.323552 K
accepted configuration at  81.0621260014
	 	depth 2 samples 4
iteration number 4
	time step size 5.56119179605 fs
			New Potential Energy: 44.3825612387 eV
			New Kinetic Energy: 4.66243394282 eV
			New Temperature: 6011.66333236 K
accepted configuration at  44.3825612387
	 	depth 1 samples 2
iteration number 5
	time step size 12.253914273 fs
	 	depth 1 samples 2
	 	depth 2 samples 4
iteration number 6
	time step size 1.61329856165 fs
			New Potential Energy: 25.476219077 eV
			New Kinetic Energy: 10.6314620423 eV
			New Temperature: 13708.0270332 K
accepted configuration at  25.476219077
	 	depth 1 samples 2
			New Potential Energy: 33.9891095506 eV
			New Kinetic Energy: 10.8330611458 eV
			New Temperature: 13967.9655017 K
accepted configuration at  33.9891095506
	 	depth 2 samples 4
	 	depth 3 samples 8
iteration number 7
	time step size 1.96078476238 fs
			New Potential Energy: 10.4322031488 eV
			New Kinetic Energy: 11.5304562042 eV
			New Temperature: 14867.1748743 K
accepted configuration at  10.4322031488
	 	depth 1 samples 2
	 	depth 2 samples 4
iteration number 8
	time step size 0.242874047747 fs
			New Potential Energy: 10.17329207 eV
			New Kinetic Energy: 0.314242428361 eV
			New Temperature: 405.17886306 K
accepted configuration at  10.17329207
	 	depth 1 samples 2
			New Potential Energy: 9.2345611935 eV
			New Kinetic Energy: 0.780091794332 eV
			New Temperature: 1005.83714287 K
accepted configuration at  9.2345611935
	 	depth 2 samples 4
			New Potential Energy: 9.98491589825 eV
			New Kinetic Energy: 0.408270322895 eV
			New Temperature: 526.416837201 K
accepted configuration at  9.98491589825
	 	depth 3 samples 8
iteration number 9
	time step size 0.688280130652 fs
			New Potential Energy: 7.61584811567 eV
			New Kinetic Energy: 1.67723247658 eV
			New Temperature: 2162.59513871 K
accepted configuration at  7.61584811567
	 	depth 1 samples 2
			New Potential Energy: 5.99803390214 eV
			New Kinetic Energy: 2.0557903249 eV
			New Temperature: 2650.7012146 K
accepted configuration at  5.99803390214
	 	depth 2 samples 4
			New Potential Energy: 7.60436366046 eV
			New Kinetic Energy: 1.53148725222 eV
			New Temperature: 1974.67371572 K
accepted configuration at  7.60436366046
	 	depth 3 samples 8
	 	depth 4 samples 16
iteration number 10
	time step size 0.74838082549 fs
			New Potential Energy: 5.59276306961 eV
			New Kinetic Energy: 1.33954085348 eV
			New Temperature: 1727.18128124 K
accepted configuration at  5.59276306961
	 	depth 1 samples 2
			New Potential Energy: 4.72415819305 eV
			New Kinetic Energy: 1.44872519816 eV
			New Temperature: 1867.9617254 K
accepted configuration at  4.72415819305
	 	depth 2 samples 4
iteration number 11
	time step size 0.558866383369 fs
			New Potential Energy: 4.83214009362 eV
			New Kinetic Energy: 1.36686370599 eV
			New Temperature: 1762.41090434 K
accepted configuration at  4.83214009362
	 	depth 1 samples 2
			New Potential Energy: 4.398772636 eV
			New Kinetic Energy: 1.54062665497 eV
			New Temperature: 1986.45790677 K
accepted configuration at  4.398772636
	 	depth 2 samples 4
			New Potential Energy: 4.08677884771 eV
			New Kinetic Energy: 1.73896974679 eV
			New Temperature: 2242.19812893 K
accepted configuration at  4.08677884771
	 	depth 3 samples 8
			New Potential Energy: 2.67253362249 eV
			New Kinetic Energy: 2.52070897509 eV
			New Temperature: 3250.15944524 K
accepted configuration at  2.67253362249
	 	depth 4 samples 16
			New Potential Energy: 4.38588848669 eV
			New Kinetic Energy: 1.54544460456 eV
			New Temperature: 1992.67008934 K
accepted configuration at  4.38588848669
	 	depth 5 samples 32
	 	depth 6 samples 64
iteration number 12
	time step size 1.09350589303 fs
			New Potential Energy: 3.92730973935 eV
			New Kinetic Energy: 1.24573921512 eV
			New Temperature: 1606.23503797 K
accepted configuration at  3.92730973935
	 	depth 1 samples 2
	 	depth 2 samples 4
			New Potential Energy: 3.70144614137 eV
			New Kinetic Energy: 1.32753677636 eV
			New Temperature: 1711.70342758 K
accepted configuration at  3.70144614137
	 	depth 3 samples 8
			New Potential Energy: 2.40212442515 eV
			New Kinetic Energy: 1.76940287098 eV
			New Temperature: 2281.43808364 K
accepted configuration at  2.40212442515
	 	depth 4 samples 16
iteration number 13
	time step size 0.961134542289 fs
			New Potential Energy: 2.79735087704 eV
			New Kinetic Energy: 0.783866694969 eV
			New Temperature: 1010.70443579 K
accepted configuration at  2.79735087704
	 	depth 1 samples 2
	 	depth 2 samples 4
	 	depth 3 samples 8
iteration number 14
	time step size 0.621136597166 fs
			New Potential Energy: 2.23202787068 eV
			New Kinetic Energy: 0.963934401686 eV
			New Temperature: 1242.88068603 K
accepted configuration at  2.23202787068
	 	depth 1 samples 2
	 	depth 2 samples 4
	 	depth 3 samples 8
	 	depth 4 samples 16
	 	depth 5 samples 32
	 	depth 6 samples 64
iteration number 15
	time step size 0.554941121387 fs
			New Potential Energy: 2.05122264008 eV
			New Kinetic Energy: 0.513549462744 eV
			New Temperature: 662.161976425 K
accepted configuration at  2.05122264008
	 	depth 1 samples 2
			New Potential Energy: 1.76994049258 eV
			New Kinetic Energy: 0.603824464175 eV
			New Temperature: 778.561033781 K
accepted configuration at  1.76994049258
	 	depth 2 samples 4
			New Potential Energy: 2.10360655451 eV
			New Kinetic Energy: 0.802092359082 eV
			New Temperature: 1034.20429831 K
accepted configuration at  2.10360655451
	 	depth 3 samples 8
	 	depth 4 samples 16
			New Potential Energy: 1.40440450847 eV
			New Kinetic Energy: 0.839152321928 eV
			New Temperature: 1081.98878651 K
accepted configuration at  1.40440450847
	 	depth 5 samples 32
	 	depth 6 samples 64
iteration number 16
	time step size 0.770283413272 fs
	 	depth 1 samples 2
			New Potential Energy: 1.82682191801 eV
			New Kinetic Energy: 1.0242472846 eV
			New Temperature: 1320.64709541 K
accepted configuration at  1.82682191801
	 	depth 2 samples 4
			New Potential Energy: 1.52909457319 eV
			New Kinetic Energy: 0.932256487429 eV
			New Temperature: 1202.03572009 K
accepted configuration at  1.52909457319
	 	depth 3 samples 8
			New Potential Energy: 1.99228988363 eV
			New Kinetic Energy: 0.921296661275 eV
			New Temperature: 1187.90430593 K
accepted configuration at  1.99228988363
	 	depth 4 samples 16
iteration number 17
	time step size 0.773665603662 fs
			New Potential Energy: 2.42274709527 eV
			New Kinetic Energy: 0.60430994351 eV
			New Temperature: 779.187002611 K
accepted configuration at  2.42274709527
	 	depth 1 samples 2
	 	depth 2 samples 4
			New Potential Energy: 2.27713837985 eV
			New Kinetic Energy: 0.475807239257 eV
			New Temperature: 613.497792911 K
accepted configuration at  2.27713837985
	 	depth 3 samples 8
			New Potential Energy: 2.0983386928 eV
			New Kinetic Energy: 0.720278714878 eV
			New Temperature: 928.715171606 K
accepted configuration at  2.0983386928
	 	depth 4 samples 16
	 	depth 5 samples 32
iteration number 18
	time step size 0.71499634903 fs
			New Potential Energy: 1.20476406977 eV
			New Kinetic Energy: 0.868598480962 eV
			New Temperature: 1119.95616508 K
accepted configuration at  1.20476406977
	 	depth 1 samples 2
	 	depth 2 samples 4
	 	depth 3 samples 8
			New Potential Energy: 1.24267796314 eV
			New Kinetic Energy: 0.879844653627 eV
			New Temperature: 1134.45678957 K
accepted configuration at  1.24267796314
	 	depth 4 samples 16
	 	depth 5 samples 32
iteration number 19
	time step size 0.550281037466 fs
	 	depth 1 samples 2
			New Potential Energy: 0.780056355097 eV
			New Kinetic Energy: 0.556834754959 eV
			New Temperature: 717.973298844 K
accepted configuration at  0.780056355097
	 	depth 2 samples 4
			New Potential Energy: 0.912521131482 eV
			New Kinetic Energy: 0.596253133148 eV
			New Temperature: 768.798687833 K
accepted configuration at  0.912521131482
	 	depth 3 samples 8
	 	depth 4 samples 16
			New Potential Energy: 0.868506689366 eV
			New Kinetic Energy: 0.598752045359 eV
			New Temperature: 772.020742899 K
accepted configuration at  0.868506689366
	 	depth 5 samples 32
			New Potential Energy: 1.40855634714 eV
			New Kinetic Energy: 0.723289411299 eV
			New Temperature: 932.597112562 K
accepted configuration at  1.40855634714
	 	depth 6 samples 64
	 	depth 7 samples 128

In [ ]:
view(traj)