Example #1
0
#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)
    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="OMP")
    omp.append(t)
    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
Example #2
0
#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)
    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="OMP")
    omp.append(t)
    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
Example #3
0
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()

	def animate(s):
		line.set_ydata(vector[s,:])
		return line,
	
	ani = animation.FuncAnimation(fig, animate, time, interval=20)
	plt.show()