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