public Element(int atomicNumber, double valence, double molarAbundance = 1, XrayLine line = XrayLine.Ka, double count = 0, double countTime = 1) { Z = atomicNumber; AtomicName = AtomStatic.AtomicName(Z); MolarAbundance = molarAbundance; Valence = valence; // Isotopes = AtomConstants.IsotopeAbundance[Z]; MolarWeight = AtomStatic.AtomicWeight(Z); }
/// <summary> /// 単原子分子のコンストラクタ /// </summary> /// <param name="z">原子番号</param> /// <param name="valence">価数</param> /// <param name="weightRatio">重量比</param> public Molecule(int z, double valence = 0, double weightRatio = 0, double molarAbundance = 0) { if (z != 0) { Element e = new Element(z, 0); Elements = new List <Element>(); Elements.Add(e); e.MolarAbundance = 1; MolarWeight = e.MolarWeight; Valence = valence; WeightRatio = weightRatio; MolarAbundance = molarAbundance; Formula = AtomStatic.AtomicName(z); } }
/// <summary> /// 文字列を分解して、化学組成を返す。戻り値は、Dictionary<Key, Value> で、Keyには原子番号、Valueにはモル比 /// </summary> /// <param name="compound"></param> /// <returns></returns> public static Dictionary <int, double> GetFormula(string str) { var formula = new Dictionary <int, double>(); for (int i = 0; i < str.Length; i++) { if (str[i] >= 'A' && str[i] <= 'Z')//一文字目が大文字のとき { int z = 0; if (i + 1 < str.Length && str[i + 1] >= 'a' && str[i + 1] <= 'z')//二文字目が小文字のとき { z = AtomStatic.AtomicNumber(str.Substring(i++, 2)); } else//二文字目が小文字ではないとき { z = AtomStatic.AtomicNumber(str.Substring(i, 1)); } string numStr = ""; while (i + 1 < str.Length && str[i + 1] >= '0' && str[i + 1] <= '9')//次に続く文字が数字の時 { numStr += str[i++ + 1]; } int num = numStr == "" ? 1 : Convert.ToInt32(numStr); if (formula.ContainsKey(z)) { formula[z] += num; } else { formula.Add(z, num); } } if (str[i] == '(') //かっこの始まりが現れたら { int count = 1; for (int j = i + 1; j < str.Length; j++)//対応するかっこの終りをみつける { if (str[j] == '(') { count++; } else if (str[j] == ')') { count--; } if (count == 0)//見つかったら { Dictionary <int, double> temp = GetFormula(str.Substring(i + 1, j - i - 1)); string numStr = ""; while (j + 1 < str.Length && str[j + 1] >= '0' && str[j + 1] <= '9')// ")"のあとが数値だったら { numStr += str[j++ + 1]; } int num = numStr == "" ? 1 : Convert.ToInt32(numStr); foreach (int n in temp.Keys) { if (formula.ContainsKey(n)) { formula[n] += num * temp[n]; } else { formula.Add(n, num * temp[n]); } } i = j; break; } } } } return(formula); }
public WaveProperty(int xrayElementNumber, XrayLine xrayLine) { Source = WaveSource.Xray; WaveLength = AtomStatic.CharacteristicXrayWavelength(xrayElementNumber, xrayLine); Energy = AtomStatic.CharacteristicXrayWavelength(xrayElementNumber, xrayLine); }