示例#1
0
    def test_rho0(self):

        muexp = MuonExperiment(['e', 'mu'])
        rho0 = muexp.get_starting_state()

        self.assertTrue(
            np.all(
                np.isclose(rho0.matrix,
                           [[0.25, 0.25, 0, 0], [0.25, 0.25, 0, 0],
                            [0, 0, 0.25, 0.25], [0, 0, 0.25, 0.25]])))

        gmu = constants.MU_GAMMA
        ge = constants.ELEC_GAMMA

        T = 100
        muexp.set_magnetic_field(2.0e-6 * cnst.k * T / (ge * cnst.h))
        muexp.set_temperature(T)
        muexp.set_muon_polarization('z')

        rho0 = muexp.get_starting_state()

        Z = np.exp([-1, 1])
        Z /= np.sum(Z)

        self.assertTrue(
            np.all(np.isclose(np.diag(rho0.matrix), [Z[0], 0, Z[1], 0])))
示例#2
0
    def test_dissipation(self):

        # Simple system
        g = 1.0
        muexp = MuonExperiment(['mu'])
        muexp.set_dissipation_coupling(0, g)

        times = np.linspace(0, 10)

        results = muexp.run_experiment(times)
        evol = results['e']

        solx = np.real(0.5 * np.exp(-np.pi * g * times))
        self.assertTrue(np.all(np.isclose(evol[:, 0], solx)))

        # Check for temperature equilibrium
        T = 0.1
        muexp.set_magnetic_field(-1.0)
        muexp.set_temperature(T)

        beta = 1.0 / (cnst.k * T)
        Z = np.exp(-cnst.h * constants.MU_GAMMA * 1e6 * beta)

        # Just let it evolve, see the result at long times
        Sz = muexp.spin_system.operator({0: 'z'})
        rhoinf = muexp.run_experiment([20], Sz)['e']

        self.assertAlmostEqual(rhoinf[0, 0], 0.5 * (1 - Z) / (1 + Z))
示例#3
0
import cProfile
import numpy as np
from muspinsim.experiment import MuonExperiment

exp = MuonExperiment(['e', 'mu', 'H'])
exp.spin_system.add_hyperfine_term(1, np.diag([1,1,4])*100)
exp.spin_system.add_hyperfine_term(2, np.diag([1,1,4])*100/3)
exp.set_powder_average(100)
exp.set_magnetic_field(5.0)
exp.set_dissipation_coupling(0, 1.0)
exp.set_muon_polarization('z')

times = np.linspace(0, 1, 1000)
op = exp.spin_system.operator({1: 'z'})

cProfile.run('exp.run_experiment(times, [op], "i")', sort='cumulative')