#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as np import scipy as sp import scipy.io import matplotlib.pyplot as plt import d3s.domain as domain import d3s.kernels as kernels import d3s.algorithms as algorithms import d3s.systems as systems plt.ion() #%% Ornstein-Uhlenbeck process Omega = domain.discretization(np.array([[-2, 2]]), np.array([50])) f = systems.OrnsteinUhlenbeck(0.001, 500) X = Omega.randPerBox(100) Y = f(X) sigma = np.sqrt(0.3) epsilon = 0.1 k = kernels.gaussianKernel(sigma) evs = 4 # number of eigenfunctions to be computed # Perron-Frobenius d, V = algorithms.kedmd(X, Y, k, epsilon=epsilon, evs=evs, operator='P') for i in range(evs): plt.figure()
a = s @ s.T tra = np.trace(a) for i in range(m): for j in range(m): G_10[i, j] = -1/k.sigma**2 * (B[i, i] - B[i, j]) \ + 0.5*(1/k.sigma**4 * np.dot(X[:, i]-X[:, j], a @ (X[:, i]-X[:, j])) - 1/k.sigma**2 * tra ) G_10 = G_10 * G_00 return (G_00, G_10) #%% Ornstein-Uhlenbeck process -------------------------------------------------------------------- #%% define domain bounds = np.array([[-2, 2]]) boxes = np.array([100]) Omega = domain.discretization(bounds, boxes) #%% define system alpha = 1 beta = 4 def b(x): return -alpha * x def sigma(x): return np.sqrt(2 / beta) * np.ones((1, 1, x.shape[1])) #%% generate data
import d3s.kernels as kernels import d3s.domain as domain import d3s.ceig as ceig import d3s.antisymmetricKernels as akernels #%% two electrons in a box # define parameters h = 1 m0 = 1 L = np.pi # define domain bounds = np.array([[0, L], [0, L]]) boxes = np.array([31, 31]) Omega = domain.discretization(bounds, boxes) # generate data X, isBoundary = Omega.vertexGrid() m = Omega.numVertices() # replace regular grid nr = np.count_nonzero(isBoundary) n_new = 1000 X = np.hstack( (X[:, isBoundary], Omega.rand(n_new)) ) isBoundary = np.hstack( (np.ones(nr, dtype='bool'), np.zeros(n_new, dtype='bool') )) m = X.shape[1] #%% plot boundary