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 @@
|
|
1
|
+
sitesingle.yaml
|
data/test/test_atom.rb
ADDED
@@ -0,0 +1,206 @@
|
|
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_Atom < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
#s001 = Crysna::Site.new("A", )
|
11
|
+
@alo000 = Crysna::Atom.new("Li", "A", [0, 0, 0])
|
12
|
+
@alo001 = Crysna::Atom.new("Li", "A", [0, 0, 1])
|
13
|
+
@alo010 = Crysna::Atom.new("Li", "A", [0, 1, 0])
|
14
|
+
@alo100 = Crysna::Atom.new("Li", "A", [1, 0, 0])
|
15
|
+
@alt000 = Crysna::Atom.new("Li", "B", [0, 0, 0])
|
16
|
+
@alt001 = Crysna::Atom.new("Li", "B", [0, 0, 1])
|
17
|
+
@alt010 = Crysna::Atom.new("Li", "B", [0, 1, 0])
|
18
|
+
@alt100 = Crysna::Atom.new("Li", "B", [1, 0, 0])
|
19
|
+
@abo000 = Crysna::Atom.new("Be", "A", [0, 0, 0])
|
20
|
+
@abo001 = Crysna::Atom.new("Be", "A", [0, 0, 1])
|
21
|
+
@abo010 = Crysna::Atom.new("Be", "A", [0, 1, 0])
|
22
|
+
@abo100 = Crysna::Atom.new("Be", "A", [1, 0, 0])
|
23
|
+
@abt000 = Crysna::Atom.new("Be", "B", [0, 0, 0])
|
24
|
+
@abt001 = Crysna::Atom.new("Be", "B", [0, 0, 1])
|
25
|
+
@abt010 = Crysna::Atom.new("Be", "B", [0, 1, 0])
|
26
|
+
@abt100 = Crysna::Atom.new("Be", "B", [1, 0, 0])
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_equal
|
30
|
+
assert_equal(true, @alo000 == Crysna::Atom.new("Li", "A", [0, 0, 0]))
|
31
|
+
assert_equal(true, @alo001 == Crysna::Atom.new("Li", "A", [0, 0, 1]))
|
32
|
+
assert_equal(true, @alo010 == Crysna::Atom.new("Li", "A", [0, 1, 0]))
|
33
|
+
assert_equal(true, @alo100 == Crysna::Atom.new("Li", "A", [1, 0, 0]))
|
34
|
+
assert_equal(true, @alt000 == Crysna::Atom.new("Li", "B", [0, 0, 0]))
|
35
|
+
assert_equal(true, @alt001 == Crysna::Atom.new("Li", "B", [0, 0, 1]))
|
36
|
+
assert_equal(true, @alt010 == Crysna::Atom.new("Li", "B", [0, 1, 0]))
|
37
|
+
assert_equal(true, @alt100 == Crysna::Atom.new("Li", "B", [1, 0, 0]))
|
38
|
+
assert_equal(true, @abo000 == Crysna::Atom.new("Be", "A", [0, 0, 0]))
|
39
|
+
assert_equal(true, @abo001 == Crysna::Atom.new("Be", "A", [0, 0, 1]))
|
40
|
+
assert_equal(true, @abo010 == Crysna::Atom.new("Be", "A", [0, 1, 0]))
|
41
|
+
assert_equal(true, @abo100 == Crysna::Atom.new("Be", "A", [1, 0, 0]))
|
42
|
+
assert_equal(true, @abt000 == Crysna::Atom.new("Be", "B", [0, 0, 0]))
|
43
|
+
assert_equal(true, @abt001 == Crysna::Atom.new("Be", "B", [0, 0, 1]))
|
44
|
+
assert_equal(true, @abt010 == Crysna::Atom.new("Be", "B", [0, 1, 0]))
|
45
|
+
assert_equal(true, @abt100 == Crysna::Atom.new("Be", "B", [1, 0, 0]))
|
46
|
+
|
47
|
+
assert_equal(false, @alo000 == Crysna::Atom.new("Li", "A", [0, 0, 1]))
|
48
|
+
assert_equal(false, @alo000 == Crysna::Atom.new("Li", "A", [0, 1, 0]))
|
49
|
+
assert_equal(false, @alo000 == Crysna::Atom.new("Li", "A", [1, 0, 0]))
|
50
|
+
assert_equal(false, @alo000 == Crysna::Atom.new("Li", "B", [0, 0, 0]))
|
51
|
+
assert_equal(false, @alo000 == Crysna::Atom.new("Be", "A", [0, 0, 0]))
|
52
|
+
end
|
53
|
+
|
54
|
+
#def test_site_name
|
55
|
+
# assert_equal("A", @alo000.site_name)
|
56
|
+
# assert_equal("B", @alt000.site_name)
|
57
|
+
# assert_equal("A", @abo000.site_name)
|
58
|
+
# assert_equal("B", @abt000.site_name)
|
59
|
+
#end
|
60
|
+
|
61
|
+
def test_migrate!
|
62
|
+
@alo001.migrate!("B", [1, 2, -3])
|
63
|
+
assert_equal( Crysna::Atom.new("Li", "B", [1, 2, -2]), @alo001)
|
64
|
+
|
65
|
+
@abo001.migrate!("B", [1, 2, -3])
|
66
|
+
assert_equal( Crysna::Atom.new("Be", "B", [1, 2, -2]), @abo001)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_migrate
|
70
|
+
result = @alo001.migrate("B", [1, 2, -3])
|
71
|
+
assert_equal( Crysna::Atom.new("Li", "A", [0, 0, 1]), @alo001)
|
72
|
+
assert_equal( Crysna::Atom.new("Li", "B", [1, 2, -2]), result)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_centering!
|
76
|
+
assert_equal(Crysna::Atom.new("Li", "A", [0, 0, 1]), @alo001)
|
77
|
+
@alo001.centering!
|
78
|
+
assert_equal(Crysna::Atom.new("Li", "A", [0, 0, 0]), @alo001)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_centering
|
82
|
+
assert_equal(Crysna::Atom.new("Li", "A", [0, 0, 0]) , @alo000.centering)
|
83
|
+
assert_equal(Crysna::Atom.new("Li", "A", [0, 0, 0]) , @alo001.centering)
|
84
|
+
assert_equal(Crysna::Atom.new("Li", "A", [0, 0, 0]) , @alo010.centering)
|
85
|
+
assert_equal(Crysna::Atom.new("Li", "A", [0, 0, 0]) , @alo100.centering)
|
86
|
+
assert_equal(Crysna::Atom.new("Li", "B", [0, 0, 0]) , @alt000.centering)
|
87
|
+
assert_equal(Crysna::Atom.new("Li", "B", [0, 0, 0]) , @alt001.centering)
|
88
|
+
assert_equal(Crysna::Atom.new("Li", "B", [0, 0, 0]) , @alt010.centering)
|
89
|
+
assert_equal(Crysna::Atom.new("Li", "B", [0, 0, 0]) , @alt100.centering)
|
90
|
+
assert_equal(Crysna::Atom.new("Be", "A", [0, 0, 0]) , @abo000.centering)
|
91
|
+
assert_equal(Crysna::Atom.new("Be", "A", [0, 0, 0]) , @abo001.centering)
|
92
|
+
assert_equal(Crysna::Atom.new("Be", "A", [0, 0, 0]) , @abo010.centering)
|
93
|
+
assert_equal(Crysna::Atom.new("Be", "A", [0, 0, 0]) , @abo100.centering)
|
94
|
+
assert_equal(Crysna::Atom.new("Be", "B", [0, 0, 0]) , @abt000.centering)
|
95
|
+
assert_equal(Crysna::Atom.new("Be", "B", [0, 0, 0]) , @abt001.centering)
|
96
|
+
assert_equal(Crysna::Atom.new("Be", "B", [0, 0, 0]) , @abt010.centering)
|
97
|
+
assert_equal(Crysna::Atom.new("Be", "B", [0, 0, 0]) , @abt100.centering)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_compare
|
101
|
+
#equal
|
102
|
+
assert_equal( 0,@alo000 <=> @alo000)
|
103
|
+
assert_equal( 0,@alo001 <=> @alo001)
|
104
|
+
assert_equal( 0,@alo010 <=> @alo010)
|
105
|
+
assert_equal( 0,@alo100 <=> @alo100)
|
106
|
+
assert_equal( 0,@alt000 <=> @alt000)
|
107
|
+
assert_equal( 0,@alt001 <=> @alt001)
|
108
|
+
assert_equal( 0,@alt010 <=> @alt010)
|
109
|
+
assert_equal( 0,@alt100 <=> @alt100)
|
110
|
+
assert_equal( 0,@abo000 <=> @abo000)
|
111
|
+
assert_equal( 0,@abo001 <=> @abo001)
|
112
|
+
assert_equal( 0,@abo010 <=> @abo010)
|
113
|
+
assert_equal( 0,@abo100 <=> @abo100)
|
114
|
+
assert_equal( 0,@abt000 <=> @abt000)
|
115
|
+
assert_equal( 0,@abt001 <=> @abt001)
|
116
|
+
assert_equal( 0,@abt010 <=> @abt010)
|
117
|
+
assert_equal( 0,@abt100 <=> @abt100)
|
118
|
+
|
119
|
+
#
|
120
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Be", "A", [ 0, 0, 0]))
|
121
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Mg", "A", [ 0, 0, 0]))
|
122
|
+
|
123
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", " ", [ 0, 0, 0]))
|
124
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "Z", [ 0, 0, 0]))
|
125
|
+
|
126
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 1, 0, 0]))
|
127
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", "A", [-1, 0, 0]))
|
128
|
+
|
129
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 0, 1, 0]))
|
130
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 0,-1, 0]))
|
131
|
+
|
132
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 0, 0, 1]))
|
133
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 0, 0,-1]))
|
134
|
+
|
135
|
+
#Element is stronger than others.
|
136
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Be", "Z", [ 1, 1, 1]))
|
137
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Mg", " ", [-1,-1,-1]))
|
138
|
+
|
139
|
+
#Sitename is stronger than gloval_vector
|
140
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", " ", [ 1, 1, 1]))
|
141
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "Z", [-1,-1,-1]))
|
142
|
+
|
143
|
+
#Order in coordinates
|
144
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 1,-1,-1]))
|
145
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", "A", [-1, 1, 1]))
|
146
|
+
|
147
|
+
assert_equal(-1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 0, 1,-1]))
|
148
|
+
assert_equal( 1,@alo000 <=> Crysna::Atom.new("Li", "A", [ 0,-1, 1]))
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_sitename
|
152
|
+
assert_equal("A", @alo000.sitename)
|
153
|
+
assert_equal("A", @alo001.sitename)
|
154
|
+
assert_equal("A", @alo010.sitename)
|
155
|
+
assert_equal("A", @alo100.sitename)
|
156
|
+
assert_equal("B", @alt000.sitename)
|
157
|
+
assert_equal("B", @alt001.sitename)
|
158
|
+
assert_equal("B", @alt010.sitename)
|
159
|
+
assert_equal("B", @alt100.sitename)
|
160
|
+
assert_equal("A", @abo000.sitename)
|
161
|
+
assert_equal("A", @abo001.sitename)
|
162
|
+
assert_equal("A", @abo010.sitename)
|
163
|
+
assert_equal("A", @abo100.sitename)
|
164
|
+
assert_equal("B", @abt000.sitename)
|
165
|
+
assert_equal("B", @abt001.sitename)
|
166
|
+
assert_equal("B", @abt010.sitename)
|
167
|
+
assert_equal("B", @abt100.sitename)
|
168
|
+
assert_equal("B", Crysna::Atom.new("Be", "B", [1, -1, 0]).sitename)
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_full_sitename
|
172
|
+
assert_equal("A555", @alo000.full_sitename)
|
173
|
+
assert_equal("A556", @alo001.full_sitename)
|
174
|
+
assert_equal("A565", @alo010.full_sitename)
|
175
|
+
assert_equal("A655", @alo100.full_sitename)
|
176
|
+
assert_equal("B555", @alt000.full_sitename)
|
177
|
+
assert_equal("B556", @alt001.full_sitename)
|
178
|
+
assert_equal("B565", @alt010.full_sitename)
|
179
|
+
assert_equal("B655", @alt100.full_sitename)
|
180
|
+
assert_equal("A555", @abo000.full_sitename)
|
181
|
+
assert_equal("A556", @abo001.full_sitename)
|
182
|
+
assert_equal("A565", @abo010.full_sitename)
|
183
|
+
assert_equal("A655", @abo100.full_sitename)
|
184
|
+
assert_equal("B555", @abt000.full_sitename)
|
185
|
+
assert_equal("B556", @abt001.full_sitename)
|
186
|
+
assert_equal("B565", @abt010.full_sitename)
|
187
|
+
assert_equal("B655", @abt100.full_sitename)
|
188
|
+
assert_equal("B645", Crysna::Atom.new("Be", "B", [1, -1, 0]).full_sitename)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
data/test/test_cell.rb
ADDED
@@ -0,0 +1,604 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "yaml"
|
5
|
+
require "helper"
|
6
|
+
#require "test/unit"
|
7
|
+
#require "fileutils"
|
8
|
+
#require "crystal/latticeaxes.rb"
|
9
|
+
#require "crysna/siteconfiguration.rb"
|
10
|
+
#require "vasputils/poscar.rb"
|
11
|
+
##require "crysna/siteoperation.rb"
|
12
|
+
|
13
|
+
class Crysna::Cell
|
14
|
+
attr_accessor :atoms
|
15
|
+
end
|
16
|
+
|
17
|
+
class TC_Cell < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
@sc00 = Crysna::Cell.new({ 0 => ["A", "B"], 1 => ["C", "D"]})
|
20
|
+
@sc01 = Crysna::Cell.new({ 0 => ["B", "C"], 1 => ["D", "A"]})
|
21
|
+
@sc02 = Crysna::Cell.new( { 3 =>["FS_00"] , 0 =>["Oc08", "Te00"]})
|
22
|
+
@sc03 = Crysna::Cell.new( { 0 =>["Oc08", "Te14"], 3 =>["FS_00"] })
|
23
|
+
@sc04 = Crysna::Cell.new( { 0 =>["Oc08", "Te00"]})
|
24
|
+
@sc05 = Crysna::Cell.new( { 0 =>["Oc08", "Te14"]})
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_load_file
|
28
|
+
site_conf_file = "tmp_site.conf"
|
29
|
+
FileUtils.rm site_conf_file if File.exist? site_conf_file
|
30
|
+
|
31
|
+
site_conf = {
|
32
|
+
0 => ["A", "B"],
|
33
|
+
1 => ["C", "D"],
|
34
|
+
}
|
35
|
+
File.open(site_conf_file, "w") do |io|
|
36
|
+
YAML.dump(site_conf, io)
|
37
|
+
end
|
38
|
+
|
39
|
+
result = Crysna::Cell.load_file(site_conf_file)
|
40
|
+
correct = Crysna::Cell.new(site_conf)
|
41
|
+
assert_equal(correct, result)
|
42
|
+
|
43
|
+
FileUtils.rm site_conf_file if File.exist? site_conf_file
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_new_elems_sitenames
|
47
|
+
correct = Crysna::Cell.new({ 'Ag' => ["A", "B"], 'I' => ["C", "D"]})
|
48
|
+
result = Crysna::Cell.new_elems_sitenames(
|
49
|
+
{'Ag' => 2, 'I' => 2},
|
50
|
+
["A", "B", "C", "D"]
|
51
|
+
)
|
52
|
+
#pp(correct, result)
|
53
|
+
assert_equal(correct, result)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_sites
|
57
|
+
correct = { 0 => ["A", "B"], 1 => ["C", "D"]}
|
58
|
+
assert_equal(correct, @sc00.sites)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_add_atom
|
62
|
+
@sc00.add_atom(2, "T00", [1,2,-1])
|
63
|
+
assert_equal(Crysna::Atom.new(2, "T00", [1,2,-1]), @sc00.atoms[4])
|
64
|
+
|
65
|
+
setup
|
66
|
+
@sc00.add_atom(1, "B", [0,0,0])
|
67
|
+
assert_equal(Crysna::Atom.new(0, "A", [0,0,0]), @sc00.atoms[0])
|
68
|
+
assert_equal(Crysna::Atom.new(0, "B", [0,0,0]), @sc00.atoms[1])
|
69
|
+
assert_equal(Crysna::Atom.new(1, "B", [0,0,0]), @sc00.atoms[2])
|
70
|
+
assert_equal(Crysna::Atom.new(1, "C", [0,0,0]), @sc00.atoms[3])
|
71
|
+
assert_equal(Crysna::Atom.new(1, "D", [0,0,0]), @sc00.atoms[4])
|
72
|
+
|
73
|
+
setup
|
74
|
+
assert_raise(Crysna::Cell::DuplicateSiteError){
|
75
|
+
@sc00.add_atom(1, "B", [0,0,0], true)
|
76
|
+
}
|
77
|
+
|
78
|
+
setup
|
79
|
+
assert_raise(Crysna::Cell::DuplicateSiteError){
|
80
|
+
@sc00.add_atom(0, "B", [0,0,0], true)
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_operate
|
85
|
+
sc01 = Crysna::Cell.new({})
|
86
|
+
sc01.atoms[0] = Crysna::Atom.new(0, "A", [ 0, 0, 1])
|
87
|
+
sc01.atoms[1] = Crysna::Atom.new(1, "B", [ 0, 1, 0])
|
88
|
+
sc01.atoms[2] = Crysna::Atom.new(2, "C", [ 1, 0, 0])
|
89
|
+
sc01.atoms[3] = Crysna::Atom.new(3, "D", [ 1,-1, 1])
|
90
|
+
|
91
|
+
#Identical operation
|
92
|
+
rotation = [
|
93
|
+
[1, 0, 0],
|
94
|
+
[0, 1, 0],
|
95
|
+
[0, 0, 1],
|
96
|
+
]
|
97
|
+
operations = {
|
98
|
+
"A" => ["A", [ 0, 0, 0], rotation],
|
99
|
+
"B" => ["B", [ 0, 0, 0], rotation],
|
100
|
+
"C" => ["C", [ 0, 0, 0], rotation],
|
101
|
+
"D" => ["D", [ 0, 0, 0], rotation],
|
102
|
+
}
|
103
|
+
results = sc01.operate(operations)
|
104
|
+
assert_equal(Crysna::Cell, results.class)
|
105
|
+
atoms = results.atoms
|
106
|
+
assert_equal(Crysna::Atom.new(0, "A", [ 0, 0, 1]), atoms.shift)
|
107
|
+
assert_equal(Crysna::Atom.new(1, "B", [ 0, 1, 0]), atoms.shift)
|
108
|
+
assert_equal(Crysna::Atom.new(2, "C", [ 1, 0, 0]), atoms.shift)
|
109
|
+
assert_equal(Crysna::Atom.new(3, "D", [ 1,-1, 1]), atoms.shift)
|
110
|
+
assert_equal(nil , atoms.shift)
|
111
|
+
|
112
|
+
#Change names
|
113
|
+
rotation = [
|
114
|
+
[1, 0, 0],
|
115
|
+
[0, 1, 0],
|
116
|
+
[0, 0, 1],
|
117
|
+
]
|
118
|
+
operations = {
|
119
|
+
"A" => ["B", [ 0, 0, 0], rotation],
|
120
|
+
"B" => ["C", [ 0, 0, 0], rotation],
|
121
|
+
"C" => ["D", [ 0, 0, 0], rotation],
|
122
|
+
"D" => ["A", [ 0, 0, 0], rotation],
|
123
|
+
}
|
124
|
+
results = sc01.operate(operations)
|
125
|
+
assert_equal(Crysna::Cell, results.class)
|
126
|
+
atoms = results.atoms
|
127
|
+
assert_equal(Crysna::Atom.new(0, "B", [ 0, 0, 1]), atoms.shift)
|
128
|
+
assert_equal(Crysna::Atom.new(1, "C", [ 0, 1, 0]), atoms.shift)
|
129
|
+
assert_equal(Crysna::Atom.new(2, "D", [ 1, 0, 0]), atoms.shift)
|
130
|
+
assert_equal(Crysna::Atom.new(3, "A", [ 1,-1, 1]), atoms.shift)
|
131
|
+
assert_equal(nil , atoms.shift)
|
132
|
+
|
133
|
+
#Change shift_vector
|
134
|
+
rotation = [
|
135
|
+
[1, 0, 0],
|
136
|
+
[0, 1, 0],
|
137
|
+
[0, 0, 1],
|
138
|
+
]
|
139
|
+
operations = {
|
140
|
+
"A" => ["A", [ 0, 1,-1], rotation],
|
141
|
+
"B" => ["B", [ 1,-1, 0], rotation],
|
142
|
+
"C" => ["C", [ 0, 1, 0], rotation],
|
143
|
+
"D" => ["D", [ 1, 1,-1], rotation],
|
144
|
+
}
|
145
|
+
results = sc01.operate(operations)
|
146
|
+
assert_equal(Crysna::Cell, results.class)
|
147
|
+
atoms = results.atoms
|
148
|
+
assert_equal(Crysna::Atom.new(0, "A", [ 0, 1, 0]), atoms.shift)
|
149
|
+
assert_equal(Crysna::Atom.new(1, "B", [ 1, 0, 0]), atoms.shift)
|
150
|
+
assert_equal(Crysna::Atom.new(2, "C", [ 1, 1, 0]), atoms.shift)
|
151
|
+
assert_equal(Crysna::Atom.new(3, "D", [ 2, 0, 0]), atoms.shift)
|
152
|
+
assert_equal(nil , atoms.shift)
|
153
|
+
|
154
|
+
#Change rotation
|
155
|
+
rotation = [
|
156
|
+
[ 0, 1, 0],
|
157
|
+
[-1, 0, 0],
|
158
|
+
[ 0, 0, 1],
|
159
|
+
]
|
160
|
+
operations = {
|
161
|
+
"A" => ["A", [ 0, 0, 0], rotation],
|
162
|
+
"B" => ["B", [ 0, 0, 0], rotation],
|
163
|
+
"C" => ["C", [ 0, 0, 0], rotation],
|
164
|
+
"D" => ["D", [ 0, 0, 0], rotation],
|
165
|
+
}
|
166
|
+
results = sc01.operate(operations)
|
167
|
+
assert_equal(Crysna::Cell, results.class)
|
168
|
+
atoms = results.atoms
|
169
|
+
assert_equal(Crysna::Atom.new(0, "A", [ 0, 0, 1]), atoms.shift)
|
170
|
+
assert_equal(Crysna::Atom.new(1, "B", [ 1, 0, 0]), atoms.shift)
|
171
|
+
assert_equal(Crysna::Atom.new(2, "C", [ 0,-1, 0]), atoms.shift)
|
172
|
+
assert_equal(Crysna::Atom.new(3, "D", [-1,-1, 1]), atoms.shift)
|
173
|
+
assert_equal(nil , atoms.shift)
|
174
|
+
|
175
|
+
#Change shift_vector and rotation
|
176
|
+
rotation = [
|
177
|
+
[ 0, 1, 0],
|
178
|
+
[-1, 0, 0],
|
179
|
+
[ 0, 0, 1],
|
180
|
+
]
|
181
|
+
operations = {
|
182
|
+
"A" => ["A", [ 0, 1,-1], rotation],
|
183
|
+
"B" => ["B", [ 1,-1, 0], rotation],
|
184
|
+
"C" => ["C", [ 0, 1, 0], rotation],
|
185
|
+
"D" => ["D", [ 1, 1,-1], rotation],
|
186
|
+
}
|
187
|
+
results = sc01.operate(operations)
|
188
|
+
assert_equal(Crysna::Cell, results.class)
|
189
|
+
atoms = results.atoms
|
190
|
+
assert_equal(Crysna::Atom.new(0, "A", [ 0, 1, 0]), atoms.shift)
|
191
|
+
assert_equal(Crysna::Atom.new(1, "B", [ 2,-1, 0]), atoms.shift)
|
192
|
+
assert_equal(Crysna::Atom.new(2, "C", [ 0, 0, 0]), atoms.shift)
|
193
|
+
assert_equal(Crysna::Atom.new(3, "D", [ 0, 0, 0]), atoms.shift)
|
194
|
+
assert_equal(nil , atoms.shift)
|
195
|
+
|
196
|
+
#Change name, shift_vector and rotation
|
197
|
+
rotation = [
|
198
|
+
[ 0, 1, 0],
|
199
|
+
[-1, 0, 0],
|
200
|
+
[ 0, 0, 1],
|
201
|
+
]
|
202
|
+
operations = {
|
203
|
+
"A" => ["B", [ 0, 1,-1], rotation],
|
204
|
+
"B" => ["C", [ 1,-1, 0], rotation],
|
205
|
+
"C" => ["D", [ 0, 1, 0], rotation],
|
206
|
+
"D" => ["E", [ 1, 1,-1], rotation],
|
207
|
+
}
|
208
|
+
results = sc01.operate(operations)
|
209
|
+
assert_equal(Crysna::Cell, results.class)
|
210
|
+
atoms = results.atoms
|
211
|
+
assert_equal(Crysna::Atom.new(0, "B", [ 0, 1, 0]), atoms.shift)
|
212
|
+
assert_equal(Crysna::Atom.new(1, "C", [ 2,-1, 0]), atoms.shift)
|
213
|
+
assert_equal(Crysna::Atom.new(2, "D", [ 0, 0, 0]), atoms.shift)
|
214
|
+
assert_equal(Crysna::Atom.new(3, "E", [ 0, 0, 0]), atoms.shift)
|
215
|
+
assert_equal(nil , atoms.shift)
|
216
|
+
|
217
|
+
|
218
|
+
#Raise error
|
219
|
+
operations = {
|
220
|
+
"A" => ["D", rotation],
|
221
|
+
"B" => ["C", rotation],
|
222
|
+
"C" => ["B", rotation],
|
223
|
+
}
|
224
|
+
assert_raise(Crysna::Cell::NoEntryError){sc01.operate(operations)}
|
225
|
+
|
226
|
+
#HERE
|
227
|
+
##Change name, shift_vector and rotation
|
228
|
+
#sc01 = Crysna::Cell.new({})
|
229
|
+
#sc01.atoms[0] = Crysna::Atom.new(0, "A", [ 0,-1, 0])
|
230
|
+
#rotation = [
|
231
|
+
# [-1, 0, 0],
|
232
|
+
# [ 0, 0, 1],
|
233
|
+
# [ 0, 1, 0],
|
234
|
+
#]
|
235
|
+
#operations = {
|
236
|
+
# "A" => ["B", [ 0, 1,-1], rotation],
|
237
|
+
# "B" => ["C", [ 1,-1, 0], rotation],
|
238
|
+
# "C" => ["D", [ 0, 1, 0], rotation],
|
239
|
+
# "D" => ["E", [ 1, 1,-1], rotation],
|
240
|
+
#}
|
241
|
+
#results = sc01.operate(operations)
|
242
|
+
#assert_equal(Crysna::Cell, results.class)
|
243
|
+
#atoms = results.atoms
|
244
|
+
#assert_equal(Crysna::Atom.new(0, "B", [ 0, 1, 0]), atoms.shift)
|
245
|
+
#assert_equal(Crysna::Atom.new(1, "C", [ 2,-1, 0]), atoms.shift)
|
246
|
+
#assert_equal(Crysna::Atom.new(2, "D", [ 0, 0, 0]), atoms.shift)
|
247
|
+
#assert_equal(Crysna::Atom.new(3, "E", [ 0, 0, 0]), atoms.shift)
|
248
|
+
#assert_equal(nil , atoms.shift)
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_equal
|
253
|
+
sites = {
|
254
|
+
0 => ["A", "B"],
|
255
|
+
1 => ["C", "D"],
|
256
|
+
}
|
257
|
+
sc01 = Crysna::Cell.new(sites)
|
258
|
+
assert_equal(true, @sc00 == sc01)
|
259
|
+
|
260
|
+
sites = {
|
261
|
+
1 => ["D", "C"],
|
262
|
+
0 => ["B", "A"],
|
263
|
+
}
|
264
|
+
sc01 = Crysna::Cell.new(sites)
|
265
|
+
assert_equal(true, @sc00 == sc01)
|
266
|
+
|
267
|
+
sites = {
|
268
|
+
0 => ["A", "C"],
|
269
|
+
1 => ["D", "D"],
|
270
|
+
}
|
271
|
+
sc01 = Crysna::Cell.new(sites)
|
272
|
+
assert_equal(false, @sc00 == sc01)
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_added_sites
|
276
|
+
corrects = [
|
277
|
+
Crysna::Cell.new(
|
278
|
+
{ 0 => ["A", "A", "B"], 1 => ["C", "D"]}),
|
279
|
+
Crysna::Cell.new(
|
280
|
+
{ 0 => ["A", "B", "C"], 1 => ["C", "D"]}),
|
281
|
+
]
|
282
|
+
results = @sc00.added_sites({ 0 => ["A", "C"] })
|
283
|
+
assert_equal(corrects, results)
|
284
|
+
|
285
|
+
corrects = []
|
286
|
+
results = @sc00.added_sites( { 0 => ["A", "C"] } , true)
|
287
|
+
assert_equal(corrects, results)
|
288
|
+
|
289
|
+
corrects = [
|
290
|
+
Crysna::Cell.new(
|
291
|
+
{ 0 => ["A", "B", "E"], 1 => ["C", "D"]}),
|
292
|
+
]
|
293
|
+
results = @sc00.added_sites( { 0 => ["A", "C", "E"] } , true)
|
294
|
+
assert_equal(corrects, results)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_elements
|
298
|
+
assert_equal([0,1], @sc00.elements)
|
299
|
+
assert_equal([0,1], @sc01.elements)
|
300
|
+
assert_equal([0,3], @sc02.elements)
|
301
|
+
assert_equal([0,3], @sc03.elements)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_atoms_of_element
|
305
|
+
atom0A = Crysna::Atom.new(0, "A", [0,0,0])
|
306
|
+
atom0B = Crysna::Atom.new(0, "B", [0,0,0])
|
307
|
+
atom0C = Crysna::Atom.new(0, "C", [0,0,0])
|
308
|
+
atom1A = Crysna::Atom.new(1, "A", [0,0,0])
|
309
|
+
atom1B = Crysna::Atom.new(1, "B", [0,0,0])
|
310
|
+
atom1C = Crysna::Atom.new(1, "C", [0,0,0])
|
311
|
+
atom1D = Crysna::Atom.new(1, "D", [0,0,0])
|
312
|
+
assert_equal([atom0A, atom0B], @sc00.atoms_of_element(0))
|
313
|
+
assert_equal([atom1C, atom1D], @sc00.atoms_of_element(1))
|
314
|
+
assert_equal([], @sc00.atoms_of_element(2))
|
315
|
+
|
316
|
+
assert_equal([atom0B, atom0C], @sc01.atoms_of_element(0))
|
317
|
+
assert_equal([atom1A, atom1D], @sc01.atoms_of_element(1))
|
318
|
+
assert_equal([], @sc01.atoms_of_element(2))
|
319
|
+
|
320
|
+
|
321
|
+
atom0a = Crysna::Atom.new(0, "Oc08", [0,0,0])
|
322
|
+
atom0b = Crysna::Atom.new(0, "Te00", [0,0,0])
|
323
|
+
atom3c = Crysna::Atom.new(3, "FS_00", [0,0,0])
|
324
|
+
|
325
|
+
assert_equal([atom0a, atom0b], @sc02.atoms_of_element(0))
|
326
|
+
assert_equal([atom3c], @sc02.atoms_of_element(3))
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_centering
|
330
|
+
bl = Crysna::Cell.new({ 'Ag' => ["Aa", "Bl"], 'I' => ["Ia", "Ib"]})
|
331
|
+
bl.atoms[0].migrate!('Aa', [0,0,1])
|
332
|
+
bl.atoms[2].migrate!('Ia', [1,0,1])
|
333
|
+
assert_equal( "Ag:Aa556-Bl555,I:Ia656-Ib555", bl.configuration_string_full)
|
334
|
+
tmp = bl.centering
|
335
|
+
assert_equal( "Ag:Aa556-Bl555,I:Ia656-Ib555", bl.configuration_string_full)
|
336
|
+
assert_equal( "Ag:Aa555-Bl555,I:Ia555-Ib555", tmp.configuration_string_full)
|
337
|
+
|
338
|
+
#assert_equal(
|
339
|
+
# Crysna::Cell.new({ 'Ag' => ["Aa", "Bl"], 'I' => ["Ia", "Ib"]}),
|
340
|
+
# bl.centering
|
341
|
+
#)
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_centering!
|
346
|
+
bl = Crysna::Cell.new({ 'Ag' => ["Aa", "Bl"], 'I' => ["Ia", "Ib"]})
|
347
|
+
bl.atoms[0].migrate!('Aa', [0,0,1])
|
348
|
+
bl.atoms[2].migrate!('Ia', [1,0,1])
|
349
|
+
assert_equal( "Ag:Aa556-Bl555,I:Ia656-Ib555", bl.configuration_string_full)
|
350
|
+
bl.centering!
|
351
|
+
assert_equal( "Ag:Aa555-Bl555,I:Ia555-Ib555", bl.configuration_string_full)
|
352
|
+
#assert_equal(
|
353
|
+
# Crysna::Cell.new({ 'Ag' => ["Aa", "Bl"], 'I' => ["Ia", "Ib"]}),
|
354
|
+
# bl.centering
|
355
|
+
#)
|
356
|
+
#
|
357
|
+
bt = Crysna::Cell.new({ 'Ag' => ["Aa", "Bt"], 'I' => ["Ia", "Ib"]})
|
358
|
+
bt.atoms[2].migrate!('Ia', [1,0,0])
|
359
|
+
assert_equal( "Ag:Aa555-Bt555,I:Ia655-Ib555", bt.configuration_string_full)
|
360
|
+
bt.centering!
|
361
|
+
assert_equal( "Ag:Aa555-Bt555,I:Ia555-Ib555", bt.configuration_string_full)
|
362
|
+
#assert_equal(
|
363
|
+
# Crysna::Cell.new({ 'Ag' => ["Aa", "bt"], 'I' => ["Ia", "Ib"]}),
|
364
|
+
# bt.centering
|
365
|
+
#)
|
366
|
+
|
367
|
+
bo = Crysna::Cell.new({ 'Ag' => ["Aa", "Bo"], 'I' => ["Ia", "Ib"]})
|
368
|
+
assert_equal( "Ag:Aa555-Bo555,I:Ia555-Ib555", bo.configuration_string_full)
|
369
|
+
bo.centering!
|
370
|
+
assert_equal( "Ag:Aa555-Bo555,I:Ia555-Ib555", bo.configuration_string_full)
|
371
|
+
#assert_equal(
|
372
|
+
# Crysna::Cell.new({ 'Ag' => ["Aa", "bo"], 'I' => ["Ia", "Ib"]}),
|
373
|
+
# bo.centering
|
374
|
+
#)
|
375
|
+
end
|
376
|
+
|
377
|
+
|
378
|
+
def test_compare
|
379
|
+
# # 原子数が少ない。
|
380
|
+
# sites = {
|
381
|
+
# 0 => ["A", "B"],
|
382
|
+
# 1 => ["C"]
|
383
|
+
# }
|
384
|
+
# sc01 = Crysna::Cell.new(sites)
|
385
|
+
# assert_equal(-1, sc01 <=> @sc00)
|
386
|
+
# assert_equal( 1, @sc00 <=> sc01 )
|
387
|
+
#
|
388
|
+
# # 原子数が同じで、元素が違う。
|
389
|
+
# sites = { 0 => ["A", "B"], 2 => ["C", "D"] }
|
390
|
+
# sc01 = Crysna::Cell.new(sites)
|
391
|
+
# #pp sc01
|
392
|
+
# #pp @sc00
|
393
|
+
# assert_equal(-1, sc01 <=> @sc00)
|
394
|
+
# assert_equal( 1, @sc00 <=> sc01 )
|
395
|
+
#
|
396
|
+
# # 原子、元素、同じで、占有サイトが違う。
|
397
|
+
# sites = { 0 => ["A", "B"], 1 => ["C", "E"] }
|
398
|
+
# sc01 = Crysna::Cell.new(sites)
|
399
|
+
# assert_equal( 1, sc01 <=> @sc00)
|
400
|
+
# assert_equal(-1, @sc00 <=> sc01 )
|
401
|
+
#
|
402
|
+
# # 等しい。
|
403
|
+
# sites = { 0 => ["A", "B"], 1 => ["C", "D"] }
|
404
|
+
# sc01 = Crysna::Cell.new(sites)
|
405
|
+
# assert_equal( 0, sc01 <=> @sc00)
|
406
|
+
# assert_equal( 0, @sc00 <=> sc01 )
|
407
|
+
#
|
408
|
+
#
|
409
|
+
# # 順序が違うもの
|
410
|
+
# assert_equal(-1, @sc02 <=> @sc03)
|
411
|
+
#
|
412
|
+
# # 複雑なもの
|
413
|
+
# sc02 = Crysna::Cell.new(
|
414
|
+
# {3=> ["FS_00", "FS_01", "FS_02", "FS_03", "FS_04", "FS_05", "FS_06",
|
415
|
+
# "FS_07", "FS_08", "FS_09", "FS_10", "FS_11", "FS_12", "FS_13",
|
416
|
+
# "FS_14", "FS_15"],
|
417
|
+
# 0=>["Oc08", "Te00"],
|
418
|
+
# 1=>["Oc00", "Oc03", "Oc05", "Oc06"],
|
419
|
+
# 2=>["Te02", "Te05", "Te09", "Te12"]
|
420
|
+
# }
|
421
|
+
# )
|
422
|
+
# sc03 = Crysna::Cell.new(
|
423
|
+
# {0=>["Oc08", "Te14"],
|
424
|
+
# 1=>["Oc00", "Oc03", "Oc05", "Oc06"],
|
425
|
+
# 2=>["Te02", "Te05", "Te09", "Te12"],
|
426
|
+
# 3=> ["FS_00", "FS_01", "FS_02", "FS_03", "FS_04", "FS_05", "FS_06",
|
427
|
+
# "FS_07", "FS_08", "FS_09", "FS_10", "FS_11", "FS_12", "FS_13",
|
428
|
+
# "FS_14", "FS_15"]}
|
429
|
+
# )
|
430
|
+
# assert_equal(-1, sc02 <=> sc03)
|
431
|
+
#
|
432
|
+
#
|
433
|
+
# assert_equal(-1, @sc04 <=> @sc05)
|
434
|
+
# assert_equal( 1, @sc05 <=> @sc04)
|
435
|
+
# assert_equal( 0, @sc04 <=> @sc04)
|
436
|
+
# assert_equal( 0, @sc05 <=> @sc05)
|
437
|
+
|
438
|
+
#operation_id: 23$
|
439
|
+
#Aa[0.0, 0.0, 1.0]$
|
440
|
+
#Bl[0.0, 0.0, 0.0]$
|
441
|
+
#Ia[1.0, 0.0, 1.0]$
|
442
|
+
#Ib[0.0, 0.0, 0.0]$
|
443
|
+
#min is updated$
|
444
|
+
#
|
445
|
+
#operation_id: 26$
|
446
|
+
#Aa[0.0, 0.0, 0.0]$
|
447
|
+
#Bt[0.0, 0.0, 0.0]$
|
448
|
+
#Ia[1.0, 0.0, 0.0]$
|
449
|
+
#Ib[0.0, 0.0, 0.0]$
|
450
|
+
#min is updated$
|
451
|
+
#
|
452
|
+
#operation_id: 48$
|
453
|
+
#Aa[0.0, 0.0, 0.0]$
|
454
|
+
#Bo[0.0, 0.0, 0.0]$
|
455
|
+
#Ia[0.0, 0.0, 0.0]$
|
456
|
+
#Ib[0.0, 0.0, 0.0]$
|
457
|
+
#min is updated$
|
458
|
+
#
|
459
|
+
bl = Crysna::Cell.new({ 'Ag' => ["Aa", "Bl"], 'I' => ["Ia", "Ib"]})
|
460
|
+
bl.atoms[0].migrate!('Aa', [0,0,1])
|
461
|
+
bl.atoms[2].migrate!('Ia', [1,0,1])
|
462
|
+
|
463
|
+
bt = Crysna::Cell.new({ 'Ag' => ["Aa", "Bt"], 'I' => ["Ia", "Ib"]})
|
464
|
+
bt.atoms[2].migrate!('Ia', [1,0,0])
|
465
|
+
|
466
|
+
bo = Crysna::Cell.new({ 'Ag' => ["Aa", "Bo"], 'I' => ["Ia", "Ib"]})
|
467
|
+
|
468
|
+
#pp bl
|
469
|
+
#pp bt
|
470
|
+
#pp bo
|
471
|
+
assert_equal(-1, bl <=> bo)
|
472
|
+
assert_equal(-1, bl <=> bt)
|
473
|
+
assert_equal(-1, bo <=> bt)
|
474
|
+
end
|
475
|
+
|
476
|
+
# def test_comparable
|
477
|
+
# sites = {
|
478
|
+
# 0 => ["A", "B"],
|
479
|
+
# 1 => ["C", "D", "E"],
|
480
|
+
# }
|
481
|
+
# sc01 = Crysna::Cell.new(sites)
|
482
|
+
# tmp = [sc01, @sc00,].sort
|
483
|
+
# assert_equal(@sc00, tmp[0])
|
484
|
+
# assert_equal( sc01, tmp[1])
|
485
|
+
#
|
486
|
+
# tmp = [sc01, @sc00,].min
|
487
|
+
# assert_equal(@sc00, tmp)
|
488
|
+
# end
|
489
|
+
|
490
|
+
#def test_min_operation
|
491
|
+
# rotation = [
|
492
|
+
# [1, 0, 0],
|
493
|
+
# [0, 1, 0],
|
494
|
+
# [0, 0, 1],
|
495
|
+
# ]
|
496
|
+
# vector = [0,0,0]
|
497
|
+
# operations = [{
|
498
|
+
# "A" => ["B", vector, rotation],
|
499
|
+
# "B" => ["A", vector, rotation],
|
500
|
+
# "C" => ["D", vector, rotation],
|
501
|
+
# "D" => ["C", vector, rotation],
|
502
|
+
# }, {
|
503
|
+
# "A" => ["R03", vector, rotation],
|
504
|
+
# "B" => ["R02", vector, rotation],
|
505
|
+
# "C" => ["R01", vector, rotation],
|
506
|
+
# "D" => ["R00", vector, rotation],
|
507
|
+
# }
|
508
|
+
# ]
|
509
|
+
# assert_equal(1, @sc00.min_operation(operations))
|
510
|
+
#end
|
511
|
+
|
512
|
+
def test_minimize
|
513
|
+
rotation = [
|
514
|
+
[1, 0, 0],
|
515
|
+
[0, 1, 0],
|
516
|
+
[0, 0, 1],
|
517
|
+
]
|
518
|
+
vector = [0,0,0]
|
519
|
+
operations = [
|
520
|
+
{
|
521
|
+
"operation_id"=>0,
|
522
|
+
"operation"=> {
|
523
|
+
"A" => ["A", vector, rotation],
|
524
|
+
"B" => ["B", vector, rotation],
|
525
|
+
"C" => ["C", vector, rotation],
|
526
|
+
"D" => ["D", vector, rotation],
|
527
|
+
"E" => ["E", vector, rotation],
|
528
|
+
"F" => ["F", vector, rotation],
|
529
|
+
}
|
530
|
+
}, {
|
531
|
+
"operation_id"=>1,
|
532
|
+
"operation"=> {
|
533
|
+
"A" => ["F", vector, rotation],
|
534
|
+
"B" => ["A", vector, rotation],
|
535
|
+
"C" => ["B", vector, rotation],
|
536
|
+
"D" => ["C", vector, rotation],
|
537
|
+
"E" => ["D", vector, rotation],
|
538
|
+
"F" => ["E", vector, rotation],
|
539
|
+
}
|
540
|
+
}
|
541
|
+
]
|
542
|
+
assert_equal(@sc00, @sc00.minimize(operations))
|
543
|
+
|
544
|
+
correct = Crysna::Cell.new({ 0 => ["A", "B"], 1 => ["C", "F"]})
|
545
|
+
assert_equal(correct, @sc01.minimize(operations))
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
end
|
550
|
+
|
551
|
+
def test_to_yaml
|
552
|
+
assert_equal(
|
553
|
+
{ 0 => ["A", "B"], 1 => ["C", "D"]},
|
554
|
+
YAML.load(@sc00.to_yaml)
|
555
|
+
)
|
556
|
+
end
|
557
|
+
|
558
|
+
def test_to_cell
|
559
|
+
axes = CrystalCell::LatticeAxes.new([
|
560
|
+
[2.0, 0.0, 0.0],
|
561
|
+
[0.0, 2.0, 0.0],
|
562
|
+
[0.0, 0.0, 2.0],
|
563
|
+
])
|
564
|
+
sites_coordinates = {
|
565
|
+
"A" => [0.00, 0.00, 0.00],
|
566
|
+
"B" => [0.00, 0.00, 0.25],
|
567
|
+
"C" => [0.00, 0.00, 0.50],
|
568
|
+
"D" => [0.00, 0.00, 0.75],
|
569
|
+
}
|
570
|
+
result = @sc00.to_cell(axes, sites_coordinates)
|
571
|
+
assert_equal(axes, result.axes)
|
572
|
+
atom = result.atoms[0]
|
573
|
+
assert_equal(0, atom.element)
|
574
|
+
assert_equal(Mageo::Vector3DInternal[0.00, 0.00, 0.00], atom.position)
|
575
|
+
atom = result.atoms[1]
|
576
|
+
assert_equal(0, atom.element)
|
577
|
+
assert_equal(Mageo::Vector3DInternal[0.00, 0.00, 0.25], atom.position)
|
578
|
+
atom = result.atoms[2]
|
579
|
+
assert_equal(1, atom.element)
|
580
|
+
assert_equal(Mageo::Vector3DInternal[0.00, 0.00, 0.50], atom.position)
|
581
|
+
atom = result.atoms[3]
|
582
|
+
assert_equal(1, atom.element)
|
583
|
+
assert_equal(Mageo::Vector3DInternal[0.00, 0.00, 0.75], atom.position)
|
584
|
+
end
|
585
|
+
|
586
|
+
def test_index
|
587
|
+
assert_equal(Crysna::Atom.new(0, "A", [0,0,0]), @sc00[0])
|
588
|
+
assert_equal(Crysna::Atom.new(0, "B", [0,0,0]), @sc00[1])
|
589
|
+
assert_equal(Crysna::Atom.new(1, "C", [0,0,0]), @sc00[2])
|
590
|
+
assert_equal(Crysna::Atom.new(1, "D", [0,0,0]), @sc00[3])
|
591
|
+
end
|
592
|
+
|
593
|
+
def test_configuration_string
|
594
|
+
assert_equal("0:A-B,1:C-D", @sc00.configuration_string)
|
595
|
+
assert_equal("0:B-C,1:A-D", @sc01.configuration_string)
|
596
|
+
end
|
597
|
+
|
598
|
+
def test_configuration_string_full
|
599
|
+
assert_equal("0:A555-B555,1:C555-D555", @sc00.configuration_string_full)
|
600
|
+
assert_equal("0:B555-C555,1:A555-D555", @sc01.configuration_string_full)
|
601
|
+
end
|
602
|
+
|
603
|
+
end
|
604
|
+
|