Exemplo n.º 1
0
def loadAndPlotSolver(f):
    """
    Load a solver from file f and produce the diagnostic plot

    Parameters:
        f: h5py.File instance
    Returns:
    """
    solver = loadGPESolver(f)
    P = f.attrs["P"]
    pl = diagnosticPlot(solver)
    fname = path.join(PATH_TO_FILES, FILE_NAME
                    + getPlotName(solver.paramContainer.getOutputParams(), P=P)
                    + ".png")
    pl.savefig(fname, dpi=500)
    plt.close(pl)
    plt.close()
Exemplo n.º 2
0
def loadAndPlotSolver(f):
    """
    Load a solver from file f and produce the diagnostic plot

    Parameters:
        f: h5py.File instance
    Returns:
    """
    solver = loadGPESolver(f)
    P = f.attrs["P"]
    pl = diagnosticPlot(solver)
    fname = path.join(
        PATH_TO_FILES, FILE_NAME +
        getPlotName(solver.paramContainer.getOutputParams(), P=P) + ".png")
    pl.savefig(fname, dpi=500)
    plt.close(pl)
    plt.close()
Exemplo n.º 3
0
def runIt(g_C, R, width, rMiddle, P):
    """
    Do a simulation, plot and save a diagnostic plot.
    """
    # if rMiddle <= 10 * ureg.micrometer.to_base_units().magnitude:
    #     N = 512
    # else:
    #     N = 1024
    ringParams = Simulator.ParameterContainer(g_C=g_C, g_R=2.0*g_C,
                                              gamma_C=gamma_C,
                                              gamma_R=a*gamma_C, R=R, m=m,
                                              charL=charL, charT=charT)

    # ringParams = Simulator.ParameterContainer(g_C=g_C, g_R=2.0*g_C,
    #                                           gamma_C=gamma_C,
    #                                           gamma_R=a*gamma_C, R=R, m=m)
    params = ringParams.getGPEParams()
    # params['charT'] = ringParams.charT
    P0 = P * params['Pth']
    # Make Grid
    # grid = Simulator.Grid(ringParams.charL, max_XY=max_XY_unscaled, N=N)
    # grid = Simulator.Grid(ringParams.charL, max_XY=3.0 * (rMiddle + width), N=N)
    grid = Simulator.Grid(ringParams.charL, max_XY=2.0 * (rMiddle + width), N=N)
    sigma = grid.toPixels(diffusionLength)
    x, y = grid.getSpatialGrid()
    x_us, y_us = grid.getSpatialGrid(scaled=False)
    pump = UtilityFunctions.AnnularPumpFlat(rMiddle, width, P, params['Pth'],
                                            sigma=sigma)
    # pump = UtilityFunctions.AnnularPumpGaussian(rMiddle, P, params['Pth'],
    #                                         sigma=width)

    # pump = UtilityFunctions.GaussianPump(rMiddle, P, params['Pth'])
    pumpFunction = pump.scaledFunction(ringParams.charL)
    P0 = np.max(pumpFunction(x, y))
    stabParam = (P0 / params['Pth']) / ((params['g_R'] * params['gamma_C'])
                                        / (params['g_C'] *
                                           params['gamma_R']))
    # Gaussian in the middle of the trap
    psi0 = UtilityFunctions.GaussianPump(0.2*rMiddle,
                                         0.01, 1, exponent=1.1).\
        scaledFunction(ringParams.charL)
    # psi0 = lambda x, y: 0.01 * pumpFunction(x, y) / P0
    print("Stability parameter %f (should be > 1)" % stabParam)
    dx = grid.dx_scaled
    print("Numerical Stability Parameter %f (should be < 1)" %
          ((np.pi * dt) / dx**2))
    print("P = %f" % P)
    print("Pth = %f" % params['Pth'])
    print("P0 = %f" % P0)
    print("P0/Pth = %f" % (P0 / params['Pth']))

    solver = Simulator.GPESolver(params, dt, grid.getSpatialGrid(),
                                 grid.getKSquaredGrid(), pumpFunction,
                                 psiInitial=psi0, gpu=True)
    energyTimes, energy = solver.stepTo(T_MAX, stepsPerObservation=100)
    # solver.stepTo(T_MAX, stepsPerObservation=1000)

    f = diagnosticPlot(1e6 * x_us, 1e6 * y_us, solver, energyTimes, energy,
                       pump.scaledFunction(charL=1e-6))
    f.savefig("Snoke" + getPlotName(params, r=rMiddle, m=m, sigma=diffusionLength) +
              ".png", dpi=800)
    # f.savefig("testNew" + ".png", dpi=800)
    plt.close(f)
Exemplo n.º 4
0
def runIt(g_C, R, gamma_C, a, width, diffusionLength, rMiddle, P):
    """
    Do a simulation, plot and save a diagnostic plot.
    """
    if singleComp:
        ringParams = Simulator.ParameterContainer(g_C=g_C,
                                                  g_R=2.0 * g_C,
                                                  gamma_nl=gamma_nl,
                                                  gamma_C=gamma_C,
                                                  gamma_R=a * gamma_C,
                                                  R=R,
                                                  m=m,
                                                  charL=charL,
                                                  charT=charT)
    else:
        ringParams = Simulator.ParameterContainer(g_C=g_C,
                                                  g_R=2.0 * g_C,
                                                  gamma_C=gamma_C,
                                                  gamma_R=a * gamma_C,
                                                  R=R,
                                                  m=m,
                                                  charL=charL,
                                                  charT=charT)
    params = ringParams.getGPEParams()
    print params
    Pth = params["Pth"]
    # --- Grid, associated quantities ---
    grid = Simulator.Grid(ringParams.charL, max_XY=max_XY_unscaled, N=N)
    sigma = grid.toPixels(diffusionLength)
    x, y = grid.getSpatialGrid()
    x_us, y_us = grid.getSpatialGrid(scaled=False)
    dx = grid.dx_scaled
    # Time to record spectrum to. This will ensure that we have a resolution of
    # at least 0.01 meV
    spectMax = int(5e-6 / grid.dx_unscaled)
    # Mask for collection of spectrum and energy. This will ensure that we only
    # collect from the center of the ring
    mask = x_us**2 + y_us**2 > (5e-6)**2

    # --- Initial wavefunction ---
    # Gaussian in the middle of the trap
    psi0 = UtilityFunctions.GaussianPump(0.2*rMiddle,
                                         0.1, 1, exponent=1.1).\
        scaledFunction(ringParams.charL)

    pump = UtilityFunctions.AnnularPumpFlat(rMiddle,
                                            width,
                                            P,
                                            Pth,
                                            sigma=sigma)
    # Since we used Pth from params, the pump will be in units of
    # L_C^-2 * T_C^-1
    pumpFunction = pump.scaledFunction(ringParams.charL)

    # P0 = np.max(pumpFunction(x, y))
    # print P0
    # stabParam = (P0 / params['Pth']) / ((params['g_R'] * params['gamma_C'])
    #                                     / (params['g_C'] *
    #                                        params['gamma_R']))
    # print("Stability parameter %f (should be > 1)" % stabParam)
    numStabParam = (np.pi * dt) / dx**2

    if numStabParam >= 0.8:
        print(
            "Warning, numerical stability parameter is %.4f \n Should be <1 " %
            numStabParam)
    print("Numerical Stability Parameter %f (should be < 1)" %
          ((np.pi * dt) / dx**2))

    solver = Simulator.GPESolver(ringParams,
                                 dt,
                                 grid,
                                 pumpFunction=pumpFunction,
                                 psiInitial=psi0,
                                 REAL_DTYPE=np.float64,
                                 COMPLEX_DTYPE=np.complex128)
    solver.stepTo(T_MAX,
                  stepsPerObservation=1000,
                  spectStart=T_STABLE,
                  normalized=False,
                  spectLength=spectLength,
                  printTime=False,
                  collectionMask=mask,
                  spectMax=spectMax)
    f = diagnosticPlot(solver)
    f.savefig("PScanSingle " + getPlotName(ringParams, P=P) + ".png", dpi=500)
    # f.savefig("testPlot" + ".png", dpi=600)
    # solver.save("testPlot", P=P)
    solver.save("PScanSingle " +
                getPlotName(ringParams.getOutputParams(), P=P),
                P=P)
    plt.close(f)
Exemplo n.º 5
0
x_us, y_us = grid.getSpatialGrid(scaled=False)
solver = Simulator.GPESolver(
    params,
    dt,
    grid.getSpatialGrid(),
    grid.getKSquaredGrid(),
    pumpFunction,
    psiInitial=(lambda x, y: 0.1 * pumpFunction(x, y) / P0),
    N_THREADS=5,
    gpu=False)

# solver = SimulatorOld.GPESolver(grid.getSpatialGrid(), grid.getkGrid(),
#                              N_THREADS=4)
P0 = np.max(pumpFunction(x, y))
stabParam = (P0 / params['Pth']) / ((params['g_R'] * params['gamma_C']) /
                                    (params['g_C'] * params['gamma_R']))
print("Stability parameter %f" % stabParam)
# energyTimes, energy = solver.stepTo(T_MAX, stepsPerObservation=1e3)
solver.stepTo(T_MAX)
energyTimes = np.array([])
energy = energyTimes
# solver.solve(params, pumpFunction,
#              psi0Function=lambda x, y: 0.1 * pumpFunction(x, y) / P0, dt=dt,
#              T_MAX=T_MAX, method='split-step')
#
f = diagnosticPlot(1e6 * x_us, 1e6 * y_us, solver, energyTimes, energy,
                   pump.scaledFunction(charL=1e-6))
# f = diagnosticPlot(1e6 * x_us, 1e6 * y_us, solver, solver.energyTimes,
#                    solver.energy, pump.scaledFunction(charL=1e-6))
f.show()
Exemplo n.º 6
0
def runIt(g_C, R, gamma_C, a, width, diffusionLength, rMiddle, P):
    """
    Do a simulation, plot and save a diagnostic plot.
    """
    if singleComp:
        ringParams = Simulator.ParameterContainer(
            g_C=g_C,
            g_R=2.0 * g_C,
            gamma_nl=gamma_nl,
            gamma_C=gamma_C,
            gamma_R=a * gamma_C,
            R=R,
            m=m,
            charL=charL,
            charT=charT,
        )
    else:
        ringParams = Simulator.ParameterContainer(
            g_C=g_C, g_R=2.0 * g_C, gamma_C=gamma_C, gamma_R=a * gamma_C, R=R, m=m, charL=charL, charT=charT
        )
    params = ringParams.getGPEParams()
    print params
    Pth = params["Pth"]
    # --- Grid, associated quantities ---
    grid = Simulator.Grid(ringParams.charL, max_XY=max_XY_unscaled, N=N)
    sigma = grid.toPixels(diffusionLength)
    x, y = grid.getSpatialGrid()
    x_us, y_us = grid.getSpatialGrid(scaled=False)
    dx = grid.dx_scaled
    # Time to record spectrum to. This will ensure that we have a resolution of
    # at least 0.01 meV
    spectMax = int(5e-6 / grid.dx_unscaled)
    # Mask for collection of spectrum and energy. This will ensure that we only
    # collect from the center of the ring
    mask = x_us ** 2 + y_us ** 2 > (5e-6) ** 2

    # --- Initial wavefunction ---
    # Gaussian in the middle of the trap
    psi0 = UtilityFunctions.GaussianPump(0.2 * rMiddle, 0.1, 1, exponent=1.1).scaledFunction(ringParams.charL)

    pump = UtilityFunctions.AnnularPumpFlat(rMiddle, width, P, Pth, sigma=sigma)
    # Since we used Pth from params, the pump will be in units of
    # L_C^-2 * T_C^-1
    pumpFunction = pump.scaledFunction(ringParams.charL)

    # P0 = np.max(pumpFunction(x, y))
    # print P0
    # stabParam = (P0 / params['Pth']) / ((params['g_R'] * params['gamma_C'])
    #                                     / (params['g_C'] *
    #                                        params['gamma_R']))
    # print("Stability parameter %f (should be > 1)" % stabParam)
    numStabParam = (np.pi * dt) / dx ** 2

    if numStabParam >= 0.8:
        print ("Warning, numerical stability parameter is %.4f \n Should be <1 " % numStabParam)
    print ("Numerical Stability Parameter %f (should be < 1)" % ((np.pi * dt) / dx ** 2))

    solver = Simulator.GPESolver(
        ringParams,
        dt,
        grid,
        pumpFunction=pumpFunction,
        psiInitial=psi0,
        REAL_DTYPE=np.float64,
        COMPLEX_DTYPE=np.complex128,
    )
    solver.stepTo(
        T_MAX,
        stepsPerObservation=1000,
        spectStart=T_STABLE,
        normalized=False,
        spectLength=spectLength,
        printTime=False,
        collectionMask=mask,
        spectMax=spectMax,
    )
    f = diagnosticPlot(solver)
    f.savefig("PScanSingle " + getPlotName(ringParams, P=P) + ".png", dpi=500)
    # f.savefig("testPlot" + ".png", dpi=600)
    # solver.save("testPlot", P=P)
    solver.save("PScanSingle " + getPlotName(ringParams.getOutputParams(), P=P), P=P)
    plt.close(f)
Exemplo n.º 7
0
def runIt(g_C, R, width, rMiddle, P):
    """
    Do a simulation, plot and save a diagnostic plot.
    """
    # if rMiddle <= 10 * ureg.micrometer.to_base_units().magnitude:
    #     N = 512
    # else:
    #     N = 1024
    ringParams = Simulator.ParameterContainer(g_C=g_C,
                                              g_R=2.0 * g_C,
                                              gamma_C=gamma_C,
                                              gamma_R=a * gamma_C,
                                              R=R,
                                              m=m,
                                              charL=charL,
                                              charT=charT)

    # ringParams = Simulator.ParameterContainer(g_C=g_C, g_R=2.0*g_C,
    #                                           gamma_C=gamma_C,
    #                                           gamma_R=a*gamma_C, R=R, m=m)
    params = ringParams.getGPEParams()
    # params['charT'] = ringParams.charT
    P0 = P * params['Pth']
    # Make Grid
    # grid = Simulator.Grid(ringParams.charL, max_XY=max_XY_unscaled, N=N)
    # grid = Simulator.Grid(ringParams.charL, max_XY=3.0 * (rMiddle + width), N=N)
    grid = Simulator.Grid(ringParams.charL,
                          max_XY=2.0 * (rMiddle + width),
                          N=N)
    sigma = grid.toPixels(diffusionLength)
    x, y = grid.getSpatialGrid()
    x_us, y_us = grid.getSpatialGrid(scaled=False)
    pump = UtilityFunctions.AnnularPumpFlat(rMiddle,
                                            width,
                                            P,
                                            params['Pth'],
                                            sigma=sigma)
    # pump = UtilityFunctions.AnnularPumpGaussian(rMiddle, P, params['Pth'],
    #                                         sigma=width)

    # pump = UtilityFunctions.GaussianPump(rMiddle, P, params['Pth'])
    pumpFunction = pump.scaledFunction(ringParams.charL)
    P0 = np.max(pumpFunction(x, y))
    stabParam = (P0 / params['Pth']) / ((params['g_R'] * params['gamma_C']) /
                                        (params['g_C'] * params['gamma_R']))
    # Gaussian in the middle of the trap
    psi0 = UtilityFunctions.GaussianPump(0.2*rMiddle,
                                         0.01, 1, exponent=1.1).\
        scaledFunction(ringParams.charL)
    # psi0 = lambda x, y: 0.01 * pumpFunction(x, y) / P0
    print("Stability parameter %f (should be > 1)" % stabParam)
    dx = grid.dx_scaled
    print("Numerical Stability Parameter %f (should be < 1)" %
          ((np.pi * dt) / dx**2))
    print("P = %f" % P)
    print("Pth = %f" % params['Pth'])
    print("P0 = %f" % P0)
    print("P0/Pth = %f" % (P0 / params['Pth']))

    solver = Simulator.GPESolver(params,
                                 dt,
                                 grid.getSpatialGrid(),
                                 grid.getKSquaredGrid(),
                                 pumpFunction,
                                 psiInitial=psi0,
                                 gpu=True)
    energyTimes, energy = solver.stepTo(T_MAX, stepsPerObservation=100)
    # solver.stepTo(T_MAX, stepsPerObservation=1000)

    f = diagnosticPlot(1e6 * x_us, 1e6 * y_us, solver, energyTimes, energy,
                       pump.scaledFunction(charL=1e-6))
    f.savefig("Snoke" +
              getPlotName(params, r=rMiddle, m=m, sigma=diffusionLength) +
              ".png",
              dpi=800)
    # f.savefig("testNew" + ".png", dpi=800)
    plt.close(f)