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 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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, 1 == check for multiply-appearing states." << endl;
  18. }
  19. char* rawfilename = argv[1];
  20. int iKmin = atoi(argv[2]);
  21. int iKmax = atoi(argv[3]);
  22. int sympoint = atoi(argv[4]);
  23. DP FFmin = atof(argv[5]);
  24. int check_option = atoi(argv[6]);
  25. ifstream RAW_infile;
  26. RAW_infile.open(rawfilename);
  27. if (RAW_infile.fail()) {
  28. cout << rawfilename << endl;
  29. ABACUSerror("Could not open sorted RAW_infile... ");
  30. }
  31. DP omega_next, omega, omega_prev;
  32. int iK_next, iK, iK_prev;
  33. DP FF_next, FF, FF_prev;
  34. //int conv_next, conv, conv_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 >> FF >> conv >> label;
  44. RAW_infile >> omega >> iK;
  45. if (check_option <= 1) RAW_infile >> FF;
  46. RAW_infile >> dev;
  47. RAW_infile >> label;
  48. //RAW_infile >> omega_next >> iK_next >> FF_next >> conv_next >> label_next;
  49. RAW_infile >> omega_next >> iK_next;
  50. if (check_option <= 1) RAW_infile >> FF_next;
  51. RAW_infile >> dev_next;
  52. RAW_infile >> label_next;
  53. int line = 1;
  54. char a;
  55. while (fabs(FF) > FFmin && RAW_infile.peek() != EOF) {
  56. //omega_prev = omega; iK_prev = iK; FF_prev = FF; conv_prev = conv; label_prev = label;
  57. omega_prev = omega; iK_prev = iK; FF_prev = FF; dev_prev = dev; label_prev = label;
  58. //omega = omega_next; iK = iK_next; FF = FF_next; conv = conv_next; label = label_next;
  59. omega = omega_next; iK = iK_next; FF = FF_next; dev = dev_next; label = label_next;
  60. //RAW_infile >> omega_next >> iK_next >> FF_next >> conv_next >> label_next;
  61. RAW_infile >> omega_next >> iK_next;
  62. if (check_option <= 1) RAW_infile >> FF_next; // for non-Z checks
  63. RAW_infile >> dev_next;
  64. RAW_infile >> label_next;
  65. //cout << "checking line " << line << endl;
  66. //cout << omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << label_prev << endl
  67. // << omega << "\t" << iK << "\t" << FF << "\t" << label << endl
  68. // << omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << label_next << endl;
  69. line++;
  70. if (label.compare(label_next) == 0)
  71. cout << "Identical labels around line " << line << ": " << endl
  72. << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label << endl;
  73. if (check_option == 0 && iK != 0 && iK != sympoint && iK >= iKmin && iK <= iKmax
  74. && fabs((FF - FF_prev)/(FF + FF_prev)) > 1.0e-6 && fabs((FF - FF_next)/(FF + FF_next)) > 1.0e-6) {
  75. cout << "State missing around line " << line << ": " << endl
  76. //<< omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << conv_prev << "\t" << label_prev << endl
  77. << omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << dev_prev << "\t" << label_prev << endl
  78. //<< omega << "\t" << iK << "\t" << FF << "\t" << conv << "\t" << label << endl
  79. << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label << endl
  80. //<< omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << conv_next << "\t" << label_next << endl;
  81. << omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << dev_next << "\t" << label_next << endl;
  82. cin >> a;
  83. //break;
  84. }
  85. if (check_option == 1 && iK_prev == iK && iK == iK_next && fabs((omega - omega_prev)/(omega + omega_prev)) < 1.0e-8 && fabs((omega - omega_next)/(omega + omega_next)) < 1.0e-8 && fabs((FF - FF_prev)/(FF + FF_prev)) < 1.0e-8 && fabs((FF - FF_next)/(FF + FF_next)) < 1.0e-8) {
  86. cout << "Triple state around line " << line << ": " << endl
  87. //<< omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << conv_prev << "\t" << label_prev << endl
  88. << omega_prev << "\t" << iK_prev << "\t" << FF_prev << "\t" << dev_prev << "\t" << label_prev << endl
  89. //<< omega << "\t" << iK << "\t" << FF << "\t" << conv << "\t" << label << endl
  90. << omega << "\t" << iK << "\t" << FF << "\t" << dev << "\t" << label << endl
  91. //<< omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << conv_next << "\t" << label_next << endl;
  92. << omega_next << "\t" << iK_next << "\t" << FF_next << "\t" << dev_next << "\t" << label_next << endl;
  93. cin >> a;
  94. }
  95. if (check_option == 2 && iK != 0 && iK != sympoint && iK >= iKmin && iK <= iKmax
  96. && fabs((omega - omega_prev)/(omega + omega_prev)) > 1.0e-6 && fabs((omega - omega_next)/(omega + omega_next)) > 1.0e-6) {
  97. cout << "State missing around line " << line << ": " << endl
  98. << omega_prev << "\t" << iK_prev << "\t" << dev_prev << "\t" << label_prev << endl
  99. << omega << "\t" << iK << "\t" << dev << "\t" << label << endl
  100. << omega_next << "\t" << iK_next << "\t" << dev_next << "\t" << label_next << endl;
  101. cin >> a;
  102. //break;
  103. }
  104. if (check_option == 3 && iK_prev == iK && iK == iK_next && fabs((omega - omega_prev)/(omega + omega_prev)) < 1.0e-8 && fabs((omega - omega_next)/(omega + omega_next)) < 1.0e-8) {
  105. cout << "Triple state around line " << line << ": " << endl
  106. << omega_prev << "\t" << iK_prev << "\t" << dev_prev << "\t" << label_prev << endl
  107. << omega << "\t" << iK << "\t" << dev << "\t" << label << endl
  108. << omega_next << "\t" << iK_next << "\t" << dev_next << "\t" << label_next << endl;
  109. cin >> a;
  110. }
  111. }
  112. return(0);
  113. }