ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/kimptors.c
Revision: 114
Committed: Wed Apr 29 19:07:31 2009 UTC (11 years, 3 months ago) by gilbertke
File size: 3237 byte(s)
Log Message:
added code for amber energy functions
Line User Rev File contents
1 gilbertke 114 #define EXTERN extern
2     #include "pcwin.h"
3     #include "pcmod.h"
4     #include "utility.h"
5     #include "angles.h"
6    
7     void four(char *,char *,char *,char *,char *);
8     void numeral(int,char *,int);
9    
10    
11     EXTERN struct t_improptor_k {
12     int nimptor, nimprop;
13     char kv[MAXIMP][13];
14     float cimptor[MAXIMP], tdi[MAXIMP];
15     float v1[MAXIMP], v2[MAXIMP], v3[MAXIMP];
16     int ph1[MAXIMP], ph2[MAXIMP], ph3[MAXIMP];
17     } improptor_k;
18    
19     struct t_improp {
20     int nimptors, **iiprop;
21     float *v1, *v2, *v3;
22     int *ph1, *ph2, *ph3;
23     } improp;
24    
25     void kimptors(void);
26    
27    
28     void kimptors()
29     {
30     int i, j, ia, ib, ic, id, k;
31     int ita, itb, itc, itd;
32     char pa[4],pb[4],pc[4],pd[4],it[6][13];
33    
34     improp.nimptors = 0;
35     improp.iiprop = imatrix(0,MAXOOP,0,4);
36     improp.v1 = vector(0,MAXOOP);
37     improp.v2 = vector(0,MAXOOP);
38     improp.v3 = vector(0,MAXOOP);
39     improp.ph1 = ivector(0,MAXOOP);
40     improp.ph2 = ivector(0,MAXOOP);
41     improp.ph3 = ivector(0,MAXOOP);
42    
43     for (i=0; i < angles.nang; i++)
44     {
45     ia = angles.i13[i][0];
46     ib = angles.i13[i][1];
47     ic = angles.i13[i][2];
48    
49     if (angles.i13[i][3] != 0)
50     {
51     id = angles.i13[i][3];
52     ita = atom.tclass[ia];
53     itb = atom.tclass[ib];
54     itc = atom.tclass[ic];
55     itd = atom.tclass[id];
56     numeral(ita,pa,3);
57     numeral(itb,pb,3);
58     numeral(itc,pc,3);
59     numeral(itd,pd,3);
60    
61     four( pa, pc, pb, pd, it[0] );
62     four( pa, pd, pb, pc, it[1] );
63     four( pc, pa, pb, pd, it[2] );
64     four( pc, pd, pb, pa, it[3] );
65     four( pd, pa, pb, pc, it[4] );
66     four( pd, pc, pb, pa, it[5] );
67    
68     improp.iiprop[improp.nimptors][0] = ib;
69     for (j=0; j < improptor_k.nimptor; j++)
70     {
71     for(k=0; k < 6; k++)
72     {
73     if (strcmp(it[k],improptor_k.kv[j]) == 0)
74     {
75     if (k == 0 || k == 1) improp.iiprop[improp.nimptors][1] = ia;
76     if (k == 2 || k == 3) improp.iiprop[improp.nimptors][1] = ic;
77     if (k == 4 || k == 5) improp.iiprop[improp.nimptors][1] = id;
78    
79     if (k == 2 || k == 4) improp.iiprop[improp.nimptors][2] = ia;
80     if (k == 0 || k == 5) improp.iiprop[improp.nimptors][2] = ic;
81     if (k == 1 || k == 3) improp.iiprop[improp.nimptors][2] = id;
82    
83     if (k == 3 || k == 5) improp.iiprop[improp.nimptors][3] = ia;
84     if (k == 1 || k == 4) improp.iiprop[improp.nimptors][3] = ic;
85     if (k == 0 || k == 2) improp.iiprop[improp.nimptors][3] = id;
86     improp.v1[improp.nimptors] = improptor_k.v1[j];
87     improp.v2[improp.nimptors] = improptor_k.v2[j];
88     improp.v3[improp.nimptors] = improptor_k.v3[j];
89     improp.ph1[improp.nimptors] = improptor_k.ph1[j];
90     improp.ph2[improp.nimptors] = improptor_k.ph2[j];
91     improp.ph3[improp.nimptors] = improptor_k.ph3[j];
92     improp.nimptors++;
93     break;
94     }
95     }
96     }
97     }
98     }
99     }