Subject: CCL: internal -> zyx summary

From: Garcia Edgardo <[email-masked]>
Date: Mon, 27 Feb 1995 19:16:38 -0700 (MST)

Dear netters, some time ago I posted the following questions to the list:

 1. Does somebody know where I can get a code (C,C++,FORTRAN)
    that transforms internal mol. coordinates in x,y,z ?
 
 2. A program (code) that gets a molecular file with charges and
    calculates the dipole.

Thanks to all of you that helped with these questions.

Edgardo Garcia

Here is a summary.

------------------------------------------------------------------------------------
From [email-masked] Feb 13 10:04:43 1995
Date: Fri, 10 Feb 95 21:29:39 EST

I can answer to the 2nd question.
It's written in AWK but I guess you can convert it to whatever language.

Here's a sample input of H2O:
  8  0.000000  0.000000  0.127189 -0.330
  1  0.000000  0.758094 -0.508756  0.165
  1  0.000000 -0.758094 -0.508756  0.165

The first column is an atomic number, 2-4 th columns are (x,y,z) coord
and the final column is an atomic charge.
Cut out the following script, make it executable and name it 'dipole'.
On the command line, you'd enter 'dipole inputfile'.
>From the above example, you'll get a dipole moment of 1.007927 Debye.

-Dongchul Lim

--------------------- CUT HERE ---------------------------------
#!/usr/bin/nawk -f

BEGIN	{
	number = "^[-+]?([0-9]+[.]?[0-9]*|[.][0-9]+)" \
		 "([eE][-+]?[0-9]+)?$"
	first = 1;
	natoms = 0;
	ANG_TO_DEBYE = 4.802813198;
}

!isdata($1,$2,$3,$4,$5)	{
	if (!first) exit;
	first = 0;
	next;
}

{
	natoms++;
	an[natoms] = $1;
	x[natoms]  = $2;
	y[natoms]  = $3;
	z[natoms]  = $4;
	charge[natoms] = $5;
}

END	{
	if (natoms == 0) {
		printf("No atoms found.\n");
		exit;
	}

	# calculate net charge and dipole moment
	netcharge = 0.0;
	dipx = dipy = dipz = 0.0;
	for(i=1;i<=natoms;i++) {
		dipx += charge[i] * (x[i] - x[1]);
		dipy += charge[i] * (y[i] - y[1]);
		dipz += charge[i] * (z[i] - z[1]);
		netcharge += charge[i];
	}
	dipole = sqrt(dipx*dipx + dipy*dipy + dipz*dipz);

	# converts to debyes when distances are in angstroms
	dipole *= ANG_TO_DEBYE;

	printf("Net charge    = % 10.6f\n", netcharge);
	printf("Dipole moment = % 10.6f Debye\n", dipole);
}

function isdata (s1, s2, s3, s4, s5) {
	if (match(s1, number) &&
	    match(s2, number) &&
	    match(s3, number) &&
	    match(s4, number) &&
	    match(s5, number)) return 1;
	else return 0;
}

--------------------- CUT HERE ---------------------------------

From : Suresh Singh <[email-masked]>
Date: Mon, Feb 13, 1995 7:33 AM

I got a piece of fortran code that transforms internal coordinates in the 
Z-format to cartesian coordinates.  I can send you the the source code and demo 
input files.  Since we operate through a firewall it is not possible for 
outsiders to access our machines.  So, does any of your machines have an 
anymous ftp access?  otherwise I will send it via e-mail.  Let me know.