Commit 5015902e authored by Malthe Kjær Bisbo's avatar Malthe Kjær Bisbo
Browse files

slight changes to descriptors and prior

parent dd3edadb
......@@ -2,6 +2,46 @@ import numpy as np
import unittest
from gpr import gpr
from ase.io import read
# old gpr
from gaussComparator import gaussComparator
from featureCalculators_multi.angular_fingerprintFeature_cy import Angular_Fingerprint
from delta_functions_multi.delta import delta as deltaFunc
from GPR import GPR
def initialize_old_gpr(atoms):
### Set up feature ###
# Radial part
Rc1 = 6
binwidth1 = 0.2
sigma1 = 0.2
# Angular part
Rc2 = 4
Nbins2 = 30
sigma2 = 0.2
gamma = 2
# Radial/angular weighting
eta = 20
use_angular = True
# Initialize feature
featureCalculator = Angular_Fingerprint(atoms, Rc1=Rc1, Rc2=Rc2, binwidth1=binwidth1, Nbins2=Nbins2, sigma1=sigma1, sigma2=sigma2, gamma=gamma, eta=eta, use_angular=use_angular)
kernel = C(10, (1e1, 1e6)) * (C(1, (1, 1)) * RBF(10, (1,1000)) + C(0.01, (0.01, 0.01)) * RBF(10, (1,1000)) + WhiteKernel(1e-5, (1e-6,1e-2)))
delta = deltaFunc(atoms=a, rcut=6)
gpr = GPR(kernel=kernel,
featureCalculator=featureCalculator,
delta_function=delta,
bias_func=None,
optimize=False,
n_restarts_optimizer=1)
return gpr
class test_kernel(unittest.TestCase):
@classmethod
......@@ -15,30 +55,22 @@ class test_kernel(unittest.TestCase):
def setUp(self):
print('setUp')
#self.kernel = gauss_kernel()
self.kernel = double_gauss_kernel()
a = read('structures.traj', index='0')
self.gpr_old = initialize_old_gpr(a)
self.gpr = gpr()
def tearDown(self):
print('tearDown\n')
def test_jac(self):
x1 = np.array([1.,2.,3.])
x2 = np.array([1.5,2.,1.])
x3 = np.array([3.,1.,1.])
y = np.c_[x1,x2,x3].T
np.testing.assert_almost_equal(self.kernel.kernel_jacobian(x1,x2),
self.kernel.numerical_jacobian(x1,x2))
np.testing.assert_almost_equal(self.kernel.kernel_jacobian(x1,y),
self.kernel.numerical_jacobian(x1,y))
np.testing.assert_almost_equal(self.kernel.kernel_jacobian(x2,y),
self.kernel.numerical_jacobian(x2,y))
def test_hyper_jac(self):
x1 = np.array([1.,2.,3.])
x2 = np.array([1.5,2.,1.])
x3 = np.array([3.,1.,1.])
X = np.c_[x1,x2,x3].T
np.testing.assert_almost_equal(self.kernel.kernel_hyperparameter_gradient(X),
self.kernel.numerical_hyperparameter_gradient(X))
def test_compare_with_old(self):
traj = read('structures.traj', index=':50')
traj_train = traj[:40]
traj_predict = traj[40:]
self.gpr.
def test_forces(self):
pass
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment