Exemple #1
0
    def test_hamiltonian_Ne_3(self):
        l1 = pymc.GrapheneLattice(10)
        FK1 = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
        FK1.calculate_eigv(temp=True)
        Ne1 = FK1.get_ne(temp=True, T=0.01, cp=-1)

        FK2 = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
        FK2.T = 0.01
        FK2.cp = 1
        FK2.calculate_eigv()
        Ne2 = FK2.get_ne()

        assert Ne1 < Ne2
    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)
Exemple #3
0
 def test_hamiltonian_Ne_2(self):
     l1 = pymc.GrapheneLattice(10)
     FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
     FK.put_adatoms(50, "sublattice")
     FK.calculate_eigv()
     Ne = FK.get_ne(T=0.01, cp=1)
     np.testing.assert_almost_equal(Ne, 50)
Exemple #4
0
    def test_swap_in_temp_H(self):
        l1 = pymc.lattice.GrapheneLattice(4)
        FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
        FK.put_adatoms(6)

        ch_empty = np.random.choice(FK.empty_sites)
        ch_filled = np.random.choice(FK.filled_sites)

        assert FK.H[ch_empty, ch_empty] == 0
        assert FK.H[ch_filled, ch_filled] == 2
        assert FK.temp_H[ch_empty, ch_empty] == 0
        assert FK.temp_H[ch_filled, ch_filled] == 2

        FK.swap_in_temp_H(ch_filled, ch_empty)

        assert FK.H[ch_empty, ch_empty] == 0
        assert FK.H[ch_filled, ch_filled] == 2
        assert FK.temp_H[ch_empty, ch_empty] == 2
        assert FK.temp_H[ch_filled, ch_filled] == 0

        FK.un_swap_in_temp_H(ch_filled, ch_empty)

        assert FK.H[ch_empty, ch_empty] == 0
        assert FK.H[ch_filled, ch_filled] == 2
        assert FK.temp_H[ch_empty, ch_empty] == 0
        assert FK.temp_H[ch_filled, ch_filled] == 2
Exemple #5
0
 def prepare_model(self, n, nad, order):
     l1 = pymc.GrapheneLattice(n)
     FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
     o_C = pymc.CorrelationObs(FK)
     for _ in range(100):
         FK.put_adatoms(nad, order)
         o_C.calculate()
     return o_C.get_result()
Exemple #6
0
 def test_adatoms_sums(self):
     l1 = pymc.lattice.GrapheneLattice(4)
     FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
     for mode in ["random", "sublattice", "separation"]:
         FK.put_adatoms(6, order=mode)
         assert np.trace(FK.H) == 12
         assert len(FK.filled_sites) == 6
         assert len(FK.empty_sites) == 10
Exemple #7
0
    def test_adatoms_sublatice(self):
        l1 = pymc.lattice.GrapheneLattice(4)
        FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
        FK.put_adatoms(6, order="sublattice")

        for i in FK.filled_sites:
            assert i in FK.lattice.sub_matrix[1]
            assert FK.H[i, i] == 2.0
Exemple #8
0
 def prepare_model_E(self, n, nad, order):
     l1 = pymc.GrapheneLattice(n)
     FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2, T=0.01)
     o_energy = pymc.EnergyObs(FK)
     for _ in range(50):
         FK.put_adatoms(nad, order)
         FK.calculate_eigv()
         o_energy.calculate()
     return o_energy.get_result()
Exemple #9
0
 def prepare_model_cv(self, n, nad, order, T):
     l1 = pymc.GrapheneLattice(n)
     FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2, T=T)
     o_cv = pymc.CVObs(FK)
     for _ in range(50):
         FK.put_adatoms(nad, order)
         FK.calculate_eigv()
         o_cv.calculate()
     return o_cv.get_result()
Exemple #10
0
    def test_obs_correlation_6(self):
        l1 = pymc.GrapheneLattice(10)
        FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
        o_C = pymc.CorrelationObs(FK)
        for _ in range(100):
            FK.put_adatoms(50, "random")
            o_C.calculate()
        o_C.reset()

        assert o_C.get_result() is None
Exemple #11
0
 def test_obs_cv_2(self):
     l1 = pymc.GrapheneLattice(10)
     FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2, T=0.2)
     o_cv = pymc.CVObs(FK)
     for _ in range(50):
         FK.put_adatoms(50, "random")
         FK.calculate_eigv()
         o_cv.calculate()
     o_cv.reset()
     assert o_cv.get_result() is None
Exemple #12
0
    def test_obs_correlation_6(self):
        l1 = pymc.GrapheneLattice(10)
        FK = pymc.Hamiltonian(lattice=l1, t=-1, U=2)
        o_C = pymc.CorrelationObs(FK)
        for _ in range(100):
            FK.put_adatoms(50, "random")
            o_C.calculate()
        d = o_C.get_result()

        assert len(o_C.value_list) == 100
        np.testing.assert_almost_equal(abs(d), 0, decimal=1)
Exemple #13
0
    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)
Exemple #14
0
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)