コード例 #1
0
ファイル: doPlots.py プロジェクト: danielct/Honours
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()
コード例 #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()
コード例 #3
0
ファイル: Ring.py プロジェクト: danielct/Honours
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)
コード例 #4
0
ファイル: Ring.py プロジェクト: danielct/Honours
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)