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,284 @@
1
+ # VESTA で使われている描画色と ionic radii をまとめたもの。
2
+ # 半径もあるが、これは原子半径やイオン半径そのものではない。
3
+ # 描画を主眼にして補正をかけている。
4
+ # VESTA は未知のものは 76 76 76 0.8 とするようだ。
5
+
6
+ class CrystalCell::Povray::Element < CrystalCell::Element
7
+ #class CrystalCell::Povray::Element
8
+ #radii
9
+ IONIC_RADII = [
10
+ nil,
11
+ 0.2 , 1.22 ,
12
+ 0.59 , 0.27 , 0.11 , 0.15 , 1.46 , 1.4 , 1.33 , 1.6 ,
13
+ 1.02 , 0.72 , 0.39 , 0.26 , 0.17 , 1.84 , 1.81 , 1.92 ,
14
+ 1.51 , 1.12 , 0.745, 0.605, 0.58 , 0.615, 0.83 , 0.78 , 0.745, 0.69 ,
15
+ 0.73 , 0.74 , 0.62 , 0.53 , 0.335, 1.98 , 1.96 , 1.98 ,
16
+ 1.61 , 1.26 , 1.019, 0.72 , 0.64 , 0.59 , 0.56 , 0.62 , 0.665, 0.86 ,
17
+ 1.15 , 0.95 , 0.8 , 0.69 , 0.76 , 2.21 , 2.2 , 0.48 ,
18
+ 1.74 , 1.42 , 1.16 , 0.97 , 1.126, 1.109, 1.093, 1.27 , 1.066, 1.053, 1.04 ,
19
+ 1.027, 1.015, 1.004, 0.994, 0.985, 0.977, 0.71 , 0.64 , 0.6 , 0.53 , 0.63 ,
20
+ 0.625, 0.625, 1.37 , 1.02 , 0.885, 1.19 , 1.03 , 0.94 , 0.62 , 0.8 ,
21
+ 1.8 , 1.48 , 1.12 , 1.05 , 0.78 , 0.73 , 0.75 , 0.86 , 0.975, 0.8 , 0.8 ,
22
+ 0.8 , 0.8 , 0.8 , 0.8 , 0.8 , 0.8 ,
23
+ ]
24
+
25
+ COLOR = [ nil,
26
+ [ 255, 204, 204], [ 252, 232, 206],
27
+ [ 134, 224, 116], [ 94, 215, 123], [ 31, 162, 15], [ 128, 73, 41],
28
+ [ 176, 185, 230], [ 254, 3, 0], [ 176, 185, 230], [ 254, 55, 181],
29
+ [ 249, 220, 60], [ 251, 123, 21], [ 129, 178, 214], [ 27, 59, 250],
30
+ [ 192, 156, 194], [ 255, 250, 0], [ 49, 252, 2], [ 207, 254, 196],
31
+ [ 161, 33, 246], [ 90, 150, 189], [ 181, 99, 171], [ 120, 202, 255],
32
+ [ 229, 25, 0], [ 0, 0, 158], [ 168, 8, 158], [ 181, 113, 0],
33
+ [ 0, 0, 175], [ 183, 187, 189], [ 34, 71, 220], [ 143, 143, 129],
34
+ [ 158, 227, 115], [ 126, 110, 166], [ 116, 208, 87], [ 154, 239, 15],
35
+ [ 126, 49, 2], [ 250, 193, 243],
36
+ [ 255, 0, 153], [ 0, 255, 38], [ 102, 152, 142], [ 0, 255, 0],
37
+ [ 76, 178, 118], [ 179, 134, 175], [ 205, 175, 202], [ 207, 183, 173],
38
+ [ 205, 209, 171], [ 193, 195, 184], [ 183, 187, 189], [ 242, 30, 220],
39
+ [ 215, 128, 187], [ 154, 142, 185], [ 215, 131, 79], [ 173, 162, 81],
40
+ [ 142, 31, 138], [ 154, 161, 248],
41
+ [ 14, 254, 185], [ 30, 239, 44], [ 90, 196, 73], [ 209, 252, 6],
42
+ [ 252, 225, 5], [ 251, 141, 6], [ 0, 0, 244], [ 252, 6, 125],
43
+ [ 250, 7, 213], [ 192, 3, 255], [ 113, 4, 254], [ 49, 6, 252],
44
+ [ 7, 65, 251], [ 73, 114, 58], [ 0, 0, 224], [ 39, 252, 244],
45
+ [ 38, 253, 181], [ 180, 179, 89], [ 183, 154, 86], [ 141, 138, 127],
46
+ [ 179, 176, 142], [ 200, 177, 120], [ 201, 206, 114], [ 203, 197, 191],
47
+ [ 254, 178, 56], [ 211, 183, 203], [ 149, 137, 108], [ 82, 83, 91],
48
+ [ 210, 47, 247], [ 0, 0, 255], [ 0, 0, 255], [ 255, 255, 0],
49
+ [ 0, 0, 0], [ 109, 169, 88], [ 100, 158, 114], [ 37, 253, 120],
50
+ [ 41, 250, 53], [ 121, 161, 170], [ 76, 76, 76], [ 76, 76, 76],
51
+ [ 76, 76, 76], [ 76, 76, 76], [ 76, 76, 76], [ 76, 76, 76],
52
+ [ 76, 76, 76], [ 76, 76, 76], [ 76, 76, 76], [ 76, 76, 76],
53
+ [ 76, 76, 76],
54
+ ]
55
+
56
+ def self.draw_radius(id)
57
+ id = self.symbol_to_num(id) if id.class == String
58
+ IONIC_RADII[id]
59
+ end
60
+
61
+ def self.color(id)
62
+ id = self.symbol_to_num(id) if id.class == String
63
+ COLOR[id].map {|i| i.to_f / 255.0}
64
+ end
65
+
66
+ end
67
+
68
+ #'H' => 0.2 ,
69
+ #'He' => 1.22 ,
70
+ #'Li' => 0.59 ,
71
+ #'Be' => 0.27 ,
72
+ #'B' => 0.11 ,
73
+ #'C' => 0.15 ,
74
+ #'N' => 1.46 ,
75
+ #'O' => 1.4 ,
76
+ #'F' => 1.33 ,
77
+ #'Ne' => 1.6 ,
78
+ #'Na' => 1.02 ,
79
+ #'Mg' => 0.72 ,
80
+ #'Al' => 0.39 ,
81
+ #'Si' => 0.26 ,
82
+ #'P' => 0.17 ,
83
+ #'S' => 1.84 ,
84
+ #'Cl' => 1.81 ,
85
+ #'Ar' => 1.92 ,
86
+ #'K' => 1.51 ,
87
+ #'Ca' => 1.12 ,
88
+ #'Sc' => 0.745,
89
+ #'Ti' => 0.605,
90
+ #'V' => 0.58 ,
91
+ #'Cr' => 0.615,
92
+ #'Mn' => 0.83 ,
93
+ #'Fe' => 0.78 ,
94
+ #'Co' => 0.745,
95
+ #'Ni' => 0.69 ,
96
+ #'Cu' => 0.73 ,
97
+ #'Zn' => 0.74 ,
98
+ #'Ga' => 0.62 ,
99
+ #'Ge' => 0.53 ,
100
+ #'As' => 0.335,
101
+ #'Se' => 1.98 ,
102
+ #'Br' => 1.96 ,
103
+ #'Kr' => 1.98 ,
104
+ #'Rb' => 1.61 ,
105
+ #'Sr' => 1.26 ,
106
+ #'Y' => 1.019,
107
+ #'Zr' => 0.72 ,
108
+ #'Nb' => 0.64 ,
109
+ #'Mo' => 0.59 ,
110
+ #'Tc' => 0.56 ,
111
+ #'Ru' => 0.62 ,
112
+ #'Rh' => 0.665,
113
+ #'Pd' => 0.86 ,
114
+ #'Ag' => 1.15 ,
115
+ #'Cd' => 0.95 ,
116
+ #'In' => 0.8 ,
117
+ #'Sn' => 0.69 ,
118
+ #'Sb' => 0.76 ,
119
+ #'Te' => 2.21 ,
120
+ #'I' => 2.2 ,
121
+ #'Xe' => 0.48 ,
122
+ #'Cs' => 1.74 ,
123
+ #'Ba' => 1.42 ,
124
+ #'La' => 1.16 ,
125
+ #'Ce' => 0.97 ,
126
+ #'Pr' => 1.126,
127
+ #'Nd' => 1.109,
128
+ #'Pm' => 1.093,
129
+ #'Sm' => 1.27 ,
130
+ #'Eu' => 1.066,
131
+ #'Gd' => 1.053,
132
+ #'Tb' => 1.04 ,
133
+ #'Dy' => 1.027,
134
+ #'Ho' => 1.015,
135
+ #'Er' => 1.004,
136
+ #'Tm' => 0.994,
137
+ #'Yb' => 0.985,
138
+ #'Lu' => 0.977,
139
+ #'Hf' => 0.71 ,
140
+ #'Ta' => 0.64 ,
141
+ #'W' => 0.6 ,
142
+ #'Re' => 0.53 ,
143
+ #'Os' => 0.63 ,
144
+ #'Ir' => 0.625,
145
+ #'Pt' => 0.625,
146
+ #'Au' => 1.37 ,
147
+ #'Hg' => 1.02 ,
148
+ #'Tl' => 0.885,
149
+ #'Pb' => 1.19 ,
150
+ #'Bi' => 1.03 ,
151
+ #'Po' => 0.94 ,
152
+ #'At' => 0.62 ,
153
+ #'Rn' => 0.8 ,
154
+ #'Fr' => 1.8 ,
155
+ #'Ra' => 1.48 ,
156
+ #'Ac' => 1.12 ,
157
+ #'Th' => 1.05 ,
158
+ #'Pa' => 0.78 ,
159
+ #'U' => 0.73 ,
160
+ #'Np' => 0.75 ,
161
+ #'Pu' => 0.86 ,
162
+ #'Am' => 0.975,
163
+ #'Cm' => 0.8 ,
164
+ #'Bk' => 0.8 ,
165
+ #'Cf' => 0.8 ,
166
+ #'Es' => 0.8 ,
167
+ #'Fm' => 0.8 ,
168
+ #'Md' => 0.8 ,
169
+ #'No' => 0.8 ,
170
+ #'Lr' => 0.8 ,
171
+
172
+ #COLOR = {
173
+ # ##1
174
+ # 'H' => [ 255, 204, 204],
175
+ # 'He' => [ 252, 232, 206],
176
+ # ##2
177
+ # 'Li' => [ 134, 224, 116],
178
+ # 'Be' => [ 94, 215, 123],
179
+ # 'B' => [ 31, 162, 15],
180
+ # 'C' => [ 128, 73, 41],
181
+ # 'N' => [ 176, 185, 230],
182
+ # 'O' => [ 254, 3, 0],
183
+ # 'F' => [ 176, 185, 230],
184
+ # 'Ne' => [ 254, 55, 181],
185
+ # ##3
186
+ # 'Na' => [ 249, 220, 60],
187
+ # 'Mg' => [ 251, 123, 21],
188
+ # 'Al' => [ 129, 178, 214],
189
+ # 'Si' => [ 27, 59, 250],
190
+ # 'P' => [ 192, 156, 194],
191
+ # 'S' => [ 255, 250, 0],
192
+ # 'Cl' => [ 49, 252, 2],
193
+ # 'Ar' => [ 207, 254, 196],
194
+ # ##4
195
+ # 'K' => [ 161, 33, 246],
196
+ # 'Ca' => [ 90, 150, 189],
197
+ # 'Sc' => [ 181, 99, 171],
198
+ # 'Ti' => [ 120, 202, 255],
199
+ # 'V' => [ 229, 25, 0],
200
+ # 'Cr' => [ 0, 0, 158],
201
+ # 'Mn' => [ 168, 8, 158],
202
+ # 'Fe' => [ 181, 113, 0],
203
+ # 'Co' => [ 0, 0, 175],
204
+ # 'Ni' => [ 183, 187, 189],
205
+ # 'Cu' => [ 34, 71, 220],
206
+ # 'Zn' => [ 143, 143, 129],
207
+ # 'Ga' => [ 158, 227, 115],
208
+ # 'Ge' => [ 126, 110, 166],
209
+ # 'As' => [ 116, 208, 87],
210
+ # 'Se' => [ 154, 239, 15],
211
+ # 'Br' => [ 126, 49, 2],
212
+ # 'Kr' => [ 250, 193, 243],
213
+ # ##5
214
+ # 'Rb' => [ 255, 0, 153],
215
+ # 'Sr' => [ 0, 255, 38],
216
+ # 'Y' => [ 102, 152, 142],
217
+ # 'Zr' => [ 0, 255, 0],
218
+ # 'Nb' => [ 76, 178, 118],
219
+ # 'Mo' => [ 179, 134, 175],
220
+ # 'Tc' => [ 205, 175, 202],
221
+ # 'Ru' => [ 207, 183, 173],
222
+ # 'Rh' => [ 205, 209, 171],
223
+ # 'Pd' => [ 193, 195, 184],
224
+ # 'Ag' => [ 183, 187, 189],
225
+ # 'Cd' => [ 242, 30, 220],
226
+ # 'In' => [ 215, 128, 187],
227
+ # 'Sn' => [ 154, 142, 185],
228
+ # 'Sb' => [ 215, 131, 79],
229
+ # 'Te' => [ 173, 162, 81],
230
+ # 'I' => [ 142, 31, 138],
231
+ # 'Xe' => [ 154, 161, 248],
232
+ # ##6
233
+ # 'Cs' => [ 14, 254, 185],
234
+ # 'Ba' => [ 30, 239, 44],
235
+ # 'La' => [ 90, 196, 73],
236
+ # 'Ce' => [ 209, 252, 6],
237
+ # 'Pr' => [ 252, 225, 5],
238
+ # 'Nd' => [ 251, 141, 6],
239
+ # 'Pm' => [ 0, 0, 244],
240
+ # 'Sm' => [ 252, 6, 125],
241
+ # 'Eu' => [ 250, 7, 213],
242
+ # 'Gd' => [ 192, 3, 255],
243
+ # 'Tb' => [ 113, 4, 254],
244
+ # 'Dy' => [ 49, 6, 252],
245
+ # 'Ho' => [ 7, 65, 251],
246
+ # 'Er' => [ 73, 114, 58],
247
+ # 'Tm' => [ 0, 0, 224],
248
+ # 'Yb' => [ 39, 252, 244],
249
+ # 'Lu' => [ 38, 253, 181],
250
+ # 'Hf' => [ 180, 179, 89],
251
+ # 'Ta' => [ 183, 154, 86],
252
+ # 'W' => [ 141, 138, 127],
253
+ # 'Re' => [ 179, 176, 142],
254
+ # 'Os' => [ 200, 177, 120],
255
+ # 'Ir' => [ 201, 206, 114],
256
+ # 'Pt' => [ 203, 197, 191],
257
+ # 'Au' => [ 254, 178, 56],
258
+ # 'Hg' => [ 211, 183, 203],
259
+ # 'Tl' => [ 149, 137, 108],
260
+ # 'Pb' => [ 82, 83, 91],
261
+ # 'Bi' => [ 210, 47, 247],
262
+ # 'Po' => [ 0, 0, 255],
263
+ # 'At' => [ 0, 0, 255],
264
+ # 'Rn' => [ 255, 255, 0],
265
+ # ##7
266
+ # 'Fr' => [ 0, 0, 0],
267
+ # 'Ra' => [ 109, 169, 88],
268
+ # 'Ac' => [ 100, 158, 114],
269
+ # 'Th' => [ 37, 253, 120],
270
+ # 'Pa' => [ 41, 250, 53],
271
+ # 'U' => [ 121, 161, 170],
272
+ # 'Np' => [ 76, 76, 76],
273
+ # 'Pu' => [ 76, 76, 76],
274
+ # 'Am' => [ 76, 76, 76],
275
+ # 'Cm' => [ 76, 76, 76],
276
+ # 'Bk' => [ 76, 76, 76],
277
+ # 'Cf' => [ 76, 76, 76],
278
+ # 'Es' => [ 76, 76, 76],
279
+ # 'Fm' => [ 76, 76, 76],
280
+ # 'Md' => [ 76, 76, 76],
281
+ # 'No' => [ 76, 76, 76],
282
+ # 'Lr' => [ 76, 76, 76],
283
+ #}
284
+
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env ruby # coding: utf-8
2
+
3
+ class Mageo::Sphere
4
+ # povray 形式の文字列を返す。
5
+ # color は Float による配列。通常、0〜1の範囲。
6
+ def to_pov(color)
7
+ sprintf( "object { sphere{<% 7.4f, % 7.4f, % 7.4f>, %7.4f} pigment {color rgb <%4.2f, %4.2f, %4.2f>} }",
8
+ *position, radius, *color)
9
+ end
10
+ end
11
+
12
+
@@ -0,0 +1,17 @@
1
+ #! /usr/bin/env ruby # coding: utf-8
2
+
3
+ class Mageo::Triangle
4
+ # povray 形式の文字列を返す。
5
+ # color は Float による配列。通常、0〜1の範囲。
6
+ def to_pov(color)
7
+ v = self.vertices
8
+ result = "polygon { 4, " + sprintf("<%7.4f, %7.4f, %7.4f>, ", v[0][0], v[0][1], v[0][2]) +
9
+ sprintf("<%7.4f, %7.4f, %7.4f>, ", v[1][0], v[1][1], v[1][2]) +
10
+ sprintf("<%7.4f, %7.4f, %7.4f>, ", v[2][0], v[2][1], v[2][2]) +
11
+ sprintf("<%7.4f, %7.4f, %7.4f> " , v[0][0], v[0][1], v[0][2]) +
12
+ "pigment { color rgb <1, 0, 0> } }"
13
+ return result
14
+ end
15
+ end
16
+
17
+
@@ -0,0 +1,7 @@
1
+ module CrystalCell::Povray; end
2
+
3
+ require 'crystalcell/povray/cell.rb'
4
+ require 'crystalcell/povray/cylinder.rb'
5
+ require 'crystalcell/povray/element.rb'
6
+ require 'crystalcell/povray/sphere.rb'
7
+ require 'crystalcell/povray/triangle.rb'
data/lib/crystalcell.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  require "rubygems"
2
2
  require "mageo"
3
+ require "maset/mapping"
4
+ #require "builtinextension"
5
+ require "array/selectindices.rb"
6
+ require "matrix"
3
7
 
4
- #include Mageo
5
8
  module CrystalCell; end
6
9
 
7
10
  require "crystalcell/latticeaxes.rb"
@@ -9,3 +12,4 @@ require "crystalcell/element.rb"
9
12
  require "crystalcell/atom.rb"
10
13
  require "crystalcell/cell.rb"
11
14
  require "crystalcell/periodiccell.rb"
15
+ require 'crystalcell/povray.rb'
@@ -0,0 +1,179 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "helper"
5
+
6
+ class TC_Povray_Sphere < Test::Unit::TestCase
7
+ def setup
8
+ @s00 = Mageo::Sphere.new( [ 1.0, 2.0, 3.0 ], 2.0)
9
+ end
10
+
11
+ def test_to_pov
12
+ assert_equal(
13
+ "object { sphere{< 1.0000, 2.0000, 3.0000>, 2.0000} pigment {color rgb <0.30, 0.60, 0.90>} }",
14
+ @s00.to_pov([0.3, 0.6, 0.9]) )
15
+ end
16
+ end
17
+
18
+ class TC_Povray_Cylinder < Test::Unit::TestCase
19
+ def setup
20
+ @c00 = Mageo::Cylinder.new([[ 1.0, 2.0, 3.0 ], [4.0, 5.0, 6.0]], 2.0)
21
+ end
22
+
23
+ def test_to_pov
24
+ assert_equal(
25
+ "object { cylinder{ < 1.0000, 2.0000, 3.0000>, < 4.0000, 5.0000, 6.0000>, 2.0000 } pigment { color rgb <0.30, 0.60, 0.90> } }",
26
+ @c00.to_pov([0.3, 0.6, 0.9]) )
27
+ end
28
+ end
29
+
30
+ class TC_Povray_Triangle < Test::Unit::TestCase
31
+ def setup
32
+ @t00 = Mageo::Triangle.new(
33
+ [[ 1.0, 2.0, 3.0 ], [4.0, 5.0, 6.0], [0.3, 0.6, 0.9 ]]
34
+ )
35
+ end
36
+
37
+ def test_to_pov
38
+ assert_equal(
39
+ "polygon { 4, < 1.0000, 2.0000, 3.0000>, < 4.0000, 5.0000, 6.0000>, < 0.3000, 0.6000, 0.9000>, < 1.0000, 2.0000, 3.0000> pigment { color rgb <1, 0, 0> } }",
40
+ @t00.to_pov([0.3, 0.6, 0.9])
41
+ )
42
+ end
43
+ end
44
+
45
+ class CrystalCell::Povray::Cell
46
+ #public :atoms_to_povs, :bonds_to_povs, :lattice_to_povs
47
+ public :atom_to_pov
48
+ public :periodic_translations
49
+
50
+ end
51
+ class TC_Povray_Cell < Test::Unit::TestCase
52
+ def setup
53
+ axes = [
54
+ [2.0, 0.0, 0.0],
55
+ [0.0, 2.0, 0.0],
56
+ [0.0, 0.0, 2.0],
57
+ ]
58
+ atoms = [
59
+ CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]),
60
+ CrystalCell::Atom.new("O", [0.2, 0.3, 0.4]),
61
+ ]
62
+ @c00 = CrystalCell::Povray::Cell.new(axes, atoms)
63
+ end
64
+
65
+ def test_atoms_to_povs
66
+ # without tolerance
67
+ assert_equal(
68
+ [ "object { sphere{< 0.0000, 0.0000, 0.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
69
+ "object { sphere{< 0.4000, 0.6000, 0.8000>, 0.4200} pigment {color rgb <1.00, 0.01, 0.00>} } // O\n"
70
+ ],
71
+ @c00.atoms_to_povs
72
+ )
73
+
74
+ # with tolerance
75
+ corrects = [
76
+ "object { sphere{< 0.0000, 0.0000, 0.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
77
+ "object { sphere{< 2.0000, 0.0000, 0.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
78
+ "object { sphere{< 0.0000, 2.0000, 0.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
79
+ "object { sphere{< 2.0000, 2.0000, 0.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
80
+ "object { sphere{< 0.0000, 0.0000, 2.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
81
+ "object { sphere{< 2.0000, 0.0000, 2.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
82
+ "object { sphere{< 0.0000, 2.0000, 2.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
83
+ "object { sphere{< 2.0000, 2.0000, 2.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
84
+ "object { sphere{< 0.4000, 0.6000, 0.8000>, 0.4200} pigment {color rgb <1.00, 0.01, 0.00>} } // O\n",
85
+ ]
86
+ t = @c00.atoms_to_povs(0.01)
87
+ corrects.each_with_index do |correct, index|
88
+ assert_equal(correct, t[index], "line #{index.to_s}")
89
+ end
90
+ assert_equal(corrects.size, t.size)
91
+ end
92
+
93
+ def test_bonds_to_povs
94
+ ## PeriodicCell.find_bonds に依存しており、
95
+ ## これがなんか不安な動作。 -0.0000 になるとか、誤差だろうなあ。
96
+ ## このためテストは頑張って作らない。
97
+ ## PeriodicCell.find_bonds をリファクタリングとかしてから
98
+ ## テストをするかもしれん。
99
+
100
+ #assert_equal( [
101
+ # "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.4000, 0.6000, 0.8000>, 0.0500 } pigment { color rgb <0.75, 0.75, 0.75> } }"
102
+ # ],
103
+ # @c00.bonds_to_povs(["Li", "O"], 0.0, 1.1)
104
+ #)
105
+
106
+ #assert_equal( [
107
+ # "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.4000, 0.6000, 0.8000>, 0.0500 } pigment { color rgb <0.75, 0.75, 0.75> } }"
108
+ # ],
109
+ # @c00.bonds_to_povs(["O", "Li"], 0, 1.1 )
110
+ #)
111
+
112
+ #assert_equal([
113
+ # "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.0000, 0.0000, 0.0000>, 0.0500 } pigment { color rgb <0.75, 0.75, 0.75> } }"
114
+ # ],
115
+ # @c00.bonds_to_povs(["Li", "Li"], 0, 2.0 )
116
+ #)
117
+ end
118
+
119
+ def test_lattice_to_povs
120
+ corrects = [
121
+ "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.0000, 0.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
122
+ "object { cylinder{ < 0.0000, 2.0000, 0.0000>, < 0.0000, 2.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
123
+ "object { cylinder{ < 2.0000, 0.0000, 0.0000>, < 2.0000, 0.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
124
+ "object { cylinder{ < 2.0000, 2.0000, 0.0000>, < 2.0000, 2.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
125
+ "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.0000, 2.0000, 0.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
126
+ "object { cylinder{ < 2.0000, 0.0000, 0.0000>, < 2.0000, 2.0000, 0.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
127
+ "object { cylinder{ < 0.0000, 0.0000, 2.0000>, < 0.0000, 2.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
128
+ "object { cylinder{ < 2.0000, 0.0000, 2.0000>, < 2.0000, 2.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
129
+ "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 2.0000, 0.0000, 0.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
130
+ "object { cylinder{ < 0.0000, 0.0000, 2.0000>, < 2.0000, 0.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
131
+ "object { cylinder{ < 0.0000, 2.0000, 0.0000>, < 2.0000, 2.0000, 0.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n",
132
+ "object { cylinder{ < 0.0000, 2.0000, 2.0000>, < 2.0000, 2.0000, 2.0000>, 0.1000 } pigment { color rgb <0.50, 0.50, 0.50> } }\n" ,
133
+ ]
134
+ t = @c00.lattice_to_povs
135
+ corrects.each_with_index do |correct, index|
136
+ assert_equal(correct, t[index], "line #{index.to_s}")
137
+ end
138
+ assert_equal(corrects.size, t.size)
139
+ end
140
+
141
+ def test_atom_to_pov
142
+ assert_equal(
143
+ "object { sphere{< 0.2000, 0.4000, 0.6000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
144
+ @c00.atom_to_pov( CrystalCell::Atom.new("Li", [0.1, 0.2, 0.3]))
145
+ )
146
+ end
147
+
148
+ def test_periodic_translations
149
+ corrects = [
150
+ Mageo::Vector3DInternal[0.0, 0.0, 0.0],
151
+ Mageo::Vector3DInternal[1.0, 0.0, 0.0],
152
+ Mageo::Vector3DInternal[0.0, 1.0, 0.0],
153
+ Mageo::Vector3DInternal[1.0, 1.0, 0.0],
154
+ Mageo::Vector3DInternal[0.0, 0.0, 1.0],
155
+ Mageo::Vector3DInternal[1.0, 0.0, 1.0],
156
+ Mageo::Vector3DInternal[0.0, 1.0, 1.0],
157
+ Mageo::Vector3DInternal[1.0, 1.0, 1.0],
158
+ ]
159
+ t = @c00.periodic_translations([0.0, 0.0, 0.0], 0.1)
160
+ assert_equal(corrects, t)
161
+
162
+ corrects = [
163
+ Mageo::Vector3DInternal[0.0, 0.0, 0.0],
164
+ Mageo::Vector3DInternal[1.0, 0.0, 0.0],
165
+ Mageo::Vector3DInternal[0.0, 1.0, 0.0],
166
+ Mageo::Vector3DInternal[1.0, 1.0, 0.0],
167
+ ]
168
+ t = @c00.periodic_translations([0.0, 0.0, 0.5], 0.1)
169
+ assert_equal(corrects, t)
170
+
171
+ corrects = [
172
+ Mageo::Vector3DInternal[0.0, 0.0, 0.0],
173
+ ]
174
+ t = @c00.periodic_translations([0.0, 0.0, 0.0], 0.0)
175
+ assert_equal(corrects, t)
176
+ end
177
+
178
+ end
179
+