ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/initiali.c
Revision: 58
Committed: Mon Dec 1 06:44:59 2008 UTC (10 years, 9 months ago) by wdelano
File size: 7269 byte(s)
Log Message:
code merge 20081130
Line User Rev File contents
1 wdelano 58 #define EXTERN extern
2    
3     #include "pcwin.h"
4     #include "pcmod.h"
5     #include "pot.h"
6     #include "field.h"
7     #include "cutoffs.h"
8     #include "energies.h"
9     #include "utility.h"
10     #include "fix.h"
11     #include "atom_k.h"
12    
13     void reset_atom_data(void);
14     void reset_calc_parameters(void);
15     FILE * fopen_path ( char * , char * , char * ) ;
16     void InitialTransform(void);
17     void zero_data(void);
18     void read_datafiles(char *);
19     void initialize_pcmodel(char *);
20     void fixdisreset(void);
21     void coordreset(void);
22     void ddrivereset(void);
23     void hbondreset(void);
24     void pireset(void);
25     void generate_bonds(void);
26     void set_field(void);
27     void fixangle_reset(void);
28     void message_alert(char *, char *);
29     int strmessage_alert(char *);
30     void gettoken(void);
31     void remove_file(char *,char *);
32    
33     struct t_optimize {
34     int param_avail, converge;
35     float initial_energy, final_energy, initial_heat, final_heat;
36     } optimize_data;
37    
38     EXTERN struct t_files {
39     int nfiles, append, batch, icurrent;
40     int ibatno;
41     } files;
42    
43     EXTERN struct t_minim_control {
44     int type, method, field, added_const;
45     char added_path[256],added_name[256];
46     } minim_control;
47    
48     EXTERN struct t_minim_values {
49     int iprint, ndc, nconst;
50     float dielc;
51     } minim_values;
52    
53     EXTERN struct t_units {
54     double bndunit, cbnd, qbnd;
55     double angunit, cang, qang, pang, sang, aaunit;
56     double stbnunit, ureyunit, torsunit, storunit, v14scale;
57     double aterm, bterm, cterm, dielec, chgscale;
58     } units;
59    
60     struct t_user {
61     int dielec;
62     } user;
63    
64     EXTERN struct t_pcmfile {
65     char string[200];
66     int head;
67     char token[20];
68     int state;
69     unsigned int nocaps;
70     } pcmfile;
71    
72     EXTERN struct t_dipolemom {
73     double total, xdipole, ydipole, zdipole;
74     } dipolemom;
75    
76    
77     #define NL gettoken(); if (pcmfile.head == 1000) goto L_30;
78     #define ALPHABETIC 2
79     #define NUMERIC 1
80    
81     // =======================================
82     void message_alert(char *astring, char *title)
83     {
84     // MessageBox(NULL, astring, title, MB_ICONEXCLAMATION);
85     fprintf(pcmlogfile,"%s\n",astring);
86     }
87     // ===================================
88     void initialize_pcmodel(char *mmxfilename)
89     {
90     int i;
91     user.dielec = FALSE;
92     units.dielec = 1.0;
93     dipolemom.total = 0.0;
94     zero_data();
95     read_datafiles(mmxfilename);
96     set_field();
97     // initialize atom definitions
98     atom_def.natomtype = atom_k.natomtype;
99     for (i=1; i < MAXATOMTYPE; i++)
100     {
101     atom_def.type[i] = atom_k.type[i];
102     atom_def.valency[i] = atom_k.valency[i];
103     atom_def.number[i] = atom_k.number[i];
104     atom_def.ligands[i] = atom_k.ligands[i];
105     atom_def.weight[i] = atom_k.weight[i];
106     strcpy(atom_def.symbol[i],atom_k.symbol[i]);
107     }
108     LPTYPE = 20;
109     if (field.type == MMX ||field.type == MM2 ||field.type == MM3 )
110     LPTYPE = 20;
111     else
112     LPTYPE = 0;
113     Openbox.ftype = FTYPE_PCM;
114     Savebox.ftype = FTYPE_PCM;
115     default_intype = MMX;
116     default_outtype = MMX;
117     strcpy(Openbox.path,pcwindir);
118     strcpy(Savebox.path,pcwindir);
119     hbond_flag = TRUE;
120     pot.use_hbond = TRUE;
121     reset_calc_parameters();
122     natom = 0;
123     bonds.numbonds = -1;
124     /* minimizer control */
125     minim_control.method = 3;
126     minim_control.field = MMX;
127     minim_control.added_const = FALSE;
128     // printout
129     minim_values.iprint = FALSE;
130     /* cutoffs */
131     cutoffs.vdwcut = 10.0;
132     cutoffs.pmecut = 9.0;
133     cutoffs.chrgcut = 100.0;
134     cutoffs.dipcut = 8.0;
135     /* solvation stuff */
136     pot.use_bounds = FALSE;
137     pot.use_image = FALSE;
138     pot.use_deform = FALSE;
139     pot.use_solv = FALSE;
140     // fixed stuff
141     fx_atom.natom_fix = 0;
142     fx_dist.ndfix = 0;
143     fx_angle.nafix = 0;
144     fx_torsion.ntfix = 0;
145     restrain_atom.natom_restrain = 0;
146     }
147    
148     int initialize(void)
149     {
150     natom = 0;
151     bonds.numbonds = -1;
152     reset_calc_parameters();
153     pot.use_bounds = FALSE;
154     pot.use_image = FALSE;
155     pot.use_deform = FALSE;
156     dipolemom.total = 0.0;
157     // optimization flags
158     optimize_data.param_avail = FALSE;
159     optimize_data.converge = FALSE;
160     optimize_data.initial_energy = 0.0;
161     optimize_data.final_energy = 0.0;
162     optimize_data.initial_heat = 0.0;
163     optimize_data.final_heat = 0.0;
164     //
165     reset_atom_data();
166     return(0);
167     }
168     /* ============================================== */
169     void reset_calc_parameters(void)
170     {
171    
172     /* default to hydrogen bonding on */
173     minim_values.ndc = 4;
174     minim_values.nconst= 0;
175     }
176     /* =============================================== */
177     void pireset()
178     {
179     }
180     /* =============================================== */
181     void reset_fixtype()
182     {
183     }
184     /* ------------------------- */
185     void hbondreset()
186     {
187     long int i,mask;
188    
189     mask = 1L << HBOND_MASK;
190     for (i = 1; i <= natom; i++)
191     atom[i].flags &= ~mask;
192     }
193     /* ------------------------- */
194     void resetsubstrmem()
195     {
196     }
197     /* ------------------------- */
198     void coordreset()
199     {
200     long int i,j, mask4,mask5,mask6,mask7,mask8;
201    
202     mask4 = 1L << METCOORD_MASK;
203     mask5 = 1L << SATMET_MASK;
204     mask6 = 1L << GT18e_MASK;
205     mask7 = 1L << LOWSPIN_MASK;
206     mask8 = 1L << SQPLAN_MASK;
207    
208     for (i=1; i <= natom; i++)
209     {
210     atom[i].flags &= ~mask4;
211     atom[i].flags &= ~mask5;
212     atom[i].flags &= ~mask6;
213     atom[i].flags &= ~mask7;
214     atom[i].flags &= ~mask8;
215    
216     for (j=0; j < MAXIAT; j++)
217     {
218     if (atom[i].bo[j] == 9)
219     {
220     atom[i].bo[j] = 0;
221     atom[i].iat[j] = 0;
222     }
223     }
224     }
225     generate_bonds();
226     }
227     /* ------------------------- */
228     void fixdisreset()
229     {
230     }
231     /* ============================================== */
232     void fixangle_reset()
233     {
234     }
235     /* ============================================== */
236     void reset_atom_data(void)
237     {
238     int i, j;
239    
240     for (i = 0; i < MAXATOM; i++)
241     {
242     atom[i].use = 0;
243     atom[i].x = 0.0F; atom[i].y = 0.0F; atom[i].z = 0.0F;
244     atom[i].charge = 0.0F;
245     atom[i].energy = 0.0F;
246     atom[i].atomnum = 0;
247     atom[i].formal_charge = 0;
248     atom[i].atomwt = 0.0;
249     atom[i].type = 0;
250     atom[i].mmx_type = 0;
251     atom[i].mm3_type = 0;
252     atom[i].mmff_type = 0;
253     atom[i].tclass = 0;
254     *atom[i].name = '\0';
255     atom[i].flags = 0;
256     for (j = 0; j < MAXIAT; j++)
257     {
258     atom[i].bo[j] = 0;
259     atom[i].iat[j] = 0;
260     }
261     }
262     }
263     // ========================================
264     void remove_file(char *path,char *name)
265     {
266     char tempname[255];
267     int ix;
268    
269     strcpy(tempname,"");
270     if ( (ix = strlen(path)) != 0)
271     {
272     strcpy(tempname,path);
273     strcat(tempname,"\\");
274     strcat(tempname,name);
275     } else
276     {
277     strcpy(tempname,name);
278     }
279     remove(tempname);
280     }