def get_results(self): lattice = pymc.GrapheneLattice(6) FK = pymc.Hamiltonian(lattice, t=-1, U=2, cp=1, T=0.2) FK.put_adatoms(18, "random") obs = pymc.ObsList([pymc.DeltaObs(FK), pymc.EnergyObs(FK), pymc.CVObs(FK), pymc.CorrelationObs(FK), pymc.NeObs(FK)]) obs_conv = pymc.ObsList( [pymc.DeltaObs(FK), pymc.EnergyObs(FK), pymc.CorrelationObs(FK)]) series = pymc.ObsSeries(obs, ["T"]) sym = pymc.Simulator(FK, pymc.metropolis_numpy, obs, obs_conv) T_range = [0.2, 0.18, 0.16, 0.14, 0.12, 0.10, 0.08, 0.06, 0.04, 0.03, 0.02, 0.01] for T in T_range: FK.T = T sym.run_termalization(10**2) res = sym.run_measurements(10**2) series.add(res, [T]) expected = np.loadtxt( "tests/simulate/half_filling_1.csv", delimiter=",") res = series.get_df().values return (expected, res)
def prepare_model(self, n, nad, order): l1 = pymc.GrapheneLattice(n) FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2) o_delta = pymc.DeltaObs(FK) for _ in range(100): FK.put_adatoms(nad, order) o_delta.calculate() return o_delta.get_result()
def test_obs_delta_7(self): l1 = pymc.GrapheneLattice(10) FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2) o_delta = pymc.DeltaObs(FK) for _ in range(100): FK.put_adatoms(50, "random") o_delta.calculate() d = o_delta.get_result() assert len(o_delta.value_list) == 100 np.testing.assert_almost_equal(d, 0, decimal=1)
import pymc import matplotlib.pyplot as plt from tqdm import tqdm import numpy as np lattice = pymc.GrapheneLattice(6) FK = pymc.Hamiltonian(lattice, t=-1, U=2, cp=-1, T=0.2) FK.put_adatoms(6 * 3, "random") obs = pymc.ObsList([ pymc.DeltaObs(FK), pymc.EnergyObs(FK), pymc.CVObs(FK), pymc.CorrelationObs(FK), pymc.NeObs(FK) ]) obs_conv = pymc.ObsList( [pymc.DeltaObs(FK), pymc.EnergyObs(FK), pymc.CorrelationObs(FK)]) series = pymc.ObsSeries(obs, ["T"]) sym = pymc.Simulator(FK, pymc.metropolis_numpy, obs, obs_conv) T_range = [ 0.2, 0.18, 0.16, 0.14, 0.12, 0.10, 0.08, 0.06, 0.04, 0.03, 0.02, 0.01 ] for T in tqdm(T_range, desc="Main loop"): FK.T = T sym.run_termalization(10**4)