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/lib/crystalcell/element.rb
CHANGED
@@ -1,148 +1,57 @@
|
|
1
|
-
#
|
2
|
-
# 元素(原子種)に関する情報を集めたクラス
|
3
|
-
# 基本理念として、原子番号を最もネイティブなデータとして ID 付けをする。
|
4
|
-
# 原子番号は人間がいなかったとしてもそれで区分できるが、
|
5
|
-
# 原子記号は人間がつけたものだから。
|
1
|
+
# Class for elements and their information.
|
6
2
|
#
|
7
3
|
class CrystalCell::Element
|
8
|
-
# 全データを生成しておく。
|
9
|
-
def initialize
|
10
|
-
#原子記号, 原子番号, 周期, 族, 質量数(平均), イオン半径
|
11
|
-
@symbol = Array.new #; @mass = Array.new @radius = Array.new
|
12
|
-
#i = 1; @symbol[i], @mass[i], @radius[i] = 'H', 1.008, nil
|
13
|
-
i = 0; @symbol[i] = nil
|
14
|
-
i = 1; @symbol[i] = 'H'
|
15
|
-
i = 2; @symbol[i] = 'He'
|
16
|
-
i = 3; @symbol[i] = 'Li'
|
17
|
-
i = 4; @symbol[i] = 'Be'
|
18
|
-
i = 5; @symbol[i] = 'B'
|
19
|
-
i = 6; @symbol[i] = 'C'
|
20
|
-
i = 7; @symbol[i] = 'N'
|
21
|
-
i = 8; @symbol[i] = 'O'
|
22
|
-
i = 9; @symbol[i] = 'F'
|
23
|
-
i = 10; @symbol[i] = 'Ne'
|
24
|
-
i = 11; @symbol[i] = 'Na'
|
25
|
-
i = 12; @symbol[i] = 'Mg'
|
26
|
-
i = 13; @symbol[i] = 'Al'
|
27
|
-
i = 14; @symbol[i] = 'Si'
|
28
|
-
i = 15; @symbol[i] = 'P'
|
29
|
-
i = 16; @symbol[i] = 'S'
|
30
|
-
i = 17; @symbol[i] = 'Cl'
|
31
|
-
i = 18; @symbol[i] = 'Ar'
|
32
|
-
i = 19; @symbol[i] = 'K'
|
33
|
-
i = 20; @symbol[i] = 'Ca'
|
34
|
-
i = 21; @symbol[i] = 'Sc'
|
35
|
-
i = 22; @symbol[i] = 'Ti'
|
36
|
-
i = 23; @symbol[i] = 'V'
|
37
|
-
i = 24; @symbol[i] = 'Cr'
|
38
|
-
i = 25; @symbol[i] = 'Mn'
|
39
|
-
i = 26; @symbol[i] = 'Fe'
|
40
|
-
i = 27; @symbol[i] = 'Co'
|
41
|
-
i = 28; @symbol[i] = 'Ni'
|
42
|
-
i = 29; @symbol[i] = 'Cu'
|
43
|
-
i = 30; @symbol[i] = 'Zn'
|
44
|
-
i = 31; @symbol[i] = 'Ga'
|
45
|
-
i = 32; @symbol[i] = 'Ge'
|
46
|
-
i = 33; @symbol[i] = 'As'
|
47
|
-
i = 34; @symbol[i] = 'Se'
|
48
|
-
i = 35; @symbol[i] = 'Br'
|
49
|
-
i = 36; @symbol[i] = 'Kr'
|
50
|
-
i = 37; @symbol[i] = 'Rb'
|
51
|
-
i = 38; @symbol[i] = 'Sr'
|
52
|
-
i = 39; @symbol[i] = 'Y'
|
53
|
-
i = 40; @symbol[i] = 'Zr'
|
54
|
-
i = 41; @symbol[i] = 'Nb'
|
55
|
-
i = 42; @symbol[i] = 'Mo'
|
56
|
-
i = 43; @symbol[i] = 'Tc'
|
57
|
-
i = 44; @symbol[i] = 'Ru'
|
58
|
-
i = 45; @symbol[i] = 'Rh'
|
59
|
-
i = 46; @symbol[i] = 'Pd'
|
60
|
-
i = 47; @symbol[i] = 'Ag'
|
61
|
-
i = 48; @symbol[i] = 'Cd'
|
62
|
-
i = 49; @symbol[i] = 'In'
|
63
|
-
i = 50; @symbol[i] = 'Sn'
|
64
|
-
i = 51; @symbol[i] = 'Sb'
|
65
|
-
i = 52; @symbol[i] = 'Te'
|
66
|
-
i = 53; @symbol[i] = 'I'
|
67
|
-
i = 54; @symbol[i] = 'Xe'
|
68
|
-
i = 55; @symbol[i] = 'Cs'
|
69
|
-
i = 56; @symbol[i] = 'Ba'
|
70
|
-
i = 57; @symbol[i] = 'La'
|
71
|
-
i = 58; @symbol[i] = 'Ce'
|
72
|
-
i = 59; @symbol[i] = 'Pr'
|
73
|
-
i = 60; @symbol[i] = 'Nd'
|
74
|
-
i = 61; @symbol[i] = 'Pm'
|
75
|
-
i = 62; @symbol[i] = 'Sm'
|
76
|
-
i = 63; @symbol[i] = 'Eu'
|
77
|
-
i = 64; @symbol[i] = 'Gd'
|
78
|
-
i = 65; @symbol[i] = 'Tb'
|
79
|
-
i = 66; @symbol[i] = 'Dy'
|
80
|
-
i = 67; @symbol[i] = 'Ho'
|
81
|
-
i = 68; @symbol[i] = 'Er'
|
82
|
-
i = 69; @symbol[i] = 'Tm'
|
83
|
-
i = 70; @symbol[i] = 'Yb'
|
84
|
-
i = 71; @symbol[i] = 'Lu'
|
85
|
-
i = 72; @symbol[i] = 'Hf'
|
86
|
-
i = 73; @symbol[i] = 'Ta'
|
87
|
-
i = 74; @symbol[i] = 'W'
|
88
|
-
i = 75; @symbol[i] = 'Re'
|
89
|
-
i = 76; @symbol[i] = 'Os'
|
90
|
-
i = 77; @symbol[i] = 'Ir'
|
91
|
-
i = 78; @symbol[i] = 'Pt'
|
92
|
-
i = 79; @symbol[i] = 'Au'
|
93
|
-
i = 80; @symbol[i] = 'Hg'
|
94
|
-
i = 81; @symbol[i] = 'Tl'
|
95
|
-
i = 82; @symbol[i] = 'Pb'
|
96
|
-
i = 83; @symbol[i] = 'Bi'
|
97
|
-
i = 84; @symbol[i] = 'Po'
|
98
|
-
i = 85; @symbol[i] = 'At'
|
99
|
-
i = 86; @symbol[i] = 'Rn'
|
100
|
-
i = 87; @symbol[i] = 'Fr'
|
101
|
-
i = 88; @symbol[i] = 'Ra'
|
102
|
-
i = 89; @symbol[i] = 'Ac'
|
103
|
-
i = 90; @symbol[i] = 'Th'
|
104
|
-
i = 91; @symbol[i] = 'Pa'
|
105
|
-
i = 92; @symbol[i] = 'U'
|
106
|
-
i = 93; @symbol[i] = 'Np'
|
107
|
-
i = 94; @symbol[i] = 'Pu'
|
108
|
-
i = 95; @symbol[i] = 'Am'
|
109
|
-
i = 96; @symbol[i] = 'Cm'
|
110
|
-
i = 97; @symbol[i] = 'Bk'
|
111
|
-
i = 98; @symbol[i] = 'Cf'
|
112
|
-
i = 99; @symbol[i] = 'Es'
|
113
|
-
i = 100; @symbol[i] = 'Fm'
|
114
|
-
i = 101; @symbol[i] = 'Md'
|
115
|
-
i = 102; @symbol[i] = 'No'
|
116
|
-
i = 103; @symbol[i] = 'Lr'
|
117
|
-
end
|
118
4
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
5
|
+
class NotExistError < Exception; end
|
6
|
+
|
7
|
+
SYMBOLS = [nil] + %w(
|
8
|
+
H He
|
9
|
+
Li Be B C N O F Ne
|
10
|
+
Na Mg Al Si P S Cl Ar
|
11
|
+
K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr
|
12
|
+
Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe
|
13
|
+
Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu
|
14
|
+
Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn
|
15
|
+
Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr
|
16
|
+
)
|
17
|
+
|
18
|
+
#https://www.hulinks.co.jp/support/c-maker/qa_05.html
|
19
|
+
ATOMIC_RADII = [nil,
|
20
|
+
0.53, 0.31,
|
21
|
+
1.67, 1.12, 0.87, 0.67, 0.56, 0.48, 0.42, 0.38,
|
22
|
+
1.90, 1.45, 1.18, 1.11, 0.98, 0.88, 0.79, 0.71,
|
23
|
+
2.43, 1.94, 1.84, 1.76, 1.71, 1.66, 1.61, 1.56,
|
24
|
+
1.52, 1.49, 1.45, 1.42, 1.36, 1.25, 1.14, 1.03, 0.94, 0.88,
|
25
|
+
2.65, 2.19, 2.12, 2.06, 1.98, 1.90, 1.83, 1.78,
|
26
|
+
1.73, 1.69, 1.65, 1.61, 1.56, 1.45, 1.33, 1.23, 1.15, 1.08,
|
27
|
+
2.98, 2.53, 1.95, 1.85, 2.47, 2.06, 2.05, 2.38,
|
28
|
+
2.31, 2.33, 2.25, 2.28, 2.26, 2.26, 2.22, 2.22, 2.17, 2.08, 2.00,
|
29
|
+
1.93, 1.88, 1.85, 1.80, 1.77, 1.74, 1.71, 1.56, 1.54, 1.43, 1.35, 1.27, 1.20,
|
30
|
+
nil, nil, 1.95, 1.80, 1.80, 1.75, 1.75, 1.75, 1.75
|
31
|
+
]
|
32
|
+
|
127
33
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
34
|
+
# Return atomic number from element symbol, e.g., H to 1.
|
35
|
+
# If not found, raise CrystalCell::Element::NotExistError.
|
36
|
+
def self.symbol_to_num(str)
|
37
|
+
symbol = SYMBOLS.index( str )
|
38
|
+
raise NotExistError, "Symbol #{str} not found." if (symbol == nil || symbol == 0)
|
39
|
+
symbol
|
40
|
+
end
|
136
41
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
42
|
+
# Return element symbols from atomic number 'num', e.g., 1 to H
|
43
|
+
# If not found, raise CrystalCell::Element::NotExistError.
|
44
|
+
def self.num_to_symbol(num)
|
45
|
+
raise NotExistError, "#{num} is not Fixnum." if (num.class != Fixnum)
|
46
|
+
raise NotExistError, "#{num} is out of range." if (num <= 0 || SYMBOLS.size <= num)
|
47
|
+
SYMBOLS[num]
|
48
|
+
end
|
143
49
|
|
144
|
-
|
145
|
-
|
146
|
-
|
50
|
+
# Return atomic radius.
|
51
|
+
# 'id' can be indicated by number and elemet symbol.
|
52
|
+
def self.atomic_radius(id)
|
53
|
+
id = self.symbol_to_num(id) if id.class == String
|
54
|
+
ATOMIC_RADII[id]
|
55
|
+
end
|
147
56
|
|
148
57
|
end
|
@@ -19,195 +19,208 @@ require "malge/simultaneousequations.rb"
|
|
19
19
|
# [0.00000, 0.00000, 0.70710]]
|
20
20
|
class CrystalCell::LatticeAxes < Mageo::Axes
|
21
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
|
-
|
22
|
+
attr_reader :axes
|
23
|
+
|
24
|
+
class InitializeError < Exception; end
|
25
|
+
class ArgumentError < Exception; end
|
26
|
+
class TypeError < Exception; end
|
27
|
+
|
28
|
+
include Math
|
29
|
+
include Mageo
|
30
|
+
|
31
|
+
# Argument 'vectors' is three vectors with the order of a, b, c.
|
32
|
+
# If you want to make LatticeAxes instances from lattice constants,
|
33
|
+
# you should convert to axes with LatticeAxes.lc_to_axes
|
34
|
+
# 任意の向きのベクトルを渡しても、必ず triangulate する。
|
35
|
+
def initialize(vectors)
|
36
|
+
raise InitializeError, "#{vectors.inspect}" unless vectors.size == 3
|
37
|
+
|
38
|
+
if vectors.class == CrystalCell::LatticeAxes
|
39
|
+
@axes = vectors
|
40
|
+
else
|
41
|
+
begin
|
42
|
+
vectors = self.class.triangulate(vectors)
|
43
|
+
rescue Vector3D::RangeError
|
44
|
+
raise InitializeError, "#{vectors.inspect}"
|
45
|
+
end
|
46
|
+
|
47
|
+
super(vectors)
|
47
48
|
end
|
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
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
## Class methods
|
53
|
+
|
54
|
+
# Generate new instance from lattice constants.
|
55
|
+
def self.new_lc(lc)
|
56
|
+
vec = CrystalCell::LatticeAxes.lc_to_axes(lc)
|
57
|
+
CrystalCell::LatticeAxes.new(vec)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Convert six lattice constants to three axes.
|
61
|
+
# Set true to the argument of 'righthand' if a assumed lattice has righthand axis system.
|
62
|
+
def self.lc_to_axes(lc, righthand = true)
|
63
|
+
raise ArgumentError if (lc.size != 6)
|
64
|
+
|
65
|
+
a = lc[0]
|
66
|
+
b = lc[1]
|
67
|
+
c = lc[2]
|
68
|
+
alpha = (2.0*PI) * lc[3] / 360.0 # radian
|
69
|
+
beta = (2.0*PI) * lc[4] / 360.0 # radian
|
70
|
+
gamma = (2.0*PI) * lc[5] / 360.0 # radian
|
71
|
+
|
72
|
+
v_c = Vector3D[0.0, 0.0, c]
|
73
|
+
v_b = Vector3D[0.0, b * Math::sin(alpha), b * Math::cos(alpha)]
|
74
|
+
v_a_z = a * Math::cos(beta)
|
75
|
+
v_a_y = (a * (Math::cos(gamma) - Math::cos(alpha) * Math::cos(beta)))/ Math::sin(alpha)
|
76
|
+
v_a_x = Math::sqrt(a**2 - v_a_y**2 - v_a_z**2)
|
77
|
+
v_a_x *= -1.0 if righthand == false
|
78
|
+
v_a = Vector3D[v_a_x, v_a_y, v_a_z]
|
79
|
+
return [v_a, v_b, v_c]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Convert three axes to six lattice constants.
|
83
|
+
def self.axes_to_lc(axes)
|
84
|
+
axes.collect!{|i| Vector3D[*i] }
|
85
|
+
a = axes[0].r
|
86
|
+
b = axes[1].r
|
87
|
+
c = axes[2].r
|
88
|
+
alpha = axes[1].angle_degree(axes[2])
|
89
|
+
beta = axes[2].angle_degree(axes[0])
|
90
|
+
gamma = axes[0].angle_degree(axes[1])
|
91
|
+
return [ a, b, c, alpha, beta, gamma ]
|
92
|
+
end
|
93
|
+
|
94
|
+
# Return true if the relation of vector order is righthand system.
|
95
|
+
def self.righthand?(axes)
|
96
|
+
axes.map! { |i| Vector3D[*i] }
|
97
|
+
return true if Vector3D.scalar_triple_product(*axes) > 0.0
|
98
|
+
return false
|
99
|
+
end
|
100
|
+
|
101
|
+
# Return true if the relation of vector order is lefthand system.
|
102
|
+
def self.lefthand?(axes)
|
103
|
+
axes.map! { |i| Vector3D[*i] }
|
104
|
+
return true if Vector3D.scalar_triple_product(*axes) < 0.0
|
105
|
+
return false
|
106
|
+
end
|
107
|
+
|
108
|
+
# Convert three axes to three axes with rules below:
|
109
|
+
# c axis is along z axis in cartesian system.
|
110
|
+
# b axis is on y-z plane in cartesian system.
|
111
|
+
# Return an array of three Vector3D instances.
|
112
|
+
# This class does not convert righthand to lefthand system.
|
113
|
+
# The name of this method 'triangulate' originates from the
|
114
|
+
# matrix indicating the vectors being triangular matrix.
|
115
|
+
#
|
116
|
+
# クラスメソッドは廃止の方向で。
|
117
|
+
# vectors の数をチェックするのは initialize でやるべきことだろうし、
|
118
|
+
# LatticeAxes クラスインスタンス以外で triangulate を使う場面が想像できない。
|
119
|
+
#
|
120
|
+
def self.triangulate(vectors)
|
121
|
+
vectors.map! { |i| Vector3D[*i] }
|
122
|
+
raise InitializeError if self.dependent?(vectors)
|
123
|
+
lc = self.axes_to_lc(vectors)
|
124
|
+
righthand = self.righthand?(vectors)
|
125
|
+
return self.lc_to_axes(lc, righthand)
|
126
|
+
end
|
127
|
+
|
128
|
+
## Instance methods.
|
129
|
+
|
130
|
+
# Get lattice constants in six values.
|
131
|
+
def get_lattice_constants
|
132
|
+
return CrystalCell::LatticeAxes.axes_to_lc(@axes)
|
133
|
+
end
|
134
|
+
|
135
|
+
def righthand?
|
136
|
+
self.class.righthand?(@axes)
|
137
|
+
end
|
138
|
+
|
139
|
+
def lefthand?
|
140
|
+
self.class.lefthand?(@axes)
|
141
|
+
end
|
142
|
+
|
143
|
+
# This class is obsoleted. [2011-12-22]
|
144
|
+
## Convert internal coordinates to cartesian coordinates.
|
145
|
+
## Return a Vector3DInternal class instance, which is not a cartesian vector.
|
146
|
+
#def internal2cartesian(internal_coord)
|
147
|
+
# Vector3DInternal[ *internal_coord ].to_v3d(axes)
|
148
|
+
#end
|
149
|
+
|
150
|
+
# This class is obsoleted. [2011-12-22]
|
151
|
+
## Convert cartesian coordinates to internal coordinates.
|
152
|
+
## Return a Vector3D class instance, which is a cartesian vector.
|
153
|
+
#def cartesian2internal(cartesian_coord)
|
154
|
+
# #pp cartesian_coord
|
155
|
+
# Vector3D[ *cartesian_coord ].to_v3di(axes)
|
156
|
+
#end
|
157
|
+
|
158
|
+
# Compare <other> CrystalCell::LatticeAxes instance.
|
159
|
+
# <length_ratio> is tolerance of ratio in length of axes.
|
160
|
+
# <angle_tolerance> is tolerance of value in angle between axes.
|
161
|
+
def equal_in_delta?(other, length_ratio, angle_tolerance)
|
162
|
+
length_a = self .get_lattice_constants[0..2]
|
163
|
+
length_b = other.get_lattice_constants[0..2]
|
164
|
+
3.times do |i|
|
165
|
+
return false unless ((length_a[i] - length_b[i]).abs <= length_ratio)
|
90
166
|
end
|
91
167
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
return false
|
168
|
+
angle_a = self .get_lattice_constants[3..5]
|
169
|
+
angle_b = other.get_lattice_constants[3..5]
|
170
|
+
3.times do |i|
|
171
|
+
return false unless ((angle_a[i] - angle_b[i]).abs <= angle_tolerance)
|
97
172
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
# Convert three axes to three axes with rules below:
|
107
|
-
# c axis is along z axis in cartesian system.
|
108
|
-
# b axis is on y-z plane in cartesian system.
|
109
|
-
# Return an array of three Vector3D instances.
|
110
|
-
# This class does not convert righthand to lefthand system.
|
111
|
-
# The name of this method 'triangulate' originates from the
|
112
|
-
# matrix indicating the vectors being triangular matrix.
|
113
|
-
#
|
114
|
-
# クラスメソッドは廃止の方向で。
|
115
|
-
# vectors の数をチェックするのは initialize でやるべきことだろうし、
|
116
|
-
# LatticeAxes クラスインスタンス以外で triangulate を使う場面が想像できない。
|
117
|
-
#
|
118
|
-
def self.triangulate(vectors)
|
119
|
-
vectors.map! { |i| Vector3D[*i] }
|
120
|
-
raise InitializeError if self.dependent?(vectors)
|
121
|
-
lc = self.axes_to_lc(vectors)
|
122
|
-
righthand = self.righthand?(vectors)
|
123
|
-
return self.lc_to_axes(lc, righthand)
|
124
|
-
end
|
125
|
-
|
126
|
-
## Instance methods.
|
127
|
-
|
128
|
-
# Get lattice constants in six values.
|
129
|
-
def get_lattice_constants
|
130
|
-
return CrystalCell::LatticeAxes.axes_to_lc(@axes)
|
173
|
+
return true
|
174
|
+
end
|
175
|
+
|
176
|
+
def ==(other)
|
177
|
+
3.times do |i|
|
178
|
+
3.times do |j|
|
179
|
+
return false if self[i][j] != other[i][j]
|
180
|
+
end
|
131
181
|
end
|
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
|
-
3.times do |i|
|
176
|
-
3.times do |j|
|
177
|
-
return false if self[i][j] != other[i][j]
|
178
|
-
end
|
179
|
-
end
|
180
|
-
return true
|
181
|
-
end
|
182
|
-
|
183
|
-
private
|
184
|
-
|
185
|
-
def triangulate
|
186
|
-
#self.class.triangulate(@axes)
|
187
|
-
# rotate(2, 2, 1)
|
188
|
-
# rotate(2, 0, 2)
|
189
|
-
# rotate(1, 2, 1)
|
190
|
-
end
|
191
|
-
|
192
|
-
#private
|
193
|
-
|
194
|
-
## 保持する全ての軸を回転する。
|
195
|
-
## 以下の index は Axes クラス保持している配列における index。
|
196
|
-
## target_index 回転の際の角度を決めるベクトルの
|
197
|
-
## self が保持する内部座標軸の index。
|
198
|
-
## center_axis_index 回転の中心軸のベクトルの index in x, y, z。
|
199
|
-
## plane_axis_index) 回転の目的地となる平面を、中心軸と共に構成するベクトルの index
|
200
|
-
## in x, y, z。
|
201
|
-
#def rotate(target_index, center_axis_index, plane_axis_index)
|
202
|
-
# theta =
|
203
|
-
|
204
|
-
# axes[target_index]
|
205
|
-
#
|
206
|
-
# HERE
|
207
|
-
|
208
|
-
# self.each do |vector|
|
209
|
-
# vector
|
210
|
-
# end
|
211
|
-
#end
|
182
|
+
return true
|
183
|
+
end
|
184
|
+
|
185
|
+
## Multiply all vectors. Not destructive.
|
186
|
+
def *(val)
|
187
|
+
#result = Marshal.load(Marshal.dump(self))
|
188
|
+
|
189
|
+
self.class.new(@axes.map{|vec| vec * val})
|
190
|
+
end
|
191
|
+
|
192
|
+
def to_a
|
193
|
+
@axes.map{|v| v.to_a}
|
194
|
+
end
|
195
|
+
|
196
|
+
private
|
197
|
+
|
198
|
+
def triangulate
|
199
|
+
#self.class.triangulate(@axes)
|
200
|
+
# rotate(2, 2, 1)
|
201
|
+
# rotate(2, 0, 2)
|
202
|
+
# rotate(1, 2, 1)
|
203
|
+
end
|
204
|
+
|
205
|
+
#private
|
206
|
+
|
207
|
+
## 保持する全ての軸を回転する。
|
208
|
+
## 以下の index は Axes クラス保持している配列における index。
|
209
|
+
## target_index 回転の際の角度を決めるベクトルの
|
210
|
+
## self が保持する内部座標軸の index。
|
211
|
+
## center_axis_index 回転の中心軸のベクトルの index in x, y, z。
|
212
|
+
## plane_axis_index) 回転の目的地となる平面を、中心軸と共に構成するベクトルの index
|
213
|
+
## in x, y, z。
|
214
|
+
#def rotate(target_index, center_axis_index, plane_axis_index)
|
215
|
+
# theta =
|
216
|
+
|
217
|
+
# axes[target_index]
|
218
|
+
#
|
219
|
+
# HERE
|
220
|
+
|
221
|
+
# self.each do |vector|
|
222
|
+
# vector
|
223
|
+
# end
|
224
|
+
#end
|
212
225
|
|
213
226
|
end
|