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

« back to all changes in this revision

Viewing changes to src/bin/mp2/mp2.c

  • 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
 
#include <stdio.h>
2
 
#include <string.h>
3
 
#include <stdlib.h>
4
 
#include <math.h>
5
 
#include <libipv1/ip_lib.h>
6
 
#include <libciomr/libciomr.h>
7
 
#include <libdpd/dpd.h>
8
 
#include <libchkpt/chkpt.h>
9
 
#include <libqt/qt.h>
10
 
#include <libiwl/iwl.h>
11
 
#include <physconst.h>
12
 
#include <psifiles.h>
13
 
#include "globals.h"
14
 
 
15
 
void init_io(int argc, char *argv[]);
16
 
void title(void);
17
 
void get_moinfo(void);
18
 
void get_params(void);
19
 
void init_ioff(void);
20
 
int **cacheprep_rhf(int level, int *cachefiles);
21
 
int **cacheprep_uhf(int level, int *cachefiles);
22
 
void cachedone_rhf(int **cachelist);
23
 
struct dpd_file4_cache_entry *priority_list(void);
24
 
double energy(void);
25
 
void sort_amps(void);
26
 
void opdm(void);
27
 
void twopdm(void);
28
 
void lag(void);
29
 
void build_X(void);
30
 
void build_A(void);
31
 
void Zvector(void);
32
 
void relax_I(void);
33
 
void relax_opdm(void);
34
 
void sort_opdm(void);
35
 
void sort_I(void);
36
 
void fold(void);
37
 
void deanti(void);
38
 
void write_data(void);
39
 
void check_energy(int);
40
 
void sort_twopdm(void);
41
 
void cleanup(void);
42
 
void exit_io(void);
43
 
 
44
 
int main(int argc, char *argv[])
45
 
{
46
 
  int *cachefiles;
47
 
  int **cachelist;
48
 
 
49
 
  struct dpd_file4_cache_entry *priority;
50
 
  
51
 
  init_io(argc,argv);
52
 
  title();
53
 
 
54
 
  get_moinfo();
55
 
  get_params();
56
 
  init_ioff();
57
 
  
58
 
  cachefiles = init_int_array(PSIO_MAXUNIT);
59
 
 
60
 
  if(params.ref == 2) { /** UHF **/
61
 
    cachelist = cacheprep_uhf(params.cachelev,cachefiles);
62
 
    dpd_init(0,mo.nirreps,params.memory,params.cachetype,cachefiles,cachelist,
63
 
             NULL,4,mo.aoccpi,mo.aocc_sym,mo.avirpi,mo.avir_sym,mo.boccpi,
64
 
             mo.bocc_sym,mo.bvirpi,mo.bvir_sym);
65
 
  }
66
 
  else { /** RHF or ROHF **/
67
 
    cachelist = cacheprep_rhf(params.cachelev,cachefiles);
68
 
    priority = priority_list();
69
 
    dpd_init(0,mo.nirreps,params.memory,params.cachetype,cachefiles,
70
 
             cachelist,priority,2,mo.occpi,mo.occ_sym,mo.virpi,mo.vir_sym);
71
 
  }
72
 
  
73
 
  amps();
74
 
 
75
 
  mo.Emp2 = energy();
76
 
  
77
 
  fprintf(outfile,"\n");
78
 
  fprintf(outfile,"\tMP2 correlation energy      = %20.15f\n",mo.Emp2);
79
 
  fprintf(outfile,"\tMP2 total energy            = %20.15f\n",mo.Escf+mo.Emp2);
80
 
  fflush(outfile);
81
 
 
82
 
  chkpt_init(PSIO_OPEN_OLD);
83
 
  chkpt_wt_etot(mo.Escf+mo.Emp2);
84
 
  chkpt_close();
85
 
  
86
 
  if(params.opdm) {
87
 
    opdm();
88
 
    if(params.relax_opdm) {
89
 
      lag();
90
 
      build_A();
91
 
      Zvector();
92
 
    }
93
 
    sort_opdm();
94
 
    //dipole();
95
 
  }
96
 
 
97
 
  if(params.gradient) {
98
 
    sort_amps();
99
 
    opdm();
100
 
    twopdm();
101
 
    lag();
102
 
    build_X();
103
 
    build_A();
104
 
    Zvector();
105
 
    relax_I();
106
 
    relax_opdm();
107
 
    sort_I(); 
108
 
    sort_opdm();
109
 
    fold();
110
 
    deanti();
111
 
    write_data();
112
 
  }
113
 
 
114
 
  dpd_close(0);
115
 
  
116
 
  cleanup();
117
 
 
118
 
  exit_io();
119
 
  
120
 
  exit(0);
121
 
}
122
 
 
123
 
void init_io(int argc, char *argv[])
124
 
{
125
 
  int i=0;
126
 
  int num_extra_args=0;
127
 
  char **extra_args;
128
 
  extern char *gprgid();
129
 
  char *progid;
130
 
 
131
 
  extra_args = (char **)malloc(argc*sizeof(char *));
132
 
  progid = (char *)malloc(strlen(gprgid())+2);
133
 
  sprintf(progid, ":%s",gprgid());
134
 
 
135
 
  params.opdm = 0;
136
 
 
137
 
  for(i=1; i<argc; i++) {
138
 
    if(strcmp(argv[i], "--opdm") == 0) {
139
 
      params.opdm = 1;
140
 
    }
141
 
    else {
142
 
      extra_args[num_extra_args++] = argv[i];
143
 
    }
144
 
  }
145
 
  
146
 
  psi_start(num_extra_args,extra_args,0);
147
 
  ip_cwk_add(progid);
148
 
  free(progid);
149
 
  tstart(outfile);
150
 
  
151
 
  psio_init();
152
 
  for(i=CC_MIN; i <= CC_MAX; i++) 
153
 
    psio_open(i,1);
154
 
 
155
 
  free(extra_args);
156
 
}
157
 
 
158
 
void title(void)
159
 
{
160
 
  fprintf(outfile, "\t\t\t*************************\n");
161
 
  fprintf(outfile, "\t\t\t*                       *\n");
162
 
  fprintf(outfile, "\t\t\t*          MP2          *\n");
163
 
  fprintf(outfile, "\t\t\t*                       *\n");
164
 
  fprintf(outfile, "\t\t\t*************************\n");
165
 
  fflush(outfile);
166
 
}
167
 
 
168
 
void init_ioff(void)
169
 
{
170
 
  int i;
171
 
  
172
 
  ioff = init_int_array(MAXIOFF);
173
 
  ioff[0] = 0;
174
 
  for(i=1; i < MAXIOFF; i++) {
175
 
    ioff[i] = ioff[i-1] + i;
176
 
  }
177
 
  
178
 
}
179
 
 
180
 
void cleanup(void)
181
 
{
182
 
  int i;
183
 
  
184
 
  free(params.wfn);
185
 
  
186
 
  free(mo.doccpi);
187
 
  free(mo.soccpi);
188
 
  free(mo.mopi);
189
 
  free(mo.fzdoccpi);
190
 
  free(mo.fzvirtpi);
191
 
  for(i=0; i < mo.nirreps; i++)
192
 
    free(mo.irreplabels[i]);
193
 
  free(mo.irreplabels);
194
 
  free(ioff);
195
 
  
196
 
  if(params.ref == 2) {
197
 
    free(mo.aoccpi);
198
 
    free(mo.boccpi);
199
 
    free(mo.avirpi);
200
 
    free(mo.bvirpi);
201
 
    free(mo.aocc_sym);
202
 
    free(mo.bocc_sym);
203
 
    free(mo.avir_sym);
204
 
    free(mo.bvir_sym);
205
 
    free(mo.aocc_off);
206
 
    free(mo.bocc_off);
207
 
    free(mo.avir_off);
208
 
    free(mo.bvir_off);
209
 
    free(mo.qt_aocc);
210
 
    free(mo.qt_bocc);
211
 
    free(mo.qt_avir);
212
 
    free(mo.qt_bvir);
213
 
  }
214
 
  else {
215
 
    free(mo.occpi);
216
 
    free(mo.virpi);
217
 
    free(mo.occ_sym);
218
 
    free(mo.vir_sym);
219
 
    free(mo.occ_off);
220
 
    free(mo.vir_off);
221
 
    free(mo.qt_occ);
222
 
    free(mo.qt_vir);
223
 
  }
224
 
}
225
 
 
226
 
void exit_io(void)
227
 
{
228
 
  int i;
229
 
 
230
 
  for(i=CC_MIN; i <= CC_MAX; i++) 
231
 
    psio_close(i,0);
232
 
  psio_done();
233
 
  tstop(outfile);
234
 
  psi_stop();
235
 
}
236
 
 
237
 
char *gprgid()
238
 
{
239
 
  char *prgid = "MP2";
240
 
  return(prgid);
241
 
}