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.
- checksums.yaml +7 -0
- data/CHANGES +23 -1
- data/Gemfile +9 -9
- data/VERSION +1 -1
- data/crystalcell.gemspec +41 -29
- data/lib/crystalcell/atom.rb +116 -118
- data/lib/crystalcell/cell.rb +542 -586
- data/lib/crystalcell/element.rb +49 -140
- data/lib/crystalcell/latticeaxes.rb +198 -185
- data/lib/crystalcell/periodiccell.rb +246 -244
- data/lib/crystalcell/povray/cell.rb +110 -0
- data/lib/crystalcell/povray/cylinder.rb +12 -0
- data/lib/crystalcell/povray/element.rb +284 -0
- data/lib/crystalcell/povray/sphere.rb +12 -0
- data/lib/crystalcell/povray/triangle.rb +17 -0
- data/lib/crystalcell/povray.rb +7 -0
- data/lib/crystalcell.rb +5 -1
- data/test/povray/test_cell.rb +179 -0
- data/test/povray/test_element.rb +230 -0
- data/test/test_atom.rb +198 -198
- data/test/test_cell.rb +1481 -1464
- data/test/test_element.rb +422 -642
- data/test/test_latticeaxes.rb +299 -283
- data/test/test_periodiccell.rb +928 -953
- metadata +63 -62
data/test/test_latticeaxes.rb
CHANGED
@@ -4,292 +4,308 @@ require "helper"
|
|
4
4
|
require "rubygems"
|
5
5
|
|
6
6
|
class CrystalCell::LatticeAxes
|
7
|
-
|
8
|
-
|
7
|
+
#public :triangulate, :rotate
|
8
|
+
#public :rotate
|
9
9
|
end
|
10
10
|
|
11
11
|
class TC_LatticeAxes < Test::Unit::TestCase
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
12
|
+
$tolerance = 10 ** (-10)
|
13
|
+
|
14
|
+
include Math
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@axes1 = [ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ]
|
18
|
+
|
19
|
+
@lc1 = CrystalCell::LatticeAxes.new([ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ])
|
20
|
+
@lc2 = CrystalCell::LatticeAxes.new([ [0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5] ])
|
21
|
+
@lc3 = CrystalCell::LatticeAxes.new(CrystalCell::LatticeAxes.lc_to_axes([1.0, 1.0, 1.0, 90.0, 90.0, 90.0]))
|
22
|
+
@lc4 = CrystalCell::LatticeAxes.new(
|
23
|
+
CrystalCell::LatticeAxes.lc_to_axes(
|
24
|
+
[ Math::sqrt(0.5), Math::sqrt(0.5), Math::sqrt(0.5),
|
25
|
+
60.0, 60.0, 60.0]) # Math::sqrt(0.5) == 0.5* Math::sqrt(2.0)
|
26
|
+
)
|
27
|
+
@lc5 = CrystalCell::LatticeAxes.new([ [1.0, 1.0, 1.0], [0.0, 1.0, 1.0], [0.0, 0.0, 1.0] ])
|
28
|
+
@lc6 = CrystalCell::LatticeAxes.new([ [1.0, 1.0, 1.0], [0.0,-1.0,-1.0], [0.0, 0.0, 1.0] ])
|
29
|
+
|
30
|
+
@vec_x = Mageo::Vector3D[ 1.0, 0.0, 0.0 ]
|
31
|
+
@vec_y = Mageo::Vector3D[ 0.0, 1.0, 0.0 ]
|
32
|
+
@vec_z = Mageo::Vector3D[ 0.0, 0.0, 1.0 ]
|
33
|
+
@vec_0 = Mageo::Vector3D[ 0.0, 0.0, 0.0 ]
|
34
|
+
@vec_1 = Mageo::Vector3D[ 1.0, 1.0, 0.0 ]
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_initialize
|
38
|
+
assert_raise(ArgumentError) { CrystalCell::LatticeAxes.new }
|
39
|
+
assert_raise(CrystalCell::LatticeAxes::InitializeError) { CrystalCell::LatticeAxes.new([]) }
|
40
|
+
assert_raise(CrystalCell::LatticeAxes::InitializeError) {
|
41
|
+
CrystalCell::LatticeAxes.new([1.0, 1.0, 1.0, 90.0, 90.0, 90.0])
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_raise(CrystalCell::LatticeAxes::InitializeError) {CrystalCell::LatticeAxes.new([0,1])}
|
45
|
+
assert_raise(CrystalCell::LatticeAxes::InitializeError) {CrystalCell::LatticeAxes.new([0,1,2,3])}
|
46
|
+
assert_nothing_raised {CrystalCell::LatticeAxes.new([ @vec_x, @vec_y, @vec_z ]) }
|
47
|
+
assert_raise(CrystalCell::LatticeAxes::InitializeError) {CrystalCell::LatticeAxes.new([ @vec_x, @vec_y, @vec_0 ]) }
|
48
|
+
assert_raise(CrystalCell::LatticeAxes::InitializeError) {CrystalCell::LatticeAxes.new([ @vec_x, @vec_y, [1, 2, 3, 4] ]) }
|
49
|
+
|
50
|
+
assert_in_delta(1.0, @lc1.axes[0][0], $tolerance)
|
51
|
+
assert_in_delta(0.0, @lc1.axes[0][1], $tolerance)
|
52
|
+
assert_in_delta(0.0, @lc1.axes[0][2], $tolerance)
|
53
|
+
assert_in_delta(0.0, @lc1.axes[1][0], $tolerance)
|
54
|
+
assert_in_delta(1.0, @lc1.axes[1][1], $tolerance)
|
55
|
+
assert_in_delta(0.0, @lc1.axes[1][2], $tolerance)
|
56
|
+
assert_in_delta(0.0, @lc1.axes[2][0], $tolerance)
|
57
|
+
assert_in_delta(0.0, @lc1.axes[2][1], $tolerance)
|
58
|
+
assert_in_delta(1.0, @lc1.axes[2][2], $tolerance)
|
59
|
+
|
60
|
+
assert_in_delta(- 0.577350269189626, @lc2.axes[0][0], $tolerance)
|
61
|
+
assert_in_delta( 0.204124145231932, @lc2.axes[0][1], $tolerance)
|
62
|
+
assert_in_delta( 0.353553390593274, @lc2.axes[0][2], $tolerance)
|
63
|
+
assert_in_delta( 0.000000000000000, @lc2.axes[1][0], $tolerance)
|
64
|
+
assert_in_delta( 0.612372435695795, @lc2.axes[1][1], $tolerance)
|
65
|
+
assert_in_delta( 0.353553390593274, @lc2.axes[1][2], $tolerance)
|
66
|
+
assert_in_delta( 0.000000000000000, @lc2.axes[2][0], $tolerance)
|
67
|
+
assert_in_delta( 0.000000000000000, @lc2.axes[2][1], $tolerance)
|
68
|
+
assert_in_delta( 0.707106781186548, @lc2.axes[2][2], $tolerance)
|
69
|
+
|
70
|
+
assert_in_delta(1.0, @lc3.axes[0][0], $tolerance)
|
71
|
+
assert_in_delta(0.0, @lc3.axes[0][1], $tolerance)
|
72
|
+
assert_in_delta(0.0, @lc3.axes[0][2], $tolerance)
|
73
|
+
assert_in_delta(0.0, @lc3.axes[1][0], $tolerance)
|
74
|
+
assert_in_delta(1.0, @lc3.axes[1][1], $tolerance)
|
75
|
+
assert_in_delta(0.0, @lc3.axes[1][2], $tolerance)
|
76
|
+
assert_in_delta(0.0, @lc3.axes[2][0], $tolerance)
|
77
|
+
assert_in_delta(0.0, @lc3.axes[2][1], $tolerance)
|
78
|
+
assert_in_delta(1.0, @lc3.axes[2][2], $tolerance)
|
79
|
+
|
80
|
+
assert_in_delta(0.577350269189626, @lc4.axes[0][0], $tolerance)
|
81
|
+
assert_in_delta(0.204124145231932, @lc4.axes[0][1], $tolerance)
|
82
|
+
assert_in_delta(0.353553390593274, @lc4.axes[0][2], $tolerance)
|
83
|
+
assert_in_delta(0.000000000000000, @lc4.axes[1][0], $tolerance)
|
84
|
+
assert_in_delta(0.612372435695795, @lc4.axes[1][1], $tolerance)
|
85
|
+
assert_in_delta(0.353553390593274, @lc4.axes[1][2], $tolerance)
|
86
|
+
assert_in_delta(0.000000000000000, @lc4.axes[2][0], $tolerance)
|
87
|
+
assert_in_delta(0.000000000000000, @lc4.axes[2][1], $tolerance)
|
88
|
+
assert_in_delta(0.707106781186548, @lc4.axes[2][2], $tolerance)
|
89
|
+
|
90
|
+
# triangulate の結果、b 軸の y 成分は 正方向であるべき。
|
91
|
+
assert_in_delta(-1.0, @lc6.axes[0][0], $tolerance)
|
92
|
+
assert_in_delta(-1.0, @lc6.axes[0][1], $tolerance)
|
93
|
+
assert_in_delta(1.0, @lc6.axes[0][2], $tolerance)
|
94
|
+
assert_in_delta(0.0, @lc6.axes[1][0], $tolerance)
|
95
|
+
assert_in_delta(1.0, @lc6.axes[1][1], $tolerance)
|
96
|
+
assert_in_delta(-1.0, @lc6.axes[1][2], $tolerance)
|
97
|
+
assert_in_delta(0.0, @lc6.axes[2][0], $tolerance)
|
98
|
+
assert_in_delta(0.0, @lc6.axes[2][1], $tolerance)
|
99
|
+
assert_in_delta(1.0, @lc6.axes[2][2], $tolerance)
|
100
|
+
end
|
101
|
+
|
102
|
+
## Class methods.
|
103
|
+
#
|
104
|
+
def test_new_lc
|
105
|
+
result = CrystalCell::LatticeAxes.new_lc([1.0, 1.0, 1.0, 90.0, 90.0, 90.0])
|
106
|
+
assert_equal(@lc3, result)
|
107
|
+
end
|
108
|
+
|
109
|
+
#def test_self_triangulate
|
110
|
+
# result = CrystalCell::LatticeAxes.triangulate([ [0.5, 0.5, 0.0], [0.0, 0.5, 0.5], [0.5, 0.0, 0.5] ])
|
111
|
+
# assert_in_delta(0.577350269189626, result[0][0], $tolerance)
|
112
|
+
# assert_in_delta(0.204124145231932, result[0][1], $tolerance)
|
113
|
+
# assert_in_delta(0.353553390593274, result[0][2], $tolerance)
|
114
|
+
# assert_in_delta(0.000000000000000, result[1][0], $tolerance)
|
115
|
+
# assert_in_delta(0.612372435695795, result[1][1], $tolerance)
|
116
|
+
# assert_in_delta(0.353553390593274, result[1][2], $tolerance)
|
117
|
+
# assert_in_delta(0.000000000000000, result[2][0], $tolerance)
|
118
|
+
# assert_in_delta(0.000000000000000, result[2][1], $tolerance)
|
119
|
+
# assert_in_delta(0.707106781186548, result[2][2], $tolerance)
|
120
|
+
#end
|
121
|
+
|
122
|
+
def test_self_lc_to_axes
|
123
|
+
axes = CrystalCell::LatticeAxes.lc_to_axes([ 1.0, 1.0, 1.0, 90.0, 90.0, 90.0 ])
|
124
|
+
assert_in_delta(@axes1[0][0], axes[0][0], $tolerance)
|
125
|
+
assert_in_delta(@axes1[0][1], axes[0][1], $tolerance)
|
126
|
+
assert_in_delta(@axes1[0][2], axes[0][2], $tolerance)
|
127
|
+
assert_in_delta(@axes1[1][0], axes[1][0], $tolerance)
|
128
|
+
assert_in_delta(@axes1[1][1], axes[1][1], $tolerance)
|
129
|
+
assert_in_delta(@axes1[1][2], axes[1][2], $tolerance)
|
130
|
+
assert_in_delta(@axes1[2][0], axes[2][0], $tolerance)
|
131
|
+
assert_in_delta(@axes1[2][1], axes[2][1], $tolerance)
|
132
|
+
assert_in_delta(@axes1[2][2], axes[2][2], $tolerance)
|
133
|
+
|
134
|
+
axes = CrystalCell::LatticeAxes.lc_to_axes([ 1.0, 1.0, 1.0, 90.0, 90.0, 90.0 ], false)
|
135
|
+
assert_in_delta(- @axes1[0][0], axes[0][0], $tolerance)
|
136
|
+
assert_in_delta( @axes1[0][1], axes[0][1], $tolerance)
|
137
|
+
assert_in_delta( @axes1[0][2], axes[0][2], $tolerance)
|
138
|
+
assert_in_delta( @axes1[1][0], axes[1][0], $tolerance)
|
139
|
+
assert_in_delta( @axes1[1][1], axes[1][1], $tolerance)
|
140
|
+
assert_in_delta( @axes1[1][2], axes[1][2], $tolerance)
|
141
|
+
assert_in_delta( @axes1[2][0], axes[2][0], $tolerance)
|
142
|
+
assert_in_delta( @axes1[2][1], axes[2][1], $tolerance)
|
143
|
+
assert_in_delta( @axes1[2][2], axes[2][2], $tolerance)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_self_axes_to_lc
|
147
|
+
correct = [ 1.0, 1.0, 1.0, 90.0, 90.0, 90.0 ]
|
148
|
+
assert_equal(correct, CrystalCell::LatticeAxes.axes_to_lc(@axes1))
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_equal_in_delta?
|
152
|
+
assert_equal(true , @lc1.equal_in_delta?(@lc1, 0.01, 1.0))
|
153
|
+
assert_equal(false, @lc1.equal_in_delta?(@lc2, 0.01, 1.0))
|
154
|
+
assert_equal(false, @lc1.equal_in_delta?(@lc4, 0.01, 1.0))
|
155
|
+
assert_equal(false, @lc2.equal_in_delta?(@lc1, 0.01, 1.0))
|
156
|
+
assert_equal(true , @lc2.equal_in_delta?(@lc2, 0.01, 1.0))
|
157
|
+
assert_equal(true , @lc2.equal_in_delta?(@lc4, 0.01, 1.0))
|
158
|
+
assert_equal(false, @lc4.equal_in_delta?(@lc1, 0.01, 1.0))
|
159
|
+
assert_equal(true , @lc4.equal_in_delta?(@lc2, 0.01, 1.0))
|
160
|
+
assert_equal(true , @lc4.equal_in_delta?(@lc4, 0.01, 1.0))
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_self_righthand?
|
164
|
+
# Righthand
|
165
|
+
assert_equal(true , CrystalCell::LatticeAxes.righthand?([ @vec_x, @vec_y, @vec_z ]))
|
166
|
+
assert_equal(true , CrystalCell::LatticeAxes.righthand?([ @vec_y, @vec_z, @vec_x ]))
|
167
|
+
assert_equal(true , CrystalCell::LatticeAxes.righthand?([ @vec_z, @vec_x, @vec_y ]))
|
168
|
+
|
169
|
+
# Lefthand
|
170
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_z, @vec_y, @vec_x ]))
|
171
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_x, @vec_z, @vec_y ]))
|
172
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_y, @vec_x, @vec_z ]))
|
173
|
+
|
174
|
+
# Including zero vector.
|
175
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_0, @vec_y, @vec_z ]))
|
176
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_0, @vec_z, @vec_x ]))
|
177
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_0, @vec_x, @vec_y ]))
|
178
|
+
|
179
|
+
# One vector is on the plane of residual two vectors.
|
180
|
+
assert_equal(false, CrystalCell::LatticeAxes.righthand?([ @vec_x, @vec_y, @vec_1 ]))
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_self_lefthand?
|
184
|
+
# Righthand
|
185
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_x, @vec_y, @vec_z ]))
|
186
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_y, @vec_z, @vec_x ]))
|
187
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_z, @vec_x, @vec_y ]))
|
188
|
+
|
189
|
+
# Lefthand
|
190
|
+
assert_equal(true , CrystalCell::LatticeAxes.lefthand?([ @vec_z, @vec_y, @vec_x ]))
|
191
|
+
assert_equal(true , CrystalCell::LatticeAxes.lefthand?([ @vec_x, @vec_z, @vec_y ]))
|
192
|
+
assert_equal(true , CrystalCell::LatticeAxes.lefthand?([ @vec_y, @vec_x, @vec_z ]))
|
193
|
+
|
194
|
+
# Including zero vector.
|
195
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_0, @vec_y, @vec_z ]))
|
196
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_0, @vec_z, @vec_x ]))
|
197
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_0, @vec_x, @vec_y ]))
|
198
|
+
|
199
|
+
# One vector is on the plane of residual two vectors.
|
200
|
+
assert_equal(false, CrystalCell::LatticeAxes.lefthand?([ @vec_x, @vec_y, @vec_1 ]))
|
201
|
+
end
|
202
|
+
|
203
|
+
## Instance methods.
|
204
|
+
|
205
|
+
def test_get_lattice_constants
|
206
|
+
assert_in_delta( 1.0, @lc1.get_lattice_constants[0], $tolerance)
|
207
|
+
assert_in_delta( 1.0, @lc1.get_lattice_constants[1], $tolerance)
|
208
|
+
assert_in_delta( 1.0, @lc1.get_lattice_constants[2], $tolerance)
|
209
|
+
assert_in_delta(90.0, @lc1.get_lattice_constants[3], $tolerance)
|
210
|
+
assert_in_delta(90.0, @lc1.get_lattice_constants[4], $tolerance)
|
211
|
+
assert_in_delta(90.0, @lc1.get_lattice_constants[5], $tolerance)
|
212
|
+
assert_in_delta(Math::sqrt(0.5), @lc2.get_lattice_constants[0], $tolerance)
|
213
|
+
assert_in_delta(Math::sqrt(0.5), @lc2.get_lattice_constants[1], $tolerance)
|
214
|
+
assert_in_delta(Math::sqrt(0.5), @lc2.get_lattice_constants[2], $tolerance)
|
215
|
+
assert_in_delta(60.0, @lc2.get_lattice_constants[3], $tolerance)
|
216
|
+
assert_in_delta(60.0, @lc2.get_lattice_constants[4], $tolerance)
|
217
|
+
assert_in_delta(60.0, @lc2.get_lattice_constants[5], $tolerance)
|
218
|
+
assert_in_delta( 1.0, @lc3.get_lattice_constants[0], $tolerance)
|
219
|
+
assert_in_delta( 1.0, @lc3.get_lattice_constants[1], $tolerance)
|
220
|
+
assert_in_delta( 1.0, @lc3.get_lattice_constants[2], $tolerance)
|
221
|
+
assert_in_delta(90.0, @lc3.get_lattice_constants[3], $tolerance)
|
222
|
+
assert_in_delta(90.0, @lc3.get_lattice_constants[4], $tolerance)
|
223
|
+
assert_in_delta(90.0, @lc3.get_lattice_constants[5], $tolerance)
|
224
|
+
assert_in_delta(Math::sqrt(0.5), @lc4.get_lattice_constants[0], $tolerance)
|
225
|
+
assert_in_delta(Math::sqrt(0.5), @lc4.get_lattice_constants[1], $tolerance)
|
226
|
+
assert_in_delta(Math::sqrt(0.5), @lc4.get_lattice_constants[2], $tolerance)
|
227
|
+
assert_in_delta(60.0, @lc4.get_lattice_constants[3], $tolerance)
|
228
|
+
assert_in_delta(60.0, @lc4.get_lattice_constants[4], $tolerance)
|
229
|
+
assert_in_delta(60.0, @lc4.get_lattice_constants[5], $tolerance)
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_righthand?
|
233
|
+
assert_equal(true , @lc1.righthand?)
|
234
|
+
assert_equal(false, @lc2.righthand?)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_lefthand?
|
238
|
+
assert_equal(false, @lc1.lefthand?)
|
239
|
+
assert_equal(true , @lc2.lefthand?)
|
240
|
+
end
|
241
|
+
|
242
|
+
#def test_internal2cartesian
|
243
|
+
# assert_raise(CrystalCell::LatticeAxes::TypeError){
|
244
|
+
# @lc5.internal2cartesian([ 2.0, 3.0, 4.0 ])
|
245
|
+
# }
|
246
|
+
# assert_in_delta(2.0, @lc5.internal2cartesian([ 2.0, 3.0, 4.0 ])[0], $tolerance)
|
247
|
+
# assert_in_delta(5.0, @lc5.internal2cartesian([ 2.0, 3.0, 4.0 ])[1], $tolerance)
|
248
|
+
# assert_in_delta(9.0, @lc5.internal2cartesian([ 2.0, 3.0, 4.0 ])[2], $tolerance)
|
249
|
+
#end
|
250
|
+
|
251
|
+
#def test_cartesian2internal
|
252
|
+
# assert_in_delta(2.0, @lc5.cartesian2internal([ 2.0, 5.0, 9.0 ])[0], $tolerance)
|
253
|
+
# assert_in_delta(3.0, @lc5.cartesian2internal([ 2.0, 5.0, 9.0 ])[1], $tolerance)
|
254
|
+
# assert_in_delta(4.0, @lc5.cartesian2internal([ 2.0, 5.0, 9.0 ])[2], $tolerance)
|
255
|
+
#end
|
256
|
+
|
257
|
+
def test_equal
|
258
|
+
assert_equal(true , @lc1 == @lc1)
|
259
|
+
assert_equal(true , @lc2 == @lc2)
|
260
|
+
assert_equal(true , @lc3 == @lc3)
|
261
|
+
|
262
|
+
assert_equal(false, @lc1 == @lc2)
|
263
|
+
assert_equal(false, @lc2 == @lc3)
|
264
|
+
assert_equal(true , @lc3 == @lc1)
|
265
|
+
|
266
|
+
assert_equal(true , @lc1 == @lc3)
|
267
|
+
assert_equal(false, @lc2 == @lc1)
|
268
|
+
assert_equal(false, @lc3 == @lc2)
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_triangulate
|
272
|
+
t = CrystalCell::LatticeAxes.new([ [0.5, 0.5, 0.0], [0.0, 0.5, 0.5], [0.5, 0.0, 0.5] ])
|
273
|
+
assert_in_delta(0.577350269189626, t[0][0], $tolerance)
|
274
|
+
assert_in_delta(0.204124145231932, t[0][1], $tolerance)
|
275
|
+
assert_in_delta(0.353553390593274, t[0][2], $tolerance)
|
276
|
+
assert_in_delta(0.000000000000000, t[1][0], $tolerance)
|
277
|
+
assert_in_delta(0.612372435695795, t[1][1], $tolerance)
|
278
|
+
assert_in_delta(0.353553390593274, t[1][2], $tolerance)
|
279
|
+
assert_in_delta(0.000000000000000, t[2][0], $tolerance)
|
280
|
+
assert_in_delta(0.000000000000000, t[2][1], $tolerance)
|
281
|
+
assert_in_delta(0.707106781186548, t[2][2], $tolerance)
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_multiply
|
285
|
+
assert_equal(
|
286
|
+
CrystalCell::LatticeAxes.new([ [2.0, 2.0, 0.0], [2.0, 0.0, 2.0], [0.0, 2.0, 2.0] ]),
|
287
|
+
@lc2 * 4.0
|
288
|
+
)
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_to_a
|
292
|
+
results = @lc1.to_a
|
293
|
+
corrects = [ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ]
|
294
|
+
assert_equal(corrects.size, results.size)
|
295
|
+
assert_equal(corrects[0].size, results[0].size)
|
296
|
+
assert_equal(corrects[1].size, results[1].size)
|
297
|
+
assert_equal(corrects[2].size, results[2].size)
|
298
|
+
assert_in_delta(corrects[0][0], results[0][0])
|
299
|
+
assert_in_delta(corrects[0][1], results[0][1])
|
300
|
+
assert_in_delta(corrects[0][2], results[0][2])
|
301
|
+
assert_in_delta(corrects[1][0], results[1][0])
|
302
|
+
assert_in_delta(corrects[1][1], results[1][1])
|
303
|
+
assert_in_delta(corrects[1][2], results[1][2])
|
304
|
+
assert_in_delta(corrects[2][0], results[2][0])
|
305
|
+
assert_in_delta(corrects[2][1], results[2][1])
|
306
|
+
assert_in_delta(corrects[2][2], results[2][2])
|
307
|
+
end
|
308
|
+
|
293
309
|
|
294
310
|
|
295
311
|
end
|