ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/initiali.c
Revision: 48
Committed: Thu Jul 31 16:34:52 2008 UTC (11 years, 1 month ago) by tjod
File size: 8974 byte(s)
Log Message:
Add modification notice to files modified for Freemol
per mengine/smi23d license requirements

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