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

« back to all changes in this revision

Viewing changes to src/bin/input/write_to_chkpt.cc

  • 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
/*! \file
 
2
    \ingroup INPUT
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#define EXTERN
 
6
#include <cstdio>
 
7
#include <cstdlib>
 
8
#include <cmath>
 
9
#include <cstring>
 
10
#include <libciomr/libciomr.h>
 
11
#include <libpsio/psio.h>
 
12
#include <libchkpt/chkpt.h>
 
13
#include <libqt/qt.h>
 
14
#include <psifiles.h>
 
15
#include "input.h"
 
16
#include "global.h"
 
17
#include "defines.h"
 
18
 
 
19
namespace psi { namespace input {
 
20
 
 
21
/*-----------------------------------------------------------------------------------------------------------------
 
22
  This function writes information out to checkpoint file
 
23
 -----------------------------------------------------------------------------------------------------------------*/
 
24
 
 
25
void write_to_chkpt(double repulsion)
 
26
{
 
27
 
 
28
  char *calc_label;
 
29
  int i,j,k,l;
 
30
  int atom,ua,shell,irr,symop,shell_first,shell_last,us;
 
31
  int eq_atom;
 
32
  int *arr_int;
 
33
  double *arr_double;
 
34
  double **mat_double;
 
35
  int *ict, **ict_tmp;
 
36
  int *scf_pointers;
 
37
  double *cspd;     /*Array of contraction coefficients in chkpt file format*/
 
38
  char *atom_label, **tmp_atom_label;
 
39
  int **shell_transm;
 
40
  int **ioff_irr;
 
41
  int max_num_prims;
 
42
  int max_atom_degen;
 
43
  int max_angmom_unique;
 
44
  psio_address chkptr;
 
45
  
 
46
  /* Check the max_angmom. If it's >= MAXANGMOM from chkpt_params.h - die */
 
47
  if (max_angmom >= MAXANGMOM)
 
48
    punt("Angular momentum is too high to be handled by your version of Psi (chkpt file)");
 
49
 
 
50
  
 
51
  /*----------------------------------
 
52
    Write out the label then 80 zeros
 
53
    ----------------------------------*/
 
54
  calc_label = init_char_array(80);
 
55
  strncpy(calc_label,label,80);
 
56
  
 
57
  /*----------------------------------
 
58
    Write out basic info to chkpt
 
59
   ----------------------------------*/
 
60
  chkpt_init(keep_chkpt ? PSIO_OPEN_OLD : PSIO_OPEN_NEW);
 
61
  chkpt_wt_label(calc_label);
 
62
  chkpt_wt_num_unique_atom(num_uniques);
 
63
  chkpt_wt_num_unique_shell(num_unique_shells);
 
64
  chkpt_wt_rottype(rotor);
 
65
  chkpt_wt_max_am(max_angmom);
 
66
  chkpt_wt_puream(puream);
 
67
  chkpt_wt_nso(num_so);
 
68
  chkpt_wt_nao(num_ao);
 
69
  chkpt_wt_nshell(num_shells);
 
70
  chkpt_wt_nirreps(nirreps);
 
71
  chkpt_wt_nprim(num_prims);
 
72
  chkpt_wt_natom(num_atoms);
 
73
  chkpt_wt_nallatom(num_allatoms);
 
74
  chkpt_wt_nfzc(nfzc);
 
75
  chkpt_wt_nfzv(nfzv);
 
76
  chkpt_wt_nfragment(nfragments);
 
77
  if (nfragments > 1) {
 
78
    chkpt_wt_natom_per_fragment(frag_num_atoms);
 
79
    chkpt_wt_nallatom_per_fragment(frag_num_allatoms);
 
80
    chkpt_wt_nref_per_fragment(nref_per_fragment);
 
81
    chkpt_wt_fragment_coeff(ref_pts_lc);
 
82
  }
 
83
  free(calc_label);
 
84
 
 
85
 
 
86
  /*-----------------------------------
 
87
    Start writing data to the file
 
88
    -----------------------------------*/
 
89
 
 
90
  /* Nuclear charges */
 
91
  chkpt_wt_zvals(nuclear_charges);
 
92
 
 
93
  /* Transformation table for atoms - just atom_orbit transposed */
 
94
  ict = init_int_array(num_atoms);
 
95
  ict_tmp = init_int_matrix(nirreps, num_atoms);
 
96
  for(i=0;i<nirreps;i++) {
 
97
    for(j=0;j<num_atoms;j++) {
 
98
      ict[j] = atom_orbit[j][i]+1;
 
99
      ict_tmp[i][j] = ict[j];
 
100
    }
 
101
  }
 
102
  chkpt_wt_ict(ict_tmp);
 
103
  free_int_matrix(ict_tmp);
 
104
  free(ict);
 
105
 
 
106
  /* Exponents of primitive gaussians */
 
107
  chkpt_wt_exps(exponents);
 
108
 
 
109
  /* Contraction coefficients */
 
110
  /*------This piece of code is for segmented contractions ONLY------*/
 
111
  cspd = init_array(num_prims*MAXANGMOM);
 
112
  for(j=0;j<num_shells;j++)
 
113
    for(k=0;k<nprim_in_shell[j];k++)
 
114
      /*---
 
115
        Pitzer normalization of Psi 2 is NOT used - cc's for d-functions used to be
 
116
        multiplied by sqrt(3), f - by sqrt(15), g - sqrt(105), etc
 
117
        ---*/
 
118
      cspd[shell_ang_mom[j]*num_prims+first_prim_shell[j]+k] = contr_coeff[first_prim_shell[j]+k];
 
119
  chkpt_wt_contr(cspd);
 
120
  free(cspd);
 
121
 
 
122
  /* Pointer to primitives for a shell */
 
123
  arr_int = init_int_array(num_shells);
 
124
  for(i=0;i<num_shells;i++)
 
125
    arr_int[i] = first_prim_shell[i]+1;
 
126
  chkpt_wt_sprim(arr_int);
 
127
 
 
128
  /* Atom on which nth shell is centered */
 
129
  for(i=0;i<num_shells;i++)
 
130
    arr_int[i] = shell_nucleus[i]+1;
 
131
  chkpt_wt_snuc(arr_int);
 
132
 
 
133
  /* Angular momentum of a shell */
 
134
  for(i=0;i<num_shells;i++)
 
135
    arr_int[i] = shell_ang_mom[i]+1;
 
136
  chkpt_wt_stype(arr_int);
 
137
 
 
138
  /* Number of contracted functions (primitives) in a shell */
 
139
  chkpt_wt_snumg(nprim_in_shell);
 
140
 
 
141
  /* Pointer to the first AO in shell */
 
142
  for(i=0;i<num_shells;i++)
 
143
    arr_int[i] = first_ao_shell[i]+1;
 
144
  chkpt_wt_sloc(arr_int);
 
145
  free(arr_int);
 
146
 
 
147
  /* Labels of irreps */
 
148
  chkpt_wt_irr_labs(irr_labels);
 
149
 
 
150
  /* Transformation matrices for coordinates (or p-functions) */
 
151
  mat_double = block_matrix(nirreps,9);
 
152
  for(symop=0;symop<nirreps;symop++) {
 
153
    mat_double[symop][0] = ao_type_transmat[1][symop][0];
 
154
    mat_double[symop][4] = ao_type_transmat[1][symop][1];
 
155
    mat_double[symop][8] = ao_type_transmat[1][symop][2];
 
156
  }
 
157
  chkpt_wt_cartrep(mat_double);
 
158
  free(mat_double);
 
159
 
 
160
  /* Transformation matrix for shells */
 
161
  shell_transm = init_int_matrix(num_shells,nirreps);;
 
162
  for(atom=0;atom<num_atoms;atom++)
 
163
    for(symop=0;symop<nirreps;symop++) {
 
164
      eq_atom = atom_orbit[atom][symop];
 
165
      for(i=0;i<nshells_per_atom[atom];i++)
 
166
        shell_transm[first_shell_on_atom[atom]+i][symop] = first_shell_on_atom[eq_atom] + i + 1;
 
167
    }
 
168
  chkpt_wt_shell_transm(shell_transm);
 
169
  free_int_matrix(shell_transm);
 
170
 
 
171
  /* Labels of atoms including dummy atoms */
 
172
  tmp_atom_label = (char **) malloc(num_allatoms*sizeof(char *));
 
173
  for(atom=0; atom<num_allatoms; atom++) {
 
174
    tmp_atom_label[atom] = init_char_array(MAX_ELEMNAME);
 
175
 
 
176
    if(strlen(full_element[atom]) > MAX_ELEMNAME)
 
177
      punt("Element name exceeds limit, MAX_ELEMNAME.\n");
 
178
 
 
179
    strncpy(tmp_atom_label[atom],full_element[atom],strlen(full_element[atom])+1);
 
180
  }
 
181
  chkpt_wt_felement(tmp_atom_label);
 
182
  for(atom=0; atom<num_allatoms; atom++) {
 
183
    free(tmp_atom_label[atom]);
 
184
  }
 
185
  free(tmp_atom_label);
 
186
 
 
187
  /* Orbitals per irrep */
 
188
  chkpt_wt_sopi(num_so_per_irrep);
 
189
 
 
190
  /* Symmetry label */
 
191
  chkpt_wt_sym_label(symmetry);
 
192
 
 
193
  /* Symmetry positions of atoms - for more info see count_uniques.c */
 
194
  chkpt_wt_atom_position(atom_position);
 
195
 
 
196
  /* Unique shell number to full shell number mapping array */
 
197
  arr_int = init_int_array(num_unique_shells);
 
198
  us = 0;
 
199
  for(ua=0;ua<num_uniques;ua++) {
 
200
    atom = u2a[ua];
 
201
    shell = first_shell_on_atom[atom];
 
202
    for(i=0;i<nshells_per_atom[atom];i++,shell++,us++)
 
203
      arr_int[us] = shell;
 
204
  }
 
205
  chkpt_wt_us2s(arr_int);
 
206
  free(arr_int);
 
207
 
 
208
  /* SO to AO transformation matrix */
 
209
  chkpt_wt_usotao(usotao);
 
210
 
 
211
  /* SO to basis functions transformation matrix */
 
212
  if (puream) {
 
213
    chkpt_wt_usotbf(usotbf);
 
214
  }
 
215
 
 
216
  /* Pointers to first basis functions from shells */
 
217
  arr_int = init_int_array(num_shells);
 
218
  for(i=0;i<num_shells;i++)
 
219
    arr_int[i] = first_basisfn_shell[i]+1;
 
220
  chkpt_wt_sloc_new(arr_int);
 
221
  free(arr_int);
 
222
 
 
223
  /* Unique atom number to full atom number mapping array */
 
224
  chkpt_wt_ua2a(u2a);
 
225
 
 
226
  /* Mapping between canonical Cotton ordering of symmetry operations
 
227
     in the point group to the symmetry.h-defined ordering */
 
228
  chkpt_wt_symoper(sym_oper);
 
229
 
 
230
  /* write z_mat if it exists, see global.h for info about z_entry structure */
 
231
  if(!cartOn) {
 
232
    chkpt_wt_zmat(z_geom);
 
233
  }
 
234
 
 
235
  /* Number of shells in each angmom block */
 
236
  chkpt_wt_shells_per_am(shells_per_am);
 
237
 
 
238
  /* Mapping array from the am-blocked to the canonical (in the order of
 
239
     appearance) ordering of shells */
 
240
  chkpt_wt_am2canon_shell_order(am2canon_shell_order);
 
241
 
 
242
  /* Matrix representation of rotation back to the reference frame */
 
243
  chkpt_wt_rref(Rref);
 
244
 
 
245
  /* write full_geom, cartesian geometry with dummy atoms included */
 
246
  chkpt_wt_fgeom(full_geom);
 
247
 
 
248
  /* write array of flags that indicate whether atoms in full_geom are dummy or not */
 
249
  chkpt_wt_atom_dummy(atom_dummy);
 
250
 
 
251
  /* nuclear repulsion energy */
 
252
  chkpt_wt_enuc(repulsion);
 
253
  
 
254
  /* Cartesian displacement SALCs */
 
255
  chkpt_wt_cdsalc2cd(const_cast<const double**>(cdsalc2cd));
 
256
  
 
257
  /* cartdisp SALCs per irrep */
 
258
  chkpt_wt_cdsalcpi(cdsalc_pi);
 
259
  
 
260
  chkpt_close();
 
261
  return;
 
262
}
 
263
 
 
264
}} // namespace psi::input