#include "utility.h"
#include "newgeo.h"
int intgen()
/*============================================================================*/
/* PURPOSE: GENERATE THE INTERNAL COORDINATES FOR THE CURRENT GEOMETRY.
*/
{
if (!continuously_bonded()) return(FALSE);
else if (!generate_reference_atoms()) return(FALSE);
else if (!generate_internal_coords()) return(FALSE);
else return(TRUE);
}
int continuously_bonded()
/*============================================================================*/
/* PURPOSE: VERIFY THAT ALL ATOMS ARE CONTINUOUSLY BONDED. THIS IS NECESSARY
/* ONLY BECAUSE THE INTERNAL COORDINATE GENERATION ROUTINE FROM JEFF GAW
/* WILL FATALLY FAIL ON NON CONNECTED MOLECULES.
*/
{
int atom_reachable[MAX_ATOMS]; /* T/F: ATOM REACHABLE FROM ROOT. */
int natom; /* WHICH ATOM. */
void mark_connected_atoms(); /* MARK ALL CONNECTED ATOMS. */
for (natom=0; natom max_con)
{
j = i;
max_con = intco[i].bond_cnt;
}
}
new_order[0] = j;
assigned = 1;
look_at = 0;
while (look_at < atom_cnt)
{
while((j=next_bonded(new_order[look_at],new_order,assigned)) >= 0)
{
new_order[assigned++] = j;
}
look_at++;
}
/* TELL USER THE NEW ORDER OF THINGS SO THAT THEY CAN RE-ARRANGE THE WORLD TO CORRESPOND. */
strcpy(reorder_file_name,input_file_name);
new_extension(reorder_file_name,".reorder");
reorder_file = fopen(reorder_file_name,"w");
for (i=0; i max_con)
{
max_con = k;
j = intco[from].bonds[i];
}
}
return(j);
}
int generate_internal_coords()
/*============================================================================*/
{
int i;
int parent;
int gparent;
int ggparent;
double bond1[3];
double bond2[3];
double bond3[3];
double bond4[3];
double cross1[3];
double cross2[3];
double cross3[3];
double length1;
double length2;
/* CALCULATE ALL THE BOND LENGTHS (WHICH START AT ATOM ONE). */
for (i=1; i
|