Example #1
0
q1range = [-3.1*σ1, 3.1*σ1]
q2range = [-3.1*σ2, 3.1*σ2]

p1range = [-3.1*m1, 3.1*m1]
p2range = [-3.1*m2, 3.1*m2]

ε = 0.01
ω_plus = numpy.complex(0.0, numpy.sqrt(α*(1.0 + γ)))
ω_minus = numpy.complex(0.0, numpy.sqrt(α*(1.0 - γ)))
t_plus = 2.0*numpy.pi / numpy.abs(ω_plus)
t_minus = 2.0*numpy.pi / numpy.abs(ω_minus)

tmax = 2.0*t_minus/3.0
nsample = 10000

U = hmc.bivariate_normal_U(γ, σ1, σ2)
K = hmc.bivariate_normal_K(m1, m2)
dUdq = hmc.bivariate_normal_dUdq(γ, σ1, σ2)
dKdp = hmc.bivariate_normal_dKdp(m1, m2)
momentum_generator = hmc.bivariate_normal_momentum_generator(m1, m2)
potential_pdf = hmc.potential_distribution(U)
momentum_pdf = hmc.momentum_distribution(K)

file_prefix = "hmc-bivariate-normal-γ-0.0"

# %%

H, p, q, accepted = hmc.HMC(q0, U, K, dUdq, dKdp, hmc.momentum_verlet_integrator, momentum_generator, nsample, tmax, ε)

# %%
Example #2
0
    return U_t + K_t

# %%
# Configuration

γ = 0.9
α = 1 / (1.0 - γ**2)

ω_plus = numpy.complex(0.0, numpy.sqrt(α*(1.0 + γ)))
ω_minus = numpy.complex(0.0, numpy.sqrt(α*(1.0 - γ)))
t_plus = 2.0*numpy.pi / numpy.abs(ω_plus)
t_minus = 2.0*numpy.pi / numpy.abs(ω_minus)

nsteps = 500

U = hmc.bivariate_normal_U(γ, 1.0, 1.0)
K = hmc.bivariate_normal_K(1.0, 1.0)

# %%
# Compute solutions using eigenvalues and eigenvectots computed from numercically diagonalizing Hamiltonian Matrix
PQ0 = numpy.matrix([[1.0], [1.0], [1.0], [1.0]])
time = numpy.linspace(0.0, 2.0*t_minus, nsteps)

# Diagonalize Hamiltonian Matrix
H = hamiltonian_matrix(γ, α)
λ, E = linalg.eig(H)
PQ = coordinate_time_series(E, PQ0, λ, time)
q = numpy.array([[numpy.real(PQ[i,2,0]), numpy.real(PQ[i,3,0])] for i in range(nsteps)])
p = numpy.array([[numpy.real(PQ[i,0,0]), numpy.real(PQ[i,1,0])] for i in range(nsteps)])

title = f"Numerical Evaluation: γ={γ}, " + r"$t_{+}=$" + f"{format(t_plus, '2.4f')}, " + r"$t_{-}=$" + f"{format(t_minus, '2.4f')}"