home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- //
- // damp
- //
- // Syntax: s=damp(a)
- //
- //
- // This routine computes the natural frequency and damping for
- // continuous systems. It prints a table of the eigenvalues of
- // the matrix a, the associated damping factors, the associated natural
- // frequency (rad/s and Hz.).
- //
- // Also, the routine returns the natrural frequencies and damping
- // factors in a list:
- //
- // a.omegan = Natural Frequencies (rad/s)
- // a.zeta = Damping Factors
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940918
- //---------------------------------------------------------------------------
-
- rfile roots
- rfile esort
-
- damp = function(a)
- {
- local(dum1,omegan,eigvlsort,omegahz,zeta,i)
-
- // Compute the eigenvalues of the matrix and sort them
- if (a.nr == a.nc) {
- dum1=esort(eig(a).val');
- eigvlsort=dum1.s;
- else if (a.nr == 1) {
- dum1=esort(roots(a));
- eigvlsort=dum1.s;
- else if (a.nc == 1) {
- eigvlsort=a;
- else
- error("damp: Must be a vector or a sqaure matrix.");
- }}}
-
- // Compute the natural frequency on rad/s.
- omegan=abs(eigvlsort);
-
- // Compute the damping factor
- zeta=-cos(atan2(imag(eigvlsort),real(eigvlsort)));
-
- // Compute the natural frequency (Hz).
- omegahz=sqrt(eigvlsort)/(2.0*pi);
-
- printf("%s"," \n");
- printf("%s"," Eigenvalue Damping Freq. (rad/s) Freq. (Hz). \n");
- printf("%s"," ---------- ------- ------------- -----------\n");
- for (i in 1:omegan.nr) {
- if (imag(eigvlsort[i]) < 0.0) {
- printf("%-10.6f -j%-10.6f", real (eigvlsort[i]), abs(imag (eigvlsort[i])));
- else
- printf("%-10.6f j%-10.6f", real (eigvlsort[i]), imag (eigvlsort[i]));
- }
- printf("%s"," ");
- printf("%-10.6f",zeta[i]);
- printf("%s"," ");
- printf("%-10.6f",omegan[i]);
- printf("%s"," ");
- printf("%-10.6f",omegahz[i]);
- printf("%s"," \n");
- }
- printf("%s"," \n");
-
- return << omegan=omegan; zeta=zeta >>
-
- };
-