crystalcell 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,230 @@
1
+ #! /usr/bin/ruby
2
+
3
+ require "helper"
4
+
5
+ class TC_Povray_Element < Test::Unit::TestCase
6
+
7
+ CPE = CrystalCell::Povray::Element
8
+
9
+ def setup
10
+ end
11
+
12
+ def test_draw_radius
13
+ assert_equal(0.2 , CPE.draw_radius(1 ))
14
+ assert_equal(1.22 , CPE.draw_radius(2 ))
15
+ assert_equal(0.59 , CPE.draw_radius(3 ))
16
+ assert_equal(0.27 , CPE.draw_radius(4 ))
17
+ assert_equal(0.11 , CPE.draw_radius(5 ))
18
+ assert_equal(0.15 , CPE.draw_radius(6 ))
19
+ assert_equal(1.46 , CPE.draw_radius(7 ))
20
+ assert_equal(1.4 , CPE.draw_radius(8 ))
21
+ assert_equal(1.33 , CPE.draw_radius(9 ))
22
+ assert_equal(1.6 , CPE.draw_radius(10 ))
23
+ assert_equal(1.02 , CPE.draw_radius(11 ))
24
+ assert_equal(0.72 , CPE.draw_radius(12 ))
25
+ assert_equal(0.39 , CPE.draw_radius(13 ))
26
+ assert_equal(0.26 , CPE.draw_radius(14 ))
27
+ assert_equal(0.17 , CPE.draw_radius(15 ))
28
+ assert_equal(1.84 , CPE.draw_radius(16 ))
29
+ assert_equal(1.81 , CPE.draw_radius(17 ))
30
+ assert_equal(1.92 , CPE.draw_radius(18 ))
31
+ assert_equal(1.51 , CPE.draw_radius(19 ))
32
+ assert_equal(1.12 , CPE.draw_radius(20 ))
33
+ assert_equal(0.745, CPE.draw_radius(21 ))
34
+ assert_equal(0.605, CPE.draw_radius(22 ))
35
+ assert_equal(0.58 , CPE.draw_radius(23 ))
36
+ assert_equal(0.615, CPE.draw_radius(24 ))
37
+ assert_equal(0.83 , CPE.draw_radius(25 ))
38
+ assert_equal(0.78 , CPE.draw_radius(26 ))
39
+ assert_equal(0.745, CPE.draw_radius(27 ))
40
+ assert_equal(0.69 , CPE.draw_radius(28 ))
41
+ assert_equal(0.73 , CPE.draw_radius(29 ))
42
+ assert_equal(0.74 , CPE.draw_radius(30 ))
43
+ assert_equal(0.62 , CPE.draw_radius(31 ))
44
+ assert_equal(0.53 , CPE.draw_radius(32 ))
45
+ assert_equal(0.335, CPE.draw_radius(33 ))
46
+ assert_equal(1.98 , CPE.draw_radius(34 ))
47
+ assert_equal(1.96 , CPE.draw_radius(35 ))
48
+ assert_equal(1.98 , CPE.draw_radius(36 ))
49
+ assert_equal(1.61 , CPE.draw_radius(37 ))
50
+ assert_equal(1.26 , CPE.draw_radius(38 ))
51
+ assert_equal(1.019, CPE.draw_radius(39 ))
52
+ assert_equal(0.72 , CPE.draw_radius(40 ))
53
+ assert_equal(0.64 , CPE.draw_radius(41 ))
54
+ assert_equal(0.59 , CPE.draw_radius(42 ))
55
+ assert_equal(0.56 , CPE.draw_radius(43 ))
56
+ assert_equal(0.62 , CPE.draw_radius(44 ))
57
+ assert_equal(0.665, CPE.draw_radius(45 ))
58
+ assert_equal(0.86 , CPE.draw_radius(46 ))
59
+ assert_equal(1.15 , CPE.draw_radius(47 ))
60
+ assert_equal(0.95 , CPE.draw_radius(48 ))
61
+ assert_equal(0.8 , CPE.draw_radius(49 ))
62
+ assert_equal(0.69 , CPE.draw_radius(50 ))
63
+ assert_equal(0.76 , CPE.draw_radius(51 ))
64
+ assert_equal(2.21 , CPE.draw_radius(52 ))
65
+ assert_equal(2.2 , CPE.draw_radius(53 ))
66
+ assert_equal(0.48 , CPE.draw_radius(54 ))
67
+ assert_equal(1.74 , CPE.draw_radius(55 ))
68
+ assert_equal(1.42 , CPE.draw_radius(56 ))
69
+ assert_equal(1.16 , CPE.draw_radius(57 ))
70
+ assert_equal(0.97 , CPE.draw_radius(58 ))
71
+ assert_equal(1.126, CPE.draw_radius(59 ))
72
+ assert_equal(1.109, CPE.draw_radius(60 ))
73
+ assert_equal(1.093, CPE.draw_radius(61 ))
74
+ assert_equal(1.27 , CPE.draw_radius(62 ))
75
+ assert_equal(1.066, CPE.draw_radius(63 ))
76
+ assert_equal(1.053, CPE.draw_radius(64 ))
77
+ assert_equal(1.04 , CPE.draw_radius(65 ))
78
+ assert_equal(1.027, CPE.draw_radius(66 ))
79
+ assert_equal(1.015, CPE.draw_radius(67 ))
80
+ assert_equal(1.004, CPE.draw_radius(68 ))
81
+ assert_equal(0.994, CPE.draw_radius(69 ))
82
+ assert_equal(0.985, CPE.draw_radius(70 ))
83
+ assert_equal(0.977, CPE.draw_radius(71 ))
84
+ assert_equal(0.71 , CPE.draw_radius(72 ))
85
+ assert_equal(0.64 , CPE.draw_radius(73 ))
86
+ assert_equal(0.6 , CPE.draw_radius(74 ))
87
+ assert_equal(0.53 , CPE.draw_radius(75 ))
88
+ assert_equal(0.63 , CPE.draw_radius(76 ))
89
+ assert_equal(0.625, CPE.draw_radius(77 ))
90
+ assert_equal(0.625, CPE.draw_radius(78 ))
91
+ assert_equal(1.37 , CPE.draw_radius(79 ))
92
+ assert_equal(1.02 , CPE.draw_radius(80 ))
93
+ assert_equal(0.885, CPE.draw_radius(81 ))
94
+ assert_equal(1.19 , CPE.draw_radius(82 ))
95
+ assert_equal(1.03 , CPE.draw_radius(83 ))
96
+ assert_equal(0.94 , CPE.draw_radius(84 ))
97
+ assert_equal(0.62 , CPE.draw_radius(85 ))
98
+ assert_equal(0.8 , CPE.draw_radius(86 ))
99
+ assert_equal(1.8 , CPE.draw_radius(87 ))
100
+ assert_equal(1.48 , CPE.draw_radius(88 ))
101
+ assert_equal(1.12 , CPE.draw_radius(89 ))
102
+ assert_equal(1.05 , CPE.draw_radius(90 ))
103
+ assert_equal(0.78 , CPE.draw_radius(91 ))
104
+ assert_equal(0.73 , CPE.draw_radius(92 ))
105
+ assert_equal(0.75 , CPE.draw_radius(93 ))
106
+ assert_equal(0.86 , CPE.draw_radius(94 ))
107
+ assert_equal(0.975, CPE.draw_radius(95 ))
108
+ assert_equal(0.8 , CPE.draw_radius(96 ))
109
+ assert_equal(0.8 , CPE.draw_radius(97 ))
110
+ assert_equal(0.8 , CPE.draw_radius(98 ))
111
+ assert_equal(0.8 , CPE.draw_radius(99 ))
112
+ assert_equal(0.8 , CPE.draw_radius(100 ))
113
+ assert_equal(0.8 , CPE.draw_radius(101 ))
114
+ assert_equal(0.8 , CPE.draw_radius(102 ))
115
+ assert_equal(0.8 , CPE.draw_radius(103 ))
116
+
117
+ assert_equal(0.2 , CPE.draw_radius( 'H' ))
118
+ assert_equal(1.22 , CPE.draw_radius( 'He' ))
119
+ assert_equal(0.59 , CPE.draw_radius( 'Li' ))
120
+ assert_equal(0.27 , CPE.draw_radius( 'Be' ))
121
+ assert_equal(0.11 , CPE.draw_radius( 'B' ))
122
+ assert_equal(0.15 , CPE.draw_radius( 'C' ))
123
+ assert_equal(1.46 , CPE.draw_radius( 'N' ))
124
+ assert_equal(1.4 , CPE.draw_radius( 'O' ))
125
+ assert_equal(1.33 , CPE.draw_radius( 'F' ))
126
+ assert_equal(1.6 , CPE.draw_radius( 'Ne' ))
127
+ assert_equal(1.02 , CPE.draw_radius( 'Na' ))
128
+ assert_equal(0.72 , CPE.draw_radius( 'Mg' ))
129
+ assert_equal(0.39 , CPE.draw_radius( 'Al' ))
130
+ assert_equal(0.26 , CPE.draw_radius( 'Si' ))
131
+ assert_equal(0.17 , CPE.draw_radius( 'P' ))
132
+ assert_equal(1.84 , CPE.draw_radius( 'S' ))
133
+ assert_equal(1.81 , CPE.draw_radius( 'Cl' ))
134
+ assert_equal(1.92 , CPE.draw_radius( 'Ar' ))
135
+ assert_equal(1.51 , CPE.draw_radius( 'K' ))
136
+ assert_equal(1.12 , CPE.draw_radius( 'Ca' ))
137
+ assert_equal(0.745, CPE.draw_radius( 'Sc' ))
138
+ assert_equal(0.605, CPE.draw_radius( 'Ti' ))
139
+ assert_equal(0.58 , CPE.draw_radius( 'V' ))
140
+ assert_equal(0.615, CPE.draw_radius( 'Cr' ))
141
+ assert_equal(0.83 , CPE.draw_radius( 'Mn' ))
142
+ assert_equal(0.78 , CPE.draw_radius( 'Fe' ))
143
+ assert_equal(0.745, CPE.draw_radius( 'Co' ))
144
+ assert_equal(0.69 , CPE.draw_radius( 'Ni' ))
145
+ assert_equal(0.73 , CPE.draw_radius( 'Cu' ))
146
+ assert_equal(0.74 , CPE.draw_radius( 'Zn' ))
147
+ assert_equal(0.62 , CPE.draw_radius( 'Ga' ))
148
+ assert_equal(0.53 , CPE.draw_radius( 'Ge' ))
149
+ assert_equal(0.335, CPE.draw_radius( 'As' ))
150
+ assert_equal(1.98 , CPE.draw_radius( 'Se' ))
151
+ assert_equal(1.96 , CPE.draw_radius( 'Br' ))
152
+ assert_equal(1.98 , CPE.draw_radius( 'Kr' ))
153
+ assert_equal(1.61 , CPE.draw_radius( 'Rb' ))
154
+ assert_equal(1.26 , CPE.draw_radius( 'Sr' ))
155
+ assert_equal(1.019, CPE.draw_radius( 'Y' ))
156
+ assert_equal(0.72 , CPE.draw_radius( 'Zr' ))
157
+ assert_equal(0.64 , CPE.draw_radius( 'Nb' ))
158
+ assert_equal(0.59 , CPE.draw_radius( 'Mo' ))
159
+ assert_equal(0.56 , CPE.draw_radius( 'Tc' ))
160
+ assert_equal(0.62 , CPE.draw_radius( 'Ru' ))
161
+ assert_equal(0.665, CPE.draw_radius( 'Rh' ))
162
+ assert_equal(0.86 , CPE.draw_radius( 'Pd' ))
163
+ assert_equal(1.15 , CPE.draw_radius( 'Ag' ))
164
+ assert_equal(0.95 , CPE.draw_radius( 'Cd' ))
165
+ assert_equal(0.8 , CPE.draw_radius( 'In' ))
166
+ assert_equal(0.69 , CPE.draw_radius( 'Sn' ))
167
+ assert_equal(0.76 , CPE.draw_radius( 'Sb' ))
168
+ assert_equal(2.21 , CPE.draw_radius( 'Te' ))
169
+ assert_equal(2.2 , CPE.draw_radius( 'I' ))
170
+ assert_equal(0.48 , CPE.draw_radius( 'Xe' ))
171
+ assert_equal(1.74 , CPE.draw_radius( 'Cs' ))
172
+ assert_equal(1.42 , CPE.draw_radius( 'Ba' ))
173
+ assert_equal(0.71 , CPE.draw_radius( 'Hf' ))
174
+ assert_equal(0.64 , CPE.draw_radius( 'Ta' ))
175
+ assert_equal(0.6 , CPE.draw_radius( 'W' ))
176
+ assert_equal(0.53 , CPE.draw_radius( 'Re' ))
177
+ assert_equal(0.63 , CPE.draw_radius( 'Os' ))
178
+ assert_equal(0.625, CPE.draw_radius( 'Ir' ))
179
+ assert_equal(0.625, CPE.draw_radius( 'Pt' ))
180
+ assert_equal(1.37 , CPE.draw_radius( 'Au' ))
181
+ assert_equal(1.02 , CPE.draw_radius( 'Hg' ))
182
+ assert_equal(0.885, CPE.draw_radius( 'Tl' ))
183
+ assert_equal(1.19 , CPE.draw_radius( 'Pb' ))
184
+ assert_equal(1.03 , CPE.draw_radius( 'Bi' ))
185
+ assert_equal(0.94 , CPE.draw_radius( 'Po' ))
186
+ assert_equal(0.62 , CPE.draw_radius( 'At' ))
187
+ assert_equal(0.8 , CPE.draw_radius( 'Rn' ))
188
+ assert_equal(1.8 , CPE.draw_radius( 'Fr' ))
189
+ assert_equal(1.48 , CPE.draw_radius( 'Ra' ))
190
+ assert_equal(1.16 , CPE.draw_radius( 'La' ))
191
+ assert_equal(0.97 , CPE.draw_radius( 'Ce' ))
192
+ assert_equal(1.126, CPE.draw_radius( 'Pr' ))
193
+ assert_equal(1.109, CPE.draw_radius( 'Nd' ))
194
+ assert_equal(1.093, CPE.draw_radius( 'Pm' ))
195
+ assert_equal(1.27 , CPE.draw_radius( 'Sm' ))
196
+ assert_equal(1.066, CPE.draw_radius( 'Eu' ))
197
+ assert_equal(1.053, CPE.draw_radius( 'Gd' ))
198
+ assert_equal(1.04 , CPE.draw_radius( 'Tb' ))
199
+ assert_equal(1.027, CPE.draw_radius( 'Dy' ))
200
+ assert_equal(1.015, CPE.draw_radius( 'Ho' ))
201
+ assert_equal(1.004, CPE.draw_radius( 'Er' ))
202
+ assert_equal(0.994, CPE.draw_radius( 'Tm' ))
203
+ assert_equal(0.985, CPE.draw_radius( 'Yb' ))
204
+ assert_equal(0.977, CPE.draw_radius( 'Lu' ))
205
+ assert_equal(1.12 , CPE.draw_radius( 'Ac' ))
206
+ assert_equal(1.05 , CPE.draw_radius( 'Th' ))
207
+ assert_equal(0.78 , CPE.draw_radius( 'Pa' ))
208
+ assert_equal(0.73 , CPE.draw_radius( 'U' ))
209
+ assert_equal(0.75 , CPE.draw_radius( 'Np' ))
210
+ assert_equal(0.86 , CPE.draw_radius( 'Pu' ))
211
+ assert_equal(0.975, CPE.draw_radius( 'Am' ))
212
+ assert_equal(0.8 , CPE.draw_radius( 'Cm' ))
213
+ assert_equal(0.8 , CPE.draw_radius( 'Bk' ))
214
+ assert_equal(0.8 , CPE.draw_radius( 'Cf' ))
215
+ assert_equal(0.8 , CPE.draw_radius( 'Es' ))
216
+ assert_equal(0.8 , CPE.draw_radius( 'Fm' ))
217
+ assert_equal(0.8 , CPE.draw_radius( 'Md' ))
218
+ assert_equal(0.8 , CPE.draw_radius( 'No' ))
219
+ assert_equal(0.8 , CPE.draw_radius( 'Lr' ))
220
+
221
+ assert_equal(0.2 , CPE.draw_radius(1 ))
222
+ assert_equal(1.22 , CPE.draw_radius(2 ))
223
+ end
224
+
225
+ def test_color
226
+ assert_equal( [ 1.00, 0.80, 0.80 ], CPE.color('H' ) )
227
+ assert_equal( [ 1.00, 0.80, 0.80 ], CPE.color(1 ) )
228
+ end
229
+ end
230
+
data/test/test_atom.rb CHANGED
@@ -3,204 +3,204 @@
3
3
  require "helper"
4
4
 
5
5
  class TC_Atom < Test::Unit::TestCase
6
- $tolerance = 10.0 ** (-10)
7
-
8
- def setup
9
- @a0 = CrystalCell::Atom.new("Li", [ 0.0, 0.0, 0.0 ])
10
- @a1 = CrystalCell::Atom.new("Li", [ 1.0, 1.0, 1.0 ])
11
- @a2 = CrystalCell::Atom.new("Li", [ 0.0, 0.0, 0.0 ])
12
- @a3 = CrystalCell::Atom.new("Be", [ 0.0, 0.0, 0.0 ])
13
- @a4 = CrystalCell::Atom.new("Li", [ 1.0, 2.3, 4.5 ])
14
- @a5 = CrystalCell::Atom.new("Li", [-1.0,-2.3,-4.5 ])
15
- @a6 = CrystalCell::Atom.new( 3, [-1.0,-2.3,-4.5 ])
16
- end
17
-
18
- def test_initialize
19
- assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, nil, nil) }
20
- assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, nil, "A") }
21
- assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, [0.0, 0.0], "A") }
22
- assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, [0.0, 0.0, 0.0, 0.0], "A") }
23
- a0 = CrystalCell::Atom.new(nil, [ 0.0, 0.0, 0.0], nil)
24
- a1 = CrystalCell::Atom.new(nil, [ 0.0, 0.0, 0.0], "A")
25
- assert_equal(nil, a0.name)
26
- assert_equal("A", a1.name)
27
- end
28
-
29
- def test_equal_in_delta?
30
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a0))
31
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a0, @a1))
32
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a2))
33
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a0, @a3))
34
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a0))
35
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a1))
36
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a2))
37
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a3))
38
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a0))
39
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a2, @a1))
40
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a2))
41
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a2, @a3))
42
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a0))
43
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a1))
44
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a2))
45
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a3, @a3))
46
-
47
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a0, 2.0))
48
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a1, 2.0))
49
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a2, 2.0))
50
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a0, @a3, 2.0))
51
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a0, 2.0))
52
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a1, 2.0))
53
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a2, 2.0))
54
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a3, 2.0))
55
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a0, 2.0))
56
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a1, 2.0))
57
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a2, 2.0))
58
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a2, @a3, 2.0))
59
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a0, 2.0))
60
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a1, 2.0))
61
- assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a2, 2.0))
62
- assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a3, @a3, 2.0))
63
-
64
- assert_equal(true , @a0.equal_in_delta?(@a0))
65
- assert_equal(false, @a0.equal_in_delta?(@a1))
66
- assert_equal(true , @a0.equal_in_delta?(@a2))
67
- assert_equal(false, @a0.equal_in_delta?(@a3))
68
- assert_equal(false, @a1.equal_in_delta?(@a0))
69
- assert_equal(true , @a1.equal_in_delta?(@a1))
70
- assert_equal(false, @a1.equal_in_delta?(@a2))
71
- assert_equal(false, @a1.equal_in_delta?(@a3))
72
- assert_equal(true , @a2.equal_in_delta?(@a0))
73
- assert_equal(false, @a2.equal_in_delta?(@a1))
74
- assert_equal(true , @a2.equal_in_delta?(@a2))
75
- assert_equal(false, @a2.equal_in_delta?(@a3))
76
- assert_equal(false, @a3.equal_in_delta?(@a0))
77
- assert_equal(false, @a3.equal_in_delta?(@a1))
78
- assert_equal(false, @a3.equal_in_delta?(@a2))
79
- assert_equal(true , @a3.equal_in_delta?(@a3))
80
-
81
- assert_equal(true , @a0.equal_in_delta?(@a0, 2.0))
82
- assert_equal(true , @a0.equal_in_delta?(@a1, 2.0))
83
- assert_equal(true , @a0.equal_in_delta?(@a2, 2.0))
84
- assert_equal(false, @a0.equal_in_delta?(@a3, 2.0))
85
- assert_equal(true , @a1.equal_in_delta?(@a0, 2.0))
86
- assert_equal(true , @a1.equal_in_delta?(@a1, 2.0))
87
- assert_equal(true , @a1.equal_in_delta?(@a2, 2.0))
88
- assert_equal(false, @a1.equal_in_delta?(@a3, 2.0))
89
- assert_equal(true , @a2.equal_in_delta?(@a0, 2.0))
90
- assert_equal(true , @a2.equal_in_delta?(@a1, 2.0))
91
- assert_equal(true , @a2.equal_in_delta?(@a2, 2.0))
92
- assert_equal(false, @a2.equal_in_delta?(@a3, 2.0))
93
- assert_equal(false, @a3.equal_in_delta?(@a0, 2.0))
94
- assert_equal(false, @a3.equal_in_delta?(@a1, 2.0))
95
- assert_equal(false, @a3.equal_in_delta?(@a2, 2.0))
96
- assert_equal(true , @a3.equal_in_delta?(@a3, 2.0))
97
- end
98
-
99
- def test_equal
100
- assert_equal(true, @a0 == CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]))
101
- assert_equal(true, @a1 == CrystalCell::Atom.new("Li", [1.0, 1.0, 1.0]))
102
- assert_equal(true, @a2 == CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]))
103
- assert_equal(true, @a3 == CrystalCell::Atom.new("Be", [0.0, 0.0, 0.0]))
104
-
105
- assert_equal(false, @a0 == CrystalCell::Atom.new("Li", [0.9, 0.0, 0.0]))
106
- assert_equal(false, @a1 == CrystalCell::Atom.new("Li", [1.1, 1.0, 1.0]))
107
- assert_equal(false, @a2 == CrystalCell::Atom.new("Li", [0.9, 0.0, 0.0]))
108
- assert_equal(false, @a3 == CrystalCell::Atom.new("Be", [0.9, 0.0, 0.0]))
109
- end
110
-
111
- def test_internal_coordinates
112
- assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a0.internal_coordinates)
113
- assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a1.internal_coordinates)
114
- assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a2.internal_coordinates)
115
- assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a3.internal_coordinates)
116
-
117
- assert_equal(Mageo::Vector3DInternal, @a4.internal_coordinates.class)
118
- assert_in_delta(0.0, @a4.internal_coordinates[0], $tolerance)
119
- assert_in_delta(0.3, @a4.internal_coordinates[1], $tolerance)
120
- assert_in_delta(0.5, @a4.internal_coordinates[2], $tolerance)
121
-
122
- assert_equal(Mageo::Vector3DInternal, @a5.internal_coordinates.class)
123
- assert_in_delta(0.0, @a5.internal_coordinates[0], $tolerance)
124
- assert_in_delta(0.7, @a5.internal_coordinates[1], $tolerance)
125
- assert_in_delta(0.5, @a5.internal_coordinates[2], $tolerance)
126
- end
127
-
128
- def test_translation_symmetry_operation
129
- assert_equal(Mageo::Vector3DInternal[ 0, 0, 0 ], @a0.translation_symmetry_operation)
130
- assert_equal(Mageo::Vector3DInternal[ 1, 1, 1 ], @a1.translation_symmetry_operation)
131
- assert_equal(Mageo::Vector3DInternal[ 0, 0, 0 ], @a2.translation_symmetry_operation)
132
- assert_equal(Mageo::Vector3DInternal[ 0, 0, 0 ], @a3.translation_symmetry_operation)
133
- assert_equal(Mageo::Vector3DInternal[ 1, 2, 4 ], @a4.translation_symmetry_operation)
134
- assert_equal(Mageo::Vector3DInternal[-1,-3,-5 ], @a5.translation_symmetry_operation)
135
- end
136
-
137
- def test_set_position
138
- assert_equal(Mageo::Vector3DInternal[ 1.2, 2.3, 3.4 ], @a3.set_position([ 1.2, 2.3, 3.4 ]))
139
- assert_equal(Mageo::Vector3DInternal[ 2.3, 3.4, 4.5 ], @a4.set_position([ 2.3, 3.4, 4.5 ]))
140
- assert_raise(CrystalCell::Atom::TypeError){
141
- @a4.set_position(Mageo::Vector3D[ 2.3, 3.4, 4.5 ])
142
- }
143
- end
144
-
145
- def test_element
146
- @a6.element = "Li"
147
- assert_equal(@a5, @a6)
148
- end
149
-
150
- def test_translate!
151
- @a0.translate!([ 1.2, 3.4, 5.6 ])
152
- assert_equal("Li", @a0.element)
153
- assert_in_delta(1.2 , @a0.position[0], $tolerance)
154
- assert_in_delta(3.4 , @a0.position[1], $tolerance)
155
- assert_in_delta(5.6 , @a0.position[2], $tolerance)
156
-
157
- @a3.translate!([ 1.2, 3.4, 5.6 ])
158
- assert_equal("Be", @a3.element)
159
- assert_in_delta(1.2 , @a3.position[0], $tolerance)
160
- assert_in_delta(3.4 , @a3.position[1], $tolerance)
161
- assert_in_delta(5.6 , @a3.position[2], $tolerance)
162
-
163
-
164
- @a5.translate!([ 1.0, 1.0, 1.0 ])
165
- assert_equal("Li", @a5.element)
166
- assert_in_delta(0.0 , @a5.position[0], $tolerance)
167
- assert_in_delta(-1.3 , @a5.position[1], $tolerance)
168
- assert_in_delta(-3.5 , @a5.position[2], $tolerance)
169
-
170
- # Mageo::Vector3D なら例外
171
- assert_raise(CrystalCell::Atom::TypeError){ @a0.translate!(Mageo::Vector3D[ 0.0, 0.0, 0.0 ]) }
172
-
173
- # 3次元でなければ例外
174
- assert_raise(CrystalCell::Atom::TypeError){ @a0.translate!([ 0.0, 0.0 ]) }
175
- assert_raise(CrystalCell::Atom::TypeError){ @a0.translate!([ 0.0, 0.0, 0.0, 0.0 ]) }
176
- end
177
-
178
- def test_translate
179
- t = @a0.translate([ 1.2, 3.4, 5.6 ])
180
- assert_equal("Li", t.element)
181
- assert_in_delta(1.2, t.position[0], $tolerance)
182
- assert_in_delta(3.4, t.position[1], $tolerance)
183
- assert_in_delta(5.6, t.position[2], $tolerance)
184
-
185
- t = @a3.translate([ 1.2, 3.4, 5.6 ])
186
- assert_equal("Be", t.element)
187
- assert_in_delta(1.2, t.position[0], $tolerance)
188
- assert_in_delta(3.4, t.position[1], $tolerance)
189
- assert_in_delta(5.6, t.position[2], $tolerance)
190
-
191
- t = @a5.translate([ 1.0, 1.0, 1.0 ])
192
- assert_equal("Li", t.element)
193
- assert_in_delta(0.0, t.position[0], $tolerance)
194
- assert_in_delta(-1.3, t.position[1], $tolerance)
195
- assert_in_delta(-3.5, t.position[2], $tolerance)
196
-
197
- # Mageo::Vector3D なら例外
198
- assert_raise(CrystalCell::Atom::TypeError){ @a0.translate(Mageo::Vector3D[ 0.0, 0.0, 0.0 ]) }
199
-
200
- # 3次元でなければ例外
201
- assert_raise(CrystalCell::Atom::TypeError){ @a0.translate([ 0.0, 0.0 ]) }
202
- assert_raise(CrystalCell::Atom::TypeError){ @a0.translate([ 0.0, 0.0, 0.0, 0.0 ]) }
203
- end
6
+ $tolerance = 10.0 ** (-10)
7
+
8
+ def setup
9
+ @a0 = CrystalCell::Atom.new("Li", [ 0.0, 0.0, 0.0 ])
10
+ @a1 = CrystalCell::Atom.new("Li", [ 1.0, 1.0, 1.0 ])
11
+ @a2 = CrystalCell::Atom.new("Li", [ 0.0, 0.0, 0.0 ])
12
+ @a3 = CrystalCell::Atom.new("Be", [ 0.0, 0.0, 0.0 ])
13
+ @a4 = CrystalCell::Atom.new("Li", [ 1.0, 2.3, 4.5 ])
14
+ @a5 = CrystalCell::Atom.new("Li", [-1.0,-2.3,-4.5 ])
15
+ @a6 = CrystalCell::Atom.new( 3, [-1.0,-2.3,-4.5 ])
16
+ end
17
+
18
+ def test_initialize
19
+ assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, nil, nil) }
20
+ assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, nil, "A") }
21
+ assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, [0.0, 0.0], "A") }
22
+ assert_raise(CrystalCell::Atom::TypeError){ CrystalCell::Atom.new(nil, [0.0, 0.0, 0.0, 0.0], "A") }
23
+ a0 = CrystalCell::Atom.new(nil, [ 0.0, 0.0, 0.0], nil)
24
+ a1 = CrystalCell::Atom.new(nil, [ 0.0, 0.0, 0.0], "A")
25
+ assert_equal(nil, a0.name)
26
+ assert_equal("A", a1.name)
27
+ end
28
+
29
+ def test_equal_in_delta?
30
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a0))
31
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a0, @a1))
32
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a2))
33
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a0, @a3))
34
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a0))
35
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a1))
36
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a2))
37
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a3))
38
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a0))
39
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a2, @a1))
40
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a2))
41
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a2, @a3))
42
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a0))
43
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a1))
44
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a2))
45
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a3, @a3))
46
+
47
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a0, 2.0))
48
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a1, 2.0))
49
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a0, @a2, 2.0))
50
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a0, @a3, 2.0))
51
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a0, 2.0))
52
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a1, 2.0))
53
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a1, @a2, 2.0))
54
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a1, @a3, 2.0))
55
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a0, 2.0))
56
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a1, 2.0))
57
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a2, @a2, 2.0))
58
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a2, @a3, 2.0))
59
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a0, 2.0))
60
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a1, 2.0))
61
+ assert_equal(false, CrystalCell::Atom.equal_in_delta?(@a3, @a2, 2.0))
62
+ assert_equal(true , CrystalCell::Atom.equal_in_delta?(@a3, @a3, 2.0))
63
+
64
+ assert_equal(true , @a0.equal_in_delta?(@a0))
65
+ assert_equal(false, @a0.equal_in_delta?(@a1))
66
+ assert_equal(true , @a0.equal_in_delta?(@a2))
67
+ assert_equal(false, @a0.equal_in_delta?(@a3))
68
+ assert_equal(false, @a1.equal_in_delta?(@a0))
69
+ assert_equal(true , @a1.equal_in_delta?(@a1))
70
+ assert_equal(false, @a1.equal_in_delta?(@a2))
71
+ assert_equal(false, @a1.equal_in_delta?(@a3))
72
+ assert_equal(true , @a2.equal_in_delta?(@a0))
73
+ assert_equal(false, @a2.equal_in_delta?(@a1))
74
+ assert_equal(true , @a2.equal_in_delta?(@a2))
75
+ assert_equal(false, @a2.equal_in_delta?(@a3))
76
+ assert_equal(false, @a3.equal_in_delta?(@a0))
77
+ assert_equal(false, @a3.equal_in_delta?(@a1))
78
+ assert_equal(false, @a3.equal_in_delta?(@a2))
79
+ assert_equal(true , @a3.equal_in_delta?(@a3))
80
+
81
+ assert_equal(true , @a0.equal_in_delta?(@a0, 2.0))
82
+ assert_equal(true , @a0.equal_in_delta?(@a1, 2.0))
83
+ assert_equal(true , @a0.equal_in_delta?(@a2, 2.0))
84
+ assert_equal(false, @a0.equal_in_delta?(@a3, 2.0))
85
+ assert_equal(true , @a1.equal_in_delta?(@a0, 2.0))
86
+ assert_equal(true , @a1.equal_in_delta?(@a1, 2.0))
87
+ assert_equal(true , @a1.equal_in_delta?(@a2, 2.0))
88
+ assert_equal(false, @a1.equal_in_delta?(@a3, 2.0))
89
+ assert_equal(true , @a2.equal_in_delta?(@a0, 2.0))
90
+ assert_equal(true , @a2.equal_in_delta?(@a1, 2.0))
91
+ assert_equal(true , @a2.equal_in_delta?(@a2, 2.0))
92
+ assert_equal(false, @a2.equal_in_delta?(@a3, 2.0))
93
+ assert_equal(false, @a3.equal_in_delta?(@a0, 2.0))
94
+ assert_equal(false, @a3.equal_in_delta?(@a1, 2.0))
95
+ assert_equal(false, @a3.equal_in_delta?(@a2, 2.0))
96
+ assert_equal(true , @a3.equal_in_delta?(@a3, 2.0))
97
+ end
98
+
99
+ def test_equal
100
+ assert_equal(true, @a0 == CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]))
101
+ assert_equal(true, @a1 == CrystalCell::Atom.new("Li", [1.0, 1.0, 1.0]))
102
+ assert_equal(true, @a2 == CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]))
103
+ assert_equal(true, @a3 == CrystalCell::Atom.new("Be", [0.0, 0.0, 0.0]))
104
+
105
+ assert_equal(false, @a0 == CrystalCell::Atom.new("Li", [0.9, 0.0, 0.0]))
106
+ assert_equal(false, @a1 == CrystalCell::Atom.new("Li", [1.1, 1.0, 1.0]))
107
+ assert_equal(false, @a2 == CrystalCell::Atom.new("Li", [0.9, 0.0, 0.0]))
108
+ assert_equal(false, @a3 == CrystalCell::Atom.new("Be", [0.9, 0.0, 0.0]))
109
+ end
110
+
111
+ def test_internal_coordinates
112
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a0.internal_coordinates)
113
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a1.internal_coordinates)
114
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a2.internal_coordinates)
115
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0 ], @a3.internal_coordinates)
116
+
117
+ assert_equal(Mageo::Vector3DInternal, @a4.internal_coordinates.class)
118
+ assert_in_delta(0.0, @a4.internal_coordinates[0], $tolerance)
119
+ assert_in_delta(0.3, @a4.internal_coordinates[1], $tolerance)
120
+ assert_in_delta(0.5, @a4.internal_coordinates[2], $tolerance)
121
+
122
+ assert_equal(Mageo::Vector3DInternal, @a5.internal_coordinates.class)
123
+ assert_in_delta(0.0, @a5.internal_coordinates[0], $tolerance)
124
+ assert_in_delta(0.7, @a5.internal_coordinates[1], $tolerance)
125
+ assert_in_delta(0.5, @a5.internal_coordinates[2], $tolerance)
126
+ end
127
+
128
+ def test_translation_symmetry_operation
129
+ assert_equal(Mageo::Vector3DInternal[ 0, 0, 0 ], @a0.translation_symmetry_operation)
130
+ assert_equal(Mageo::Vector3DInternal[ 1, 1, 1 ], @a1.translation_symmetry_operation)
131
+ assert_equal(Mageo::Vector3DInternal[ 0, 0, 0 ], @a2.translation_symmetry_operation)
132
+ assert_equal(Mageo::Vector3DInternal[ 0, 0, 0 ], @a3.translation_symmetry_operation)
133
+ assert_equal(Mageo::Vector3DInternal[ 1, 2, 4 ], @a4.translation_symmetry_operation)
134
+ assert_equal(Mageo::Vector3DInternal[-1,-3,-5 ], @a5.translation_symmetry_operation)
135
+ end
136
+
137
+ def test_set_position
138
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 2.3, 3.4 ], @a3.set_position([ 1.2, 2.3, 3.4 ]))
139
+ assert_equal(Mageo::Vector3DInternal[ 2.3, 3.4, 4.5 ], @a4.set_position([ 2.3, 3.4, 4.5 ]))
140
+ assert_raise(CrystalCell::Atom::TypeError){
141
+ @a4.set_position(Mageo::Vector3D[ 2.3, 3.4, 4.5 ])
142
+ }
143
+ end
144
+
145
+ def test_element
146
+ @a6.element = "Li"
147
+ assert_equal(@a5, @a6)
148
+ end
149
+
150
+ def test_translate!
151
+ @a0.translate!([ 1.2, 3.4, 5.6 ])
152
+ assert_equal("Li", @a0.element)
153
+ assert_in_delta(1.2 , @a0.position[0], $tolerance)
154
+ assert_in_delta(3.4 , @a0.position[1], $tolerance)
155
+ assert_in_delta(5.6 , @a0.position[2], $tolerance)
156
+
157
+ @a3.translate!([ 1.2, 3.4, 5.6 ])
158
+ assert_equal("Be", @a3.element)
159
+ assert_in_delta(1.2 , @a3.position[0], $tolerance)
160
+ assert_in_delta(3.4 , @a3.position[1], $tolerance)
161
+ assert_in_delta(5.6 , @a3.position[2], $tolerance)
162
+
163
+
164
+ @a5.translate!([ 1.0, 1.0, 1.0 ])
165
+ assert_equal("Li", @a5.element)
166
+ assert_in_delta(0.0 , @a5.position[0], $tolerance)
167
+ assert_in_delta(-1.3 , @a5.position[1], $tolerance)
168
+ assert_in_delta(-3.5 , @a5.position[2], $tolerance)
169
+
170
+ # Mageo::Vector3D なら例外
171
+ assert_raise(CrystalCell::Atom::TypeError){ @a0.translate!(Mageo::Vector3D[ 0.0, 0.0, 0.0 ]) }
172
+
173
+ # 3次元でなければ例外
174
+ assert_raise(CrystalCell::Atom::TypeError){ @a0.translate!([ 0.0, 0.0 ]) }
175
+ assert_raise(CrystalCell::Atom::TypeError){ @a0.translate!([ 0.0, 0.0, 0.0, 0.0 ]) }
176
+ end
177
+
178
+ def test_translate
179
+ t = @a0.translate([ 1.2, 3.4, 5.6 ])
180
+ assert_equal("Li", t.element)
181
+ assert_in_delta(1.2, t.position[0], $tolerance)
182
+ assert_in_delta(3.4, t.position[1], $tolerance)
183
+ assert_in_delta(5.6, t.position[2], $tolerance)
184
+
185
+ t = @a3.translate([ 1.2, 3.4, 5.6 ])
186
+ assert_equal("Be", t.element)
187
+ assert_in_delta(1.2, t.position[0], $tolerance)
188
+ assert_in_delta(3.4, t.position[1], $tolerance)
189
+ assert_in_delta(5.6, t.position[2], $tolerance)
190
+
191
+ t = @a5.translate([ 1.0, 1.0, 1.0 ])
192
+ assert_equal("Li", t.element)
193
+ assert_in_delta(0.0, t.position[0], $tolerance)
194
+ assert_in_delta(-1.3, t.position[1], $tolerance)
195
+ assert_in_delta(-3.5, t.position[2], $tolerance)
196
+
197
+ # Mageo::Vector3D なら例外
198
+ assert_raise(CrystalCell::Atom::TypeError){ @a0.translate(Mageo::Vector3D[ 0.0, 0.0, 0.0 ]) }
199
+
200
+ # 3次元でなければ例外
201
+ assert_raise(CrystalCell::Atom::TypeError){ @a0.translate([ 0.0, 0.0 ]) }
202
+ assert_raise(CrystalCell::Atom::TypeError){ @a0.translate([ 0.0, 0.0, 0.0, 0.0 ]) }
203
+ end
204
204
 
205
205
  end
206
206