Beispiel #1
0
def calculateTunnelingRate(distance):
    print('Calculating transition rate for distance %0.2f' % distance)
    # calculate potential parameter
    lambda_ = distanceToParameter(distance)
    p = Potential(mu, lambda_)
    a = Action(tau, mass, p)
    m = Metropolis(N, a, borders=[-10, 10], hbar=hbar, tau=tau)

    tC = TransitionCounter()

    for value in m:
        tC.registerValue(value)
    return tC.getTransitions()
Beispiel #2
0
def calculatePositionDistribution(distance):
	print('calculating for distance=%0.2f' % distance)
	lambda_ = distanceToParameter(distance)
	# generate objects related to metropolis

	init = initial if initial != None else -distance

	m = Metropolis(init=init, valWidth=random_width, initValWidth=initial_random, hbar=hbar, tau=tau, N=N, m=mass, lambda_=lambda_, mu=mu)

	values = []
	accept_ratios = []
	# start after 50 samples
	for _ in range(iteration):
		vals, accept_ratio = next(m)
		values.append(vals.copy())		# important!
		accept_ratios.append(accept_ratio)

	values = values[50:]
	accept_ratios = accept_ratios[50:]
	tint_max = 0

	# calculate worst case integrated autocorrelation time
	# leads to inhomogeneous distribution along hbar, tint is thus fixed
	"""
	xdata = np.arange(data.shape[0])
	for i in range(0, data.shape[1], data.shape[1] // 50):
		ydata = autoCorrelationNormalized(data[:,i], xdata)
		tint, dtint, w_max = getIntegratedCorrelationTime(ydata)
		if tint_max < tint + dtint:
			tint_max = tint + dtint
	"""

	tint_max = 15.0

	# step size between uncorrelated samples
	step_size = int(tint_max * 2 + 1)

	data_use = values[::step_size]

	transitions = [countTransitions(v) for v in data_use]

	return list(np.histogram(data_use, bins)[0]), np.mean(accept_ratios), np.mean(transitions), np.std(transitions)
Beispiel #3
0
def calculatePositionDistribution(distance):
    print("calculating for distance=%0.2f" % distance)
    lambda_ = distanceToParameter(distance)
    p = Potential(-mu, lambda_)

    k = Kinetic(mass, tau)

    de = deltaEnergy(k, p)

    m = Metropolis(de,
                   init=initial,
                   valWidth=1,
                   initValWidth=initial_random,
                   hbar=hbar,
                   tau=tau,
                   N=N)

    vals = next(islice(m, iteration, iteration +
                       1))  # get iterations th metropolis iteration
    return list(np.histogram(vals[0], bins)[0]), vals[1]
from matplotlib import pyplot as plt
from tools import Potential, distanceToParameter
import numpy as np

# number of distances evaluated
min_distance = 1
max_distance = 16
step_distance = 1

params = [
	(10, 0, 'harm', 0)
]

distances = np.arange(min_distance, max_distance, step_distance)

params += [
	(-10, distanceToParameter(d), 'anharm: %0.2f' %d, d) for d in distances
]

for mu, lambda_, name, d in params:
	xvalues = np.arange(-5-d / 2, 5+d / 2, 0.01)
	p = Potential(mu, lambda_)
	yvalues = p(xvalues)
	plt.figure()
	plt.errorbar(xvalues, yvalues)
	plt.xlabel('Distance')
	plt.ylabel('Tunneling rate')
	plt.savefig('imgs/d_%s.png' %name)
	plt.savefig('imgs/d_%s.pdf' %name)
	plt.close()
Beispiel #5
0
parser.add_argument("-o", "--output", type=str, default='',
                    help="Output filename")
args = parser.parse_args()


# parameters
iterations = args.iterations
N = args.number
mass = args.mass
mu = args.mu
tau = args.tau
hbar = args.hbar
initial = args.initial
initial_random = args.initial_random
distance = args.distance
lambda_ = distanceToParameter(distance)
output = args.output

parameters = [
			'iterations', 'N', 'mass', 'mu', 'tau', 'hbar', 'initial', 'initial_random',
            'distance', 'lambda_',
			]

p = Potential(-mu, lambda_)

k = Kinetic(mass, tau)

de = deltaEnergy(k, p)

m = Metropolis(de, init=initial, valWidth=1, initValWidth=initial_random, hbar=hbar, tau=tau, N=N)