コード例 #1
0
 def setBCFunc(self, func):
     """Sets the BC given a function of two variables."""
     xmin, ymin = self.xmin, self.ymin
     xmax, ymax = self.xmax, self.ymax
     x = numpy.arange(xmin, xmax + self.dx*0.5, self.dx)
     y = numpy.arange(ymin, ymax + self.dy*0.5, self.dy)
     self.u[0 ,:] = func(xmin,y)
     self.u[-1,:] = func(xmax,y)
     self.u[:, 0] = func(x,ymin)
     self.u[:,-1] = func(x,ymax)
コード例 #2
0
ファイル: laplace.py プロジェクト: dmlb2000/nwchem-cml
 def setBCFunc(self, func):
     """Sets the BC given a function of two variables."""
     xmin, ymin = self.xmin, self.ymin
     xmax, ymax = self.xmax, self.ymax
     x = numpy.arange(xmin, xmax + self.dx * 0.5, self.dx)
     y = numpy.arange(ymin, ymax + self.dy * 0.5, self.dy)
     self.u[0, :] = func(xmin, y)
     self.u[-1, :] = func(xmax, y)
     self.u[:, 0] = func(x, ymin)
     self.u[:, -1] = func(x, ymax)
コード例 #3
0
def test(nmin=5, nmax=30, dn=5, eps=1.0e-16, n_iter=0, stepper='numeric'):
    iters = []
    n_grd = numpy.arange(nmin, nmax, dn)
    times = []
    for i in n_grd:
        g = Grid(nx=i, ny=i)
        g.setBCFunc(BC)
        s = LaplaceSolver(g, stepper)
        t1 = timer()
        iters.append(s.solve(n_iter=n_iter, eps=eps))
        dt = timer() - t1
        times.append(dt)
        print "Solution for nx = ny = %d, took %f seconds"%(i, dt)
    return (n_grd**2, iters, times)
コード例 #4
0
ファイル: laplace.py プロジェクト: dmlb2000/nwchem-cml
def test(nmin=5, nmax=30, dn=5, eps=1.0e-16, n_iter=0, stepper='numeric'):
    iters = []
    n_grd = numpy.arange(nmin, nmax, dn)
    times = []
    for i in n_grd:
        g = Grid(nx=i, ny=i)
        g.setBCFunc(BC)
        s = LaplaceSolver(g, stepper)
        t1 = timer()
        iters.append(s.solve(n_iter=n_iter, eps=eps))
        dt = timer() - t1
        times.append(dt)
        print "Solution for nx = ny = %d, took %f seconds" % (i, dt)
    return (n_grd**2, iters, times)