~ubuntu-branches/ubuntu/quantal/psicode/quantal

« back to all changes in this revision

Viewing changes to src/bin/ccresponse/get_params.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2006-09-10 14:01:33 UTC
  • Revision ID: james.westby@ubuntu.com-20060910140133-ib2j86trekykfsfv
Tags: upstream-3.2.3
ImportĀ upstreamĀ versionĀ 3.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
#include <math.h>
 
4
#include <stdlib.h>
 
5
#include <libipv1/ip_lib.h>
 
6
#include <libciomr/libciomr.h>
 
7
#include <psifiles.h>
 
8
#include <physconst.h>
 
9
#define EXTERN
 
10
#include "globals.h"
 
11
 
 
12
void get_params()
 
13
{
 
14
  int i, errcod, ref, count, iconv, *tmpi;
 
15
  char *junk, units[20];
 
16
 
 
17
  params.print = 1;
 
18
  errcod = ip_data("PRINT","%d",&(params.print),0);
 
19
 
 
20
  fndcor(&(params.memory), infile, outfile);
 
21
 
 
22
  params.cachelev = 2;
 
23
  errcod = ip_data("CACHELEV", "%d", &(params.cachelev),0);
 
24
  params.cachelev = 0;
 
25
 
 
26
  errcod = ip_string("REFERENCE", &(junk),0);
 
27
  /* if no reference is given, assume rhf */
 
28
  if (errcod != IPE_OK) {
 
29
    ref = 0;
 
30
  }
 
31
  else {
 
32
    if(!strcmp(junk, "RHF")) ref = 0;
 
33
    else if(!strcmp(junk, "ROHF")) ref = 1;
 
34
    else if(!strcmp(junk, "UHF")) ref = 2;
 
35
    else { 
 
36
      printf("Invalid value of input keyword REFERENCE: %s\n", junk);
 
37
      exit(PSI_RETURN_FAILURE); 
 
38
    }
 
39
    free(junk);
 
40
  }
 
41
 
 
42
  /* Make sure the value of ref matches that from CC_INFO */
 
43
  if(params.ref != ref) {
 
44
    fprintf(outfile, "Value of REFERENCE from input.dat (%1d) and CC_INFO (%1d) do not match!\n", 
 
45
            ref, params.ref);
 
46
    fprintf(outfile, "Is this what you want to do?\n");
 
47
    params.ref = ref;
 
48
  }
 
49
 
 
50
  /* grab the field strength from input -- a few different units are converted to E_h */
 
51
  params.omega = 0.0; /* static polarizability by default */
 
52
  if(ip_exist("OMEGA",0)) {
 
53
    errcod = ip_count("OMEGA", &count, 0);
 
54
 
 
55
    if(errcod == IPE_NOT_AN_ARRAY)  /* assume Hartrees */
 
56
      errcod = ip_data("OMEGA", "%lf", &(params.omega), 0);
 
57
 
 
58
    else if(count == 2) {
 
59
 
 
60
      errcod = ip_data("OMEGA", "%lf", &(params.omega), 1, 0);
 
61
      errcod = ip_data("OMEGA", "%s", units, 1, 1);
 
62
 
 
63
      for(junk = units; *junk != '\0'; junk++)
 
64
        if(*junk>='a' && *junk <= 'z') *junk += 'A' - 'a';
 
65
 
 
66
      if(!strcmp(units, "HZ")) params.omega *= _h / _hartree2J;
 
67
      else if(!strcmp(units, "NM")) params.omega = (_c*_h*1e9)/(params.omega*_hartree2J);
 
68
      else if(!strcmp(units, "EV")) params.omega /= _hartree2ev;
 
69
    }
 
70
  }
 
71
 
 
72
  moinfo.mu_irreps = init_int_array(3);
 
73
  errcod = ip_int_array("MU_IRREPS", moinfo.mu_irreps, 3);
 
74
  if(errcod == IPE_OK) {
 
75
    moinfo.irrep_x = moinfo.mu_irreps[0];
 
76
    moinfo.irrep_y = moinfo.mu_irreps[1];
 
77
    moinfo.irrep_z = moinfo.mu_irreps[2];
 
78
  }
 
79
  else {
 
80
    fprintf(outfile, "\nYou must supply the irreps of x, y, and z with the MU_IRREPS keyword.\n");
 
81
    exit(PSI_RETURN_FAILURE);
 
82
  }
 
83
 
 
84
  /* compute the irreps of the angular momentum operator while we're here */
 
85
  moinfo.l_irreps = init_int_array(3);
 
86
  for(i=0; i < 3; i++)
 
87
    moinfo.l_irreps[i] = moinfo.mu_irreps[(int) (i+1)%3] ^ moinfo.mu_irreps[(int) (i+2)%3];
 
88
 
 
89
  moinfo.irrep_Rx = moinfo.l_irreps[0];
 
90
  moinfo.irrep_Ry = moinfo.l_irreps[1];
 
91
  moinfo.irrep_Rz = moinfo.l_irreps[2];
 
92
 
 
93
  params.maxiter = 50;
 
94
  errcod = ip_data("MAXITER","%d",&(params.maxiter),0);
 
95
  params.convergence = 1e-7;
 
96
  errcod = ip_data("CONVERGENCE","%d",&(iconv),0);
 
97
  if(errcod == IPE_OK) params.convergence = 1.0*pow(10.0,(double) -iconv);
 
98
  params.diis = 1;
 
99
  errcod = ip_boolean("DIIS", &(params.diis), 0);
 
100
 
 
101
  if(ip_exist("PROPERTY",0)) {
 
102
    errcod = ip_string("PROPERTY", &(params.prop), 0);
 
103
    if(strcmp(params.prop,"POLARIZABILITY") && strcmp(params.prop,"ROTATION") && 
 
104
       strcmp(params.prop,"ALL")) {
 
105
      fprintf(outfile, "Invalid choice of response property: %s\n", params.prop);
 
106
      exit(PSI_RETURN_FAILURE);
 
107
    }
 
108
  }
 
109
  else params.prop = strdup("POLARIZABILITY");
 
110
 
 
111
  params.local = 0;
 
112
  errcod = ip_boolean("LOCAL", &(params.local),0);
 
113
  local.cutoff = 0.02;
 
114
  errcod = ip_data("LOCAL_CUTOFF", "%lf", &(local.cutoff), 0);
 
115
 
 
116
  if(ip_exist("LOCAL_METHOD",0)) {
 
117
    errcod = ip_string("LOCAL_METHOD", &(local.method), 0);
 
118
    if(strcmp(local.method,"AOBASIS") && strcmp(local.method,"WERNER")) {
 
119
      fprintf(outfile, "Invalid local correlation method: %s\n", local.method);
 
120
      exit(PSI_RETURN_FAILURE);
 
121
    }
 
122
  }
 
123
  else if(params.local) {
 
124
    local.method = (char *) malloc(7 * sizeof(char));
 
125
    sprintf(local.method, "%s", "WERNER");
 
126
  }
 
127
 
 
128
  if(ip_exist("LOCAL_WEAKP",0)) {
 
129
    errcod = ip_string("LOCAL_WEAKP", &(local.weakp), 0);
 
130
    if(strcmp(local.weakp,"MP2") && strcmp(local.weakp,"NEGLECT") && strcmp(local.weakp,"NONE")) {
 
131
      fprintf(outfile, "Invalid method for treating local pairs: %s\n", local.weakp);
 
132
      exit(PSI_RETURN_FAILURE);
 
133
    }
 
134
  }
 
135
  else if(params.local) {
 
136
    local.weakp = (char *) malloc(4 * sizeof(char));
 
137
    sprintf(local.weakp, "%s", "NONE");
 
138
  }
 
139
 
 
140
  local.filter_singles = 1;
 
141
  ip_boolean("LOCAL_FILTER_SINGLES", &(local.filter_singles), 0);
 
142
 
 
143
  params.analyze = 0;
 
144
  ip_boolean("ANALYZE", &(params.analyze), 0);
 
145
 
 
146
  fprintf(outfile, "\n\tInput parameters:\n");
 
147
  fprintf(outfile, "\t-----------------\n");
 
148
  if(!strcmp(params.prop,"ALL"))
 
149
    fprintf(outfile, "\tProperty        =    POLARIZABILITY + ROTATION\n");
 
150
  else
 
151
    fprintf(outfile, "\tProperty        =    %s\n", params.prop);
 
152
  fprintf(outfile, "\tReference wfn   =    %5s\n",
 
153
          (params.ref == 0) ? "RHF" : ((params.ref == 1) ? "ROHF" : "UHF"));
 
154
  fprintf(outfile, "\tMemory (Mbytes) =  %5.1f\n",params.memory/1e6);
 
155
  fprintf(outfile, "\tCache Level     =    %1d\n", params.cachelev);
 
156
  fprintf(outfile, "\tPrint Level     =    %1d\n",  params.print);
 
157
  fprintf(outfile, "\tMaxiter         =    %3d\n",  params.maxiter);
 
158
  fprintf(outfile, "\tConvergence     = %3.1e\n", params.convergence);
 
159
  fprintf(outfile, "\tDIIS            =     %s\n", params.diis ? "Yes" : "No");
 
160
  fprintf(outfile, "\tIrrep X         =    %3s\n", moinfo.labels[moinfo.irrep_x]);
 
161
  fprintf(outfile, "\tIrrep Y         =    %3s\n", moinfo.labels[moinfo.irrep_y]);
 
162
  fprintf(outfile, "\tIrrep Z         =    %3s\n", moinfo.labels[moinfo.irrep_z]);
 
163
  fprintf(outfile, "\tIrrep RX        =    %3s\n", moinfo.labels[moinfo.irrep_Rx]);
 
164
  fprintf(outfile, "\tIrrep RY        =    %3s\n", moinfo.labels[moinfo.irrep_Ry]);
 
165
  fprintf(outfile, "\tIrrep RZ        =    %3s\n", moinfo.labels[moinfo.irrep_Rz]);
 
166
  if(params.omega == 0.0) 
 
167
    fprintf(outfile, "\tApplied field   = none\n");
 
168
  else 
 
169
    fprintf(outfile, "\tApplied field   =    %5.3f E_h (%6.2f nm, %5.3f eV, %8.2f cm-1)\n", params.omega,
 
170
            (_c*_h*1e9)/(_hartree2J*params.omega), _hartree2ev*params.omega,
 
171
            _hartree2wavenumbers*params.omega);
 
172
  fprintf(outfile, "\tLocal CC        =     %s\n", params.local ? "Yes" : "No");
 
173
  if(params.local) {
 
174
    fprintf(outfile, "\tLocal Cutoff    = %3.1e\n", local.cutoff);
 
175
    fprintf(outfile, "\tLocal Method    =    %s\n", local.method);
 
176
    fprintf(outfile, "\tWeak pairs      =    %s\n", local.weakp);
 
177
    fprintf(outfile, "\tFilter singles  =    %s\n", local.filter_singles ? "Yes" : "No");
 
178
  }
 
179
  fprintf(outfile, "\tAnalyze X2 Amps  =    %s\n", params.analyze ? "Yes" : "No");
 
180
  fprintf(outfile, "\n");
 
181
}
 
182