test.py 2.37 KB
Newer Older
Carl Poelking's avatar
Setup.  
Carl Poelking committed
1
2
3
4
5
6
7
8
#! /usr/bin/env python
import soap
import soap.tools

import os
import numpy as np
from momo import osio, endl, flush

9
10
11
12
13
14
15
16
17
18
19
20
21
element_vdw_radius = { 
'C':1.70,
'N':1.55,
'O':1.52,
'H':1.20
}
element_mass = {
'C':12,
'N':14,
'O':16,
'H':1
}

Carl Poelking's avatar
Setup.  
Carl Poelking committed
22
ase_config_list = soap.tools.ase_load_all('configs')
Carl Poelking's avatar
Carl Poelking committed
23
config = ase_config_list[1]
Carl Poelking's avatar
Setup.  
Carl Poelking committed
24
25
26
27
28
osio << config.atoms << endl

# INITIALIZE OPTIONS
options = soap.Options()
options.set('radialbasis.type', 'gaussian')
Carl Poelking's avatar
Carl Poelking committed
29
30
options.set('radialbasis.mode', 'adaptive')
#options.set('radialbasis.mode', 'equispaced')
31
options.set('radialbasis.N', 9)
Carl Poelking's avatar
Setup.  
Carl Poelking committed
32
options.set('radialbasis.sigma', 0.5)
33
options.set('radialbasis.integration_steps', 15)
Carl Poelking's avatar
Carl Poelking committed
34
35
36
37
38
39
40
#options.set('radialbasis.N', 9)
options.set('radialcutoff.Rc', 4.)
options.set('radialcutoff.Rc_width', 0.5)
options.set('radialcutoff.type', 'shifted-cosine')
options.set('radialcutoff.center_weight', -7.)
options.set('radialcutoff.center_weight', 1.)

41
options.set('angularbasis.type', 'spherical-harmonic')
42
options.set('angularbasis.L', 6)
Carl Poelking's avatar
Carl Poelking committed
43
#options.set('angularbasis.L', 6)
44
options.set('densitygrid.N', 20)
Carl Poelking's avatar
Carl Poelking committed
45
options.set('densitygrid.dx', 0.15)
Carl Poelking's avatar
Setup.  
Carl Poelking committed
46
47
48
49

# LOAD STRUCTURE
structure = soap.tools.setup_structure_ase(config.config_file, config.atoms)

50
osio << osio.mg << structure.label << endl
51

52
for atom in structure:
Carl Poelking's avatar
Carl Poelking committed
53
    atom.sigma = 0.5 # 0.4*element_vdw_radius[atom.type]
54
    atom.weight = 1. #element_mass[atom.type]
Carl Poelking's avatar
Carl Poelking committed
55
56
    #atom.sigma = 0.5*element_vdw_radius[atom.type]
    #atom.weight = element_mass[atom.type]
57
    osio << atom.name << atom.type << atom.weight << atom.sigma << atom.pos << endl
58

Carl Poelking's avatar
Setup.  
Carl Poelking committed
59
60
61
# COMPUTE SPECTRUM
spectrum = soap.Spectrum(structure, options)
spectrum.compute()
Carl Poelking's avatar
Carl Poelking committed
62
63
#spectrum.writeDensityOnGrid(1, "C", "")
spectrum.save("test_serialization/%s.spectrum.arch" % structure.label)
Carl Poelking's avatar
Setup.  
Carl Poelking committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

osio.okquit()




































structure = soap.Structure(config.config_file)

# BOX TESTS
osio << osio.mg << "Box checks ..." << endl
r1 = np.array([0.2,0.3,0.4])
r2 = np.array([0.8,1.0,1.2])
# OPEN BOX
structure.box = np.array([[0,0,0],[0,0,0],[0,0,0]])
print "Connect", r1, r2, " => ", structure.connect(r1,r2)
# CUBIC BOX
a = np.array([0.9,0,0])
b = np.array([0,0.7,0])
c = np.array([0,0,0.5])
structure.box = np.array([a,b,c])
print "Connect", r1, r2, " => ", structure.connect(r1,r2)


segment = structure.addSegment()
particle = structure.addParticle(segment)
particle.pos = np.array([-1,0,1]) # vec(0,1,-1)
print type(particle.pos), particle.pos
particle.mass = 12.