crystalcell 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a6d81b3b2df5aebe2d59092c8af9a06a86de351
4
- data.tar.gz: 5956faf1dcd9aba246f3738ec238dd99d10bf0f6
3
+ metadata.gz: f9397d63b61597552c608dbef090bd1648bb5685
4
+ data.tar.gz: 7b10b0f30d8552a5e6be3481e3735cad5d595ed2
5
5
  SHA512:
6
- metadata.gz: 93d44dd90fcc58571b9db57aa3cf1f072ab2469743d2d190bd17bf0b046f38f1ad3b2e5fd59d05fc7e3ef9efd75b706d834031830375b4d1fbf1f3c2d70b426b
7
- data.tar.gz: 7b07a0e21b1972342ef2b647f215b4ec66c02aedeafead6de6c72d076250fc44d05366da87df2ff7a2f236b0ca0ff02d183250787cc7c2c623d2372922101a28
6
+ metadata.gz: 9392b319f43e8b50921e1fe25b4b4a4037d6c21d24f729290620b71be337f9b5631d2e1e3552ad7dbd42f1edc5ef0e1dfbb64f94b4233103c47cf0055b09e3ce
7
+ data.tar.gz: b8deedf28f6e4a0420f3a7873119998ca0a6557ab9769a10e6e56e8b733ab8213d564883f050a4127ded7b133958a033c30e43f015106d4117b5df9c35e2a8a0
data/CHANGES CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  <!-- Master -->
4
4
 
5
+ == Version 0.1.1 [2017-05-23] released
6
+
7
+ * Add CrystalCell::Povray::Cell.bond
8
+ * Add CrystalCell::atoms_of_element
9
+ * Add name in CrystalCell::Cell.atoms_in_supercell
10
+
5
11
  == Version 0.1.0 [2016-07-12] released
6
12
 
7
13
  * Add Cell.to_povcell
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: crystalcell 0.1.0 ruby lib
5
+ # stub: crystalcell 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "crystalcell"
9
- s.version = "0.1.0"
9
+ s.version = "0.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["ippei94da"]
14
- s.date = "2016-07-12"
14
+ s.date = "2017-05-23"
15
15
  s.description = "This gem provides Cell, LatticeAxes, Atom classes, and so on.\n And this provides simple treatment of a periodic boundary condition.\n "
16
16
  s.email = "ippei94da@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -99,13 +99,19 @@ class CrystalCell::Cell
99
99
  @atoms.collect{ |i| i.position }
100
100
  end
101
101
 
102
- #元素情報が elem の原子の index を配列にまとめて返す。
103
- #index は原子の永続的な id ではない。
102
+ # ブロックの評価が真になった原子の index を配列にして返す。
104
103
  #Array#select は index ではなく要素そのものを配列にして返すので、少し違う。
104
+ #index は原子の永続的な id ではない。
105
105
  def select_indices( &block )
106
106
  return @atoms.select_indices( &block )
107
107
  end
108
108
 
109
+ #元素情報が elem の原子を配列にまとめて返す。(not indices)
110
+ def atoms_of_element(str)
111
+ @atoms.select{ |i| i.element == str }
112
+ end
113
+
114
+
109
115
  #Set element name to each atom in self.
110
116
  #Argument 'elems' is a list of new names, which has [] method. e.g.,
111
117
  # 1. Array, [ 'Li', 'O' ]
@@ -139,10 +145,22 @@ class CrystalCell::Cell
139
145
  def atoms_in_supercell( a_min, a_max, b_min, b_max, c_min, c_max )
140
146
  results = []
141
147
  @atoms.each do |atom|
148
+ #pp atom; exit
142
149
  a_min.upto( a_max ) do |a|
143
150
  b_min.upto( b_max ) do |b|
144
151
  c_min.upto( c_max ) do |c|
145
- results << CrystalCell::Atom.new( atom.element, (atom.position.to_v3di + [ a, b, c ].to_v3di).to_a )
152
+ new_name = sprintf("%s-%d%d%d",
153
+ atom.name,
154
+ a + 5,
155
+ b + 5,
156
+ c + 5
157
+ )
158
+ results << CrystalCell::Atom.new(
159
+ atom.element,
160
+ (atom.position.to_v3di + [ a, b, c ].to_v3di).to_a,
161
+ new_name
162
+ )
163
+
146
164
  end
147
165
  end
148
166
  end
@@ -10,13 +10,14 @@ require 'crystalcell/povray/tetrahedron.rb'
10
10
  require 'crystalcell/povray/color.rb'
11
11
 
12
12
 
13
- DEFAULT_ENVIRONMENTS = [
14
- 'background {color rgb<1,1,1>}',
15
- 'light_source{ < 4, 1, 4 > color <1,1,1> parallel point_at 0 }',
16
- 'default{ texture{ finish{ ambient 0.4 phong 1.0 phong_size 10 } } }',
17
- ]
18
-
19
13
  class CrystalCell::Povray
14
+
15
+ DEFAULT_ENVIRONMENTS = [
16
+ 'background {color rgb<1,1,1>}',
17
+ 'light_source{ < 4, 1, 4 > color <1,1,1> parallel point_at 0 }',
18
+ 'default{ texture{ finish{ ambient 0.4 phong 1.0 phong_size 10 } } }',
19
+ ]
20
+
20
21
  attr_reader :camera, :environments, :cell, :axes
21
22
 
22
23
  # camera_info indicates hash with the keys of camera info,
@@ -60,7 +61,7 @@ class CrystalCell::Povray
60
61
  File.open(povfile, 'w') do |io|
61
62
  dump(io)
62
63
  end
63
- system "povray -D #{povfile}"
64
+ system "povray -D #{povfile} > /dev/null"
64
65
  end
65
66
 
66
67
  # shoot 4 angles and unite.
@@ -6,7 +6,11 @@ class CrystalCell::Povray::Cell < CrystalCell::Cell
6
6
  LATTICE_RADIUS = 0.02
7
7
  LATTICE_COLOR = [0.50, 0.50, 0.50]
8
8
  BOND_RADIUS = 0.05
9
- BOND_COLOR = [0.75, 0.75, 0.75]
9
+ #BOND_COLOR = [0.75, 0.75, 0.75]
10
+
11
+
12
+ class SizeError < StandardError; end
13
+ class AtomNotFoundError < StandardError; end
10
14
 
11
15
  # povray 形式の文字列を返す。
12
16
  def to_pov
@@ -22,43 +26,89 @@ class CrystalCell::Povray::Cell < CrystalCell::Cell
22
26
 
23
27
  # 原子を描画するための pov 形式文字列を返す。
24
28
  # 周期境界近傍の原子が tolerance 未満ならば、反対側のセル境界にも描画する。
25
- def atoms_to_povs(tolerance = 0.0)
29
+ def atoms_to_povs(tolerance: 0.0, transmit: nil)
26
30
  results = []
27
31
  atoms.each do |atom|
28
32
  periodic_translations(atom.position, tolerance).each do |translation|
29
- results << atom_to_pov(atom.translate(translation))
33
+ results << atom_to_pov(atom: atom.translate(translation), transmit: transmit)
34
+ #results << atom_to_pov(atom.translate(translation))
30
35
  end
31
36
  end
32
37
  results
33
38
  end
34
39
 
35
- ## 原子間の連結棒を描画するための pov 形式文字列を返す。
36
- ## E.g.,
37
- ## elem0 = 'O'
38
- ## elem1 = 'Li'
39
- ## min_distance = 0.0
40
- ## max_distance = 1.0
41
- ## 上記の指定の場合、O-O 間かつ距離が 0.0〜1.0 の原子間のみ
42
- ## bond を出力する。
43
- #def bonds_to_povs(elem0, elem1, min_distance, max_distance)
44
- # results = []
45
- # cell = self.to_pcell
46
- # cell.find_bonds(elem0, elem1, min_distance, max_distance).each do |pair|
47
- # cart0 = pair[0].to_v3d(self.axes)
48
- # cart1 = pair[1].to_v3d(self.axes)
49
- # midpoint = Mageo::Vector3D.midpoint(cart0, cart1)
50
- # results << Mageo::Cylinder.new(
51
- # [cart0, midpoint], BOND_RADIUS).to_pov(
52
- # CrystalCell::Povray::Element.color(elem0)) + "\n"
53
- # results << Mageo::Cylinder.new(
54
- # [cart1, midpoint], BOND_RADIUS).to_pov(
55
- # CrystalCell::Povray::Element.color(elem1)) + "\n"
56
- # end
57
- # results
58
- #end
40
+ # Return povray format string to draw bond between two atoms.
41
+ # contents should be like ['Na1', 'Cl2'] # (element + number)
42
+ def bond(atomids)
43
+ #pp atomids
44
+ if atomids.size != 2
45
+ raise SizeError
46
+ end
47
+ atoms = []
48
+ atomids.each do |atomid|
49
+ atom = atom_by_id(atomid)
50
+ raise AtomNotFoundError, atomid unless atom
51
+ atoms << atom
52
+ end
53
+ intermediate =
54
+ (( atoms[0].position + atoms[1].position )/ 2.0) .to_v3d(self.axes)
55
+ results = []
56
+ atoms.each do |atom|
57
+ cyl = CrystalCell::Povray::Cylinder.new(
58
+ atom.position.to_v3d(self.axes),
59
+ intermediate,
60
+ BOND_RADIUS,
61
+ CrystalCell::Povray::Element.color( atom.element)
62
+ )
63
+ results << cyl.to_pov
64
+ end
65
+ results.join("\n")
66
+ end
67
+
68
+ # Return povray format string to draw triangle among three atoms.
69
+ # contents should be like ['Na1', 'Cl2', 'Cl3'] # (element + number from 1)
70
+ # Color is set as 0th item in atomids
71
+ def triangle(atomids)
72
+ if atomids.size != 3
73
+ raise SizeError
74
+ end
75
+ atoms = []
76
+ atomids.each do |atomid|
77
+ atom = atom_by_id(atomid)
78
+ raise AtomNotFoundError, atomid unless atom
79
+ atoms << atom
80
+ end
81
+ #pp atoms
82
+ tri = CrystalCell::Povray::Triangle.new(
83
+ *atoms.map { |atom| atom.position.to_v3d(self.axes)},
84
+ CrystalCell::Povray::Element.color( atoms[0].element)
85
+ )
86
+ tri.to_pov
87
+ end
88
+
89
+ # Return povray format string to draw tetrahedron among four atoms.
90
+ # contents should be like ['Na1', 'Cl2', 'Cl3', 'Cl4'] # (element + number from 1)
91
+ # Color is set as 0th item in atomids
92
+ def tetrahedron(atomids)
93
+ if atomids.size != 4
94
+ raise SizeError
95
+ end
96
+ atoms = []
97
+ atomids.each do |atomid|
98
+ atom = atom_by_id(atomid)
99
+ raise AtomNotFoundError, atomid unless atom
100
+ atoms << atom
101
+ end
102
+ #pp atoms
103
+ tetra = CrystalCell::Povray::Tetrahedron.new(
104
+ *atoms.map { |atom| atom.position.to_v3d(self.axes)},
105
+ CrystalCell::Povray::Element.color( atoms[0].element)
106
+ )
107
+ tetra.to_pov
108
+ end
59
109
 
60
110
  # 格子の棒を描画するための pov 形式文字列を返す。
61
- def lattice_to_povs
111
+ def lattice_to_povs # should be changed to 'lattice'
62
112
  v000 = Vector3DInternal[ 0.0, 0.0, 0.0 ].to_v3d(self.axes)
63
113
  v001 = Vector3DInternal[ 0.0, 0.0, 1.0 ].to_v3d(self.axes)
64
114
  v010 = Vector3DInternal[ 0.0, 1.0, 0.0 ].to_v3d(self.axes)
@@ -87,12 +137,25 @@ class CrystalCell::Povray::Cell < CrystalCell::Cell
87
137
  results
88
138
  end
89
139
 
140
+ # Return atom from 'atom_id' like 'Na1' or 'Na1-556'.
141
+ def atom_by_id(atom_id)
142
+ elem_num, perio = atom_id.split('-')
143
+ /^(\D+)(\d+)/ =~ elem_num
144
+ elem = $1
145
+ num = $2
146
+ perio ||= '555'
147
+ atom = atoms_of_element(elem)[num.to_i - 1]
148
+ vec = perio.split(//).map { |figure| figure.to_i - 5 }
149
+ atom.translate(vec.to_v3di)
150
+ end
151
+
90
152
  private
91
153
 
92
- def atom_to_pov(atom)
154
+ def atom_to_pov(atom:, transmit: nil)
155
+ #def atom_to_pov(atom)
93
156
  color = CrystalCell::Povray::Element.color( atom.element)
94
157
  radius = CrystalCell::Povray::Element.draw_radius(atom.element) * RADIUS_RATIO
95
- Mageo::Sphere.new(atom.position.to_v3d(axes), radius).to_pov(color) +
158
+ Mageo::Sphere.new(atom.position.to_v3d(axes), radius).to_pov(color: color, transmit: transmit) +
96
159
  " // #{atom.element}" + "\n"
97
160
  end
98
161
 
@@ -3,9 +3,16 @@
3
3
  class Mageo::Sphere
4
4
  # povray 形式の文字列を返す。
5
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)
6
+ def to_pov(color: , transmit: nil)
7
+ result = sprintf("object { sphere{<% 7.4f, % 7.4f, % 7.4f>, %7.4f} ", *position, radius)
8
+ #sprintf( "object { sphere{<% 7.4f, % 7.4f, % 7.4f>, %7.4f} pigment {color rgb <%4.2f, %4.2f, %4.2f>} }",
9
+ # *position, radius, *color)
10
+
11
+ if transmit
12
+ result += sprintf("pigment {color rgbt <%4.2f, %4.2f, %4.2f, %4.2f>} }", *color, transmit)
13
+ else
14
+ result += sprintf("pigment {color rgb <%4.2f, %4.2f, %4.2f>} }", *color)
15
+ end
9
16
  end
10
17
 
11
18
  def dump(io)
@@ -13,16 +13,13 @@ class CrystalCell::Povray::Triangle < Mageo::Triangle
13
13
  # povray 形式の文字列を返す。
14
14
  # color は Float による配列。通常、0〜1の範囲。
15
15
  def to_pov
16
- v = self.vertices
17
- result = sprintf("triangle{<%f,%f,%f>,<%f,%f,%f>,<%f,%f,%f>",
16
+ #v = self.vertices
17
+ #sprintf( "object { cylinder{ <% 7.4f, % 7.4f, % 7.4f>, <% 7.4f, % 7.4f, % 7.4f>, %7.4f } pigment { color rgb <%4.2f, %4.2f, %4.2f> } }",
18
+ result = sprintf("triangle{ < % 7.4f, % 7.4f, % 7.4f>,<% 7.4f,% 7.4f,% 7.4f>,<% 7.4f,% 7.4f,% 7.4f>",
18
19
  *@vertices[0], *@vertices[1], *@vertices[2])
19
- result += sprintf(" pigment {color rgb<%f,%f,%f>", *@color)
20
- result += sprintf(" transmit %f", @transmit) if @transmit
20
+ result += sprintf(" pigment {color rgb<% 7.4f,% 7.4f,% 7.4f>", *@color)
21
+ result += sprintf(" transmit % 7.4f", @transmit) if @transmit
21
22
  result += "}}"
22
- #result = sprintf("triangle{<%f,%f,%f>,<%f,%f,%f>,<%f,%f,%f> " +
23
- # "pigment {color rgb<%f,%f,%f>}}",
24
- # *@vertices[0], *@vertices[1], *@vertices[2], *@color)
25
- #
26
23
  return result
27
24
  end
28
25
 
@@ -2,6 +2,7 @@
2
2
  # coding: utf-8
3
3
 
4
4
  require "helper"
5
+ require "pp"
5
6
 
6
7
  class TC_Povray_Sphere < Test::Unit::TestCase
7
8
  def setup
@@ -11,7 +12,11 @@ class TC_Povray_Sphere < Test::Unit::TestCase
11
12
  def test_to_pov
12
13
  assert_equal(
13
14
  "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
+ @s00.to_pov(color: [0.3, 0.6, 0.9]) )
16
+
17
+ assert_equal(
18
+ "object { sphere{< 1.0000, 2.0000, 3.0000>, 2.0000} pigment {color rgbt <0.30, 0.60, 0.90, 0.50>} }",
19
+ @s00.to_pov(color: [0.3, 0.6, 0.9], transmit: 0.5) )
15
20
  end
16
21
  end
17
22
 
@@ -83,37 +88,95 @@ class TC_Povray_Cell < Test::Unit::TestCase
83
88
  "object { sphere{< 2.0000, 2.0000, 2.0000>, 0.1770} pigment {color rgb <0.53, 0.88, 0.45>} } // Li\n",
84
89
  "object { sphere{< 0.4000, 0.6000, 0.8000>, 0.4200} pigment {color rgb <1.00, 0.01, 0.00>} } // O\n",
85
90
  ]
86
- t = @c00.atoms_to_povs(0.01)
91
+ t = @c00.atoms_to_povs(tolerance: 0.01)
87
92
  corrects.each_with_index do |correct, index|
88
93
  assert_equal(correct, t[index], "line #{index.to_s}")
89
94
  end
90
95
  assert_equal(corrects.size, t.size)
96
+
97
+ # with transmit
98
+ results = @c00.atoms_to_povs(transmit: 0.5)
99
+ corrects = [ "object { sphere{< 0.0000, 0.0000, 0.0000>, 0.1770} pigment {color rgbt <0.53, 0.88, 0.45, 0.50>} } // Li\n",
100
+ "object { sphere{< 0.4000, 0.6000, 0.8000>, 0.4200} pigment {color rgbt <1.00, 0.01, 0.00, 0.50>} } // O\n"
101
+ ]
102
+ assert_equal(corrects, results)
103
+
91
104
  end
92
105
 
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
- #)
106
+ def test_bond
107
+ axes = [
108
+ [2.0, 0.0, 0.0],
109
+ [0.0, 2.0, 0.0],
110
+ [0.0, 0.0, 2.0],
111
+ ]
112
+ atoms = [
113
+ CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]),
114
+ CrystalCell::Atom.new("O", [0.2, 0.3, 0.4]),
115
+ CrystalCell::Atom.new("O", [0.3, 0.3, 0.4]),
116
+ ]
117
+ c00 = CrystalCell::Povray::Cell.new(axes, atoms)
118
+ result = c00.bond(['Li1', 'O2'])
119
+ correct = [
120
+ "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.3000, 0.3000, 0.4000>, 0.0500 } pigment { color rgb <0.53, 0.88, 0.45> } }",
121
+ "object { cylinder{ < 0.6000, 0.6000, 0.8000>, < 0.3000, 0.3000, 0.4000>, 0.0500 } pigment { color rgb <1.00, 0.01, 0.00> } }",
122
+ ].join("\n")
123
+ assert_equal( correct, result)
124
+
125
+ result = c00.bond(['Li1-555', 'O2-555'])
126
+ correct = [
127
+ "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.3000, 0.3000, 0.4000>, 0.0500 } pigment { color rgb <0.53, 0.88, 0.45> } }",
128
+ "object { cylinder{ < 0.6000, 0.6000, 0.8000>, < 0.3000, 0.3000, 0.4000>, 0.0500 } pigment { color rgb <1.00, 0.01, 0.00> } }",
129
+ ].join("\n")
130
+ assert_equal( correct, result)
131
+
132
+ result = c00.bond(['Li1-555', 'Li1-556'])
133
+ correct = [
134
+ "object { cylinder{ < 0.0000, 0.0000, 0.0000>, < 0.0000, 0.0000, 1.0000>, 0.0500 } pigment { color rgb <0.53, 0.88, 0.45> } }",
135
+ "object { cylinder{ < 0.0000, 0.0000, 2.0000>, < 0.0000, 0.0000, 1.0000>, 0.0500 } pigment { color rgb <0.53, 0.88, 0.45> } }",
136
+ ].join("\n")
137
+ assert_equal( correct, result)
138
+ end
139
+
140
+ def test_triangle
141
+ axes = [
142
+ [2.0, 0.0, 0.0],
143
+ [0.0, 2.0, 0.0],
144
+ [0.0, 0.0, 2.0],
145
+ ]
146
+ atoms = [
147
+ CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]),
148
+ CrystalCell::Atom.new("O", [0.2, 0.3, 0.4]),
149
+ CrystalCell::Atom.new("O", [0.3, 0.3, 0.4]),
150
+ ]
151
+ c00 = CrystalCell::Povray::Cell.new(axes, atoms)
152
+ result = c00.triangle(['Li1', 'O1', 'O2'])
153
+ correct = [
154
+ "triangle{ < 0.0000, 0.0000, 0.0000>,< 0.4000, 0.6000, 0.8000>,< 0.6000, 0.6000, 0.8000> pigment {color rgb< 0.5255, 0.8784, 0.4549>}}",
155
+ ].join('')
156
+ assert_equal( correct, result)
157
+ end
158
+
159
+ def test_tetrahedron
160
+ axes = [
161
+ [2.0, 0.0, 0.0],
162
+ [0.0, 2.0, 0.0],
163
+ [0.0, 0.0, 2.0],
164
+ ]
165
+ atoms = [
166
+ CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0]),
167
+ CrystalCell::Atom.new("Li", [0.5, 0.5, 0.5]),
168
+ CrystalCell::Atom.new("O", [0.2, 0.3, 0.4]),
169
+ CrystalCell::Atom.new("O", [0.3, 0.3, 0.4]),
170
+ ]
171
+ c00 = CrystalCell::Povray::Cell.new(axes, atoms)
172
+ result = c00.tetrahedron(['Li1', 'Li2', 'O1', 'O2'])
173
+ correct = [
174
+ "triangle{ < 0.0000, 0.0000, 0.0000>,< 1.0000, 1.0000, 1.0000>,< 0.4000, 0.6000, 0.8000> pigment {color rgb< 0.5255, 0.8784, 0.4549>}}",
175
+ "triangle{ < 1.0000, 1.0000, 1.0000>,< 0.4000, 0.6000, 0.8000>,< 0.6000, 0.6000, 0.8000> pigment {color rgb< 0.5255, 0.8784, 0.4549>}}",
176
+ "triangle{ < 0.4000, 0.6000, 0.8000>,< 0.6000, 0.6000, 0.8000>,< 0.0000, 0.0000, 0.0000> pigment {color rgb< 0.5255, 0.8784, 0.4549>}}",
177
+ "triangle{ < 0.6000, 0.6000, 0.8000>,< 0.0000, 0.0000, 0.0000>,< 1.0000, 1.0000, 1.0000> pigment {color rgb< 0.5255, 0.8784, 0.4549>}}"
178
+ ].join("\n")
179
+ assert_equal( correct, result)
117
180
  end
118
181
 
119
182
  def test_lattice_to_povs
@@ -141,7 +204,12 @@ class TC_Povray_Cell < Test::Unit::TestCase
141
204
  def test_atom_to_pov
142
205
  assert_equal(
143
206
  "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]))
207
+ @c00.atom_to_pov(atom: CrystalCell::Atom.new("Li", [0.1, 0.2, 0.3]))
208
+ )
209
+
210
+ assert_equal(
211
+ "object { sphere{< 0.2000, 0.4000, 0.6000>, 0.1770} pigment {color rgbt <0.53, 0.88, 0.45, 0.50>} } // Li\n",
212
+ @c00.atom_to_pov(atom: CrystalCell::Atom.new("Li", [0.1, 0.2, 0.3]), transmit: 0.5)
145
213
  )
146
214
  end
147
215
 
@@ -175,5 +243,28 @@ class TC_Povray_Cell < Test::Unit::TestCase
175
243
  assert_equal(corrects, t)
176
244
  end
177
245
 
246
+ def test_atom_by_id
247
+ result = @c00.atom_by_id('Li1-555')
248
+ correct = CrystalCell::Atom.new("Li", [0.0, 0.0, 0.0])
249
+ assert_equal(correct, result)
250
+
251
+ result = @c00.atom_by_id('Li1-556')
252
+ correct = CrystalCell::Atom.new("Li", [0.0, 0.0, 1.0])
253
+ assert_equal(correct, result)
254
+
255
+ result = @c00.atom_by_id('Li1-565')
256
+ correct = CrystalCell::Atom.new("Li", [0.0, 1.0, 0.0])
257
+ assert_equal(correct, result)
258
+
259
+ result = @c00.atom_by_id('Li1-655')
260
+ correct = CrystalCell::Atom.new("Li", [1.0, 0.0, 0.0])
261
+ assert_equal(correct, result)
262
+
263
+ result = @c00.atom_by_id('Li1-455')
264
+ correct = CrystalCell::Atom.new("Li", [-1.0, 0.0, 0.0])
265
+ assert_equal(correct, result)
266
+
267
+ end
268
+
178
269
  end
179
270
 
@@ -19,10 +19,10 @@ class TC_Tetrahedron < Test::Unit::TestCase
19
19
  def test_to_pov
20
20
  #VERTEX_INDICES_OF_TRIANGLES = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 0 ], [ 3, 0, 1 ] ]
21
21
  correct = [
22
- "triangle{<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
23
- "triangle{<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
24
- "triangle{<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
25
- "triangle{<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
22
+ "triangle{ < 0.0000, 0.0000, 0.0000>,< 1.0000, 1.0000, 0.0000>,< 0.0000, 1.0000, 1.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500>}}",
23
+ "triangle{ < 1.0000, 1.0000, 0.0000>,< 0.0000, 1.0000, 1.0000>,< 1.0000, 0.0000, 1.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500>}}",
24
+ "triangle{ < 0.0000, 1.0000, 1.0000>,< 1.0000, 0.0000, 1.0000>,< 0.0000, 0.0000, 0.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500>}}",
25
+ "triangle{ < 1.0000, 0.0000, 1.0000>,< 0.0000, 0.0000, 0.0000>,< 1.0000, 1.0000, 0.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500>}}",
26
26
  ].join("\n")
27
27
  assert_equal(
28
28
  correct,
@@ -31,10 +31,10 @@ class TC_Tetrahedron < Test::Unit::TestCase
31
31
 
32
32
  @t00.transmit = 0.5
33
33
  correct = [
34
- "triangle{<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
35
- "triangle{<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
36
- "triangle{<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
37
- "triangle{<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
34
+ "triangle{ < 0.0000, 0.0000, 0.0000>,< 1.0000, 1.0000, 0.0000>,< 0.0000, 1.0000, 1.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500> transmit 0.5000}}",
35
+ "triangle{ < 1.0000, 1.0000, 0.0000>,< 0.0000, 1.0000, 1.0000>,< 1.0000, 0.0000, 1.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500> transmit 0.5000}}",
36
+ "triangle{ < 0.0000, 1.0000, 1.0000>,< 1.0000, 0.0000, 1.0000>,< 0.0000, 0.0000, 0.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500> transmit 0.5000}}",
37
+ "triangle{ < 1.0000, 0.0000, 1.0000>,< 0.0000, 0.0000, 0.0000>,< 1.0000, 1.0000, 0.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500> transmit 0.5000}}",
38
38
  ].join("\n")
39
39
  assert_equal(
40
40
  correct,
@@ -25,13 +25,13 @@ class TC_Triangle < Test::Unit::TestCase
25
25
 
26
26
  def test_to_pov
27
27
  assert_equal(
28
- "triangle{<0.000000,0.000000,0.000000>,<1.000000,0.000000,0.000000>,<0.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
28
+ "triangle{ < 0.0000, 0.0000, 0.0000>,< 1.0000, 0.0000, 0.0000>,< 0.0000, 1.0000, 0.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500>}}",
29
29
  @t00.to_pov
30
30
  )
31
31
 
32
32
  @t00.transmit = 0.5
33
33
  assert_equal(
34
- "triangle{<0.000000,0.000000,0.000000>,<1.000000,0.000000,0.000000>,<0.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
34
+ "triangle{ < 0.0000, 0.0000, 0.0000>,< 1.0000, 0.0000, 0.0000>,< 0.0000, 1.0000, 0.0000> pigment {color rgb< 0.2500, 0.5000, 0.7500> transmit 0.5000}}",
35
35
  @t00.to_pov
36
36
  )
37
37
  end
@@ -3,6 +3,7 @@
3
3
 
4
4
  require "helper"
5
5
  require 'stringio'
6
+ require 'pp'
6
7
 
7
8
  #class CrystalCell::Cell
8
9
  # public :symmetry_operations
@@ -33,8 +34,8 @@ class TC_Cell < Test::Unit::TestCase
33
34
  # Li と O を1つずつ入れたセル。
34
35
  # @c02 = CrystalCell::Cell.new( [ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ] )
35
36
  atoms = [
36
- CrystalCell::Atom.new( 'Li', [0.0, 0.0, 0.0] ),
37
- CrystalCell::Atom.new( 'O' , [0.2, 0.2, 0.2] ),
37
+ CrystalCell::Atom.new( 'Li', [0.0, 0.0, 0.0], 'Li1' ),
38
+ CrystalCell::Atom.new( 'O' , [0.2, 0.2, 0.2], 'O1' ),
38
39
  ]
39
40
  @c02 = CrystalCell::Cell.new(vectors00, atoms)
40
41
  @c02.comment = 'c02'
@@ -214,8 +215,6 @@ class TC_Cell < Test::Unit::TestCase
214
215
  assert_in_delta( 0.0, c10.axes[2][0], $tolerance )
215
216
  assert_in_delta( 0.0, c10.axes[2][1], $tolerance )
216
217
  assert_in_delta( 2.0, c10.axes[2][2], $tolerance )
217
-
218
-
219
218
  end
220
219
 
221
220
  def test_positions
@@ -244,6 +243,25 @@ class TC_Cell < Test::Unit::TestCase
244
243
  assert_equal( [1, 2], @c04.select_indices{ |i| i.position[0] > 0.05 } )
245
244
  end
246
245
 
246
+ def test_atoms_of_element
247
+ vectors00 = [[2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0]]
248
+ atom0 = CrystalCell::Atom.new( 'Li', [0.0, 0.0, 0.0] )
249
+ atom1 = CrystalCell::Atom.new( 'Li', [0.1, 0.2, 0.3] )
250
+ atom2 = CrystalCell::Atom.new( 'O' , [0.2, 0.2, 0.2] )
251
+ atoms = [ atom0, atom1, atom2]
252
+ c04 = CrystalCell::Cell.new(vectors00, atoms)
253
+ c04.comment = 'c04'
254
+
255
+ assert_equal([atom0, atom1], c04.atoms_of_element('Li'))
256
+ assert_equal([atom2] , c04.atoms_of_element('O'))
257
+ assert_equal([] , c04.atoms_of_element('S'))
258
+ end
259
+
260
+ #def test_supercell
261
+ # @c02.supercell(
262
+
263
+ #end
264
+
247
265
  def test_atoms_in_supercell
248
266
  t = @c02.atoms_in_supercell( 0, 0, 0, 0, 0, 1 )
249
267
  assert_equal( 'Li', t[0].element )
@@ -257,61 +275,63 @@ class TC_Cell < Test::Unit::TestCase
257
275
  assert_equal( Mageo::Vector3DInternal[0.2, 0.2, 1.2], t[3].position )
258
276
 
259
277
  t = @c02.atoms_in_supercell(-1, 1,-1, 1,-1, 1 )
260
- assert_equal( ['Li']*27 + ['O'] * 27 , t.map{|i| i.element} )
261
- assert_equal( Mageo::Vector3DInternal[-1.0, -1.0, -1.0], t[ 0].position )
262
- assert_equal( Mageo::Vector3DInternal[-1.0, -1.0, 0.0], t[ 1].position )
263
- assert_equal( Mageo::Vector3DInternal[-1.0, -1.0, 1.0], t[ 2].position )
264
- assert_equal( Mageo::Vector3DInternal[-1.0, 0.0, -1.0], t[ 3].position )
265
- assert_equal( Mageo::Vector3DInternal[-1.0, 0.0, 0.0], t[ 4].position )
266
- assert_equal( Mageo::Vector3DInternal[-1.0, 0.0, 1.0], t[ 5].position )
267
- assert_equal( Mageo::Vector3DInternal[-1.0, 1.0, -1.0], t[ 6].position )
268
- assert_equal( Mageo::Vector3DInternal[-1.0, 1.0, 0.0], t[ 7].position )
269
- assert_equal( Mageo::Vector3DInternal[-1.0, 1.0, 1.0], t[ 8].position )
270
- assert_equal( Mageo::Vector3DInternal[ 0.0, -1.0, -1.0], t[ 9].position )
271
- assert_equal( Mageo::Vector3DInternal[ 0.0, -1.0, 0.0], t[10].position )
272
- assert_equal( Mageo::Vector3DInternal[ 0.0, -1.0, 1.0], t[11].position )
273
- assert_equal( Mageo::Vector3DInternal[ 0.0, 0.0, -1.0], t[12].position )
274
- assert_equal( Mageo::Vector3DInternal[ 0.0, 0.0, 0.0], t[13].position )
275
- assert_equal( Mageo::Vector3DInternal[ 0.0, 0.0, 1.0], t[14].position )
276
- assert_equal( Mageo::Vector3DInternal[ 0.0, 1.0, -1.0], t[15].position )
277
- assert_equal( Mageo::Vector3DInternal[ 0.0, 1.0, 0.0], t[16].position )
278
- assert_equal( Mageo::Vector3DInternal[ 0.0, 1.0, 1.0], t[17].position )
279
- assert_equal( Mageo::Vector3DInternal[ 1.0, -1.0, -1.0], t[18].position )
280
- assert_equal( Mageo::Vector3DInternal[ 1.0, -1.0, 0.0], t[19].position )
281
- assert_equal( Mageo::Vector3DInternal[ 1.0, -1.0, 1.0], t[20].position )
282
- assert_equal( Mageo::Vector3DInternal[ 1.0, 0.0, -1.0], t[21].position )
283
- assert_equal( Mageo::Vector3DInternal[ 1.0, 0.0, 0.0], t[22].position )
284
- assert_equal( Mageo::Vector3DInternal[ 1.0, 0.0, 1.0], t[23].position )
285
- assert_equal( Mageo::Vector3DInternal[ 1.0, 1.0, -1.0], t[24].position )
286
- assert_equal( Mageo::Vector3DInternal[ 1.0, 1.0, 0.0], t[25].position )
287
- assert_equal( Mageo::Vector3DInternal[ 1.0, 1.0, 1.0], t[26].position )
288
- assert_equal( Mageo::Vector3DInternal[-0.8, -0.8, -0.8], t[27].position )
289
- assert_equal( Mageo::Vector3DInternal[-0.8, -0.8, 0.2], t[28].position )
290
- assert_equal( Mageo::Vector3DInternal[-0.8, -0.8, 1.2], t[29].position )
291
- assert_equal( Mageo::Vector3DInternal[-0.8, 0.2, -0.8], t[30].position )
292
- assert_equal( Mageo::Vector3DInternal[-0.8, 0.2, 0.2], t[31].position )
293
- assert_equal( Mageo::Vector3DInternal[-0.8, 0.2, 1.2], t[32].position )
294
- assert_equal( Mageo::Vector3DInternal[-0.8, 1.2, -0.8], t[33].position )
295
- assert_equal( Mageo::Vector3DInternal[-0.8, 1.2, 0.2], t[34].position )
296
- assert_equal( Mageo::Vector3DInternal[-0.8, 1.2, 1.2], t[35].position )
297
- assert_equal( Mageo::Vector3DInternal[ 0.2, -0.8, -0.8], t[36].position )
298
- assert_equal( Mageo::Vector3DInternal[ 0.2, -0.8, 0.2], t[37].position )
299
- assert_equal( Mageo::Vector3DInternal[ 0.2, -0.8, 1.2], t[38].position )
300
- assert_equal( Mageo::Vector3DInternal[ 0.2, 0.2, -0.8], t[39].position )
301
- assert_equal( Mageo::Vector3DInternal[ 0.2, 0.2, 0.2], t[40].position )
302
- assert_equal( Mageo::Vector3DInternal[ 0.2, 0.2, 1.2], t[41].position )
303
- assert_equal( Mageo::Vector3DInternal[ 0.2, 1.2, -0.8], t[42].position )
304
- assert_equal( Mageo::Vector3DInternal[ 0.2, 1.2, 0.2], t[43].position )
305
- assert_equal( Mageo::Vector3DInternal[ 0.2, 1.2, 1.2], t[44].position )
306
- assert_equal( Mageo::Vector3DInternal[ 1.2, -0.8, -0.8], t[45].position )
307
- assert_equal( Mageo::Vector3DInternal[ 1.2, -0.8, 0.2], t[46].position )
308
- assert_equal( Mageo::Vector3DInternal[ 1.2, -0.8, 1.2], t[47].position )
309
- assert_equal( Mageo::Vector3DInternal[ 1.2, 0.2, -0.8], t[48].position )
310
- assert_equal( Mageo::Vector3DInternal[ 1.2, 0.2, 0.2], t[49].position )
311
- assert_equal( Mageo::Vector3DInternal[ 1.2, 0.2, 1.2], t[50].position )
312
- assert_equal( Mageo::Vector3DInternal[ 1.2, 1.2, -0.8], t[51].position )
313
- assert_equal( Mageo::Vector3DInternal[ 1.2, 1.2, 0.2], t[52].position )
314
- assert_equal( Mageo::Vector3DInternal[ 1.2, 1.2, 1.2], t[53].position )
278
+ assert_equal(['Li']*27 + ['O'] * 27 , t.map{|i| i.element} )
279
+ assert_equal(Mageo::Vector3DInternal[-1.0,-1.0,-1.0],t[ 0].position)
280
+ assert_equal(Mageo::Vector3DInternal[-1.0,-1.0, 0.0],t[ 1].position)
281
+ assert_equal(Mageo::Vector3DInternal[-1.0,-1.0, 1.0],t[ 2].position)
282
+ assert_equal(Mageo::Vector3DInternal[-1.0, 0.0,-1.0],t[ 3].position)
283
+ assert_equal(Mageo::Vector3DInternal[-1.0, 0.0, 0.0],t[ 4].position)
284
+ assert_equal(Mageo::Vector3DInternal[-1.0, 0.0, 1.0],t[ 5].position)
285
+ assert_equal(Mageo::Vector3DInternal[-1.0, 1.0,-1.0],t[ 6].position)
286
+ assert_equal(Mageo::Vector3DInternal[-1.0, 1.0, 0.0],t[ 7].position)
287
+ assert_equal(Mageo::Vector3DInternal[-1.0, 1.0, 1.0],t[ 8].position)
288
+ assert_equal(Mageo::Vector3DInternal[ 0.0,-1.0,-1.0],t[ 9].position)
289
+ assert_equal(Mageo::Vector3DInternal[ 0.0,-1.0, 0.0],t[10].position)
290
+ assert_equal(Mageo::Vector3DInternal[ 0.0,-1.0, 1.0],t[11].position)
291
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0,-1.0],t[12].position)
292
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 0.0],t[13].position)
293
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 0.0, 1.0],t[14].position)
294
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 1.0,-1.0],t[15].position)
295
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 1.0, 0.0],t[16].position)
296
+ assert_equal(Mageo::Vector3DInternal[ 0.0, 1.0, 1.0],t[17].position)
297
+ assert_equal(Mageo::Vector3DInternal[ 1.0,-1.0,-1.0],t[18].position)
298
+ assert_equal(Mageo::Vector3DInternal[ 1.0,-1.0, 0.0],t[19].position)
299
+ assert_equal(Mageo::Vector3DInternal[ 1.0,-1.0, 1.0],t[20].position)
300
+ assert_equal(Mageo::Vector3DInternal[ 1.0, 0.0,-1.0],t[21].position)
301
+ assert_equal(Mageo::Vector3DInternal[ 1.0, 0.0, 0.0],t[22].position)
302
+ assert_equal(Mageo::Vector3DInternal[ 1.0, 0.0, 1.0],t[23].position)
303
+ assert_equal(Mageo::Vector3DInternal[ 1.0, 1.0,-1.0],t[24].position)
304
+ assert_equal(Mageo::Vector3DInternal[ 1.0, 1.0, 0.0],t[25].position)
305
+ assert_equal(Mageo::Vector3DInternal[ 1.0, 1.0, 1.0],t[26].position)
306
+ assert_equal(Mageo::Vector3DInternal[-0.8,-0.8,-0.8],t[27].position)
307
+ assert_equal(Mageo::Vector3DInternal[-0.8,-0.8, 0.2],t[28].position)
308
+ assert_equal(Mageo::Vector3DInternal[-0.8,-0.8, 1.2],t[29].position)
309
+ assert_equal(Mageo::Vector3DInternal[-0.8, 0.2,-0.8],t[30].position)
310
+ assert_equal(Mageo::Vector3DInternal[-0.8, 0.2, 0.2],t[31].position)
311
+ assert_equal(Mageo::Vector3DInternal[-0.8, 0.2, 1.2],t[32].position)
312
+ assert_equal(Mageo::Vector3DInternal[-0.8, 1.2,-0.8],t[33].position)
313
+ assert_equal(Mageo::Vector3DInternal[-0.8, 1.2, 0.2],t[34].position)
314
+ assert_equal(Mageo::Vector3DInternal[-0.8, 1.2, 1.2],t[35].position)
315
+ assert_equal(Mageo::Vector3DInternal[ 0.2,-0.8,-0.8],t[36].position)
316
+ assert_equal(Mageo::Vector3DInternal[ 0.2,-0.8, 0.2],t[37].position)
317
+ assert_equal(Mageo::Vector3DInternal[ 0.2,-0.8, 1.2],t[38].position)
318
+ assert_equal(Mageo::Vector3DInternal[ 0.2, 0.2,-0.8],t[39].position)
319
+ assert_equal(Mageo::Vector3DInternal[ 0.2, 0.2, 0.2],t[40].position)
320
+ assert_equal(Mageo::Vector3DInternal[ 0.2, 0.2, 1.2],t[41].position)
321
+ assert_equal(Mageo::Vector3DInternal[ 0.2, 1.2,-0.8],t[42].position)
322
+ assert_equal(Mageo::Vector3DInternal[ 0.2, 1.2, 0.2],t[43].position)
323
+ assert_equal(Mageo::Vector3DInternal[ 0.2, 1.2, 1.2],t[44].position)
324
+ assert_equal(Mageo::Vector3DInternal[ 1.2,-0.8,-0.8],t[45].position)
325
+ assert_equal(Mageo::Vector3DInternal[ 1.2,-0.8, 0.2],t[46].position)
326
+ assert_equal(Mageo::Vector3DInternal[ 1.2,-0.8, 1.2],t[47].position)
327
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 0.2,-0.8],t[48].position)
328
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 0.2, 0.2],t[49].position)
329
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 0.2, 1.2],t[50].position)
330
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 1.2,-0.8],t[51].position)
331
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 1.2, 0.2],t[52].position)
332
+ assert_equal(Mageo::Vector3DInternal[ 1.2, 1.2, 1.2],t[53].position)
333
+
334
+ assert_equal('Li1-444',t[ 0].name)
315
335
  end
316
336
 
317
337
  def test_elements
@@ -968,11 +988,11 @@ class TC_Cell < Test::Unit::TestCase
968
988
  # checking atom 0
969
989
  assert_equal( 'Li' , t.atoms[0].element)
970
990
  assert_equal( Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
971
- assert_equal( nil , t.atoms[0].name )
991
+ assert_equal( 'Li1' , t.atoms[0].name )
972
992
  # checking atom 1
973
993
  assert_equal( 'O' , t.atoms[1].element)
974
994
  assert_equal( Mageo::Vector3DInternal[-0.2, 0.2, 0.2], t.atoms[1].position)
975
- assert_equal( nil , t.atoms[1].name )
995
+ assert_equal( 'O1' , t.atoms[1].name )
976
996
  end
977
997
 
978
998
  def test_inverse_axis
@@ -995,11 +1015,11 @@ class TC_Cell < Test::Unit::TestCase
995
1015
  # checking atom 0
996
1016
  assert_equal( 'Li' , t.atoms[0].element)
997
1017
  assert_equal( Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
998
- assert_equal( nil , t.atoms[0].name )
1018
+ assert_equal( 'Li1' , t.atoms[0].name )
999
1019
  # checking atom 1
1000
1020
  assert_equal( 'O' , t.atoms[1].element)
1001
1021
  assert_equal( Mageo::Vector3DInternal[-0.2, 0.2, 0.2], t.atoms[1].position)
1002
- assert_equal( nil , t.atoms[1].name )
1022
+ assert_equal( 'O1' , t.atoms[1].name )
1003
1023
  # checking non-destructive
1004
1024
  assert_equal( CrystalCell::Cell, t.class )
1005
1025
  assert_in_delta( 2.0, @c02.axes[0][0], $tolerance )
@@ -1015,11 +1035,11 @@ class TC_Cell < Test::Unit::TestCase
1015
1035
  # checking atom 0
1016
1036
  assert_equal( 'Li' , @c02.atoms[0].element)
1017
1037
  assert_equal( Mageo::Vector3DInternal[0.0, 0.0, 0.0], @c02.atoms[0].position)
1018
- assert_equal( nil , @c02.atoms[0].name )
1038
+ assert_equal( 'Li1' , @c02.atoms[0].name )
1019
1039
  # checking atom 1
1020
1040
  assert_equal( 'O' , @c02.atoms[1].element)
1021
1041
  assert_equal( Mageo::Vector3DInternal[ 0.2, 0.2, 0.2], @c02.atoms[1].position)
1022
- assert_equal( nil , @c02.atoms[1].name )
1042
+ assert_equal( 'O1' , @c02.atoms[1].name )
1023
1043
 
1024
1044
  # y 軸反転
1025
1045
  # [ [ ax, ay, az], [ 0, by, bz], [ 0, 0, cz] ]
@@ -1043,11 +1063,11 @@ class TC_Cell < Test::Unit::TestCase
1043
1063
  # checking atom 0
1044
1064
  assert_equal( 'Li' , t.atoms[0].element)
1045
1065
  assert_equal( Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
1046
- assert_equal( nil , t.atoms[0].name )
1066
+ assert_equal( 'Li1' , t.atoms[0].name )
1047
1067
  # checking atom 1
1048
1068
  assert_equal( 'O' , t.atoms[1].element)
1049
1069
  assert_equal( Mageo::Vector3DInternal[ 0.2,-0.2, 0.2], t.atoms[1].position)
1050
- assert_equal( nil , t.atoms[1].name )
1070
+ assert_equal( 'O1' , t.atoms[1].name )
1051
1071
 
1052
1072
  # z 軸反転
1053
1073
  # [ [ ax, ay, az], [ 0, by, bz], [ 0, 0, cz] ]
@@ -1072,11 +1092,11 @@ class TC_Cell < Test::Unit::TestCase
1072
1092
  # checking atom 0
1073
1093
  assert_equal( 'Li' , t.atoms[0].element)
1074
1094
  assert_equal( Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
1075
- assert_equal( nil , t.atoms[0].name )
1095
+ assert_equal( 'Li1' , t.atoms[0].name )
1076
1096
  # checking atom 1
1077
1097
  assert_equal( 'O' , t.atoms[1].element)
1078
1098
  assert_equal( Mageo::Vector3DInternal[ 0.2, 0.2,-0.2], t.atoms[1].position)
1079
- assert_equal( nil , t.atoms[1].name )
1099
+ assert_equal( 'O1' , t.atoms[1].name )
1080
1100
 
1081
1101
  end
1082
1102
 
@@ -1102,7 +1122,7 @@ class TC_Cell < Test::Unit::TestCase
1102
1122
  # checking atom 1
1103
1123
  assert_equal( 'O' , t.atoms[1].element)
1104
1124
  assert_equal( Mageo::Vector3DInternal[-1.2, -5.6, -3.4], t.atoms[1].position)
1105
- assert_equal( nil , t.atoms[1].name )
1125
+ assert_equal( nil , t.atoms[1].name )
1106
1126
  end
1107
1127
 
1108
1128
  def test_exchange_axes
@@ -1285,7 +1305,6 @@ class TC_Cell < Test::Unit::TestCase
1285
1305
  end
1286
1306
 
1287
1307
  def test_symmetry_operations
1288
- f13 = 1.0/3.0
1289
1308
 
1290
1309
  #cubic/POSCAR #Pm-3m (221) / m-3m / -P 4 2 3 (517)
1291
1310
  corrects = [
@@ -1416,6 +1435,7 @@ class TC_Cell < Test::Unit::TestCase
1416
1435
  #]
1417
1436
  #assert_equal(corrects, @c15 .symmetry_operations) #triclinic
1418
1437
 
1438
+ #f13 = 1.0/3.0
1419
1439
  ##trigonal/POSCAR #P-3m1 (164) / -3m / -P 3 2= (456)
1420
1440
  #corrects = [
1421
1441
  # {:rotation => [[ 1.0, 0.0, 0], [ 0.0, 1.0, 0], [ 0.0, 0.0, 1.0]], :translation => [0.0, 0.0, 0.0]}, #----01----
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crystalcell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ippei94da
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit