crysna 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/CHANGES +24 -0
  4. data/Gemfile +26 -0
  5. data/Gemfile.lock +91 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +53 -0
  9. data/VERSION +1 -0
  10. data/bin/checkmodel +66 -0
  11. data/bin/collectcell +92 -0
  12. data/bin/fitframe +68 -0
  13. data/bin/occupiedpolyhedralsite +96 -0
  14. data/bin/occupiedscattersite +77 -0
  15. data/bin/site2poscar +66 -0
  16. data/bin/site2pov +30 -0
  17. data/bin/sitecombination +69 -0
  18. data/bin/sitemigration +80 -0
  19. data/bin/sitemigrationdistance +87 -0
  20. data/bin/siteoperation +109 -0
  21. data/bin/sitesingle +36 -0
  22. data/bin/siteuniq +32 -0
  23. data/bin/symidsite +65 -0
  24. data/bin/transitcell +46 -0
  25. data/crysna.gemspec +219 -0
  26. data/lib/crysna.rb +26 -0
  27. data/lib/crysna/atom.rb +97 -0
  28. data/lib/crysna/cell.rb +314 -0
  29. data/lib/crysna/frameatom.rb +13 -0
  30. data/lib/crysna/frameinterstitialcell.rb +309 -0
  31. data/lib/crysna/interstitialatom.rb +13 -0
  32. data/lib/crysna/modelstructure.rb +333 -0
  33. data/lib/crysna/optionmanager.rb +177 -0
  34. data/lib/crysna/site.rb +35 -0
  35. data/lib/crysna/siteconfiguration.rb +26 -0
  36. data/lib/crysna/sitenamelabeledcell.rb +220 -0
  37. data/lib/crysna/siteoperation.rb +56 -0
  38. data/lib/crysna/sitewithposition.rb +24 -0
  39. data/lib/crysna/transitionfinder.rb +448 -0
  40. data/lib/crysna/transitionfinder/cell.rb +144 -0
  41. data/lib/crysna/transitionfinder/cellmanager.rb +129 -0
  42. data/lib/crysna/transitionfinder/edge.rb +54 -0
  43. data/test/.gitignore +1 -0
  44. data/test/cell_orig/POSCAR +17 -0
  45. data/test/cell_orig/model.yaml +122 -0
  46. data/test/collectcells/.gitignore +2 -0
  47. data/test/collectcells/model.yaml +154 -0
  48. data/test/collectcells/nooutcar/minexpconfiguration.yaml +22 -0
  49. data/test/collectcells/normal-higher/OUTCAR +2406 -0
  50. data/test/collectcells/normal-higher/minexpconfiguration.yaml +22 -0
  51. data/test/collectcells/normal-lower/OUTCAR +2406 -0
  52. data/test/collectcells/normal-lower/minexpconfiguration.yaml +22 -0
  53. data/test/collectcells/normal/OUTCAR +2406 -0
  54. data/test/collectcells/normal/minexpconfiguration.yaml +22 -0
  55. data/test/collectcells/normalB/OUTCAR +2406 -0
  56. data/test/collectcells/normalB/minexpconfiguration.yaml +22 -0
  57. data/test/collectcells/unfinished/OUTCAR +40702 -0
  58. data/test/collectcells/unfinished/minexpconfiguration.yaml +22 -0
  59. data/test/collectcells/unidentified/OUTCAR +3541 -0
  60. data/test/collectcells/unidentified/minexpconfiguration.yaml +2 -0
  61. data/test/fitmodelstructure/.gitignore +1 -0
  62. data/test/fitmodelstructure/AgI/CONTCAR +17 -0
  63. data/test/fitmodelstructure/AgI/fitmodelstructure.log +1161 -0
  64. data/test/fitmodelstructure/AgI/model.yaml +45 -0
  65. data/test/fitmodelstructure/normal/CONTCAR +17 -0
  66. data/test/fitmodelstructure/normal/fitmodelstructure.log +5063 -0
  67. data/test/fitmodelstructure/normal/model.yaml +122 -0
  68. data/test/fitmodelstructure/unidentified/CONTCAR +44 -0
  69. data/test/fitmodelstructure/unidentified/fitmodelstructure.log +8833 -0
  70. data/test/fitmodelstructure/unidentified/model.yaml +154 -0
  71. data/test/helper.rb +17 -0
  72. data/test/identifypolyhedralsites/.gitignore +1 -0
  73. data/test/identifypolyhedralsites/identifyatomsites.log +333 -0
  74. data/test/identifypolyhedralsites/normal/fitmodelstructure.yaml +60 -0
  75. data/test/identifypolyhedralsites/normal/model.yaml +122 -0
  76. data/test/identifypolyhedralsites/unidentified/fitmodelstructure.yaml +2 -0
  77. data/test/identifypolyhedralsites/unidentified/model.yaml +154 -0
  78. data/test/identifypolyhedralsites/volumemismatch/fitmodelstructure.yaml +101 -0
  79. data/test/identifypolyhedralsites/volumemismatch/model.yaml +154 -0
  80. data/test/identifyscattersites/CONTCAR +17 -0
  81. data/test/identifyscattersites/POSCAR +12 -0
  82. data/test/identifyscattersites/fitmodelstructure.log +1 -0
  83. data/test/identifyscattersites/fitmodelstructure.yaml +0 -0
  84. data/test/identifyscattersites/identifyscattersites.yaml +5 -0
  85. data/test/identifyscattersites/model.yaml +45 -0
  86. data/test/minexpconfiguration/.gitignore +1 -0
  87. data/test/minexpconfiguration/collective/AgI/.gitignore +2 -0
  88. data/test/minexpconfiguration/collective/AgI/siteoperations.yaml +51265 -0
  89. data/test/minexpconfiguration/collective/AgI/sitesingle.yaml +15 -0
  90. data/test/minexpconfiguration/collective/AgI/test.sh +2 -0
  91. data/test/minexpconfiguration/normal/identifysites.yaml +22 -0
  92. data/test/minexpconfiguration/normal/minexpconfiguration.log +0 -0
  93. data/test/minexpconfiguration/normal/siteoperations.yaml +1793 -0
  94. data/test/minexpconfiguration/unidentified/identifysites.yaml +2 -0
  95. data/test/minexpconfiguration/unidentified/siteoperations.yaml +1793 -0
  96. data/test/sitecombination/initsites.yaml +7 -0
  97. data/test/sitecombination/initsites_test2.yaml +8 -0
  98. data/test/sitecombination/sitecombination.yaml +29 -0
  99. data/test/siteconfiguration/elements-sitenames.yaml +2 -0
  100. data/test/siteconfiguration/latticeaxes.yaml +3 -0
  101. data/test/siteconfiguration/sitenames-coordinates.yaml +4 -0
  102. data/test/sitemigrationsdistance/model.yaml +45 -0
  103. data/test/siteoperations/.gitignore +2 -0
  104. data/test/siteoperations/model.yaml +43 -0
  105. data/test/siteoperations/symmetryoperations.yaml +1441 -0
  106. data/test/sitesingle/.gitignore +1 -0
  107. data/test/sitesingle/sitecombination.yaml +29 -0
  108. data/test/siteuniq/minexpconfiguration.yaml +15 -0
  109. data/test/siteuniq/siteuniq.yaml +8 -0
  110. data/test/test_atom.rb +206 -0
  111. data/test/test_cell.rb +604 -0
  112. data/test/test_commands.rb +340 -0
  113. data/test/test_crystana.rb +7 -0
  114. data/test/test_frameatom.rb +22 -0
  115. data/test/test_frameinterstitialcell.rb +939 -0
  116. data/test/test_interstitialatom.rb +22 -0
  117. data/test/test_modelstructure.rb +807 -0
  118. data/test/test_optionmanager.rb +172 -0
  119. data/test/test_site.rb +40 -0
  120. data/test/test_siteconfiguration.rb +29 -0
  121. data/test/test_sitenamelabeledcell.rb +528 -0
  122. data/test/test_siteoperation.rb +79 -0
  123. data/test/test_sitewithposition.rb +20 -0
  124. data/test/test_transitionfinder.rb +432 -0
  125. data/test/transitcell/.gitignore +2 -0
  126. data/test/transitcell/collectcells.yaml +51 -0
  127. data/test/transitcell/sitemigrations.yaml +8 -0
  128. data/test/transitcell/siteoperations.yaml +17 -0
  129. data/test/transitcell/transitcell.log +1342 -0
  130. data/test/transitionfinder/collectcells.yaml +81 -0
  131. data/test/transitionfinder/sitemigrations.yaml +33 -0
  132. data/test/transitionfinder/siteoperations.yaml +16 -0
  133. data/test/transitionfinder/test_cell.rb +287 -0
  134. data/test/transitionfinder/test_cellmanager.rb +185 -0
  135. data/test/transitionfinder/test_edge.rb +49 -0
  136. data/test/uniquesitesgenerator/elements-sitenames.yaml +1 -0
  137. data/test/uniquesitesgenerator/siteoperations.yaml +9 -0
  138. metadata +406 -0
@@ -0,0 +1,79 @@
1
+ ##! /usr/bin/env ruby
2
+ ## coding: utf-8
3
+ #
4
+ #require "yaml"
5
+ #require "helper"
6
+ ##require "test/unit"
7
+ ##require "crysna/siteoperation.rb"
8
+ #
9
+ #class TC_SiteOperation< Test::Unit::TestCase
10
+ # #def setup
11
+ # # @so00 = Crysna::SiteOperation.new
12
+ # #end
13
+ #
14
+ # def test_site_operation
15
+ # sites = {
16
+ # "FS_00" => [ 0.0, 0.0, 0.00 ],
17
+ # "FS_01" => [ 0.0, 0.0, 0.25 ],
18
+ # "FS_02" => [ 0.0, 0.0, 0.50 ],
19
+ # "FS_03" => [ 0.0, 0.0, 0.75 ],
20
+ # }
21
+ #
22
+ # operations = [
23
+ # { "rotation" => [
24
+ # [ 1, 0, 0],
25
+ # [ 0, 1, 0],
26
+ # [ 0, 0, 1],
27
+ # ],
28
+ # "translation" => [ 0.00, 0.00, 0.00]
29
+ # },{ "rotation" => [
30
+ # [ 1, 0, 0],
31
+ # [ 0, 1, 0],
32
+ # [ 0, 0, 1],
33
+ # ],
34
+ # "translation" => [ 0.00, 0.00, 0.25]
35
+ # },{ "rotation" => [
36
+ # [ 1, 0, 0],
37
+ # [ 0, 1, 0],
38
+ # [ 0, 0, -1],
39
+ # ],
40
+ # "translation" => [ 0.00, 0.00, 0.00]
41
+ # },{ "rotation" => [
42
+ # [ 1, 0, 0],
43
+ # [ 0, 1, 0],
44
+ # [ 0, 0, -1],
45
+ # ],
46
+ # "translation" => [ 0.00, 0.00, 0.25]
47
+ # }
48
+ # ]
49
+ # results = Crysna::SiteOperation.site_operation(sites, operations)
50
+ # corrects = [
51
+ # {
52
+ # "FS_00" => ["FS_00", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
53
+ # "FS_01" => ["FS_01", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
54
+ # "FS_02" => ["FS_02", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
55
+ # "FS_03" => ["FS_03", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
56
+ # }, {
57
+ # "FS_00" => ["FS_01", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
58
+ # "FS_01" => ["FS_02", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
59
+ # "FS_02" => ["FS_03", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
60
+ # "FS_03" => ["FS_00", [ 0, 0, 1], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1],]],
61
+ # }, {
62
+ # "FS_00" => ["FS_00", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
63
+ # "FS_01" => ["FS_03", [ 0, 0,-1], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
64
+ # "FS_02" => ["FS_02", [ 0, 0,-1], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
65
+ # "FS_03" => ["FS_01", [ 0, 0,-1], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
66
+ # }, {
67
+ # "FS_00" => ["FS_01", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
68
+ # "FS_01" => ["FS_00", [ 0, 0, 0], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
69
+ # "FS_02" => ["FS_03", [ 0, 0,-1], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
70
+ # "FS_03" => ["FS_02", [ 0, 0,-1], [[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1],]],
71
+ # }
72
+ # ]
73
+ # corrects.size.times do |index|
74
+ # assert_equal(corrects[index], results[index], "#{index}th")
75
+ # end
76
+ # assert_equal(corrects.size, results.size)
77
+ # end
78
+ #end
79
+ #
@@ -0,0 +1,20 @@
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_SiteWithPosition < Test::Unit::TestCase
9
+ def setup
10
+ @cs_S00_m01_123 = Crysna::SiteWithPosition.new("S00", [-1, 0, 1], [0.1, 0.2, 0.3])
11
+ end
12
+
13
+ def test_internal_vector
14
+ assert_equal(Mageo::Vector3DInternal[0.1, 0.2, 0.3], @cs_S00_m01_123.internal_vector)
15
+ end
16
+
17
+ def test_coordinates
18
+ assert_equal(Mageo::Vector3DInternal[-0.9, 0.2, 1.3], @cs_S00_m01_123.coordinates)
19
+ end
20
+ end
@@ -0,0 +1,432 @@
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 Crysna::TransitionFinder::Cell
9
+ attr_accessor :atoms
10
+ attr_accessor :reach_flag
11
+ end
12
+
13
+ class Crysna::TransitionFinder
14
+ public :reach_unreach_edges
15
+ public :find_periodically_candidate
16
+ public :from_to_node_indices
17
+ public :expand_edges
18
+ public :minimum_operation
19
+ public :two_indices
20
+ public :each_sort
21
+ attr_accessor :edges
22
+ attr_accessor :cell_manager
23
+ end
24
+
25
+ class TC_TransitionFinder < Test::Unit::TestCase
26
+ CTCell = Crysna::TransitionFinder::Cell
27
+
28
+ ATOM_A4 = Crysna::Atom.new(0, "A", [-1,0,0])
29
+ ATOM_B4 = Crysna::Atom.new(0, "B", [-1,0,0])
30
+ ATOM_C4 = Crysna::Atom.new(0, "C", [-1,0,0])
31
+ ATOM_D4 = Crysna::Atom.new(0, "D", [-1,0,0])
32
+ ATOM_E4 = Crysna::Atom.new(1, "E", [-1,0,0])
33
+ ATOM_F4 = Crysna::Atom.new(1, "F", [-1,0,0])
34
+ ATOM_G4 = Crysna::Atom.new(1, "G", [-1,0,0])
35
+
36
+ ATOM_A5 = Crysna::Atom.new(0, "A", [0,0,0])
37
+ ATOM_B5 = Crysna::Atom.new(0, "B", [0,0,0])
38
+ ATOM_C5 = Crysna::Atom.new(0, "C", [0,0,0])
39
+ ATOM_D5 = Crysna::Atom.new(0, "D", [0,0,0])
40
+ ATOM_E5 = Crysna::Atom.new(1, "E", [0,0,0])
41
+ ATOM_F5 = Crysna::Atom.new(1, "F", [0,0,0])
42
+ ATOM_G5 = Crysna::Atom.new(1, "G", [0,0,0])
43
+
44
+ ATOM_A6 = Crysna::Atom.new(0, "A", [1,0,0])
45
+ ATOM_B6 = Crysna::Atom.new(0, "B", [1,0,0])
46
+ ATOM_C6 = Crysna::Atom.new(0, "C", [1,0,0])
47
+ ATOM_D6 = Crysna::Atom.new(0, "D", [1,0,0])
48
+ ATOM_E6 = Crysna::Atom.new(1, "E", [1,0,0])
49
+ ATOM_F6 = Crysna::Atom.new(1, "F", [1,0,0])
50
+ ATOM_G6 = Crysna::Atom.new(1, "G", [1,0,0])
51
+
52
+ SITE_MIG = {
53
+ "A"=>[["D", [-1, 0, 0]], ["B", [0, 0, 0]]],
54
+ "B"=>[["A", [0, 0, 0]], ["C", [0, 0, 0]]],
55
+ "C"=>[["B", [0, 0, 0]], ["D", [0, 0, 0]]],
56
+ "D"=>[["C", [0, 0, 0]], ["A", [1, 0, 0]]],
57
+ "E"=>[["F", [0, 0, 0]]],
58
+ "F"=>[["E", [0, 0, 0]], ["F", [0, 0, 0]]],
59
+ "G"=>[["F", [0, 0, 0]]]
60
+ }
61
+
62
+ SITE_OPE = [
63
+ {
64
+ "operation_id"=> 0,
65
+ "operation"=> {
66
+ "A"=>["A", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
67
+ "B"=>["B", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
68
+ "C"=>["C", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
69
+ "D"=>["D", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
70
+ "E"=>["E", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
71
+ "F"=>["F", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
72
+ "G"=>["G", [0, 0, 0], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]],
73
+ }
74
+ } , {
75
+ "operation_id"=> 1,
76
+ "operation"=> {
77
+ "A"=>["D", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
78
+ "B"=>["C", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
79
+ "C"=>["B", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
80
+ "D"=>["A", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
81
+ "E"=>["G", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
82
+ "F"=>["F", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
83
+ "G"=>["E", [0, 0, 0], [[-1, 0, 0], [0, 0, 0], [0, 0, 0]]],
84
+ }
85
+ }
86
+ ]
87
+
88
+ ENERGY_ABE = 0.0
89
+ ENERGY_ABF = 6.0
90
+ ENERGY_ACE = 1.0
91
+ ENERGY_ACF = 7.0
92
+ ENERGY_ADE = 2.0
93
+ ENERGY_ADF = 8.0
94
+ ENERGY_BCE = 3.0
95
+ ENERGY_BCF = 9.0
96
+ ENERGY_BDE = 4.0
97
+ ENERGY_CDE = 5.0
98
+ ENERGY_OTHER = Float::INFINITY
99
+
100
+ def setup
101
+ ##memo, all is (4x3/2) *3 = 18
102
+ ##ABE ABF ABG
103
+ ##ACE ACF ACG
104
+ ##ADE ADF ADG
105
+ ##BCE BCF BCG
106
+ ##BDE BDF BDG
107
+ ##CDE CDF CDG
108
+ @cell_ABE = CTCell.new({0=>["A", "B"], 1=>["E"]},ENERGY_ABE,"A555-B555-E555")
109
+ @cell_ABF = CTCell.new({0=>["A", "B"], 1=>["F"]},ENERGY_ABF,"A555-B555-F555")
110
+ #@cell_ABG is not included. identical to CDE
111
+ @cell_ACE = CTCell.new({0=>["A", "C"], 1=>["E"]},ENERGY_ACE,"A555-C555-E555")
112
+ @cell_ACF = CTCell.new({0=>["A", "C"], 1=>["F"]},ENERGY_ACF,"A555-C555-F555")
113
+ #@cell_ACG is not included. identical to BDE
114
+ @cell_ADE = CTCell.new({0=>["A", "D"], 1=>["E"]},ENERGY_ADE,"A555-D555-E555")
115
+ @cell_ADF = CTCell.new({0=>["A", "D"], 1=>["F"]},ENERGY_ADF,"A555-D555-F555")
116
+ #@cell_ADG is not included. identical to ADE
117
+ @cell_BCE = CTCell.new({0=>["B", "C"], 1=>["E"]},ENERGY_BCE,"B555-C555-E555")
118
+ @cell_BCF = CTCell.new({0=>["B", "C"], 1=>["F"]},ENERGY_BCF,"B555-C555-F555")
119
+ #@cell_BCG is not included. identical to BCE
120
+ @cell_BDE = CTCell.new({0=>["B", "D"], 1=>["E"]},ENERGY_BDE,"B555-D555-E555")
121
+ #@cell_BDF is not included. identical to ACF
122
+ #@cell_BDG is not included. identical to ACE
123
+ @cell_CDE = CTCell.new({0=>["C", "D"], 1=>["E"]},ENERGY_CDE,"C555-D555-E555")
124
+ #@cell_CDF is not included. identical to ABF
125
+ #@cell_CDG is not included. identical to ABE
126
+
127
+ cells = [
128
+ @cell_ABE,
129
+ @cell_ABF,
130
+ @cell_ACE,
131
+ @cell_ACF,
132
+ @cell_ADE,
133
+ @cell_ADF,
134
+ @cell_BCE,
135
+ @cell_BCF,
136
+ @cell_BDE,
137
+ @cell_CDE,
138
+ ]
139
+
140
+ @edges = [
141
+ Crysna::TransitionFinder::Edge.new([0, 1], 0.0, "0->1"), #false-false
142
+ Crysna::TransitionFinder::Edge.new([0, 2], 0.0, "0->2"), #false-true
143
+ Crysna::TransitionFinder::Edge.new([2, 0], 0.0, "2->0"), #true -false
144
+ Crysna::TransitionFinder::Edge.new([2, 3], 0.0, "2->3"), #true -true
145
+ ]
146
+
147
+ @t00 = Crysna::TransitionFinder.new(cells, SITE_MIG, SITE_OPE)
148
+ @t01 = Crysna::TransitionFinder.new(cells, SITE_MIG, SITE_OPE)
149
+ @t01.edges = @edges
150
+ @t01.cell_manager.add @cell_ABE
151
+ @t01.cell_manager.add @cell_ACE
152
+ @t01.cell_manager.add @cell_ADE
153
+ @t01.cell_manager.add @cell_BCE
154
+
155
+ $log_io = StringIO.new
156
+ end
157
+
158
+ #def test_initialize
159
+ # @t00
160
+ #end
161
+
162
+ def test_find_path
163
+ result_io = StringIO.new
164
+ dot_io = StringIO.new
165
+ t = @t00.find_path("A555-B555-E555", false, result_io, dot_io)
166
+ result_io.rewind
167
+ #puts result_io.read
168
+
169
+ correct = <<HERE
170
+ ------------------------------------------------------------
171
+ One direction
172
+ [cell]
173
+ atoms: 0:A555-B555,1:E555
174
+ symmetrically identical cell: 0:A-B,1:E(operation_id=0)
175
+ energy: 0.0
176
+ |
177
+ |[migration] elem=0, A -> D[-1, 0, 0]
178
+ |
179
+ [cell]
180
+ atoms: 0:B555-D455,1:E555
181
+ symmetrically identical cell: 0:A-C,1:G(operation_id=1)
182
+ energy: 4.0
183
+ ------------------------------------------------------------
184
+ The other direction
185
+ [cell]
186
+ atoms: 0:A555-B555,1:E555
187
+ symmetrically identical cell: 0:A-B,1:E(operation_id=0)
188
+ energy: 0.0
189
+ |
190
+ |[migration] elem=0, B -> C[0, 0, 0]
191
+ |
192
+ [cell]
193
+ atoms: 0:A555-C555,1:E555
194
+ symmetrically identical cell: 0:A-C,1:E(operation_id=0)
195
+ energy: 1.0
196
+ |
197
+ |[migration] elem=0, C -> D[0, 0, 0]
198
+ |
199
+ [cell]
200
+ atoms: 0:A555-D555,1:E555
201
+ symmetrically identical cell: 0:A-D,1:E(operation_id=0)
202
+ energy: 2.0
203
+ |
204
+ |[migration] elem=0, A -> B[0, 0, 0]
205
+ |
206
+ [cell]
207
+ atoms: 0:B555-D555,1:E555
208
+ symmetrically identical cell: 0:A-C,1:G(operation_id=1)
209
+ energy: 4.0
210
+ HERE
211
+ assert_equal(correct, result_io.read)
212
+
213
+ dot_io.rewind
214
+ #puts dot_io.read
215
+
216
+ #puts "経路がないときの終了条件。"
217
+ #puts "等価なサイトに到達したあとにnew edge を伸ばさない仕組み。"
218
+ #assert(false)
219
+ #
220
+ end
221
+
222
+ def test_reach_unreach_edges
223
+ @cell_ADE.reach_flag = true #2
224
+ @cell_BCE.reach_flag = true #3
225
+ assert_equal(
226
+ [
227
+ Crysna::TransitionFinder::Edge.new([0, 2], 0.0, "0->2"),
228
+ Crysna::TransitionFinder::Edge.new([2, 0], 0.0, "2->0"),
229
+ ],
230
+ @t01.reach_unreach_edges
231
+ )
232
+ end
233
+
234
+ def test_find_periodically_candidate
235
+ cell_A5B4E5 = CTCell.new({}, ENERGY_ABE, "A5B4E5") ; cell_A5B4E5.atoms = [ATOM_A5, ATOM_B4, ATOM_E5]
236
+ cell_A6B5E5 = CTCell.new({}, ENERGY_ABE, "A6B5E5") ; cell_A6B5E5.atoms = [ATOM_A6, ATOM_B5, ATOM_E5]
237
+ cell_A5D4E5 = CTCell.new({}, ENERGY_ADE, "A5D4E5") ; cell_A5D4E5.atoms = [ATOM_A5, ATOM_D4, ATOM_E5]
238
+ cell_A5C4E5 = CTCell.new({}, ENERGY_ACE, "A5C4E5") ; cell_A5C4E5.atoms = [ATOM_A5, ATOM_C4, ATOM_E5]
239
+ cell_B5D4E5 = CTCell.new({}, ENERGY_BDE, "B5D4E5") ; cell_B5D4E5.atoms = [ATOM_B5, ATOM_D4, ATOM_E5]
240
+
241
+ assert_equal(0, @t00.find_periodically_candidate(@cell_ABE ))
242
+ assert_equal(0, @t00.find_periodically_candidate(cell_A5B4E5))
243
+ assert_equal(0, @t00.find_periodically_candidate(cell_A6B5E5))
244
+ assert_equal(1, @t00.find_periodically_candidate(@cell_ABF ))
245
+ assert_equal(2, @t00.find_periodically_candidate(@cell_ACE ))
246
+ assert_equal(2, @t00.find_periodically_candidate(cell_A5C4E5))
247
+ assert_equal(3, @t00.find_periodically_candidate(@cell_ACF ))
248
+ assert_equal(4, @t00.find_periodically_candidate(@cell_ADE ))
249
+ assert_equal(4, @t00.find_periodically_candidate(cell_A5D4E5))
250
+ assert_equal(5, @t00.find_periodically_candidate(@cell_ADF ))
251
+ assert_equal(6, @t00.find_periodically_candidate(@cell_BCE ))
252
+ assert_equal(7, @t00.find_periodically_candidate(@cell_BCF ))
253
+ assert_equal(8, @t00.find_periodically_candidate(@cell_BDE ))
254
+ assert_equal(8, @t00.find_periodically_candidate(cell_B5D4E5))
255
+ assert_equal(9, @t00.find_periodically_candidate(@cell_CDE ))
256
+
257
+ cell = CTCell.new({0=>["A", "A"], 1=>["E"]}, 0.0)
258
+ assert_equal(nil, @t00.find_periodically_candidate(cell))
259
+
260
+ end
261
+
262
+ def test_from_to_node_indices
263
+ @cell_ADE.reach_flag = true #2
264
+ @cell_BCE.reach_flag = true #3
265
+ assert_equal([2, 0], @t01.from_to_node_indices(@edges[1]))
266
+ assert_equal([2, 0], @t01.from_to_node_indices(@edges[2]))
267
+ assert_raise(RuntimeError){@t01.from_to_node_indices(@edges[0])}
268
+ assert_raise(RuntimeError){@t01.from_to_node_indices(@edges[3])}
269
+ end
270
+
271
+ def test_expand_edges
272
+ cell_B5D4E5 = CTCell.new({}, ENERGY_BDE, "B555-D455-E555") ; cell_B5D4E5.atoms = [ATOM_B5, ATOM_D4, ATOM_E5]
273
+ cell_BBE = CTCell.new({}, ENERGY_OTHER, "B555-B555-E555") ; cell_BBE.atoms = [ATOM_B5, ATOM_B5, ATOM_E5]
274
+ cell_AAE = CTCell.new({}, ENERGY_OTHER, "A555-A555-E555") ; cell_AAE.atoms = [ATOM_A5, ATOM_A5, ATOM_E5]
275
+
276
+ ## before expand_edges ##############################
277
+ @t00.cell_manager.add(@cell_ABE)
278
+ @t00.cell_manager.reach(0, nil)
279
+ assert_equal(1, @t00.cell_manager.cells.size)
280
+ assert_equal(0, @t00.edges.size)
281
+
282
+ @t00.expand_edges(0)
283
+
284
+ ## 1st expand_edges ##############################
285
+ ## should be
286
+ ## cell_manager
287
+ ##@t00.cell_manager.cells.each {|cell| puts cell.occupied_sitename}
288
+ ##=>
289
+ ##A555-B555-E555 #[0]
290
+ ##B555-D455-E555 #[1]
291
+ ##B555-B555-E555 #[2]
292
+ ##A555-A555-E555 #[3]
293
+ ##A555-C555-E555 #[4]
294
+ ##A555-B555-F555 #[5]
295
+
296
+ ## @t00.edges ...
297
+ ## [#<Crysna::TransitionFinder::Edge:0x000000022a48b8
298
+ ## =>
299
+ ## [0, 1],
300
+ ## [0, 2],
301
+ ## [0, 3],
302
+ ## [0, 4],
303
+ ## [0, 5],
304
+
305
+ assert_equal(1+5, @t00.cell_manager.cells.size)
306
+ assert_equal(5, @t00.edges.size)
307
+ assert_equal(@cell_ABE, @t00.cell_manager[0])
308
+ assert_equal( cell_B5D4E5, @t00.cell_manager[1])
309
+ assert_equal( cell_BBE, @t00.cell_manager[2])
310
+ assert_equal( cell_AAE, @t00.cell_manager[3])
311
+ assert_equal(@cell_ACE, @t00.cell_manager[4])
312
+ assert_equal(@cell_ABF, @t00.cell_manager[5])
313
+
314
+ assert_equal(ENERGY_ABE, @t00.cell_manager[0].energy)
315
+ assert_equal(ENERGY_BDE, @t00.cell_manager[1].energy)
316
+ assert_equal(ENERGY_OTHER, @t00.cell_manager[2].energy)
317
+ assert_equal(ENERGY_OTHER, @t00.cell_manager[3].energy)
318
+ assert_equal(ENERGY_ACE, @t00.cell_manager[4].energy)
319
+ assert_equal(ENERGY_ABF, @t00.cell_manager[5].energy)
320
+
321
+ assert_equal(0+5, @t00.edges.size)
322
+ assert_equal([0,1], @t00.edges[0].nodes)
323
+ assert_equal([0,2], @t00.edges[1].nodes)
324
+ assert_equal([0,3], @t00.edges[2].nodes)
325
+ assert_equal([0,4], @t00.edges[3].nodes)
326
+ assert_equal([0,5], @t00.edges[4].nodes)
327
+
328
+ assert_equal(ENERGY_BDE , @t00.edges[0].weight)
329
+ assert_equal(ENERGY_OTHER, @t00.edges[1].weight)
330
+ assert_equal(ENERGY_OTHER, @t00.edges[2].weight)
331
+ assert_equal(ENERGY_ACE , @t00.edges[3].weight)
332
+ assert_equal(ENERGY_ABF , @t00.edges[4].weight)
333
+
334
+ ## 2nd expand_edges ##############################
335
+ ## should be
336
+ ## cell_manager
337
+ ##@t00.cell_manager.cells.each {|cell| puts cell.occupied_sitename}
338
+ ##=>
339
+ ##A555-B555-E555 #[0]
340
+ ##B555-D455-E555 #[1]
341
+ ##B555-B555-E555 #[2]
342
+ ##A555-A555-E555 #[3]
343
+ ##A555-C555-E555 #[4]
344
+ ##A555-B555-F555 #[5]
345
+ ##B555-C555-E555 #[6] new
346
+ ##C555-D455-E555 #[7] new
347
+ ##A555-D555-E555 #[8] new
348
+ ##A555-C555-F555 #[9] new
349
+
350
+ ## @t00.edges ...
351
+ ## [#<Crysna::TransitionFinder::Edge:0x000000022a48b8
352
+ ## =>
353
+ ## [0, 1], #[0]
354
+ ## [0, 2], #[1]
355
+ ## [0, 3], #[2]
356
+ ## [0, 4], #[3]
357
+ ## [0, 5], #[4]
358
+ ## [4, 6], #[5] new
359
+ ## [4, 7], #[6] new
360
+ ## [4, 8], #[7] new
361
+ ## [4, 9], #[8] new
362
+ ## [4, 0], is not included due to duplicated to [0]
363
+ #
364
+ cell_C5D4E5 = CTCell.new({}, ENERGY_CDE, "C555-D455-E555") ; cell_C5D4E5.atoms = [ATOM_C5, ATOM_D4, ATOM_E5]
365
+
366
+ @t00.expand_edges(4)
367
+ assert_equal(@cell_ABE, @t00.cell_manager[0])
368
+ assert_equal( cell_B5D4E5, @t00.cell_manager[1])
369
+ assert_equal( cell_BBE, @t00.cell_manager[2])
370
+ assert_equal( cell_AAE, @t00.cell_manager[3])
371
+ assert_equal(@cell_ACE, @t00.cell_manager[4])
372
+ assert_equal(@cell_ABF, @t00.cell_manager[5])
373
+ assert_equal( cell_C5D4E5, @t00.cell_manager[6])
374
+ assert_equal(@cell_BCE, @t00.cell_manager[7])
375
+ assert_equal(@cell_ADE, @t00.cell_manager[8])
376
+ assert_equal(@cell_ACF, @t00.cell_manager[9])
377
+
378
+ assert_equal(ENERGY_ABE, @t00.cell_manager[0].energy)
379
+ assert_equal(ENERGY_BDE, @t00.cell_manager[1].energy)
380
+ assert_equal(ENERGY_OTHER, @t00.cell_manager[2].energy)
381
+ assert_equal(ENERGY_OTHER, @t00.cell_manager[3].energy)
382
+ assert_equal(ENERGY_ACE, @t00.cell_manager[4].energy)
383
+ assert_equal(ENERGY_ABF, @t00.cell_manager[5].energy)
384
+ assert_equal(ENERGY_CDE, @t00.cell_manager[6].energy)
385
+ assert_equal(ENERGY_BCE, @t00.cell_manager[7].energy)
386
+ assert_equal(ENERGY_ADE, @t00.cell_manager[8].energy)
387
+ assert_equal(ENERGY_ACF, @t00.cell_manager[9].energy)
388
+
389
+ #pp @t00.edges.map {|edge| edge.nodes}
390
+ assert_equal([0,1], @t00.edges[0].nodes)
391
+ assert_equal([0,2], @t00.edges[1].nodes)
392
+ assert_equal([0,3], @t00.edges[2].nodes)
393
+ assert_equal([0,4], @t00.edges[3].nodes)
394
+ assert_equal([0,5], @t00.edges[4].nodes)
395
+ assert_equal([4,6], @t00.edges[5].nodes)
396
+ assert_equal([4,7], @t00.edges[6].nodes)
397
+ assert_equal([4,8], @t00.edges[7].nodes)
398
+ assert_equal([4,9], @t00.edges[8].nodes)
399
+
400
+ assert_equal(ENERGY_BDE , @t00.edges[0].weight)
401
+ assert_equal(ENERGY_OTHER, @t00.edges[1].weight)
402
+ assert_equal(ENERGY_OTHER, @t00.edges[2].weight)
403
+ assert_equal(ENERGY_ACE , @t00.edges[3].weight)
404
+ assert_equal(ENERGY_ABF , @t00.edges[4].weight)
405
+ assert_equal(ENERGY_CDE , @t00.edges[5].weight)#ACE,CDE
406
+ assert_equal(ENERGY_BCE , @t00.edges[6].weight)#ACE,BCE
407
+ assert_equal(ENERGY_ADE , @t00.edges[7].weight)#ACE,ADE
408
+ assert_equal(ENERGY_ACF , @t00.edges[8].weight)#ACE,ACF
409
+
410
+ assert_equal(1+5+4, @t00.cell_manager.cells.size)
411
+ assert_equal(0+5+4, @t00.edges.size)
412
+ end
413
+
414
+ def test_minimum_operation
415
+ result_io = StringIO.new
416
+ #assert_equal(0, @t00.minimum_operation(@cell_ACE))
417
+
418
+ cell_bdg = CTCell.new({0=>["B", "D"], 1=>["G"]}, 0.0, "BDG")
419
+ assert_equal(1, @t00.minimum_operation(cell_bdg))
420
+ end
421
+
422
+ def test_two_indices
423
+ assert_equal( [ [0,2], [2,4], [4,6]],
424
+ @t00.two_indices([0,2,4,6]))
425
+ end
426
+
427
+ def test_each_sort
428
+ assert_equal( [ [0,2], [2,4], [4,6]],
429
+ @t00.each_sort( [ [0,2], [4,2], [4,6]]))
430
+ end
431
+ end
432
+