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,144 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ class Crysna::TransitionFinder::Cell < Crysna::Cell
5
+
6
+ #@from_edges of a start cell must be set to be []
7
+ attr_reader :from_edges
8
+ attr_reader :reach_flag
9
+ attr_reader :atoms
10
+ attr_accessor :name
11
+ attr_accessor :energy
12
+
13
+ class RangeError < Exception; end
14
+
15
+ def initialize(sites, energy = nil, name = "")
16
+ super(sites)
17
+ @energy = energy
18
+ @reach_flag = false
19
+ @from_edges = [] # include Edge.
20
+ @name = name
21
+ end
22
+
23
+ def ==(other)
24
+ result = true
25
+ result = false if @atoms != other.atoms
26
+ result = false if @energy != other.energy
27
+ result = false if @reach_flag != other.reach_flag
28
+ result = false if @from_edges != other.from_edges
29
+ result = false if @name != other.name
30
+ return result
31
+ end
32
+
33
+ def same_atoms?(other)
34
+ return @atoms == other.atoms
35
+ end
36
+
37
+ def same_sites?(other)
38
+ result = true
39
+ @atoms.size.times do |index|
40
+ if @atoms[index].site.name != other.atoms[index].site.name
41
+ result = false
42
+ break
43
+ end
44
+ end
45
+ return result
46
+ end
47
+
48
+ #Migrate atom of index to site and in the cell
49
+ #which is neighboring with the direction of global_vector.
50
+ #Generating new cell which is not reached.
51
+ #This method does not raise error even when destination site
52
+ #is already occupied,
53
+ #then, there are two atoms in the site.
54
+ def migrate!(index, site, global_vector, io = File.open(File::NULL, "w"))
55
+ io.puts "##{self.class}.migrate!(#{index}, #{site}, #{global_vector}"
56
+ raise RangeError if index >= atoms.size
57
+
58
+ atoms #sort
59
+ @atoms[index].migrate!(site, global_vector)
60
+ io.puts "Atoms after migration:"
61
+ @atoms.each do |atom|
62
+ io.puts "#{atom.element}, #{atom.site.name}, #{atom.site.global_vector}"
63
+ end
64
+
65
+ @atoms.sort!
66
+ io.puts "Atoms after sort:"
67
+ @atoms.each do |atom|
68
+ io.puts "#{atom.element}, #{atom.site.name}, #{atom.site.global_vector}"
69
+ end
70
+ reset
71
+ end
72
+
73
+ #Not-destructive method of migrate!()
74
+ def migrate(index, site, global_vector)
75
+ result = Marshal.load(Marshal.dump(self))
76
+ result.migrate!(index, site, global_vector)
77
+ result
78
+ end
79
+
80
+ #Set reach flag to be true.
81
+ #'edge' is the one between cells of already reached cell and self.
82
+ def reach(edge)
83
+ @reach_flag = true
84
+ @from_edges << edge
85
+ end
86
+
87
+ #Return true if already reached.
88
+ def reach?
89
+ return @reach_flag
90
+ end
91
+
92
+ #Return true if all sites correspond to those of the other.
93
+ #It is ok even if global vector is different.
94
+ def periodically_equal?(other)
95
+ self.atoms.sort.map{|atom| atom.site.name} == other.atoms.sort.map{|atom| atom.site.name}
96
+ end
97
+
98
+ def occupied_sitename
99
+ result = ''
100
+ result += atoms.map do |atom|
101
+ periodic_num = ''
102
+ atom.site.global_vector.each do |i|
103
+ periodic_num += (i + 5).to_s
104
+ end
105
+ atom.site.name + periodic_num
106
+ end . join "-"
107
+ result
108
+ end
109
+
110
+ def inspect_short
111
+ result = "#{self.class}: "
112
+ result += occupied_sitename
113
+ #result += '-'
114
+ result += ", @energy = #{@energy}"
115
+ result += ", @reach_flag = #{@reach_flag}"
116
+ result += ", @from_edges = #{@from_edges}"
117
+ result += ", @name = \"#{@name}\""
118
+ return result
119
+ end
120
+
121
+ #def inspect
122
+ # result =
123
+ # to_s
124
+ #end
125
+ #
126
+
127
+ def operate(operation)
128
+ result = super(operation)
129
+ result.energy = @energy
130
+ return result
131
+ end
132
+
133
+ private
134
+
135
+ #Reset information of reach and edge.
136
+ #(@reach_flag and @from_edges)
137
+ def reset
138
+ @reach_flag = false
139
+ @from_edges = []
140
+ @name = nil
141
+ end
142
+
143
+ end
144
+
@@ -0,0 +1,129 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ #
5
+ #
6
+ #
7
+ class Crysna::TransitionFinder::CellManager
8
+
9
+ attr_reader :cells
10
+
11
+ #
12
+ def initialize
13
+ @cells = []
14
+ end
15
+
16
+ #Add entry of cell as node.
17
+ #Return index of the name.
18
+ #If the cell is already added, do nothing and return the same cell.
19
+ def add(cell)
20
+ #index = @cells.find {|tgt_cell| cell == tgt_cell}
21
+ index = index_same_atoms cell
22
+ if index
23
+ return index
24
+ else
25
+ @cells << cell
26
+ return @cells.size - 1
27
+ end
28
+ end
29
+
30
+ #Return a cell of index.
31
+ def [](nth)
32
+ @cells[nth]
33
+ end
34
+
35
+ #Return index of the cell in CellManager instance.
36
+ def index_same_atoms(cell)
37
+ #@cells.index(cell)
38
+
39
+ result = nil
40
+ @cells.each_with_index do |tmp_cell, id|
41
+ if cell.same_atoms?(tmp_cell)
42
+ result = id
43
+ break
44
+ end
45
+ end
46
+ return result
47
+ end
48
+
49
+ #Return index of the cell with the same site in CellManager instance.
50
+ def index_same_sites(cell)
51
+ result = nil
52
+ @cells.each_with_index do |tmp_cell, id|
53
+ if cell.same_sites?(tmp_cell)
54
+ result = id
55
+ break
56
+ end
57
+ end
58
+ return result
59
+ end
60
+
61
+ #Set reach flag to the cell of 'dst_cell_index'.
62
+ #'edge' is added into '@from_edges' of the cell.
63
+ #'nil' data is available for 'edge'. (E.g., starting cell.)
64
+ def reach(dest_cell_index, edge)
65
+ @cells[dest_cell_index].reach(edge)
66
+ end
67
+
68
+
69
+ #Return a two-dimensional array,
70
+ #whose items are indices of the cells of groups of identical nodes
71
+ #among reached cells.
72
+ def periodically_shift_indices
73
+ results = []
74
+ @cells.each_with_index do |cell, c_index|
75
+ next unless cell.reach?
76
+ entering_index = results.size
77
+ results.each_with_index do |group, g_index|
78
+ if @cells[group[0]].periodically_equal? cell
79
+ entering_index = g_index
80
+ break
81
+ end
82
+ end
83
+ results[entering_index] ||= []
84
+ results[entering_index] << c_index
85
+ end
86
+ return results
87
+ end
88
+
89
+ def contain_periodically_shift_cells?
90
+ if periodically_shift_indices.find {|i| i.size > 1}
91
+ return true
92
+ else
93
+ return false # nil is converted to false.
94
+ end
95
+ end
96
+
97
+ #Return an array of indices from a cell of 'index' in @cells
98
+ #to the origin cell.
99
+ #The origin cell is the cell whose @from_edges has nil
100
+ #at the first item.
101
+ #Note that this method uses only the first item in @flom_edges
102
+ #of cells.
103
+ def ascend(index)
104
+ results = []
105
+ while true
106
+ results << index
107
+ edge = @cells[index].from_edges[0]
108
+ #pp edge
109
+ break unless edge
110
+ index = edge.nodes[0]
111
+ end
112
+
113
+ #current_index = last_index
114
+ #while current_index != nil
115
+ # results << current_index
116
+ # current_index = @cells[current_index].previous_cell
117
+ #end
118
+ return results
119
+ end
120
+
121
+ #def to_s
122
+ # result = "["
123
+ # tmp = @cells.map { |cell| result += cell.to_s }.join(", ")
124
+ # result += "]"
125
+ # return result
126
+ #end
127
+
128
+ end
129
+
@@ -0,0 +1,54 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ class Crysna::TransitionFinder::Edge
5
+
6
+ #attr_reader :nodes, :atom_id, :to_site, :global_vector, :operation, :weight
7
+ attr_reader :nodes, :weight, :note
8
+
9
+ class InitializeError < Exception; end
10
+
11
+ #'nodes' is assumed to be an array of 2 items which have indices of cells.
12
+ # E.g., [0, 3]
13
+ #'migration' indicates an array of 2 items which have source and destination sites
14
+ #as String. E.g., ["A", "C"]
15
+ #'operation' indicates an index of symmetry_operations in model.yaml.
16
+ #'weight' indicates a weight of the edge.
17
+ #def initialize(nodes, atom_id, to_site, global_vector, operation, weight)
18
+ def initialize(nodes, weight, note)
19
+ if nodes.size != 2
20
+ raise InitializeError, nodes.to_s
21
+ end
22
+ @nodes = nodes
23
+ #@atom_id = atom_id
24
+ #@to_site = to_site
25
+ #@global_vector = global_vector
26
+ #@operation = operation
27
+ @weight = weight
28
+ @note = note
29
+ end
30
+
31
+ #Return true if @nodes, @migrations, @operation, @weight are the same as others',
32
+ #respectively.
33
+ #Inverse edge will return false. E.g.,
34
+ #e00 = Crysna::TransitionFinder::Edge.new([0, 1], ["A", "B"], 0, -1.0)
35
+ #e01 = Crysna::TransitionFinder::Edge.new([1, 0], ["B", "A"], 0, -1.0)
36
+ #e00 == e01 #=> false
37
+ def ==(other)
38
+ result = true
39
+ result = false if @nodes != other.nodes
40
+ #result = false if @atom_id != other.atom_id
41
+ #result = false if @to_site != other.to_site
42
+ #result = false if @global_vector != other.global_vector
43
+ #result = false if @operation != other.operation
44
+ result = false if @weight != other.weight
45
+ result = false if @note != other.note
46
+ return result
47
+ end
48
+
49
+ #def to_s_short
50
+ # #"cell:#{@nodes[0]}->#{@nodes[1]}(mig:#{@migration[0]}->#{@migration[1]}, ope:#{@operation}, wgt:#{@weight})"
51
+ #end
52
+
53
+ end
54
+
data/test/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.out
@@ -0,0 +1,17 @@
1
+ Model to test optimizeframe command
2
+ 1.0
3
+ 2.0 2.0 2.0
4
+ 0.0 2.0 2.0
5
+ 0.0 0.0 2.0
6
+ 7 1 2
7
+ Direct
8
+ 0.10 0.10 0.10
9
+ 0.10 0.10 0.11
10
+ 0.10 0.10 0.13
11
+ 0.10 0.12 0.10
12
+ 0.10 0.16 0.10
13
+ 0.13 0.10 0.10
14
+ 0.19 0.10 0.10
15
+ 0.11 0.11 0.11
16
+ 0.00 0.00 0.00
17
+ 0.90 0.90 0.90
@@ -0,0 +1,122 @@
1
+ ---
2
+ frame_elements:
3
+ - 0
4
+ frame_sites:
5
+ FS_000:
6
+ - 0.0
7
+ - 0.0
8
+ - 0.0
9
+ FS_001:
10
+ - 0.0
11
+ - 0.0
12
+ - 0.01
13
+ FS_003:
14
+ - 0.0
15
+ - 0.0
16
+ - 0.03
17
+ FS_020:
18
+ - 0.0
19
+ - 0.02
20
+ - 0.0
21
+ FS_060:
22
+ - 0.0
23
+ - 0.06
24
+ - 0.0
25
+ FS_300:
26
+ - 0.03
27
+ - 0.0
28
+ - 0.0
29
+ FS_900:
30
+ - 0.09
31
+ - 0.0
32
+ - 0.0
33
+ symmetry_operations:
34
+ - rotation:
35
+ - - 1
36
+ - 0
37
+ - 0
38
+ - - 0
39
+ - 1
40
+ - 0
41
+ - - 0
42
+ - 0
43
+ - 1
44
+ translation:
45
+ - 0.0
46
+ - 0.0
47
+ - 0.0
48
+ - rotation:
49
+ - - -1
50
+ - 0
51
+ - 0
52
+ - - 0
53
+ - -1
54
+ - 0
55
+ - - 0
56
+ - 0
57
+ - -1
58
+ translation:
59
+ - 0.0
60
+ - 0.0
61
+ - 0.0
62
+ octahedral_sites:
63
+ Oc_000:
64
+ - - - FS_000
65
+ - - 0
66
+ - 0
67
+ - 1
68
+ - - FS_000
69
+ - - 1
70
+ - 1
71
+ - 0
72
+ - - - FS_000
73
+ - - 0
74
+ - 1
75
+ - 0
76
+ - - FS_000
77
+ - - 1
78
+ - 0
79
+ - 1
80
+ - - - FS_000
81
+ - - 1
82
+ - 0
83
+ - 0
84
+ - - FS_000
85
+ - - 0
86
+ - 1
87
+ - 1
88
+ tetrahedral_sites:
89
+ Te_000:
90
+ - - FS_000
91
+ - - 0
92
+ - 0
93
+ - 0
94
+ - - FS_000
95
+ - - 0
96
+ - 0
97
+ - 1
98
+ - - FS_000
99
+ - - 0
100
+ - 1
101
+ - 0
102
+ - - FS_000
103
+ - - 1
104
+ - 0
105
+ - 0
106
+ Te_001:
107
+ - - FS_000
108
+ - - 1
109
+ - 1
110
+ - 1
111
+ - - FS_000
112
+ - - 1
113
+ - 1
114
+ - 0
115
+ - - FS_000
116
+ - - 1
117
+ - 0
118
+ - 1
119
+ - - FS_000
120
+ - - 0
121
+ - 1
122
+ - 1