コード例 #1
0
ファイル: tests.py プロジェクト: anthony-walker/pysweep-git
 def testConfigurations(arraysize=120, timesteps=200, runTest=True):
     shares = [
         1,
     ]  #Shares for GPU
     sims = [
         True,
     ]  #different simulations
     blocksizes = [
         24,
     ]  #blocksizes with most options
     #Create solver object
     solver = pysweep.Solver(sendWarning=False)
     solver.dtypeStr = 'float64'
     solver.dtype = numpy.dtype(solver.dtypeStr)
     solver.verbose = True
     for sim in sims:
         for bs in blocksizes:
             for sh in shares:
                 solver.moments = [
                     time.time(),
                 ]
                 solver.share = sh
                 solver.simulation = sim
                 solver.blocksize = (bs, bs, 1)
                 func(solver,
                      arraysize,
                      timesteps=timesteps,
                      runTest=runTest)
コード例 #2
0
ファイル: tests.py プロジェクト: anthony-walker/pysweep-git
def testVerifyOrderForwardEulerHeat(fname="forwardEuler", printError=True):
    """Use this function to test the order of convergence."""
    sizes = [int(32 * i) for i in range(1, 5, 1)]
    #Create solver object
    solver = pysweep.Solver(sendWarning=False)
    solver.simulation = False
    solver.dtypeStr = 'float64'
    solver.dtype = numpy.dtype(solver.dtypeStr)
    solver.verbose = False
    filename = "heatConditions.hdf5"
    d = 0.1
    solver.globals = [0, 0.1, None, None, None, 1, True]
    solver.share = 0
    solver.blocksize = (16, 16, 1)
    error = []
    dts = []
    for arraysize in sizes:
        dx = dy = 1 / arraysize
        dt = float(d * dx * dx)
        dts.append(dt)
        solver.globals[2:5] = dt, dx, dy
        filename = pysweep.equations.heat.createInitialConditions(
            arraysize, arraysize, alpha=solver.globals[-2])
        solver = setupSolver(solver, filename, "heat.py", "heat.cu", 1, 1)
        solver()
        #Determining error
        if solver.clusterMasterBool:
            print(arraysize, solver.timeSteps)
            with h5py.File(solver.output, "r") as f:
                data = f["data"]
                T, x, y = pysweep.equations.heat.analytical(
                    arraysize,
                    arraysize,
                    t=dt * solver.timeSteps,
                    alpha=solver.globals[-2])
                error.append(numpy.amax(numpy.absolute(data[-1, 0] - T[0])))
    if solver.clusterMasterBool:
        pltname = fname + "SweptOrder" if solver.simulation else fname + "StandardOrder"
        if solver.share == 1:
            pltname += "G.pdf"
        elif solver.share == 0:
            pltname += "C.pdf"
        else:
            pltname += "H.pdf"
        plt.loglog(dts, error, marker='o')
        plt.title("Forward Euler Order Verification")
        plt.xlabel("dt")
        plt.ylabel("error")
        plt.savefig(pltname)
コード例 #3
0
def runHeat(args):
    """Use this function to run Heat example."""
    if args.ignore:
        warnings.filterwarnings('ignore') #Ignore warnings for processes
    adjustArraySize(args)
    #step stuff
    d = 0.1
    alpha = 1
    dx = 1/(args.spacesteps-1)
    dt = float(d*dx**2/alpha)
    #Make ics if needed
    filename = "heatConditions{}.hdf5".format(args.spacesteps)
    if not os.path.isfile(filename):
        pysweep.equations.heat.createInitialConditions(args.spacesteps,args.spacesteps,filename=filename,alpha=alpha)
    simwarn = False if args.ignore else True
    solver = pysweep.Solver(initialConditions=filename,sendWarning=simwarn)
    #Setting globals
    solver.globals = [0,dt*args.timesteps,dt,dx,dx,alpha,True]
    solver.dtypeStr = 'float64'
    solver.dtype = numpy.dtype(solver.dtypeStr)
    solver.verbose = False 
    solver.operating = 1
    solver.intermediate = 1
    solver.share = args.share
    solver.simulation = True if args.swept else False
    solver.blocksize = (args.blocksize,args.blocksize,1)
    solver.setCPU(getEqnPath("heat.py"))
    solver.setGPU(getEqnPath("heat.cu"))
    solver.exid = []
    solver.output = "heatOutput.hdf5"
    solver.loadCPUModule()
    if args.verbose:
        if solver.rank==0:
            #os.system('nvidia-smi --list-gpus')
            print(solver)
    solver()
    #Clean up 
    if args.clean:
        if solver.rank == 0:
            try:
                # os.system("rm {}".format(filename))
                os.system("rm {}".format(solver.output))
            except Exception as e:
                pass
コード例 #4
0
ファイル: tests.py プロジェクト: anthony-walker/pysweep-git
 def testConfigurations():
     arraysize = 384
     shares = [0, 0.5, 1]  #Shares for GPU
     sims = [True, False]  #different simulations
     blocksizes = [8, 12, 16, 24]  #blocksizes with most options
     #Create solver object
     solver = pysweep.Solver(sendWarning=False)
     solver.dtypeStr = 'float64'
     solver.dtype = numpy.dtype(solver.dtypeStr)
     solver.verbose = False
     for sim in sims:
         for bs in blocksizes:
             for sh in shares:
                 solver.moments = [
                     time.time(),
                 ]
                 solver.share = sh
                 solver.simulation = sim
                 solver.blocksize = (bs, bs, 1)
                 func(solver, arraysize)
コード例 #5
0
ファイル: tests.py プロジェクト: anthony-walker/pysweep-git
 def testConfigurations():
     numSizes = 5
     shares = [0, 0.625, 1]  #Shares for GPU
     sims = [True, False]  #different simulations
     blocksizes = [8, 12, 16, 24, 32]  #blocksizes with most options
     sizes = [int(768 * i)
              for i in range(1, 6, 1)]  #Performance array sizes
     #Create solver object
     solver = pysweep.Solver(sendWarning=False)
     solver.dtypeStr = 'float64'
     solver.dtype = numpy.dtype(solver.dtypeStr)
     solver.verbose = False
     for arraysize in sizes:
         for sim in sims:
             for bs in blocksizes:
                 for sh in shares:
                     solver.moments = [
                         time.time(),
                     ]
                     solver.share = sh
                     solver.simulation = sim
                     solver.blocksize = (bs, bs, 1)
                     func(solver, arraysize)