00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "dyn.h"
00016
00017 #ifdef TOOLBOX
00018
00019
00020
00021
00022
00023
00024
00025 real dyndiff(dyn * b1, dyn * b2, bool r_flag)
00026 {
00027
00028
00029 int n1, n2;
00030 dyn * bi1;
00031 dyn * bi2;
00032 for (n1 = 0, bi1 = b1->get_oldest_daughter(); bi1 != NULL;
00033 bi1 = bi1->get_younger_sister())
00034 n1++;
00035 for (n2 = 0, bi2 = b2->get_oldest_daughter(); bi2 != NULL;
00036 bi2 = bi2->get_younger_sister())
00037 n2++;
00038 if (n1 != n2)
00039 {
00040 cerr << "dyndiff: N1 = " << n1 << " != N2 = " << n2 << endl;
00041 exit(1);
00042 }
00043
00044 real sum_sq_diff = 0;
00045
00046 for (bi1 = b1->get_oldest_daughter(), bi2 = b2->get_oldest_daughter();
00047 bi1 != NULL;
00048 bi1 = bi1->get_younger_sister(), bi2 = bi2->get_younger_sister())
00049 {
00050 vector dr = bi1->get_pos() - bi2->get_pos();
00051 sum_sq_diff += dr*dr;
00052
00053 if (!r_flag)
00054 {
00055 vector dv = bi1->get_vel() - bi2->get_vel();
00056 sum_sq_diff += dv*dv;
00057 }
00058 }
00059
00060 if (r_flag)
00061 return sqrt(sum_sq_diff / (3 * n1));
00062 else
00063 return sqrt(sum_sq_diff / (6 * n1));
00064 }
00065
00066 main(int argc, char ** argv)
00067 {
00068 bool r_flag = FALSE;
00069
00070 check_help();
00071
00072 extern char *poptarg;
00073 int c;
00074 char* param_string = "r";
00075
00076 while ((c = pgetopt(argc, argv, param_string)) != -1)
00077 switch(c) {
00078
00079 case 'r': r_flag = TRUE;
00080 break;
00081 case '?': params_to_usage(cerr, argv[0], param_string);
00082 get_help();
00083 exit(1);
00084 }
00085
00086 dyn * b1;
00087 dyn * b2;
00088 b1 = get_dyn(cin);
00089 b2 = get_dyn(cin);
00090
00091 real rmsdiff = dyndiff(b1, b2, r_flag);
00092
00093 if (r_flag)
00094 cout << " rms configuration space differences per coordinate: "
00095 << rmsdiff << endl;
00096 else
00097 cout << " rms phasespace differences per coordinate: "
00098 << rmsdiff << endl;
00099 }
00100
00101 #endif
00102
00103