Class: Chem::G98::G98Atom

Inherits:
Object
  • Object
show all
Defined in:
lib/chem/db/g98.rb

Constant Summary collapse

VALENCY =
{'C'=>4, 'N'=>3, 'H'=>1, 'F'=>1, 'CL'=>1, 'I'=>1, 'O'=>2, 'BR'=>1}
VALENCY2 =
{'C'=>2, 'H'=>-1, 'O'=>0, 'F'=>-1, 'CL'=>-1, 'BR'=>-1}
WEIGHT =
{'O'=>15.9999, 'BR'=>79.904, 'H'=>1.00794, 'C'=>12.001, 'F'=>18.9984032, 'CL'=>35.4527, 'N'=>14.00674}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, molecule) ⇒ G98Atom

Returns a new instance of G98Atom.



619
620
621
622
623
624
# File 'lib/chem/db/g98.rb', line 619

def initialize index, molecule
  @index = index
  @molecule = molecule
  @density = Hash.new
  @orbital = Hash.new
end

Instance Attribute Details

#angle(atom, angle) ⇒ Object

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def angle
  @angle
end

#angle_atomObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def angle_atom
  @angle_atom
end

#densityObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def density
  @density
end

#dihedral_angle_atomObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def dihedral_angle_atom
  @dihedral_angle_atom
end

#dihedral_angle_bObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def dihedral_angle_b
  @dihedral_angle_b
end

#diheral_angle_aObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def diheral_angle_a
  @diheral_angle_a
end

#distance_atomObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def distance_atom
  @distance_atom
end

#distance_lengthObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def distance_length
  @distance_length
end

#elementObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def element
  @element
end

#heavy_chargeObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def heavy_charge
  @heavy_charge
end

#indexObject (readonly)

Returns the value of attribute index.



615
616
617
# File 'lib/chem/db/g98.rb', line 615

def index
  @index
end

#total_atomic_chargeObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def total_atomic_charge
  @total_atomic_charge
end

#xObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def x
  @x
end

#yObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def y
  @y
end

#zObject

include Atom



612
613
614
# File 'lib/chem/db/g98.rb', line 612

def z
  @z
end

Instance Method Details

#ao(hash) ⇒ Object



651
652
653
654
655
656
657
# File 'lib/chem/db/g98.rb', line 651

def ao hash
  if @orbital[hash] == nil
    return @orbital[hash] = AtomicOrbital.new(hash)
  else
    return @orbital[hash]
  end
end

#dihedral(atom, angle_a, angle_b) ⇒ Object



666
667
668
669
670
# File 'lib/chem/db/g98.rb', line 666

def dihedral atom, angle_a, angle_b
  @dihedral_atom = atom
  @dihedral_angle_a = angle_a
  @dihedral_angle_b = angle_b
end

#distance(atom, length) ⇒ Object



658
659
660
661
# File 'lib/chem/db/g98.rb', line 658

def distance atom, length
  @distance_atom = atom
  @distance_length = length
end

#each_aoObject



646
647
648
649
650
# File 'lib/chem/db/g98.rb', line 646

def each_ao
  @orbital.each_value do |atomic_orbital|
    yield atomic_orbital
  end
end

#get_distance(atom) ⇒ Object



625
626
627
# File 'lib/chem/db/g98.rb', line 625

def get_distance atom
  Math.sqrt((@x - atom.x)*(@x - atom.x) + (@y - atom.y)*(@y - atom.y) + (@z - atom.z)*(@z - atom.z))
end

#neighbor?(atom, length) ⇒ Boolean

Returns:

  • (Boolean)


628
629
630
# File 'lib/chem/db/g98.rb', line 628

def neighbor? atom, length
  return (get_distance(atom) < length)
end

#to_cartessian_coodinateObject



685
686
687
# File 'lib/chem/db/g98.rb', line 685

def to_cartessian_coodinate
  sprintf(" %2s  % f  % f  % f", @element, @x, @y, @z)
end

#to_condensed_densityObject



678
679
680
681
682
683
684
# File 'lib/chem/db/g98.rb', line 678

def to_condensed_density
  s = sprintf("%2s  ", @element)
  1.upto @molecule.atoms.length do |num|
    s = s + sprintf("% f  ", @density[num].to_s)
  end
  return s
end

#to_molObject



688
689
690
# File 'lib/chem/db/g98.rb', line 688

def to_mol
  sprintf("%10.4f%10.4f%10.4f %-2s  0  0  0  0  0", @x, @y, @z, @element)
end

#to_sObject



671
672
673
674
675
676
677
# File 'lib/chem/db/g98.rb', line 671

def to_s
  if @molecule.has_cartessian_coordinate
    return to_cartessian_coodinate
  elsif @molecule.has_z_matrix
    return to_z_matrix
  end
end

#to_xyzObject



691
692
693
# File 'lib/chem/db/g98.rb', line 691

def to_xyz
  sprintf("%2s% 8.3f% 8.3f% 8.3f\n", @element, @x, @y, @z)
end

#to_z_matrixObject



694
695
696
697
698
699
700
701
702
703
704
705
706
# File 'lib/chem/db/g98.rb', line 694

def to_z_matrix
  s = sprintf("%d  %s ", @molecule.atoms.index(self), @element)
  if @distance_atom != nil
    s = s + sprintf("%2d  %f  ", @molecule.atoms.index(@distance_atom), @distance_length)
  end
  if @angle_atom != nil
    s = s + sprintf("%2d  %f  ", @molecule.atoms.index(@angle_atom), @angle)
  end
  if @dihedral_atom != nil
    s = s + sprintf("%2d  %f  %f", @molecule.atoms.index(@dihedral_atom), @dihedral_angle_a, @dihedral_angle_b)
  end
  return s
end

#valencyObject



638
639
640
641
# File 'lib/chem/db/g98.rb', line 638

def valency
  puts('@element : ' + @element + 'is not defined valency!!') if VALENCY[@element] == nil
  VALENCY[@element]
end

#valency2Object



642
643
644
645
# File 'lib/chem/db/g98.rb', line 642

def valency2
  puts('@element : ' + @element + 'is not defined valency2!!') if VALENCY2[@element] == nil
  VALENCY2[@element]
end

#weightObject



634
635
636
637
# File 'lib/chem/db/g98.rb', line 634

def weight
  puts('@element : ' + @element + 'is not defined weight!!') if WEIGHT[@element] == nil
  return WEIGHT[@element]
end