ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/initiali.c
Revision: 25
Committed: Tue Jul 8 15:38:24 2008 UTC (11 years, 2 months ago) by tjod
Original Path: trunk/smi23d/src/mengine/initiali.c
File size: 8899 byte(s)
Log Message:
Incoporate the parameter files mmff94.prm and mmxconst.prm
into the mengine code by turning them into header files.
Each line becomes a string array element that is parsed in
place of lines in the .prm files.  The .prm files are no
longer needed, but are not deleted from the repository.

Line User Rev File contents
1 tjod 3 #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 "substr.h"
12     #include "atom_k.h"
13    
14     void reset_atom_data(void);
15     void reset_calc_parameters(void);
16     FILE * fopen_path ( char * , char * , char * ) ;
17     void InitialTransform(void);
18     void zero_data(void);
19     void read_datafiles(char *);
20 tjod 25 void initialize_pcmodel(char *);
21 tjod 3 void fixdisreset(void);
22     void coordreset(void);
23     void ddrivereset(void);
24     void hbondreset(void);
25     void pireset(void);
26     void generate_bonds(void);
27     void set_field(void);
28     void fixangle_reset(void);
29     void message_alert(char *, char *);
30     int strmessage_alert(char *);
31     void gettoken(void);
32     void free_dotmem(void);
33     void init_pov(void);
34     void reset_fixtype(void);
35     void set_window_title(void);
36     void remove_file(char *,char *);
37    
38     struct t_optimize {
39     int param_avail, converge;
40     float initial_energy, final_energy, initial_heat, final_heat;
41     } optimize_data;
42    
43    
44     struct t_ts_bondorder {
45     float fbnd[15];
46     } ts_bondorder;
47    
48     EXTERN struct t_files {
49     int nfiles, append, batch, icurrent;
50     int ibatno;
51     } files;
52    
53     EXTERN struct t_minim_control {
54     int type, method, field, added_const;
55     char added_path[256],added_name[256];
56     } minim_control;
57    
58     EXTERN struct t_minim_values {
59     int iprint, ndc, nconst;
60     float dielc;
61     } minim_values;
62    
63    
64     EXTERN struct t_units {
65     double bndunit, cbnd, qbnd;
66     double angunit, cang, qang, pang, sang, aaunit;
67     double stbnunit, ureyunit, torsunit, storunit, v14scale;
68     double aterm, bterm, cterm, dielec, chgscale;
69     } units;
70    
71    
72     struct t_user {
73     int dielec;
74     } user;
75    
76     EXTERN struct t_pcmfile {
77     char string[200];
78     int head;
79     char token[20];
80     int state;
81     unsigned int nocaps;
82     } pcmfile;
83    
84     EXTERN struct t_residues {
85     int nchain, ichainstart[10];
86     int ngroup, iresnum[200], irestype[200], istartatom[200];
87     } residues;
88    
89     EXTERN struct t_dipolemom {
90     double total, xdipole, ydipole, zdipole;
91     } dipolemom;
92    
93     struct t_dmomv {
94     float xn,yn,zn,xp,yp,zp;
95     } dmomv;
96    
97     #define NL gettoken(); if (pcmfile.head == 1000) goto L_30;
98     #define ALPHABETIC 2
99     #define NUMERIC 1
100    
101     // =======================================
102     void message_alert(char *astring, char *title)
103     {
104     // MessageBox(NULL, astring, title, MB_ICONEXCLAMATION);
105     printf("%s\n",astring);
106     }
107     // ===================================
108 tjod 25 void initialize_pcmodel(char *pfile)
109 tjod 3 {
110     int i;
111     char string[256];
112     strcpy(pcwindir,"");
113     user.dielec = FALSE;
114     units.dielec = 1.0;
115     dipolemom.total = 0.0;
116     use_external_chrg = FALSE;
117     use_gast_chrg = FALSE;
118     zero_data();
119 tjod 25 // strcpy(string,mmxfile);
120     read_datafiles(pfile);
121 tjod 3 set_field();
122     // initialize atom definitions
123     atom_def.natomtype = atom_k.natomtype;
124     for (i=1; i < MAXATOMTYPE; i++)
125     {
126     atom_def.type[i] = atom_k.type[i];
127     atom_def.valency[i] = atom_k.valency[i];
128     atom_def.number[i] = atom_k.number[i];
129     atom_def.ligands[i] = atom_k.ligands[i];
130     atom_def.weight[i] = atom_k.weight[i];
131     strcpy(atom_def.symbol[i],atom_k.symbol[i]);
132     }
133     LPTYPE = 20;
134     if (field.type == MMX ||field.type == MM2 ||field.type == MM3 )
135     LPTYPE = 20;
136     else
137     LPTYPE = 0;
138     Openbox.ftype = FTYPE_PCM;
139     Savebox.ftype = FTYPE_PCM;
140     default_intype = MMX;
141     default_outtype = MMX;
142     strcpy(Openbox.path,pcwindir);
143     strcpy(Savebox.path,pcwindir);
144     hbond_flag = TRUE;
145     pot.use_hbond = TRUE;
146     reset_calc_parameters();
147     curtype = 1;
148     natom = 0;
149     bonds.numbonds = -1;
150     residues.ngroup = 0;
151     /* minimizer control */
152     minim_control.method = 3;
153     minim_control.field = MMX;
154     minim_control.added_const = FALSE;
155     // printout
156     minim_values.iprint = FALSE;
157     /* cutoffs */
158     cutoffs.vdwcut = 10.0;
159     cutoffs.pmecut = 9.0;
160     cutoffs.chrgcut = 100.0;
161     cutoffs.dipcut = 8.0;
162     /* solvation stuff */
163     pot.use_bounds = FALSE;
164     pot.use_image = FALSE;
165     pot.use_deform = FALSE;
166     pot.use_solv = FALSE;
167     }
168    
169     int initialize(void)
170     {
171     curtype = 1;
172     natom = 0;
173     bonds.numbonds = -1;
174     reset_calc_parameters();
175     pot.use_bounds = FALSE;
176     pot.use_image = FALSE;
177     pot.use_deform = FALSE;
178     dipolemom.total = 0.0;
179     // optimization flags
180     optimize_data.param_avail = FALSE;
181     optimize_data.converge = FALSE;
182     optimize_data.initial_energy = 0.0;
183     optimize_data.final_energy = 0.0;
184     optimize_data.initial_heat = 0.0;
185     optimize_data.final_heat = 0.0;
186     //
187     reset_atom_data();
188     return(0);
189     }
190     /* ============================================== */
191     void reset_calc_parameters(void)
192     {
193     flags.noh = False;
194     flags.nohyd = False;
195     flags.immx = True;
196    
197     /* default to hydrogen bonding on */
198     minim_values.ndc = 4;
199     minim_values.nconst= 0;
200     }
201     /* =============================================== */
202     void pireset()
203     {
204     long int i,mask;
205     mask = 1L << PI_MASK;
206     }
207     /* =============================================== */
208     void reset_fixtype()
209     {
210     long int i,mask;
211     mask = 1L << NO_RETYPE;
212     for (i = 1; i <= natom; i++)
213     atom[i].flags &= ~mask;
214     }
215     /* ------------------------- */
216     void hbondreset()
217     {
218     long int i,mask;
219    
220     mask = 1L << HBOND_MASK;
221     for (i = 1; i <= natom; i++)
222     atom[i].flags &= ~mask;
223     }
224     /* ------------------------- */
225     void resetsubstrmem()
226     {
227     }
228     /* ------------------------- */
229     void coordreset()
230     {
231     long int i,j, mask4,mask5,mask6,mask7,mask8;
232    
233     mask4 = 1L << METCOORD_MASK;
234     mask5 = 1L << SATMET_MASK;
235     mask6 = 1L << GT18e_MASK;
236     mask7 = 1L << LOWSPIN_MASK;
237     mask8 = 1L << SQPLAN_MASK;
238    
239     for (i=1; i <= natom; i++)
240     {
241     atom[i].flags &= ~mask4;
242     atom[i].flags &= ~mask5;
243     atom[i].flags &= ~mask6;
244     atom[i].flags &= ~mask7;
245     atom[i].flags &= ~mask8;
246    
247     for (j=0; j < MAXIAT; j++)
248     {
249     if (atom[i].bo[j] == 9)
250     {
251     atom[i].bo[j] = 0;
252     atom[i].iat[j] = 0;
253     }
254     }
255     }
256     generate_bonds();
257     }
258     /* ------------------------- */
259     void fixdisreset()
260     {
261     }
262     /* ============================================== */
263     void fixangle_reset()
264     {
265     }
266     /* ============================================== */
267     void reset_atom_data(void)
268     {
269     int i, j;
270    
271     for (i = 0; i < MAXATOM; i++)
272     {
273     selatom[i] = 0;
274     atom[i].use = 0;
275     atom[i].x = 0.0F; atom[i].y = 0.0F; atom[i].z = 0.0F;
276     atom[i].color = 0;
277     atom[i].chrg_color = 7;
278     atom[i].charge = 0.0F;
279     atom[i].energy = 0.0F;
280     atom[i].atomnum = 0;
281     atom[i].serno = 0;
282     atom[i].molecule = 0;
283     atom[i].residue = 0;
284     atom[i].formal_charge = 0;
285     atom[i].atomwt = 0.0;
286     atom[i].type = 0;
287     atom[i].mmx_type = 0;
288     atom[i].mm3_type = 0;
289     atom[i].mmff_type = 0;
290     atom[i].tclass = 0;
291     *atom[i].name = '\0';
292     atom[i].flags = 0;
293     for (j = 0; j < MAXIAT; j++)
294     {
295     atom[i].bo[j] = 0;
296     atom[i].iat[j] = 0;
297     }
298     for (j=0; j < MAXSS; j++)
299     {
300     atom[i].substr[j] = 0;
301     substr.istract[j] = 0;
302     }
303     }
304     }
305     #ifdef PCM_WIN
306     // =======================================
307     /*int strcasecmp(char *str1,char *str2)
308     {
309     char c1,c2;
310     while(1)
311     {
312     c1 = tolower(*str1++);
313     c2 = tolower(*str2++);
314     if (c1 < c2) return -1;
315     if (c1 > c2) return 1;
316     if (c1 == 0) return 0;
317     }
318     } */
319     // ========================================
320     /*int strncasecmp(char *s1,char *s2,int n)
321     {
322     int i;
323     char c1, c2;
324     for (i=0; i<n; i++)
325     {
326     c1 = tolower(*s1++);
327     c2 = tolower(*s2++);
328     if (c1 < c2) return -1;
329     if (c1 > c2) return 1;
330     if (!c1) return 0;
331     }
332     return 0;
333     }*/
334     #endif
335     // void itoa(int n,char *s, int radix)
336     //{
337     // sprintf(s,"%d",n);
338     //}
339     // ========================================
340     void remove_file(char *path,char *name)
341     {
342     char tempname[255];
343     int ix;
344    
345     strcpy(tempname,"");
346     if ( (ix = strlen(path)) != 0)
347     {
348     strcpy(tempname,path);
349     strcat(tempname,"\\");
350     strcat(tempname,name);
351     } else
352     {
353     strcpy(tempname,name);
354     }
355     remove(tempname);
356     }