Class: Chem::G98::GaussianResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, view = false) ⇒ GaussianResult

Returns a new instance of GaussianResult.


714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
# File 'lib/chem/db/g98.rb', line 714

def initialize input, view=false
  @mo = Hash.new
  @has_cartessian_coordinate = false
  @has_z_matrix_coordinate = false
  @input = input
  read_link
  lines = Lines.new input.readlines
  link = @links[0].first
  puts_links if view
  while ! lines.eof?
    link.process lines
    break if link.stop
    link = link.next_link
  end
  #      link.process lines
end

Instance Attribute Details

#atomsObject

Returns the value of attribute atoms


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def atoms
  @atoms
end

#dipole_moment_totalObject

Returns the value of attribute dipole_moment_total


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def dipole_moment_total
  @dipole_moment_total
end

#electronic_spatial_extentObject

Returns the value of attribute electronic_spatial_extent


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def electronic_spatial_extent
  @electronic_spatial_extent
end

#energyObject

Returns the value of attribute energy


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def energy
  @energy
end

#exist_condensed_to_atomObject

Returns the value of attribute exist_condensed_to_atom


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def exist_condensed_to_atom
  @exist_condensed_to_atom
end

#guessObject

Returns the value of attribute guess


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def guess
  @guess
end

#has_cartessian_coordinateObject

Returns the value of attribute has_cartessian_coordinate


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def has_cartessian_coordinate
  @has_cartessian_coordinate
end

#has_z_matrix_coordinateObject

Returns the value of attribute has_z_matrix_coordinate


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def has_z_matrix_coordinate
  @has_z_matrix_coordinate
end

#homoObject

Returns the value of attribute homo


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def homo
  @homo
end

#lumoObject

Returns the value of attribute lumo


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def lumo
  @lumo
end

#moObject

Returns the value of attribute mo


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def mo
  @mo
end

#n_atomsObject

Returns the value of attribute n_atoms


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def n_atoms
  @n_atoms
end

#n_electronObject

Returns the value of attribute n_electron


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def n_electron
  @n_electron
end

#n_orbitalsObject

Returns the value of attribute n_orbitals


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def n_orbitals
  @n_orbitals
end

#nuclear_repulsion_energyObject

Returns the value of attribute nuclear_repulsion_energy


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def nuclear_repulsion_energy
  @nuclear_repulsion_energy
end

#scrf_delta_gObject

Returns the value of attribute scrf_delta_g


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def scrf_delta_g
  @scrf_delta_g
end

#standard_basisObject

Returns the value of attribute standard_basis


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def standard_basis
  @standard_basis
end

#stoichiometryObject

Returns the value of attribute stoichiometry


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def stoichiometry
  @stoichiometry
end

#sum_of_mulliken_chargeObject

Returns the value of attribute sum_of_mulliken_charge


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def sum_of_mulliken_charge
  @sum_of_mulliken_charge
end

#symmetricityObject

Returns the value of attribute symmetricity


710
711
712
# File 'lib/chem/db/g98.rb', line 710

def symmetricity
  @symmetricity
end

Instance Method Details

#entropy(temperature) ⇒ Object


754
755
756
# File 'lib/chem/db/g98.rb', line 754

def entropy temperature
  return entropy_trans(temperature)
end

#entropy_rotate(temperature, sigma) ⇒ Object


751
752
753
# File 'lib/chem/db/g98.rb', line 751

def entropy_rotate temperature, sigma
  return 877.37 + 8.3144 * (Math.log10(moment) + Math.log10(temperature) - Math.log10(sigma))
end

#entropy_trans(temperature) ⇒ Object


748
749
750
# File 'lib/chem/db/g98.rb', line 748

def entropy_trans temperature
  return 76.57 + 12.47 * Math.log10(weight) + 20.79 * Math.log10(temperature)
end

#include?(major, minor, parameter) ⇒ Boolean

Returns:

  • (Boolean)

860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
# File 'lib/chem/db/g98.rb', line 860

def include? major, minor, parameter
  @links.each do | link |
    link.each do |minor_link|
      if parameter
        if(minor_link.major_number == major &&
             minor_link.minor_number == minor &&
             minor_link.parameters.has_key?(parameter))
          return true
        end
      else
        if(minor_link.major_number == major && minor_link.minor_number == minor)
          return true
        end
      end
    end
  end
  false
end

#momentObject


737
738
739
740
741
742
743
744
745
746
747
# File 'lib/chem/db/g98.rb', line 737

def moment
  total_moment_x = 0
  total_moment_y = 0
  total_moment_z = 0
  @atoms.each do |key, atom|
    total_moment_x = total_moment_x + atom.weight * atom.x * atom.x
    total_moment_y = total_moment_y + atom.weight * atom.y * atom.y
    total_moment_z = total_moment_z + atom.weight * atom.z * atom.z
  end
  return total_moment_x * total_moment_y * total_moment_z
end

#near(one, distance) ⇒ Object


771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'lib/chem/db/g98.rb', line 771

def near one, distance
  @atoms.each do |key, another|
    puts '.'
    puts ((another.x - one.x) * (another.x - one.x) +
            (another.y - one.y) * (another.y - one.y) +
            (another.z + one.z) * (another.z - one.z)).to_s
    if ((another.x - one.x) * (another.x - one.x) +
          (another.y - one.y) * (another.y - one.y) +
          (another.z + one.z) * (another.z - one.z)) < distance * distance
      yield another
    end
  end
end

792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
# File 'lib/chem/db/g98.rb', line 792

def process_link_line line, last_link
  /\// =~ line
  major_no =  $`.to_i
  /\// =~ $'
  parameters = Hash.new
  minor_no = $'.chop.chop.split ','
  $`.split(',').each do |p|
    /=/ =~ p
    parameters[$`.to_i] = $'.to_i
  end
  goto = 0
  if /\((-?\d+)/ =~ minor_no.last
    minor_no[-1] = $`
    goto = $+.to_i
  end
  stop = false
  major_links = Array.new
  minor_no.each do |minor|
    link = Link.new(major_no, minor.to_i, parameters, goto, self)# if(major_no == 1 && minor == '1')
    major_links.push link
  end
  major_links
end

878
879
880
881
882
# File 'lib/chem/db/g98.rb', line 878

def puts_links
  @links.each do | link |
    puts link
  end
end

815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
# File 'lib/chem/db/g98.rb', line 815

def read_link
  @links = Array.new
  while(/[*]{10}/ !~ @input.readline)
    ;
  end
  while(/[*]{10}/ !~ @input.readline)
    ;
  end
  while /[%]/ =~ @input.readline
    ;
  end
  @input.readline if / Will use up to/ =~ $_
  @input.readline# # RHF/6-31G(d) Pop=Full Test
  @input.readline# ----------------------------
  while(/(--+)|( Leave Link)/ !~ @input.readline)
    if /^$/ =~ $_
      @input.readline
      @input.readline
      @input.readline
      @input.readline
    end
    if(@links.last != nil)
      last = @links.last.last
    else
      last = nil
    end
    link =  process_link_line $_, last
    @links.push link
    #        puts link
  end
  last_link = nil
  @links.each do |link|
    link.each do |minor_link|
      if (last_link != nil)
        last_link.default_link = minor_link
        if minor_link.goto > 0
          minor_link.jump_link = @links[@links.index(link) + minor_link.goto + 1].first
        elsif minor_link.goto < 0
          minor_link.jump_link = @links[@links.index(link) + minor_link.goto].first
        end
      end
      last_link = minor_link
    end
  end
end

#to_xyzObject


784
785
786
787
788
789
790
791
# File 'lib/chem/db/g98.rb', line 784

def to_xyz
  s = @atoms.length.to_s + "\n"
  s = s + "*\n"
  @atoms.each do |key, atom|
    s = s + sprintf("%2s% 8.3f% 8.3f% 8.3f\n", atom.element, atom.x, atom.y, atom.z)
  end
  s
end

#valencyObject


757
758
759
760
761
762
763
# File 'lib/chem/db/g98.rb', line 757

def valency
  total_valency = 0
  @atoms.each do |key, atom|
    total_valency = total_valency + atom.valency
  end
  total_valency
end

#valency2Object


764
765
766
767
768
769
770
# File 'lib/chem/db/g98.rb', line 764

def valency2
  total_valency2 = 0
  @atoms.each do |key, atom|
    total_valency2 = total_valency2 + atom.valency2
  end
  total_valency2 / 2 + 1
end

#weightObject

link.process lines


730
731
732
733
734
735
736
# File 'lib/chem/db/g98.rb', line 730

def weight
  total_weight = 0
  @atoms.each do |key, atom|
    total_weight = total_weight + atom.weight
  end
  total_weight
end