Element.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. #pragma once
  2. #include "otsdataconst.h"
  3. #include "XMLSerialization.h"
  4. namespace OTSDATA
  5. {
  6. const CString ELEMENT_NAMES[ATOMIC_NUMBER_MAX] =
  7. { _T("H"),_T("He"),
  8. _T("Li"),_T("Be"),_T("B"),_T("C"),_T("N"),_T("O"),_T("F"),_T("Ne"),
  9. _T("Na"),_T("Mg"),_T("Al"),_T("Si"),_T("P"),_T("S"),_T("Cl"),_T("Ar"),
  10. _T("K"),_T("Ca"),_T("Sc"),_T("Ti"),_T("V"),_T("Cr"),_T("Mn"),_T("Fe"),_T("Co"),_T("Ni"),_T("Cu"),_T("Zn"),_T("Ga"),_T("Ge"),_T("As"),_T("Se"),_T("Br"),_T("Kr"),
  11. _T("Rb"),_T("Sr"),_T("Y"),_T("Zr"),_T("Nb"),_T("Mo"),_T("Tc"),_T("Ru"),_T("Rh"),_T("Pd"),_T("Ag"),_T("Cd"),_T("In"),_T("Sn"),_T("Sb"),_T("Te"),_T("I"),_T("Xe"),
  12. _T("Cs"),_T("Ba"),_T("La"),
  13. _T("Ce"),_T("Pr"),_T("Nd"),_T("Pm"),_T("Sm"),_T("Eu"),_T("Gd"),_T("Tb"),_T("Dy"),_T("Ho"),_T("Er"),_T("Tm"),_T("Yb"),_T("Lu"),
  14. _T("Hf"),_T("Ta"),_T("W"),_T("Re"),_T("Os"),_T("Ir"),_T("Pt"),_T("Au"),_T("Hg"),_T("Tl"),_T("Pb"),_T("Bi"),_T("Po"),_T("At"),_T("Rn"),
  15. _T("Fr"),_T("Ra"),_T("Ac"),
  16. _T("Th"),_T("Pa"),_T("U"),_T("Np"),_T("Pu"),_T("Am"),_T("Cm"),_T("Bk"),_T("Cf"),_T("Es"),_T("Fm"),_T("Md"),_T("No"),_T("Lr"),
  17. };
  18. const double ELEMENT_ATOMIC_WEIGHT_VALUES[ATOMIC_NUMBER_MAX] =
  19. {
  20. 1.008,4.003,
  21. 6.941,9.012,10.811,12.011,14.007,15.999,18.998,20.180,
  22. 22.990,24.305,26.982,28.086,30.974,32.066,35.453,39.948,
  23. 39.098,40.08,44.956,47.88,50.942,51.996,54.938,55.847,58.933,58.70,63.546,65.39,69.72,72.61,74.922,78.96,79.904,83.80,
  24. 85.468,87.62,88.906,91.22,92.906,95.94,98.00,101.07,102.906,106.42,107.868,112.41,114.82,118.71,121.76,127.60,126.905,131.29,
  25. 132.905,137.33,138.906,
  26. 140.12,140.908,144.24,145.0,150.36,151.97,157.25,158.925,162.50,64.93,167.26,168.934,173.04,174.967,
  27. 178.49,180.948,183.85,186.207,190.20,192.22,195.08,196.967,200.59,204.38,207.2,208.980,209.00,210.00,222.00,
  28. 223.00,226.025,227.028,
  29. 232.038,231.036,238.029,237.048,244.00,243.00,247.00,247.00,251.00,252.00,257.00,258.00,259.00,260.00
  30. };
  31. const double ELEMENT_ENERGY_VALUES_K[ATOMIC_NUMBER_MAX] =
  32. {
  33. 0.0,0.0,
  34. 0.0,0.108,0.185,0.277,0.392,0.523,0.677,0.848,
  35. 1.040,1.254,1.486,1.740,2.013,2.307,2.622,2.957,
  36. 2.313,3.691,4.090,4.510,4.952,5.414,5.898,6.403,6.929,7.477,8.040,8.637,9.250,9.885,10.542,11.220,11.922,12.649,
  37. 13.393,14.163,14.955,15.776,16.617,17.481,18.368,19.282,20.217,21.180,22.166,23.175,24.209,25.272,26.359,27.471,28.615,29.779,
  38. 30.971,32.196,33.441,
  39. 34.717,36.031,37.358,38.725,40.118,41.534,42.992,44.476,45.997,47.534,49.100,50.730,52.362,54.078,
  40. 55.801,57.450,59.305,61.122,62.989,64.906,66.834,68.804,70.806,72.769,74.989,77.091,79.272,81.513,83.771,
  41. 86.098,88.480,90.880,
  42. 93.382,95.886,98.434,100.800,103.320,105.970,109.737,111.676,114.776,0.0,0.0,0.0,0.0,0.0
  43. };
  44. const double ELEMENT_ENERGY_VALUES_L[ATOMIC_NUMBER_MAX] =
  45. {
  46. 0.0,0.0,
  47. 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
  48. 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
  49. 0.0,0.341,0.395,0.452,0.511,0.573,0.637,0.705,0.776,0.851,0.930,1.012,1.098,1.188,1.282,1.379,1.480,1.586,
  50. 1.694,1.806,1.922,2.042,2.166,2.293,2.424,2.558,2.696,2.838,2.984,3.133,3.286,3.443,3.604,3.768,3.937,4.109,
  51. 4.286,4.465,4.650,
  52. 4.839,5.033,5.229,5.432,5.636,5.845,6.056,6.272,6.494,6.719,6.947,7.179,7.414,7.654,
  53. 7.898,8.145,8.396,8.651,8.910,9.174,9.441,9.712,9.987,10.256,10.550,10.837,11.129,11.425,11.725,
  54. 12.029,12.338,12.650,
  55. 12.967,13.288,13.612,13.941,14.275,14.615,14.961,15.309,15.661,16.018,0.0,0.0,0.0,0.0
  56. };
  57. const double ELEMENT_ENERGY_VALUES_M[ATOMIC_NUMBER_MAX] =
  58. {
  59. 0.0,0.0,
  60. 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
  61. 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
  62. 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
  63. 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
  64. 0.0,0.779,0.833,
  65. 0.883,0.929,0.978,1.032,1.081,1.137,1.185,1.240,1.293,1.347,1.405,1.462,1.521,1.581,
  66. 1.644,1.709,1.774,1.842,1.910,1.978,2.048,2.120,2.191,2.268,2.342,2.419,2.505,2.585,2.665,
  67. 2.747,2.830,2.915,
  68. 2.991,3.077,3.165,3.253,3.344,3.435,3.539,3.634,3.731,3.829,0.0,0.0,0.0,0.0
  69. };
  70. class __declspec(dllexport) CElementChemistry /*: public xmls::ISlo*/
  71. {
  72. /*protected:
  73. DECLARE_SERIAL(CElementChemistry)*/
  74. public:
  75. CElementChemistry(); // constructor
  76. CElementChemistry(CString a_strName, const double a_dPercentage); // constructor
  77. CElementChemistry(const CElementChemistry&); // copy constructor
  78. CElementChemistry(CElementChemistry*); // copy constructor
  79. CElementChemistry& operator=(const CElementChemistry&); // =operator
  80. BOOL operator==(const CElementChemistry&); // ==operator
  81. virtual ~CElementChemistry(); // detractor
  82. // serialization
  83. //void Serialize(bool isStoring, tinyxml2::XMLDocument *classDoc, tinyxml2::XMLElement *rootNode);
  84. // name
  85. CString GetName() { return m_strName; }
  86. void SetName(CString a_strName) { m_strName = a_strName; }
  87. // percentage
  88. double GetPercentage() { return m_dPercentage; }
  89. void SetPercentage(double a_dPercentage) { m_dPercentage = a_dPercentage; }
  90. // MolarRatio
  91. double GetMolarPercentage();
  92. void SetMolarPercentage(double a_dMolarPer);
  93. protected:
  94. // cleanup
  95. void Cleanup();
  96. // initialization
  97. void Init();
  98. // duplication
  99. void Duplicate(const CElementChemistry& a_oSource);
  100. // name
  101. CString m_strName;
  102. // percentage (element)
  103. double m_dPercentage;
  104. };
  105. typedef std::shared_ptr<CElementChemistry> __declspec(dllexport) CElementChemistryPtr;
  106. typedef std::vector<CElementChemistryPtr> __declspec(dllexport) CElementChemistriesList;
  107. class __declspec(dllexport) CElementArea
  108. {
  109. public:
  110. CElementArea(); // constructor
  111. CElementArea(const CElementArea&); // copy constructor
  112. CElementArea(CElementArea*); // copy constructor
  113. CElementArea& operator=(const CElementArea&); // =operator
  114. BOOL operator==(const CElementArea&); // ==operator
  115. virtual ~CElementArea(); // detractor
  116. // serialization
  117. // element chemistry list
  118. CElementChemistriesList GetElementList() { return m_listCElementChemistries; }
  119. void SetElementList(CElementChemistriesList a_listElementChemistries);
  120. // area (element)
  121. double GetArea() { return m_dArea; }
  122. void SetArea(double a_dArea) { m_dArea = a_dArea; }
  123. protected:
  124. // cleanup
  125. void Cleanup();
  126. // initialization
  127. void Init();
  128. // duplication
  129. void Duplicate(const CElementArea& a_oSource);
  130. // element chemistry list
  131. CElementChemistriesList m_listCElementChemistries;
  132. // area (element)
  133. double m_dArea;
  134. };
  135. typedef std::shared_ptr<CElementArea> __declspec(dllexport) CElementAreaPtr;
  136. typedef std::vector<CElementAreaPtr> __declspec(dllexport) CElementAreaList;
  137. class __declspec(dllexport) CElement : public xmls::ISlo
  138. {
  139. public:
  140. CElement(); // constructor
  141. CElement(long m_nAtomNum); // constructor
  142. CElement(CString a_strName); // constructor
  143. CElement(const CElement&); // copy constructor
  144. CElement(CElement*); // copy constructor
  145. CElement& operator=(const CElement&); // =operator
  146. BOOL operator==(const CElement&); // ==operator
  147. virtual ~CElement(); // detractor
  148. // serialization
  149. // valid element
  150. bool IsValid() { return IsValidAtomNum(m_nAtomNum); }
  151. // atomic number
  152. int GetAtomNum() const { return m_nAtomNum; }
  153. void SetAtomNum(long a_nAtomNum) { m_nAtomNum = a_nAtomNum; }
  154. // percentage
  155. double GetPercentage() const { return m_dPercentage; }
  156. void SetPercentage(double a_dPercentage);
  157. double GetMolarPercentage();
  158. // name
  159. CString GetName();
  160. static CString GetName(long a_nAtomNum);
  161. static long GetAtomicNum(CString a_strName);
  162. // atomic weight
  163. double GetAtomWeight();
  164. static double GetAtomWeight(long a_nAtomNum);
  165. static double GetAtomWeight(CString a_strName);
  166. // energy values
  167. double GetEnergyValueK();
  168. double GetEnergyValueL();
  169. double GetEnergyValueM();
  170. std::vector<double> GetEnergyValues();
  171. static std::vector<CString>& GetElementNameList();
  172. static bool IsValidAtomNum(long a_nAtomNum) { return a_nAtomNum >= ATOMIC_NUMBER_MIN && a_nAtomNum <= ATOMIC_NUMBER_MAX; }
  173. static CElementChemistriesList ExtractElementChemistrys(CString a_strSource);
  174. void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  175. protected:
  176. // cleanup
  177. void Cleanup();
  178. // initialization
  179. void Init();
  180. // duplication
  181. void Duplicate(const CElement& a_oSource);
  182. // atomic number
  183. long m_nAtomNum;
  184. // percentage
  185. double m_dPercentage;
  186. static std::vector<CString> m_theElementNameVector;
  187. static const CString theElementNameList;
  188. static std::vector<CString> SplitString(const CString& a_sSource, LPCTSTR a_sTok);
  189. };
  190. typedef std::shared_ptr<CElement> __declspec(dllexport) CElementPtr;
  191. typedef std::vector<CElementPtr> __declspec(dllexport) CElementsList;
  192. }