Ejemplo n.º 1
0
class AveragesCollector:

	def __init__(self, env, constants):
		self._env = env
		self._constants = constants
		self._stats = ParticleStatistics(env, constants)
		self._reduce = createReduce(env, constants.scalar.dtype)
		self._creduce = createReduce(env, constants.complex.dtype)

		self.times = []
		self.n1 = []
		self.n2 = []
		self.i = []

	def __call__(self, t, cloud):
		self.times.append(t)

		ensembles = cloud.a.size / self._constants.cells
		get = self._env.fromDevice
		reduce = self._reduce
		creduce = self._creduce
		dV = self._constants.dV

		i = self._stats._getInteraction(cloud.a, cloud.b)
		n1 = self._stats.getDensity(cloud.a)
		n2 = self._stats.getDensity(cloud.b)

		self.i.append(get(creduce(i, ensembles)) * dV)
		self.n1.append(get(reduce(n1, ensembles)) * dV)
		self.n2.append(get(reduce(n2, ensembles)) * dV)

	def getData(self):
		return numpy.array(self.times), self.i, self.n1, self.n2
Ejemplo n.º 2
0
class AveragesCollector:
    def __init__(self, env, constants):
        self._env = env
        self._constants = constants
        self._stats = ParticleStatistics(env, constants)
        self._reduce = createReduce(env, constants.scalar.dtype)
        self._creduce = createReduce(env, constants.complex.dtype)

        self.times = []
        self.n1 = []
        self.n2 = []
        self.i = []

    def __call__(self, t, cloud):
        self.times.append(t)

        ensembles = cloud.a.size / self._constants.cells
        get = self._env.fromDevice
        reduce = self._reduce
        creduce = self._creduce
        dV = self._constants.dV

        i = self._stats._getInteraction(cloud.a, cloud.b)
        n1 = self._stats.getDensity(cloud.a)
        n2 = self._stats.getDensity(cloud.b)

        self.i.append(get(creduce(i, ensembles)) * dV)
        self.n1.append(get(reduce(n1, ensembles)) * dV)
        self.n2.append(get(reduce(n2, ensembles)) * dV)

    def getData(self):
        return numpy.array(self.times), self.i, self.n1, self.n2
Ejemplo n.º 3
0
    def __init__(self, env, constants):
        self._env = env
        self._constants = constants
        self._stats = ParticleStatistics(env, constants)
        self._reduce = createReduce(env, constants.scalar.dtype)
        self._creduce = createReduce(env, constants.complex.dtype)

        self.times = []
        self.n1 = []
        self.n2 = []
        self.i = []
Ejemplo n.º 4
0
def testRephasing(gpu):

    m = Model(N=44000, detuning=-41, nvx=8, nvy=8, nvz=64, ensembles=1, e_cut=1e6, dt_evo=1e-5)
    t_max = 0.5
    t_step = 0.05

    constants = Constants(m, double=False if gpu else True)
    env = envs.cuda() if gpu else envs.cpu()
    evolution = SplitStepEvolution(env, constants)
    pulse = Pulse(env, constants)
    stats = ParticleStatistics(env, constants)

    gs = GPEGroundState(env, constants)

    times = [0.0]
    vis = [1.0]

    cloud = gs.createCloud()
    # cloud.toWigner()

    pulse.apply(cloud, 0.5 * math.pi, matrix=True)

    t = t_step
    while t <= t_max:
        evolution.run(cloud, t_step / 2, noise=False)
        print "Pre-pi step finished, t=" + str(cloud.time)
        new_cloud = cloud.copy()
        pulse.apply(new_cloud, math.pi, matrix=True)
        evolution.run(new_cloud, t / 2, noise=False)
        print "Post-pi step finished"

        times.append(t)
        vis.append(stats.getVisibility(new_cloud.a, new_cloud.b))
        print "Visibility=" + str(vis[-1])

        del new_cloud
        t += t_step

    times = numpy.array(times)
    vis = numpy.array(vis)
    XYPlot([XYData("test", times, vis, ymin=0, ymax=1, xname="Time, s", yname="Visibility")]).save(
        "rephasing_" + str(env) + ".pdf"
    )

    env.release()
Ejemplo n.º 5
0
	def __init__(self, env, constants):
		self._env = env
		self._constants = constants
		self._stats = ParticleStatistics(env, constants)
		self._reduce = createReduce(env, constants.scalar.dtype)
		self._creduce = createReduce(env, constants.complex.dtype)

		self.times = []
		self.n1 = []
		self.n2 = []
		self.i = []
Ejemplo n.º 6
0
def testRephasing(wigner):

	if wigner:
		nvx = nvy = 8
		nvz = 64
		dt_evo = 4e-5
	else:
		nvx = nvy = 16
		nvz = 128
		dt_evo = 1e-5

	m = Model(N=55000, detuning=-37,
		nvx=nvx, nvy=nvy, nvz=nvz, dt_evo=dt_evo, ensembles=64, e_cut=1e6,
		fx=97.0, fy=97.0 * 1.03, fz=11.69,
		gamma12=1.53e-20, gamma22=7.7e-20,
		a12=97.99, a22=95.57)

	t_max = 8.0
	t_step = 0.05

	constants = Constants(m, double=True)
	env = envs.cuda(device_num=0)
	evolution = SplitStepEvolution(env, constants)
	pulse = Pulse(env, constants)

	stats = ParticleStatistics(env, constants)
	unc = Uncertainty(env, constants)

	gs = GPEGroundState(env, constants)

	times = [0.0]
	vis = [1.0]
	phnoise = []
	phis = []
	ypss = []

	cloud = gs.createCloud()
	if wigner:
		cloud.toWigner()

		phnoise.append(stats.getPhaseNoise(cloud.a, cloud.b))
		phi, yps = unc.getSpins(cloud.a, cloud.b)
		phis.append(phi)
		ypss.append(yps)

	pulse.apply(cloud, 0.5 * math.pi, matrix=True)

	if wigner:
		name = 'rephasing_wigner'
	else:
		name = 'rephasing_gpe'

	t = t_step
	while t <= t_max:
		evolution.run(cloud, t_step / 2, noise=wigner)
		print "Pre-pi step finished, t=" + str(cloud.time)
		new_cloud = cloud.copy()
		pulse.apply(new_cloud, math.pi, matrix=True)
		evolution.run(new_cloud, t / 2, noise=wigner)
		print "Post-pi step finished"

		times.append(t)
		vis.append(stats.getVisibility(new_cloud.a, new_cloud.b))
		print "Visibility=" + str(vis[-1])

		if wigner:
			phnoise.append(stats.getPhaseNoise(new_cloud.a, new_cloud.b))
			phi, yps = unc.getSpins(new_cloud.a, new_cloud.b)
			phis.append(phi)
			ypss.append(yps)

		XYData(name, numpy.array(times), numpy.array(vis),
			ymin=0, ymax=1, xname="T, s", yname="$\\mathcal{V}$").save(name + '_vis.json')

		if wigner:
			XYData(name, numpy.array(times), numpy.array(phnoise), ymin=0,
				xname="T, s", yname="Phase noise, rad").save(name + '_phnoise.json')

			Data('spins',
				['name', 'phi', 'yps', 'time', 'timename', 'phiname', 'ypsname'],
				time=numpy.array(times), phi=numpy.array(phis), yps=numpy.array(ypss), timename="T (s)",
				phiname="Spin, azimuth, rad", ypsname="Spin, inclination, rad",
				name=name).save(name + "_phnoise_points.pickle")

		XYPlot([XYData.load(name + '_vis.json')]).save(name + '_vis.pdf')

		del new_cloud
		t += t_step

	env.release()
Ejemplo n.º 7
0
def testRephasing(wigner):

    if wigner:
        nvx = nvy = 8
        nvz = 64
        dt_evo = 4e-5
    else:
        nvx = nvy = 16
        nvz = 128
        dt_evo = 1e-5

    m = Model(N=55000,
              detuning=-37,
              nvx=nvx,
              nvy=nvy,
              nvz=nvz,
              dt_evo=dt_evo,
              ensembles=64,
              e_cut=1e6,
              fx=97.0,
              fy=97.0 * 1.03,
              fz=11.69,
              gamma12=1.53e-20,
              gamma22=7.7e-20,
              a12=97.99,
              a22=95.57)

    t_max = 8.0
    t_step = 0.05

    constants = Constants(m, double=True)
    env = envs.cuda(device_num=0)
    evolution = SplitStepEvolution(env, constants)
    pulse = Pulse(env, constants)

    stats = ParticleStatistics(env, constants)
    unc = Uncertainty(env, constants)

    gs = GPEGroundState(env, constants)

    times = [0.0]
    vis = [1.0]
    phnoise = []
    phis = []
    ypss = []

    cloud = gs.createCloud()
    if wigner:
        cloud.toWigner()

        phnoise.append(stats.getPhaseNoise(cloud.a, cloud.b))
        phi, yps = unc.getSpins(cloud.a, cloud.b)
        phis.append(phi)
        ypss.append(yps)

    pulse.apply(cloud, 0.5 * math.pi, matrix=True)

    if wigner:
        name = 'rephasing_wigner'
    else:
        name = 'rephasing_gpe'

    t = t_step
    while t <= t_max:
        evolution.run(cloud, t_step / 2, noise=wigner)
        print "Pre-pi step finished, t=" + str(cloud.time)
        new_cloud = cloud.copy()
        pulse.apply(new_cloud, math.pi, matrix=True)
        evolution.run(new_cloud, t / 2, noise=wigner)
        print "Post-pi step finished"

        times.append(t)
        vis.append(stats.getVisibility(new_cloud.a, new_cloud.b))
        print "Visibility=" + str(vis[-1])

        if wigner:
            phnoise.append(stats.getPhaseNoise(new_cloud.a, new_cloud.b))
            phi, yps = unc.getSpins(new_cloud.a, new_cloud.b)
            phis.append(phi)
            ypss.append(yps)

        XYData(name,
               numpy.array(times),
               numpy.array(vis),
               ymin=0,
               ymax=1,
               xname="T, s",
               yname="$\\mathcal{V}$").save(name + '_vis.json')

        if wigner:
            XYData(name,
                   numpy.array(times),
                   numpy.array(phnoise),
                   ymin=0,
                   xname="T, s",
                   yname="Phase noise, rad").save(name + '_phnoise.json')

            Data('spins', [
                'name', 'phi', 'yps', 'time', 'timename', 'phiname', 'ypsname'
            ],
                 time=numpy.array(times),
                 phi=numpy.array(phis),
                 yps=numpy.array(ypss),
                 timename="T (s)",
                 phiname="Spin, azimuth, rad",
                 ypsname="Spin, inclination, rad",
                 name=name).save(name + "_phnoise_points.pickle")

        XYPlot([XYData.load(name + '_vis.json')]).save(name + '_vis.pdf')

        del new_cloud
        t += t_step

    env.release()