You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Check_RAW_File.cc 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: Check_RAW_File.cc
  6. Purpose: from a .raw_srt file, check that nonzero momentum states
  7. appear (only) twice, and zero momentum ones (only) once.
  8. ***********************************************************/
  9. #include "ABACUS.h"
  10. using namespace std;
  11. using namespace ABACUS;
  12. int main(int argc, char* argv[])
  13. {
  14. if (argc != 7) { // print out some instructions
  15. cout << "Usage of Check_RAW_File executable: provide the following arguments:" << endl;
  16. cout << "(sorted!) raw file name, iKmin, iKmax, sympoint, FFmin, check_option." << endl;
  17. cout << "Check option: 0 == check for missing states, "
  18. "1 == check for multiply-appearing states." << endl;
  19. }
  20. char* rawfilename = argv[1];
  21. int iKmin = atoi(argv[2]);
  22. int iKmax = atoi(argv[3]);
  23. int sympoint = atoi(argv[4]);
  24. DP FFmin = atof(argv[5]);
  25. int check_option = atoi(argv[6]);
  26. ifstream RAW_infile;
  27. RAW_infile.open(rawfilename);
  28. if (RAW_infile.fail()) {
  29. cout << rawfilename << endl;
  30. ABACUSerror("Could not open sorted RAW_infile... ");
  31. }
  32. DP omega_next, omega, omega_prev;
  33. int iK_next, iK, iK_prev;
  34. DP FF_next, FF, FF_prev;
  35. DP dev_next, dev, dev_prev;
  36. string label_next, label, label_prev;
  37. if (check_option > 1) {
  38. FF = 0.0;
  39. FF_prev = 0.0;
  40. FF_next = 0.0;
  41. FFmin = -1.0;
  42. }
  43. RAW_infile >> omega >> iK;
  44. if (check_option <= 1) RAW_infile >> FF;
  45. RAW_infile >> dev;
  46. RAW_infile >> label;
  47. RAW_infile >> omega_next >> iK_next;
  48. if (check_option <= 1) RAW_infile >> FF_next;
  49. RAW_infile >> dev_next;
  50. RAW_infile >> label_next;
  51. int line = 1;
  52. char a;
  53. while (fabs(FF) > FFmin && RAW_infile.peek() != EOF) {
  54. omega_prev = omega; iK_prev = iK; FF_prev = FF; dev_prev = dev; label_prev = label;
  55. omega = omega_next; iK = iK_next; FF = FF_next; dev = dev_next; label = label_next;
  56. RAW_infile >> omega_next >> iK_next;
  57. if (check_option <= 1) RAW_infile >> FF_next; // for non-Z checks
  58. RAW_infile >> dev_next;
  59. RAW_infile >> label_next;
  60. line++;
  61. if (label.compare(label_next) == 0)
  62. cout << "Identical labels around line " << line << ": " << endl
  63. << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label << endl;
  64. if (check_option == 0 && iK != 0 && iK != sympoint && iK >= iKmin && iK <= iKmax
  65. && fabs((FF - FF_prev)/(FF + FF_prev)) > 1.0e-6 && fabs((FF - FF_next)/(FF + FF_next)) > 1.0e-6) {
  66. cout << "State missing around line " << line << ": " << endl
  67. << omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << dev_prev << "\t" << label_prev << endl
  68. << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label << endl
  69. << omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << dev_next << "\t" << label_next << endl;
  70. cin >> a;
  71. }
  72. if (check_option == 1 && iK_prev == iK
  73. && iK == iK_next && fabs((omega - omega_prev)/(omega + omega_prev)) < 1.0e-8
  74. && fabs((omega - omega_next)/(omega + omega_next)) < 1.0e-8
  75. && fabs((FF - FF_prev)/(FF + FF_prev)) < 1.0e-8
  76. && fabs((FF - FF_next)/(FF + FF_next)) < 1.0e-8) {
  77. cout << "Triple state around line " << line << ": " << endl
  78. << omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << dev_prev << "\t" << label_prev << endl
  79. << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label << endl
  80. << omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << dev_next << "\t" << label_next << endl;
  81. cin >> a;
  82. }
  83. if (check_option == 2 && iK != 0 && iK != sympoint && iK >= iKmin && iK <= iKmax
  84. && fabs((omega - omega_prev)/(omega + omega_prev)) > 1.0e-6
  85. && fabs((omega - omega_next)/(omega + omega_next)) > 1.0e-6) {
  86. cout << "State missing around line " << line << ": " << endl
  87. << omega_prev << "\t" << iK_prev << "\t" << dev_prev << "\t" << label_prev << endl
  88. << omega << "\t" << iK << "\t" << dev << "\t" << label << endl
  89. << omega_next << "\t" << iK_next << "\t" << dev_next << "\t" << label_next << endl;
  90. cin >> a;
  91. }
  92. if (check_option == 3 && iK_prev == iK && iK == iK_next
  93. && fabs((omega - omega_prev)/(omega + omega_prev)) < 1.0e-8
  94. && fabs((omega - omega_next)/(omega + omega_next)) < 1.0e-8) {
  95. cout << "Triple state around line " << line << ": " << endl
  96. << omega_prev << "\t" << iK_prev << "\t" << dev_prev << "\t" << label_prev << endl
  97. << omega << "\t" << iK << "\t" << dev << "\t" << label << endl
  98. << omega_next << "\t" << iK_next << "\t" << dev_next << "\t" << label_next << endl;
  99. cin >> a;
  100. }
  101. }
  102. return(0);
  103. }