crysna 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/CHANGES +24 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +91 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/checkmodel +66 -0
- data/bin/collectcell +92 -0
- data/bin/fitframe +68 -0
- data/bin/occupiedpolyhedralsite +96 -0
- data/bin/occupiedscattersite +77 -0
- data/bin/site2poscar +66 -0
- data/bin/site2pov +30 -0
- data/bin/sitecombination +69 -0
- data/bin/sitemigration +80 -0
- data/bin/sitemigrationdistance +87 -0
- data/bin/siteoperation +109 -0
- data/bin/sitesingle +36 -0
- data/bin/siteuniq +32 -0
- data/bin/symidsite +65 -0
- data/bin/transitcell +46 -0
- data/crysna.gemspec +219 -0
- data/lib/crysna.rb +26 -0
- data/lib/crysna/atom.rb +97 -0
- data/lib/crysna/cell.rb +314 -0
- data/lib/crysna/frameatom.rb +13 -0
- data/lib/crysna/frameinterstitialcell.rb +309 -0
- data/lib/crysna/interstitialatom.rb +13 -0
- data/lib/crysna/modelstructure.rb +333 -0
- data/lib/crysna/optionmanager.rb +177 -0
- data/lib/crysna/site.rb +35 -0
- data/lib/crysna/siteconfiguration.rb +26 -0
- data/lib/crysna/sitenamelabeledcell.rb +220 -0
- data/lib/crysna/siteoperation.rb +56 -0
- data/lib/crysna/sitewithposition.rb +24 -0
- data/lib/crysna/transitionfinder.rb +448 -0
- data/lib/crysna/transitionfinder/cell.rb +144 -0
- data/lib/crysna/transitionfinder/cellmanager.rb +129 -0
- data/lib/crysna/transitionfinder/edge.rb +54 -0
- data/test/.gitignore +1 -0
- data/test/cell_orig/POSCAR +17 -0
- data/test/cell_orig/model.yaml +122 -0
- data/test/collectcells/.gitignore +2 -0
- data/test/collectcells/model.yaml +154 -0
- data/test/collectcells/nooutcar/minexpconfiguration.yaml +22 -0
- data/test/collectcells/normal-higher/OUTCAR +2406 -0
- data/test/collectcells/normal-higher/minexpconfiguration.yaml +22 -0
- data/test/collectcells/normal-lower/OUTCAR +2406 -0
- data/test/collectcells/normal-lower/minexpconfiguration.yaml +22 -0
- data/test/collectcells/normal/OUTCAR +2406 -0
- data/test/collectcells/normal/minexpconfiguration.yaml +22 -0
- data/test/collectcells/normalB/OUTCAR +2406 -0
- data/test/collectcells/normalB/minexpconfiguration.yaml +22 -0
- data/test/collectcells/unfinished/OUTCAR +40702 -0
- data/test/collectcells/unfinished/minexpconfiguration.yaml +22 -0
- data/test/collectcells/unidentified/OUTCAR +3541 -0
- data/test/collectcells/unidentified/minexpconfiguration.yaml +2 -0
- data/test/fitmodelstructure/.gitignore +1 -0
- data/test/fitmodelstructure/AgI/CONTCAR +17 -0
- data/test/fitmodelstructure/AgI/fitmodelstructure.log +1161 -0
- data/test/fitmodelstructure/AgI/model.yaml +45 -0
- data/test/fitmodelstructure/normal/CONTCAR +17 -0
- data/test/fitmodelstructure/normal/fitmodelstructure.log +5063 -0
- data/test/fitmodelstructure/normal/model.yaml +122 -0
- data/test/fitmodelstructure/unidentified/CONTCAR +44 -0
- data/test/fitmodelstructure/unidentified/fitmodelstructure.log +8833 -0
- data/test/fitmodelstructure/unidentified/model.yaml +154 -0
- data/test/helper.rb +17 -0
- data/test/identifypolyhedralsites/.gitignore +1 -0
- data/test/identifypolyhedralsites/identifyatomsites.log +333 -0
- data/test/identifypolyhedralsites/normal/fitmodelstructure.yaml +60 -0
- data/test/identifypolyhedralsites/normal/model.yaml +122 -0
- data/test/identifypolyhedralsites/unidentified/fitmodelstructure.yaml +2 -0
- data/test/identifypolyhedralsites/unidentified/model.yaml +154 -0
- data/test/identifypolyhedralsites/volumemismatch/fitmodelstructure.yaml +101 -0
- data/test/identifypolyhedralsites/volumemismatch/model.yaml +154 -0
- data/test/identifyscattersites/CONTCAR +17 -0
- data/test/identifyscattersites/POSCAR +12 -0
- data/test/identifyscattersites/fitmodelstructure.log +1 -0
- data/test/identifyscattersites/fitmodelstructure.yaml +0 -0
- data/test/identifyscattersites/identifyscattersites.yaml +5 -0
- data/test/identifyscattersites/model.yaml +45 -0
- data/test/minexpconfiguration/.gitignore +1 -0
- data/test/minexpconfiguration/collective/AgI/.gitignore +2 -0
- data/test/minexpconfiguration/collective/AgI/siteoperations.yaml +51265 -0
- data/test/minexpconfiguration/collective/AgI/sitesingle.yaml +15 -0
- data/test/minexpconfiguration/collective/AgI/test.sh +2 -0
- data/test/minexpconfiguration/normal/identifysites.yaml +22 -0
- data/test/minexpconfiguration/normal/minexpconfiguration.log +0 -0
- data/test/minexpconfiguration/normal/siteoperations.yaml +1793 -0
- data/test/minexpconfiguration/unidentified/identifysites.yaml +2 -0
- data/test/minexpconfiguration/unidentified/siteoperations.yaml +1793 -0
- data/test/sitecombination/initsites.yaml +7 -0
- data/test/sitecombination/initsites_test2.yaml +8 -0
- data/test/sitecombination/sitecombination.yaml +29 -0
- data/test/siteconfiguration/elements-sitenames.yaml +2 -0
- data/test/siteconfiguration/latticeaxes.yaml +3 -0
- data/test/siteconfiguration/sitenames-coordinates.yaml +4 -0
- data/test/sitemigrationsdistance/model.yaml +45 -0
- data/test/siteoperations/.gitignore +2 -0
- data/test/siteoperations/model.yaml +43 -0
- data/test/siteoperations/symmetryoperations.yaml +1441 -0
- data/test/sitesingle/.gitignore +1 -0
- data/test/sitesingle/sitecombination.yaml +29 -0
- data/test/siteuniq/minexpconfiguration.yaml +15 -0
- data/test/siteuniq/siteuniq.yaml +8 -0
- data/test/test_atom.rb +206 -0
- data/test/test_cell.rb +604 -0
- data/test/test_commands.rb +340 -0
- data/test/test_crystana.rb +7 -0
- data/test/test_frameatom.rb +22 -0
- data/test/test_frameinterstitialcell.rb +939 -0
- data/test/test_interstitialatom.rb +22 -0
- data/test/test_modelstructure.rb +807 -0
- data/test/test_optionmanager.rb +172 -0
- data/test/test_site.rb +40 -0
- data/test/test_siteconfiguration.rb +29 -0
- data/test/test_sitenamelabeledcell.rb +528 -0
- data/test/test_siteoperation.rb +79 -0
- data/test/test_sitewithposition.rb +20 -0
- data/test/test_transitionfinder.rb +432 -0
- data/test/transitcell/.gitignore +2 -0
- data/test/transitcell/collectcells.yaml +51 -0
- data/test/transitcell/sitemigrations.yaml +8 -0
- data/test/transitcell/siteoperations.yaml +17 -0
- data/test/transitcell/transitcell.log +1342 -0
- data/test/transitionfinder/collectcells.yaml +81 -0
- data/test/transitionfinder/sitemigrations.yaml +33 -0
- data/test/transitionfinder/siteoperations.yaml +16 -0
- data/test/transitionfinder/test_cell.rb +287 -0
- data/test/transitionfinder/test_cellmanager.rb +185 -0
- data/test/transitionfinder/test_edge.rb +49 -0
- data/test/uniquesitesgenerator/elements-sitenames.yaml +1 -0
- data/test/uniquesitesgenerator/siteoperations.yaml +9 -0
- metadata +406 -0
@@ -0,0 +1,172 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "pkg/klass.rb"
|
7
|
+
|
8
|
+
class TC_OptionManager < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@o00 = Crysna::OptionManager.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_parse_all
|
14
|
+
ary = []
|
15
|
+
@o00.parser.parse!(ary)
|
16
|
+
corrects = {
|
17
|
+
:cells=>"cells.yaml",
|
18
|
+
:fitted=>"fittedstructure.yaml",
|
19
|
+
:occupied=>"occupiedsite.yaml",
|
20
|
+
:model=>"model.yaml",
|
21
|
+
:symid=>"symidsite.yaml",
|
22
|
+
:migration=>"sitemigration.yaml",
|
23
|
+
:operation=>"siteoperation.yaml",
|
24
|
+
:symmetry=>"symoperation.yaml",
|
25
|
+
:unique =>"siteunique.yaml",
|
26
|
+
:single=>"sitesingle.yaml",
|
27
|
+
:combination=> 'sitecombination.yaml',
|
28
|
+
:candidate=> 'sitecandidate.yaml',
|
29
|
+
:quiet=>false,
|
30
|
+
}
|
31
|
+
assert_equal(corrects, @o00.options)
|
32
|
+
|
33
|
+
setup
|
34
|
+
ary = %w(-m test.yaml)
|
35
|
+
@o00.parser.parse!(ary)
|
36
|
+
corrects = {
|
37
|
+
:cells=>"cells.yaml",
|
38
|
+
:fitted=>"fittedstructure.yaml",
|
39
|
+
:occupied=>"occupiedsite.yaml",
|
40
|
+
:model=>"test.yaml",
|
41
|
+
:symid=>"symidsite.yaml",
|
42
|
+
:migration=>"sitemigration.yaml",
|
43
|
+
:operation=>"siteoperation.yaml",
|
44
|
+
:symmetry=>"symoperation.yaml",
|
45
|
+
:unique =>"siteunique.yaml",
|
46
|
+
:single=>"sitesingle.yaml",
|
47
|
+
:combination=> 'sitecombination.yaml',
|
48
|
+
:candidate=> 'sitecandidate.yaml',
|
49
|
+
:quiet=>false,
|
50
|
+
}
|
51
|
+
assert_equal(corrects, @o00.options)
|
52
|
+
|
53
|
+
setup
|
54
|
+
ary = %w(-f test.yaml)
|
55
|
+
@o00.parser.parse!(ary)
|
56
|
+
assert_equal('test.yaml', @o00.options[:fitted])
|
57
|
+
|
58
|
+
setup
|
59
|
+
ary = %w(-M test.yaml)
|
60
|
+
@o00.parser.parse!(ary)
|
61
|
+
assert_equal('test.yaml', @o00.options[:migration])
|
62
|
+
|
63
|
+
setup
|
64
|
+
ary = %w(-o test.yaml)
|
65
|
+
@o00.parser.parse!(ary)
|
66
|
+
assert_equal('test.yaml', @o00.options[:operation])
|
67
|
+
|
68
|
+
setup
|
69
|
+
ary = %w(-c test.yaml)
|
70
|
+
@o00.parser.parse!(ary)
|
71
|
+
assert_equal('test.yaml', @o00.options[:cells])
|
72
|
+
|
73
|
+
setup
|
74
|
+
ary = %w(-i test.yaml)
|
75
|
+
@o00.parser.parse!(ary)
|
76
|
+
assert_equal('test.yaml', @o00.options[:symid])
|
77
|
+
|
78
|
+
setup
|
79
|
+
ary = %w(-y test.yaml)
|
80
|
+
@o00.parser.parse!(ary)
|
81
|
+
assert_equal('test.yaml', @o00.options[:symmetry])
|
82
|
+
|
83
|
+
#### --model=-
|
84
|
+
setup
|
85
|
+
ary = %w(--model=-)
|
86
|
+
@o00.parser.parse!(ary)
|
87
|
+
assert_equal('-', @o00.options[:model])
|
88
|
+
|
89
|
+
setup
|
90
|
+
ary = %w(-m -)
|
91
|
+
@o00.parser.parse!(ary)
|
92
|
+
assert_equal('-', @o00.options[:model])
|
93
|
+
|
94
|
+
setup
|
95
|
+
ary = %w(-b test.yaml)
|
96
|
+
@o00.parser.parse!(ary)
|
97
|
+
assert_equal('test.yaml', @o00.options[:combination])
|
98
|
+
|
99
|
+
setup
|
100
|
+
ary = %w(-d test.yaml)
|
101
|
+
@o00.parser.parse!(ary)
|
102
|
+
assert_equal('test.yaml', @o00.options[:candidate])
|
103
|
+
|
104
|
+
setup
|
105
|
+
ary = %w(-s test.yaml)
|
106
|
+
@o00.parser.parse!(ary)
|
107
|
+
assert_equal('test.yaml', @o00.options[:single])
|
108
|
+
|
109
|
+
setup
|
110
|
+
ary = %w(-u test.yaml)
|
111
|
+
@o00.parser.parse!(ary)
|
112
|
+
assert_equal('test.yaml', @o00.options[:unique])
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_init
|
117
|
+
ary = []
|
118
|
+
@o00.parser.parse!(ary)
|
119
|
+
corrects = {
|
120
|
+
:cells=>"cells.yaml",
|
121
|
+
:fitted=>"fittedstructure.yaml",
|
122
|
+
:occupied=>"occupiedsite.yaml",
|
123
|
+
:model=>"model.yaml",
|
124
|
+
:symid=>"symidsite.yaml",
|
125
|
+
:migration=>"sitemigration.yaml",
|
126
|
+
:operation=>"siteoperation.yaml",
|
127
|
+
:symmetry=>"symoperation.yaml",
|
128
|
+
:unique =>"siteunique.yaml",
|
129
|
+
:single=>"sitesingle.yaml",
|
130
|
+
:combination=> 'sitecombination.yaml',
|
131
|
+
:candidate=> 'sitecandidate.yaml',
|
132
|
+
:quiet=>false,
|
133
|
+
}
|
134
|
+
assert_equal(corrects, @o00.options)
|
135
|
+
|
136
|
+
o10 = Crysna::OptionManager.new([:model])
|
137
|
+
ary = []
|
138
|
+
o10.parser.parse!(ary)
|
139
|
+
corrects = {
|
140
|
+
:model=>"model.yaml",
|
141
|
+
}
|
142
|
+
assert_equal(corrects, o10.options)
|
143
|
+
|
144
|
+
assert_raise(Crysna::OptionManager::INVARID_OPTION){
|
145
|
+
Crysna::OptionManager.new([:cells, :unknown])
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_parse
|
150
|
+
setup
|
151
|
+
ary = %w(-m test.yaml abc)
|
152
|
+
@o00.parse!(ary)
|
153
|
+
corrects = {
|
154
|
+
:cells=>"cells.yaml",
|
155
|
+
:fitted=>"fittedstructure.yaml",
|
156
|
+
:occupied=>"occupiedsite.yaml",
|
157
|
+
:model=>"test.yaml",
|
158
|
+
:symid=>"symidsite.yaml",
|
159
|
+
:migration=>"sitemigration.yaml",
|
160
|
+
:operation=>"siteoperation.yaml",
|
161
|
+
:symmetry=>"symoperation.yaml",
|
162
|
+
:unique =>"siteunique.yaml",
|
163
|
+
:single=>"sitesingle.yaml",
|
164
|
+
:combination=> 'sitecombination.yaml',
|
165
|
+
:candidate=> 'sitecandidate.yaml',
|
166
|
+
:quiet=>false,
|
167
|
+
}
|
168
|
+
assert_equal(corrects, @o00.options)
|
169
|
+
assert_equal(['abc'], ary)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
data/test/test_site.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "pkg/klass.rb"
|
7
|
+
|
8
|
+
class TC_Site < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@cs_S00_m01 = Crysna::Site.new("S00", [-1, 0, 1])
|
11
|
+
@cs_S00_101 = Crysna::Site.new("S00", [ 0, 0, 1])
|
12
|
+
@cs_S00_m11 = Crysna::Site.new("S00", [-1, 1, 1])
|
13
|
+
@cs_S00_m00 = Crysna::Site.new("S00", [-1, 0, 0])
|
14
|
+
@cs_S01_m01 = Crysna::Site.new("S01", [-1, 0, 1])
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_equal?
|
18
|
+
assert_equal(true , @cs_S00_m01.equal?(Crysna::Site.new("S00", [-1, 0, 1] )))
|
19
|
+
assert_equal(false, @cs_S00_m01.equal?(@cs_S00_101))
|
20
|
+
assert_equal(false, @cs_S00_m01.equal?(@cs_S00_m11))
|
21
|
+
assert_equal(false, @cs_S00_m01.equal?(@cs_S00_m00))
|
22
|
+
assert_equal(false, @cs_S00_m01.equal?(@cs_S01_m01))
|
23
|
+
|
24
|
+
assert_equal(true , @cs_S00_m01 == Crysna::Site.new("S00", [-1, 0, 1] ))
|
25
|
+
assert_equal(false, @cs_S00_m01 == @cs_S00_101)
|
26
|
+
assert_equal(false, @cs_S00_m01 == @cs_S00_m11)
|
27
|
+
assert_equal(false, @cs_S00_m01 == @cs_S00_m00)
|
28
|
+
assert_equal(false, @cs_S00_m01 == @cs_S01_m01)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_same_globla_vector?
|
32
|
+
assert_equal(true , @cs_S00_m01.same_globla_vector?(Crysna::Site.new("S00", [-1, 0, 1])))
|
33
|
+
assert_equal(false, @cs_S00_m01.same_globla_vector?(@cs_S00_101))
|
34
|
+
assert_equal(false, @cs_S00_m01.same_globla_vector?(@cs_S00_m11))
|
35
|
+
assert_equal(false, @cs_S00_m01.same_globla_vector?(@cs_S00_m00))
|
36
|
+
assert_equal(true , @cs_S00_m01.same_globla_vector?(@cs_S01_m01))
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'helper'
|
5
|
+
#require 'test/unit'
|
6
|
+
#require 'pkg/klass.rb'
|
7
|
+
|
8
|
+
class SiteConfiguration
|
9
|
+
end
|
10
|
+
|
11
|
+
class TC_SiteConfiguration < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
hash = {
|
14
|
+
'Ag' => ['1A', '2A'],
|
15
|
+
'I' => ['IA', 'IB'],
|
16
|
+
}
|
17
|
+
@sc = Crysna::SiteConfiguration.new(hash)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_initalize
|
21
|
+
hash = {
|
22
|
+
'Ag' => ['1A', '2A'],
|
23
|
+
'I' => ['IA', 'IB'],
|
24
|
+
}
|
25
|
+
assert_equal(hash, @sc.elem_sites)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,528 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "mathextension/vector3dinternal.rb"
|
7
|
+
#require "crystal/atom2.rb"
|
8
|
+
#require "crysna/sitenamelabeledcell.rb"
|
9
|
+
|
10
|
+
# assert_equal( cor, data)
|
11
|
+
# assert_in_delta( cor, data, $tolerance )
|
12
|
+
# assert_raise( RuntimeError ){}
|
13
|
+
|
14
|
+
class SiteNameLabeledCell
|
15
|
+
public :nearest_atom_index
|
16
|
+
public_class_method :nearest_site
|
17
|
+
public_class_method :unique_sitenames?
|
18
|
+
end
|
19
|
+
|
20
|
+
class TC_SiteNameLabeledCell < Test::Unit::TestCase
|
21
|
+
$tolerance = 1.0 * (10 **(-10))
|
22
|
+
|
23
|
+
def setup
|
24
|
+
@sites00 = {
|
25
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
26
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
27
|
+
}
|
28
|
+
@atoms00 = [
|
29
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ]),
|
30
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ])
|
31
|
+
]
|
32
|
+
@c00 = SiteNameLabeledCell.new(
|
33
|
+
[ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ], @atoms00, @sites00
|
34
|
+
)
|
35
|
+
@c00.comment = "c00"
|
36
|
+
|
37
|
+
@sites01 = {
|
38
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
39
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
40
|
+
}
|
41
|
+
@atoms01 = [
|
42
|
+
CrystalCell::Atom.new( 0, [ 0.99, 0.99, 0.99 ]),
|
43
|
+
CrystalCell::Atom.new( 0, [ 0.90, 0.20, 0.30 ])
|
44
|
+
]
|
45
|
+
@c01 = SiteNameLabeledCell.new(
|
46
|
+
[ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ], @atoms01, @sites01
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_initialize
|
51
|
+
# サイト数と原子数が一致しないときに例外。
|
52
|
+
assert_raise( SiteNameLabeledCell::InitializeError ){
|
53
|
+
SiteNameLabeledCell.new(
|
54
|
+
[ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ],
|
55
|
+
@atoms00,
|
56
|
+
{}
|
57
|
+
)
|
58
|
+
}
|
59
|
+
|
60
|
+
# 同上
|
61
|
+
sites = Hash.new
|
62
|
+
sites["site00"] = Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ]
|
63
|
+
sites["site01"] = Mageo::Vector3DInternal[ 0.20, 0.20, 0.20 ]
|
64
|
+
sites["site02"] = Mageo::Vector3DInternal[ 0.80, 0.80, 0.80 ]
|
65
|
+
assert_raise( SiteNameLabeledCell::InitializeError ){
|
66
|
+
SiteNameLabeledCell.new(
|
67
|
+
[ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ],
|
68
|
+
@atoms00,
|
69
|
+
sites
|
70
|
+
)
|
71
|
+
}
|
72
|
+
|
73
|
+
# 最近接の原子とサイト名が一対一対応しないときに例外。
|
74
|
+
sites = Hash.new
|
75
|
+
sites["site00"] = Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ]
|
76
|
+
sites["site01"] = Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ]
|
77
|
+
assert_raise( SiteNameLabeledCell::InitializeError ){
|
78
|
+
SiteNameLabeledCell.new(
|
79
|
+
[ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ],
|
80
|
+
@atoms00,
|
81
|
+
sites
|
82
|
+
)
|
83
|
+
}
|
84
|
+
|
85
|
+
# 同上、ただし周期境界を考慮していることを確認。
|
86
|
+
sites = Hash.new
|
87
|
+
sites["site00"] = Mageo::Vector3DInternal[ 0.0, 0.0, 0.8 ]
|
88
|
+
sites["site01"] = Mageo::Vector3DInternal[ 0.0, 0.0, 0.1 ]
|
89
|
+
atoms = []
|
90
|
+
atoms << CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.05 ])
|
91
|
+
atoms << CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.99 ])
|
92
|
+
assert_raise( SiteNameLabeledCell::InitializeError ){
|
93
|
+
SiteNameLabeledCell.new(
|
94
|
+
[ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ],
|
95
|
+
atoms,
|
96
|
+
sites
|
97
|
+
)
|
98
|
+
}
|
99
|
+
|
100
|
+
axes = [ [2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0] ]
|
101
|
+
sites = {
|
102
|
+
"site00" => Mageo::Vector3DInternal[ 0.99, 0.99, 0.01 ],
|
103
|
+
"site01" => Mageo::Vector3DInternal[ 0.90, 0.99, 0.01 ]
|
104
|
+
}
|
105
|
+
atoms = [
|
106
|
+
CrystalCell::Atom.new( 0, [ 0.90, 0.01, 0.01 ]),
|
107
|
+
CrystalCell::Atom.new( 0, [ 0.99, 0.01, 0.01 ])
|
108
|
+
]
|
109
|
+
#
|
110
|
+
assert_nothing_raised{ SiteNameLabeledCell.new(axes, atoms, sites) }
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_nearest_atom_index
|
114
|
+
assert_raise(SiteNameLabeledCell::TypeError){
|
115
|
+
@c00.nearest_atom_index( Mageo::Vector3DInternal[0.0, 0.0, 0.0] )
|
116
|
+
}
|
117
|
+
|
118
|
+
assert_equal(0 , @c00.nearest_atom_index("site00"))
|
119
|
+
assert_equal(1 , @c00.nearest_atom_index("site01"))
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_sum_square_distances
|
123
|
+
# 破壊的でないことを確認。
|
124
|
+
sites = {
|
125
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
126
|
+
}
|
127
|
+
atoms = [
|
128
|
+
CrystalCell::Atom.new( 0, [-0.01,-0.01,-0.01 ], "site00"),
|
129
|
+
]
|
130
|
+
cell = SiteNameLabeledCell.new(
|
131
|
+
[ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ], atoms, sites
|
132
|
+
)
|
133
|
+
#pp cell
|
134
|
+
assert_in_delta( 0.0012, cell.sum_square_distances, $tolerance)
|
135
|
+
assert_in_delta(-0.01, cell.atoms[0].position[0], $tolerance)
|
136
|
+
assert_in_delta(-0.01, cell.atoms[0].position[1], $tolerance)
|
137
|
+
assert_in_delta(-0.01, cell.atoms[0].position[2], $tolerance)
|
138
|
+
|
139
|
+
# 機能テスト
|
140
|
+
assert_in_delta(0.0112 , @c00.sum_square_distances, $tolerance)
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_to_cell
|
145
|
+
t = @c00.to_cell
|
146
|
+
assert_equal(CrystalCell::Cell, t.class)
|
147
|
+
assert_equal(2, t.atoms.size)
|
148
|
+
assert_equal(0, t.atoms[0].element)
|
149
|
+
assert_equal("site00", t.atoms[0].name)
|
150
|
+
assert_equal(Mageo::Vector3DInternal[0.0, 0.0, 0.0], t.atoms[0].position)
|
151
|
+
assert_equal(0, t.atoms[1].element)
|
152
|
+
assert_equal("site01", t.atoms[1].name)
|
153
|
+
assert_equal(Mageo::Vector3DInternal[0.1, 0.2, 0.3], t.atoms[1].position)
|
154
|
+
assert_equal("c00", t.comment)
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_center_of_sites
|
158
|
+
vec = @c00.center_of_sites
|
159
|
+
assert_equal(Mageo::Vector3DInternal, vec.class)
|
160
|
+
assert_in_delta(0.06, vec[0], $tolerance)
|
161
|
+
assert_in_delta(0.11, vec[1], $tolerance)
|
162
|
+
assert_in_delta(0.16, vec[2], $tolerance)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_center_of_atoms
|
166
|
+
vec = @c00.center_of_atoms
|
167
|
+
assert_equal(Mageo::Vector3DInternal, vec.class)
|
168
|
+
assert_in_delta(0.05, vec[0], $tolerance)
|
169
|
+
assert_in_delta(0.10, vec[1], $tolerance)
|
170
|
+
assert_in_delta(0.15, vec[2], $tolerance)
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_sitenames_positions
|
174
|
+
t = @c00.sitenames_positions
|
175
|
+
assert_equal(2, t.size)
|
176
|
+
assert_equal(Mageo::Vector3DInternal, t["site00"].class)
|
177
|
+
assert_in_delta(0.00, t["site00"][0], $tolerance)
|
178
|
+
assert_in_delta(0.00, t["site00"][1], $tolerance)
|
179
|
+
assert_in_delta(0.00, t["site00"][2], $tolerance)
|
180
|
+
#
|
181
|
+
assert_equal(Mageo::Vector3DInternal, t["site01"].class)
|
182
|
+
assert_in_delta(0.10, t["site01"][0], $tolerance)
|
183
|
+
assert_in_delta(0.20, t["site01"][1], $tolerance)
|
184
|
+
assert_in_delta(0.30, t["site01"][2], $tolerance)
|
185
|
+
|
186
|
+
t = @c01.sitenames_positions
|
187
|
+
assert_equal(2, t.size)
|
188
|
+
assert_equal(Mageo::Vector3DInternal, t["site00"].class)
|
189
|
+
assert_in_delta(-0.01, t["site00"][0], $tolerance)
|
190
|
+
assert_in_delta(-0.01, t["site00"][1], $tolerance)
|
191
|
+
assert_in_delta(-0.01, t["site00"][2], $tolerance)
|
192
|
+
#
|
193
|
+
assert_equal(Mageo::Vector3DInternal, t["site01"].class)
|
194
|
+
assert_in_delta(-0.10, t["site01"][0], $tolerance)
|
195
|
+
assert_in_delta( 0.20, t["site01"][1], $tolerance)
|
196
|
+
assert_in_delta( 0.30, t["site01"][2], $tolerance)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_sitenames_elements
|
200
|
+
assert_equal(
|
201
|
+
{ "site00" => 0,
|
202
|
+
"site01" => 0
|
203
|
+
},
|
204
|
+
@c00.sitenames_elements
|
205
|
+
)
|
206
|
+
assert_equal(
|
207
|
+
{ "site00" => 0,
|
208
|
+
"site01" => 0
|
209
|
+
},
|
210
|
+
@c01.sitenames_elements
|
211
|
+
)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
class TC_SiteNameLabeledCellClassMethods < Test::Unit::TestCase
|
216
|
+
def setup
|
217
|
+
@sites00 = {
|
218
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
219
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
220
|
+
}
|
221
|
+
@atoms00 = [
|
222
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ]),
|
223
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ])
|
224
|
+
]
|
225
|
+
|
226
|
+
@sites01 = {
|
227
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
228
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
229
|
+
}
|
230
|
+
@atoms01 = [
|
231
|
+
CrystalCell::Atom.new( 0, [ 0.99, 0.99, 0.99 ]),
|
232
|
+
CrystalCell::Atom.new( 0, [ 0.90, 0.20, 0.30 ])
|
233
|
+
]
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_self_unique_sitenames?
|
237
|
+
atoms01 = [
|
238
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
239
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site01")
|
240
|
+
]
|
241
|
+
assert_equal(true , SiteNameLabeledCell.unique_sitenames?(atoms01))
|
242
|
+
|
243
|
+
atoms01 = [
|
244
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
245
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00")
|
246
|
+
]
|
247
|
+
assert_equal(false, SiteNameLabeledCell.unique_sitenames?(atoms01))
|
248
|
+
|
249
|
+
atoms01 = [
|
250
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
251
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], nil)
|
252
|
+
]
|
253
|
+
assert_equal(false, SiteNameLabeledCell.unique_sitenames?(atoms01))
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_label_sitenames
|
257
|
+
axes = [ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ]
|
258
|
+
sites = @sites00
|
259
|
+
atoms = @atoms00
|
260
|
+
t = SiteNameLabeledCell.label_sitenames(axes, atoms, sites)
|
261
|
+
assert_equal(2, t.size)
|
262
|
+
assert_equal("site00", t[0].name)
|
263
|
+
assert_in_delta(0.00, t[0].position[0])
|
264
|
+
assert_in_delta(0.00, t[0].position[1])
|
265
|
+
assert_in_delta(0.00, t[0].position[2])
|
266
|
+
#
|
267
|
+
assert_equal("site01", t[1].name)
|
268
|
+
assert_in_delta(0.10, t[1].position[0])
|
269
|
+
assert_in_delta(0.20, t[1].position[1])
|
270
|
+
assert_in_delta(0.30, t[1].position[2])
|
271
|
+
|
272
|
+
axes = [ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ]
|
273
|
+
sites = @sites01
|
274
|
+
atoms = @atoms01
|
275
|
+
t = SiteNameLabeledCell.label_sitenames(axes, atoms, sites)
|
276
|
+
assert_equal(2, t.size)
|
277
|
+
assert_equal("site00", t[0].name)
|
278
|
+
assert_in_delta( 0.99, t[0].position[0])
|
279
|
+
assert_in_delta( 0.99, t[0].position[1])
|
280
|
+
assert_in_delta( 0.99, t[0].position[2])
|
281
|
+
#
|
282
|
+
assert_equal("site01", t[1].name)
|
283
|
+
assert_in_delta( 0.90, t[1].position[0])
|
284
|
+
assert_in_delta( 0.20, t[1].position[1])
|
285
|
+
assert_in_delta( 0.30, t[1].position[2])
|
286
|
+
|
287
|
+
axes = [ [2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0] ]
|
288
|
+
sites = {
|
289
|
+
"site00" => Mageo::Vector3DInternal[ 0.99, 0.99, 0.01 ],
|
290
|
+
"site01" => Mageo::Vector3DInternal[ 0.90, 0.99, 0.01 ]
|
291
|
+
}
|
292
|
+
#
|
293
|
+
atoms = [
|
294
|
+
CrystalCell::Atom.new( 0, [ 0.90, 0.01, 0.01 ]),
|
295
|
+
CrystalCell::Atom.new( 0, [ 0.99, 0.01, 0.01 ])
|
296
|
+
]
|
297
|
+
#
|
298
|
+
t = SiteNameLabeledCell.label_sitenames(axes, atoms, sites)
|
299
|
+
assert_equal(2, t.size)
|
300
|
+
assert_in_delta( 0.90, t[0].position[0])
|
301
|
+
assert_in_delta( 0.01, t[0].position[1])
|
302
|
+
assert_in_delta( 0.01, t[0].position[2])
|
303
|
+
assert_equal("site01", t[0].name)
|
304
|
+
#
|
305
|
+
assert_in_delta( 0.99, t[1].position[0])
|
306
|
+
assert_in_delta( 0.01, t[1].position[1])
|
307
|
+
assert_in_delta( 0.01, t[1].position[2])
|
308
|
+
assert_equal("site00", t[1].name)
|
309
|
+
|
310
|
+
axes = [ [2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0] ]
|
311
|
+
#
|
312
|
+
atoms = [
|
313
|
+
CrystalCell::Atom.new( 0, [ 0.01, 0.01, 0.01 ]),
|
314
|
+
CrystalCell::Atom.new( 0, [-0.89,-0.79,-0.69 ])
|
315
|
+
]
|
316
|
+
sites = {
|
317
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
318
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
319
|
+
}
|
320
|
+
t = SiteNameLabeledCell.label_sitenames(axes, atoms, sites)
|
321
|
+
assert_equal(2, t.size)
|
322
|
+
assert_in_delta( 0.01, t[0].position[0])
|
323
|
+
assert_in_delta( 0.01, t[0].position[1])
|
324
|
+
assert_in_delta( 0.01, t[0].position[2])
|
325
|
+
assert_equal("site00", t[0].name)
|
326
|
+
#
|
327
|
+
assert_in_delta(-0.89, t[1].position[0])
|
328
|
+
assert_in_delta(-0.79, t[1].position[1])
|
329
|
+
assert_in_delta(-0.69, t[1].position[2])
|
330
|
+
assert_equal("site01", t[1].name)
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_periodically_translate_atoms_to_nearest_site
|
334
|
+
axes = [ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ]
|
335
|
+
sites = @sites00
|
336
|
+
atoms = [
|
337
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
338
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ], "site01")
|
339
|
+
]
|
340
|
+
t = SiteNameLabeledCell.periodically_translate_atoms_to_nearest_site(
|
341
|
+
axes, atoms, sites)
|
342
|
+
assert_equal(2, t.size)
|
343
|
+
assert_equal("site00", t[0].name)
|
344
|
+
assert_in_delta(0.00, t[0].position[0])
|
345
|
+
assert_in_delta(0.00, t[0].position[1])
|
346
|
+
assert_in_delta(0.00, t[0].position[2])
|
347
|
+
#
|
348
|
+
assert_equal("site01", t[1].name)
|
349
|
+
assert_in_delta(0.10, t[1].position[0])
|
350
|
+
assert_in_delta(0.20, t[1].position[1])
|
351
|
+
assert_in_delta(0.30, t[1].position[2])
|
352
|
+
|
353
|
+
axes = [ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ]
|
354
|
+
sites = @sites01
|
355
|
+
atoms = [
|
356
|
+
CrystalCell::Atom.new( 0, [ 0.99, 0.99, 0.99 ], "site00"),
|
357
|
+
CrystalCell::Atom.new( 0, [ 0.90, 0.20, 0.30 ], "site01")
|
358
|
+
]
|
359
|
+
t = SiteNameLabeledCell.periodically_translate_atoms_to_nearest_site(
|
360
|
+
axes, atoms, sites)
|
361
|
+
assert_equal(2, t.size)
|
362
|
+
assert_equal("site00", t[0].name)
|
363
|
+
assert_in_delta(-0.01, t[0].position[0])
|
364
|
+
assert_in_delta(-0.01, t[0].position[1])
|
365
|
+
assert_in_delta(-0.01, t[0].position[2])
|
366
|
+
#
|
367
|
+
assert_equal("site01", t[1].name)
|
368
|
+
assert_in_delta(-0.10, t[1].position[0])
|
369
|
+
assert_in_delta( 0.20, t[1].position[1])
|
370
|
+
assert_in_delta( 0.30, t[1].position[2])
|
371
|
+
|
372
|
+
axes = [ [2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0] ]
|
373
|
+
sites = {
|
374
|
+
"site00" => Mageo::Vector3DInternal[ 0.99, 0.99, 0.01 ],
|
375
|
+
"site01" => Mageo::Vector3DInternal[ 0.90, 0.99, 0.01 ]
|
376
|
+
}
|
377
|
+
#
|
378
|
+
atoms = [
|
379
|
+
CrystalCell::Atom.new( 0, [ 0.90, 0.01, 0.01 ], "site01"),
|
380
|
+
CrystalCell::Atom.new( 0, [ 0.99, 0.01, 0.01 ], "site00")
|
381
|
+
]
|
382
|
+
#
|
383
|
+
t = SiteNameLabeledCell.periodically_translate_atoms_to_nearest_site(
|
384
|
+
axes, atoms, sites)
|
385
|
+
assert_equal(2, t.size)
|
386
|
+
assert_in_delta( 0.90, t[0].position[0])
|
387
|
+
assert_in_delta( 1.01, t[0].position[1])
|
388
|
+
assert_in_delta( 0.01, t[0].position[2])
|
389
|
+
assert_equal("site01", t[0].name)
|
390
|
+
#
|
391
|
+
assert_in_delta( 0.99, t[1].position[0])
|
392
|
+
assert_in_delta( 1.01, t[1].position[1])
|
393
|
+
assert_in_delta( 0.01, t[1].position[2])
|
394
|
+
assert_equal("site00", t[1].name)
|
395
|
+
|
396
|
+
axes = [ [2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0] ]
|
397
|
+
#
|
398
|
+
atoms = [
|
399
|
+
CrystalCell::Atom.new( 0, [ 0.01, 0.01, 0.01 ], "site00"),
|
400
|
+
CrystalCell::Atom.new( 0, [-0.89,-0.79,-0.69 ], "site01")
|
401
|
+
]
|
402
|
+
sites = {
|
403
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
404
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
405
|
+
}
|
406
|
+
#
|
407
|
+
t = SiteNameLabeledCell.periodically_translate_atoms_to_nearest_site(
|
408
|
+
axes, atoms, sites)
|
409
|
+
assert_equal(2, t.size)
|
410
|
+
assert_in_delta( 0.01, t[0].position[0])
|
411
|
+
assert_in_delta( 0.01, t[0].position[1])
|
412
|
+
assert_in_delta( 0.01, t[0].position[2])
|
413
|
+
assert_equal("site00", t[0].name)
|
414
|
+
#
|
415
|
+
assert_in_delta( 0.11, t[1].position[0])
|
416
|
+
assert_in_delta( 0.21, t[1].position[1])
|
417
|
+
assert_in_delta( 0.31, t[1].position[2])
|
418
|
+
assert_equal("site01", t[1].name)
|
419
|
+
|
420
|
+
end
|
421
|
+
|
422
|
+
def test_self_nearest_site
|
423
|
+
la = CrystalCell::LatticeAxes.new([ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ])
|
424
|
+
pos = Mageo::Vector3DInternal[0.0, 0.0, 0.0]
|
425
|
+
t = SiteNameLabeledCell.nearest_site(la, pos, @sites00)
|
426
|
+
assert_equal("site00" , t)
|
427
|
+
|
428
|
+
pos = Mageo::Vector3DInternal[0.1, 0.2, 0.3]
|
429
|
+
t = SiteNameLabeledCell.nearest_site(la, pos, @sites00)
|
430
|
+
assert_equal("site01" , t)
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_labeled_all_atoms?
|
434
|
+
atoms = [
|
435
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
436
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ], "site01")
|
437
|
+
]
|
438
|
+
assert_equal(true, SiteNameLabeledCell.labeled_all_atoms?(atoms, @sites00))
|
439
|
+
|
440
|
+
atoms = [
|
441
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
442
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ], "site00")
|
443
|
+
]
|
444
|
+
assert_equal(true, SiteNameLabeledCell.labeled_all_atoms?(atoms, @sites00))
|
445
|
+
|
446
|
+
atoms = [
|
447
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ], "site00"),
|
448
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ])
|
449
|
+
]
|
450
|
+
assert_equal(false, SiteNameLabeledCell.labeled_all_atoms?(atoms, @sites00))
|
451
|
+
|
452
|
+
atoms = [
|
453
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ]),
|
454
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ], "site00")
|
455
|
+
]
|
456
|
+
assert_equal(false, SiteNameLabeledCell.labeled_all_atoms?(atoms, @sites00))
|
457
|
+
|
458
|
+
atoms = [
|
459
|
+
CrystalCell::Atom.new( 0, [ 0.00, 0.00, 0.00 ]),
|
460
|
+
CrystalCell::Atom.new( 0, [ 0.10, 0.20, 0.30 ])
|
461
|
+
]
|
462
|
+
assert_equal(false, SiteNameLabeledCell.labeled_all_atoms?(atoms, @sites00))
|
463
|
+
|
464
|
+
end
|
465
|
+
|
466
|
+
def test_self_check_inside_all_sites
|
467
|
+
assert_nothing_raised{SiteNameLabeledCell.check_inside_all_sites(@sites00)}
|
468
|
+
assert_nothing_raised{SiteNameLabeledCell.check_inside_all_sites(@sites01)}
|
469
|
+
|
470
|
+
sites = {
|
471
|
+
"site00" => Mageo::Vector3DInternal[ 0.00, 0.00, 0.00 ],
|
472
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
473
|
+
}
|
474
|
+
assert_nothing_raised{SiteNameLabeledCell.check_inside_all_sites(sites)}
|
475
|
+
|
476
|
+
sites = {
|
477
|
+
"site00" => Mageo::Vector3DInternal[ 1.01, 0.00, 0.00 ],
|
478
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
479
|
+
}
|
480
|
+
assert_raise(SiteNameLabeledCell::OutOfCellError){
|
481
|
+
SiteNameLabeledCell.check_inside_all_sites(sites)}
|
482
|
+
|
483
|
+
sites = {
|
484
|
+
"site00" => Mageo::Vector3DInternal[-0.01, 0.00, 0.00 ],
|
485
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
486
|
+
}
|
487
|
+
assert_raise(SiteNameLabeledCell::OutOfCellError){
|
488
|
+
SiteNameLabeledCell.check_inside_all_sites(sites)}
|
489
|
+
end
|
490
|
+
|
491
|
+
#def test_site_name
|
492
|
+
# assert_equal("site00", @c00.site_name(Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ]))
|
493
|
+
# assert_equal("site00", @c00.site_name(Mageo::Vector3DInternal[ 0.00, 0.00, 0.00 ]))
|
494
|
+
# assert_equal("site01", @c00.site_name(Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]))
|
495
|
+
# assert_equal("site01", @c00.site_name(Mageo::Vector3DInternal[ 0.10, 0.20, 0.30 ]))
|
496
|
+
|
497
|
+
# assert_raise(SiteNameLabeledCell::TypeError){
|
498
|
+
# @c00.site_name(Mageo::Vector3D[ 0.10, 0.20, 0.30 ]))
|
499
|
+
# }
|
500
|
+
#end
|
501
|
+
|
502
|
+
end
|
503
|
+
|
504
|
+
class TC_Crystalcell_Cell < Test::Unit::TestCase
|
505
|
+
def setup
|
506
|
+
# 元素の識別子を数字にしたもの。
|
507
|
+
atoms = [
|
508
|
+
CrystalCell::Atom.new( 0, [0.0, 0.0, 0.0] ),
|
509
|
+
CrystalCell::Atom.new( 1, [0.1, 0.2, 0.3] ),
|
510
|
+
]
|
511
|
+
@c00 = CrystalCell::Cell.new( [ [2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0] ], atoms )
|
512
|
+
@c00.comment = "c01"
|
513
|
+
end
|
514
|
+
|
515
|
+
def test_to_snlcell
|
516
|
+
sites = {
|
517
|
+
"site00" => Mageo::Vector3DInternal[ 0.01, 0.01, 0.01 ],
|
518
|
+
"site01" => Mageo::Vector3DInternal[ 0.11, 0.21, 0.31 ]
|
519
|
+
}
|
520
|
+
|
521
|
+
t = @c00.to_snlcell( sites )
|
522
|
+
assert_equal(SiteNameLabeledCell, t.class)
|
523
|
+
assert_equal( 2, t.atoms.size)
|
524
|
+
assert_equal( "site00", t.atoms[0].name)
|
525
|
+
assert_equal( "site01", t.atoms[1].name)
|
526
|
+
assert_equal( "c01", t.comment)
|
527
|
+
end
|
528
|
+
end
|