test_gpr.py 1.85 KB
Newer Older
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
1
2
3
4
import numpy as np
import unittest
from gpr import gpr

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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

Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
45
46
47
48
49
50
51
52
53
54
55
56
57
class test_kernel(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        print('setupClass')

    @classmethod
    def tearDownClass(cls):
        print('teardownClass')

    def setUp(self):
        print('setUp')
        #self.kernel = gauss_kernel()
58
59
60
        a = read('structures.traj', index='0')
        self.gpr_old = initialize_old_gpr(a)
        self.gpr = gpr()
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
61
62
63
64

    def tearDown(self):
        print('tearDown\n')
    
65
66
67
68
69
70
71
72
73
    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
Malthe Kjær Bisbo's avatar
Malthe Kjær Bisbo committed
74
75
76

if __name__ == '__main__':
    unittest.main()