예제 #1
0
from yeecuda import YeeCuda

# Macros
indexed = lambda l, offset=0: zip(np.arange(len(l)) + offset, l)


def gauss(fdtd):
    width = (2 * np.power(fdtd.tal, 2))
    func = lambda t: np.exp(-np.power(t - 2 * fdtd.t0, 2) / width)
    for k, t in indexed(fdtd.td):
        fdtd.Ez[k, :, 2] = func(t)


#sim = YeeCuda('./caixa.png', verbose=False)
sim = YeeCuda([200, 200], verbose=False)
cpu = []
omp = []
gpu = []
iters = 800
print "Starting benchmark with %d iterations." % iters
for s in range(5):
    sim.setFreq(2.4E9)
    sim.bound['Ez'][:, 2] = 0
    sim.bound['Ez'][1, :] = 2
    sim.bound['Ez'][:, 1] = 2
    sim.bound['Ez'][-1, :] = 2
    sim.bound['Ez'][:, -1] = 2
    t = sim.run(gauss, t=iters, proc="CPU")
    cpu.append(t)
    sim.setFreq(2.4E9)
예제 #2
0
파일: bench.py 프로젝트: kewitz/YeeCUDA
import matplotlib.pyplot as plt
import matplotlib.animation as animation

from yeecuda import YeeCuda

# Macros
indexed = lambda l, offset=0: zip(np.arange(len(l))+offset,l)

def gauss(fdtd):
	width = (2*np.power(fdtd.tal,2))
	func = lambda t: np.exp(-np.power(t-2*fdtd.t0,2) / width)
	for k,t in indexed(fdtd.td):
		fdtd.Ez[k,:,2] = func(t)

#sim = YeeCuda('./caixa.png', verbose=False)
sim = YeeCuda([200,200], verbose=False)
cpu = []
omp = []
gpu = []
iters = 800
print "Starting benchmark with %d iterations." % iters
for s in range(5):
    sim.setFreq(2.4E9)
    sim.bound['Ez'][:,2] = 0
    sim.bound['Ez'][1,:] = 2
    sim.bound['Ez'][:,1] = 2
    sim.bound['Ez'][-1,:] = 2
    sim.bound['Ez'][:,-1] = 2
    t = sim.run(gauss,t=iters,proc="CPU")
    cpu.append(t)
    sim.setFreq(2.4E9)
예제 #3
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

from yeecuda import YeeCuda

# Macros
indexed = lambda l, offset=0: zip(np.arange(len(l))+offset,l)

def gauss(fdtd):
	width = (2*np.power(fdtd.tal,2))
	func = lambda t: np.exp(-np.power(t-2*fdtd.t0,2) / width)
	for k,t in indexed(fdtd.td):
		fdtd.Ez[k,:,2] = func(t)

sim = YeeCuda('./caixa.png', verbose=False)
sim.setFreq(2.4E9)
sim.bound['Ez'][:,2] = 0
sim.bound['Ez'][1,:] = 2
sim.bound['Ez'][:,1] = 2
sim.bound['Ez'][-1,:] = 2
sim.bound['Ez'][:,-1] = 2
t = sim.run(gauss,t=800,proc="GPU")

#%%Plot
def anim1D(vector, time=None):
	time = np.arange(len(vector[:,0])) if time is None else time
	fig, ax = plt.subplots()
	line, = ax.plot(vector[0,:])
	plt.ylim(vector.min(),vector.max())
	plt.grid()