~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to lib/ruby/cceom.rb

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Handle access to Psi ccenergy module
 
2
 
 
3
module Psi
 
4
  class CCEom
 
5
    
 
6
    # Mixin the InputGenerator
 
7
    include InputGenerator
 
8
    include Executor
 
9
    # Which references does this method support
 
10
    def self.supports_analytic_gradients
 
11
      { "rhf" => false, "rohf" => false, "uhf" => false, "twocon" => false }
 
12
    end
 
13
    def self.supports_analytic_second_derivatives
 
14
      { "rhf" => false, "rohf" => false, "uhf" => false, "twocon" => false }
 
15
    end
 
16
    
 
17
    def initialize(task_obj)
 
18
      @task = task_obj
 
19
      # Set the generic command for this class
 
20
      set_binary_command Psi::Commands::CCEOM
 
21
    end
 
22
  end
 
23
  
 
24
  # Add ccenergy ability to Task
 
25
  class Task
 
26
    def eom(*args)
 
27
      # convert to a hash
 
28
      args_hash = args[0]
 
29
 
 
30
      # Call transqt and ccsort unless told not to
 
31
      if args_hash != nil
 
32
        if args_hash.has_key?(:cchbar) == false or 
 
33
           (args_hash.has_key?(:cchbar) and args_hash[:cchbar] == true)
 
34
          cchbar(args_hash)
 
35
        end
 
36
      else
 
37
        cchbar(args_hash)
 
38
      end
 
39
      args_hash.delete(:cchbar) unless args_hash == nil
 
40
 
 
41
      # Create a new scf object
 
42
      eom_obj = Psi::CCEom.new self
 
43
 
 
44
      # Form the input hash and generate the input file
 
45
      input_hash = { }
 
46
 
 
47
      # Check to see if the function arguments have the reference, if so use it, otherwise use
 
48
      # global setting
 
49
      if args_hash == nil or args_hash.has_key?("reference") == false
 
50
        input_hash["reference"] = reference
 
51
      end
 
52
 
 
53
      # If we are doing analytic gradients make sure ccenergy knows
 
54
      if get_gradients == true and CCEom.supports_analytic_gradients[reference] == true
 
55
        input_hash["dertype"] = "first"
 
56
      else
 
57
        input_hash["dertype"] = "none"
 
58
      end
 
59
      
 
60
      # Check the wavefunction
 
61
      if args_hash == nil or args_hash.has_key?("wfn") == false
 
62
        input_hash["wfn"] = wavefunction
 
63
      end
 
64
 
 
65
      # Merge what we've done with what the user wants, user settings should override
 
66
      input_hash = input_hash.merge(args_hash) unless args_hash == nil
 
67
 
 
68
      # Run the ccenergy module, sending the input file as keyboard input
 
69
      puts "eom"
 
70
      eom_obj.execute(input_hash)
 
71
      
 
72
      # Check to see if we are supposed to compute analytical gradients, only do if
 
73
      #  1. It is supported
 
74
      #  2. The user requested it
 
75
      #  3. The wavefunction is CCSD
 
76
      if get_gradients == true and CCEom.supports_analytic_gradients[reference] == true and wavefunction.casecmp("eom_ccsd") == 0
 
77
        puts "gradient:"
 
78
        Psi::indent_puts
 
79
        cclambda(input_hash, :binary => Psi::Commands::CCLAMBDA_EXCITED)
 
80
        ccdensity(input_hash, :binary => Psi::Commands::CCDENSITY_CALC_XI)
 
81
        cclambda(input_hash, :binary => Psi::Commands::CCLAMBDA_ZETA)
 
82
        ccdensity(input_hash, :binary => Psi::Commands::CCDENSITY_USE_ZETA)
 
83
        oeprop(input_hash)
 
84
        
 
85
        # Tell transqt to do a back transformation
 
86
        transqt_input_hash = input_hash
 
87
        transqt_input_hash[:backtr] = true
 
88
        transqt(transqt_input_hash)
 
89
        deriv(input_hash)
 
90
        Psi::unindent_puts
 
91
      end
 
92
      
 
93
      eom_states_energy
 
94
    end
 
95
  end
 
96
end
 
97
 
 
98
# Create some global functions
 
99
# User can send additional input parameters to the function
 
100
def eom(*args)
 
101
  # convert to a hash
 
102
  args_hash = args[0]
 
103
  Psi::global_task.eom(args_hash)
 
104
end