class Crysna::TransitionFinder::CellManager
Attributes
Public Class Methods
# File lib/crysna/transitionfinder/cellmanager.rb, line 12 def initialize @cells = [] end
Public Instance Methods
Return a cell of index.
# File lib/crysna/transitionfinder/cellmanager.rb, line 31 def [](nth) @cells[nth] end
Add entry of cell as node. Return index of the name. If the cell is already added, do nothing and return the same cell.
# File lib/crysna/transitionfinder/cellmanager.rb, line 19 def add(cell) #index = @cells.find {|tgt_cell| cell == tgt_cell} index = index_same_atoms cell if index return index else @cells << cell return @cells.size - 1 end end
Return an array of indices from a cell of ‘index’ in @cells to the origin cell. The origin cell is the cell whose @from_edges has nil at the first item. Note that this method uses only the first item in @flom_edges of cells.
# File lib/crysna/transitionfinder/cellmanager.rb, line 103 def ascend(index) results = [] while true results << index edge = @cells[index].from_edges[0] #pp edge break unless edge index = edge.nodes[0] end #current_index = last_index #while current_index != nil # results << current_index # current_index = @cells[current_index].previous_cell #end return results end
# File lib/crysna/transitionfinder/cellmanager.rb, line 89 def contain_periodically_shift_cells? if periodically_shift_indices.find {|i| i.size > 1} return true else return false # nil is converted to false. end end
Return index of the cell in CellManager
instance.
# File lib/crysna/transitionfinder/cellmanager.rb, line 36 def index_same_atoms(cell) #@cells.index(cell) result = nil @cells.each_with_index do |tmp_cell, id| if cell.same_atoms?(tmp_cell) result = id break end end return result end
Return index of the cell with the same site in CellManager
instance.
# File lib/crysna/transitionfinder/cellmanager.rb, line 50 def index_same_sites(cell) result = nil @cells.each_with_index do |tmp_cell, id| if cell.same_sites?(tmp_cell) result = id break end end return result end
Return a two-dimensional array, whose items are indices of the cells of groups of identical nodes among reached cells.
# File lib/crysna/transitionfinder/cellmanager.rb, line 72 def periodically_shift_indices results = [] @cells.each_with_index do |cell, c_index| next unless cell.reach? entering_index = results.size results.each_with_index do |group, g_index| if @cells[group[0]].periodically_equal? cell entering_index = g_index break end end results[entering_index] ||= [] results[entering_index] << c_index end return results end
Set reach flag to the cell of ‘dst_cell_index’. ‘edge’ is added into ‘@from_edges’ of the cell. ‘nil’ data is available for ‘edge’. (E.g., starting cell.)
# File lib/crysna/transitionfinder/cellmanager.rb, line 64 def reach(dest_cell_index, edge) @cells[dest_cell_index].reach(edge) end