def KLE1D(a=1, c=1, k=10): from kle import KLE mesh = UnitInterval(1000) mesh.coordinates()[:] = 2. * a * mesh.coordinates()[:] - a def kernel(R): return np.exp(-c * R) kle = KLE(mesh, kernel) from time import time start = time() la, va = kle.compute_eigendecomposition(k=k) la = la[::-1] va = va[:, ::-1] print "Time for arpack %g " % (time() - start) return la, va
def KLE1D(a = 1, c = 1, k = 10): from kle import KLE mesh = UnitInterval(1000) mesh.coordinates()[:] = 2.*a*mesh.coordinates()[:] - a def kernel(R): return np.exp(-c*R) kle = KLE(mesh,kernel) from time import time start = time() la, va = kle.compute_eigendecomposition(k = k) la = la[::-1] va = va[:,::-1] print "Time for arpack %g " %(time()-start) return la, va
fig.colorbar(im, cax = cbar_ax) plt.savefig('figs/square.png') plt.show() return if __name__ == '__main__': from dolfin import * mesh = UnitSquare(20,20) #really a 101 x 101 grid mesh.coordinates()[:] = 2.*mesh.coordinates()-1. print mesh.coordinates() kernel = Matern(p = 0, l = 1.) #Exponential covariance kernel kle = KLE(mesh, kernel, verbose = True) kle.compute_eigendecomposition(k = 20) print kle.l import matplotlib.pyplot as plt plt.close('all') ploteigenvectors(kle)
fig.suptitle('Eigenvectors of KLE', fontsize=20) fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7]) fig.colorbar(im, cax=cbar_ax) plt.savefig('figs/square.png') plt.show() return if __name__ == '__main__': from dolfin import * mesh = UnitSquare(20, 20) #really a 101 x 101 grid mesh.coordinates()[:] = 2. * mesh.coordinates() - 1. kernel = Matern(p=0, l=1.) #Exponential covariance kernel kle = KLE(mesh, kernel, verbose=True) kle.compute_eigendecomposition(k=20) print kle.l import matplotlib.pyplot as plt plt.close('all') #ploteigenvectors(kle) #Generate realizations real = kle.realizations()
# Generate samples by quasi-random samples qmc_scheme = "H" nnodes = 2*len(Polynomials) nodes = joint_KL.sample(nnodes, qmc_scheme) # Regression method in Point Collocation rgm_rule ="T" #Orthogonal Matching Pursuit#"LS" # Random Field p , l = np.inf, 1 k = nkl kernel = Matern(p = p,l = l) #0,1Exponential covariance kernel kle = KLE(model.mesh, kernel, verbose = True) kle.compute_eigendecomposition(k = k)#20 by default #real = kle.realizations(epsilon) # range of pressure pi = 0.0 pf = 0.03 dp = 0.01 pressures = np.arange(pi, pf+dp, dp) print "---------------------------------" print "PCE-Random Field" print "Nkl terms:", int(nkl) print "Order:", order print "Sampling Method:", qmc_scheme print "Number of nodes:", nnodes print "Regression method:", rgm_rule