class Crysna::TransitionFinder::Cell

Attributes

atoms[R]
energy[RW]
from_edges[R]

@from_edges of a start cell must be set to be []

name[RW]
reach_flag[R]

Public Class Methods

new(sites, energy = nil, name = "") click to toggle source
Calls superclass method Crysna::Cell::new
# File lib/crysna/transitionfinder/cell.rb, line 15
def initialize(sites, energy = nil, name = "")
  super(sites)
  @energy = energy
  @reach_flag = false
  @from_edges = [] # include Edge.
  @name = name
end

Public Instance Methods

==(other) click to toggle source
# File lib/crysna/transitionfinder/cell.rb, line 23
def ==(other)
  result = true
  result = false if @atoms            != other.atoms
  result = false if @energy           != other.energy
  result = false if @reach_flag != other.reach_flag
  result = false if @from_edges != other.from_edges
  result = false if @name             != other.name
  return result
end
inspect_short() click to toggle source
# File lib/crysna/transitionfinder/cell.rb, line 110
def inspect_short
  result = "#{self.class}: "
  result += occupied_sitename
  #result += '-'
  result += ", @energy = #{@energy}"
  result += ", @reach_flag = #{@reach_flag}"
  result += ", @from_edges = #{@from_edges}"
  result += ", @name = \"#{@name}\""
  return result
end
migrate(index, site, global_vector) click to toggle source

Not-destructive method of migrate!()

# File lib/crysna/transitionfinder/cell.rb, line 74
def migrate(index, site, global_vector)
  result = Marshal.load(Marshal.dump(self))
  result.migrate!(index, site, global_vector)
  result
end
migrate!(index, site, global_vector, io = File.open(File::NULL, "w")) click to toggle source

Migrate atom of index to site and in the cell which is neighboring with the direction of global_vector. Generating new cell which is not reached. This method does not raise error even when destination site is already occupied, then, there are two atoms in the site.

# File lib/crysna/transitionfinder/cell.rb, line 54
def migrate!(index, site, global_vector, io = File.open(File::NULL, "w"))
  io.puts "##{self.class}.migrate!(#{index}, #{site}, #{global_vector}"
  raise RangeError if index >= atoms.size

  atoms #sort
  @atoms[index].migrate!(site, global_vector)
  io.puts "Atoms after migration:"
  @atoms.each do |atom|
    io.puts "#{atom.element}, #{atom.site.name}, #{atom.site.global_vector}"
  end

  @atoms.sort!
  io.puts "Atoms after sort:"
  @atoms.each do |atom|
    io.puts "#{atom.element}, #{atom.site.name}, #{atom.site.global_vector}"
  end
  reset
end
occupied_sitename() click to toggle source
# File lib/crysna/transitionfinder/cell.rb, line 98
def occupied_sitename
  result = ''
  result += atoms.map do |atom|
    periodic_num = ''
    atom.site.global_vector.each do |i|
      periodic_num += (i + 5).to_s
    end
    atom.site.name + periodic_num
  end . join "-"
  result
end
operate(operation) click to toggle source

def inspect

result = 
to_s

end

Calls superclass method Crysna::Cell#operate
# File lib/crysna/transitionfinder/cell.rb, line 127
def operate(operation)
  result = super(operation)
  result.energy = @energy
  return result
end
periodically_equal?(other) click to toggle source

Return true if all sites correspond to those of the other. It is ok even if global vector is different.

# File lib/crysna/transitionfinder/cell.rb, line 94
def periodically_equal?(other)
  self.atoms.sort.map{|atom| atom.site.name} == other.atoms.sort.map{|atom| atom.site.name}
end
reach(edge) click to toggle source

Set reach flag to be true. ‘edge’ is the one between cells of already reached cell and self.

# File lib/crysna/transitionfinder/cell.rb, line 82
def reach(edge)
  @reach_flag = true
  @from_edges << edge
end
reach?() click to toggle source

Return true if already reached.

# File lib/crysna/transitionfinder/cell.rb, line 88
def reach?
  return @reach_flag
end
same_atoms?(other) click to toggle source
# File lib/crysna/transitionfinder/cell.rb, line 33
def same_atoms?(other)
  return @atoms == other.atoms
end
same_sites?(other) click to toggle source
# File lib/crysna/transitionfinder/cell.rb, line 37
def same_sites?(other)
  result = true
  @atoms.size.times do |index|
    if @atoms[index].site.name != other.atoms[index].site.name
      result = false
      break
    end
  end
  return result
end

Private Instance Methods

reset() click to toggle source

Reset information of reach and edge. (@reach_flag and @from_edges)

# File lib/crysna/transitionfinder/cell.rb, line 137
def reset
  @reach_flag = false
  @from_edges = []
  @name = nil
end