diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..09356534 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,22 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.18362.0", + "compilerPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\cl.exe", + "cStandard": "c89", + "cppStandard": "c++11", + "intelliSenseMode": "windows-msvc-x64", + "compileCommands": "C:\\Users\\TomSc\\github\\xraylib\\meson-build\\compile_commands.json" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/csharp/AssemblyInfo.cpp b/csharp/AssemblyInfo.cpp new file mode 100644 index 00000000..38ba5058 --- /dev/null +++ b/csharp/AssemblyInfo.cpp @@ -0,0 +1,39 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("XrayLibNET")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("XrayLibNET")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2010-2019 Matthew Wormington")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("4.0.0.0")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + diff --git a/csharp/AssemblyInfo.cs b/csharp/AssemblyInfo.cs new file mode 100644 index 00000000..2790f813 --- /dev/null +++ b/csharp/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Test")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1d2d7b66-e084-42b5-a3fd-8165b0a670bb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/csharp/Compound.h b/csharp/Compound.h new file mode 100644 index 00000000..c453a7f0 --- /dev/null +++ b/csharp/Compound.h @@ -0,0 +1,342 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: Compound.h + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: September 5, 2010 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains a managed class around the XrayLib CompoundParser for + use with XrayLib.NET. + + "A library for X-ray�matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725�1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ + + +#include "xraylib.h" + +using namespace System; +using namespace System::Collections::Generic; +using namespace System::Runtime::InteropServices; +using namespace System::Text; + +/// +/// A namespace that contains scientific classes. +/// +namespace Science { + + /// + /// A simple class that gives information on the composition of a compound. + /// + public ref class CompoundData + { + List^ _atomCount; + List^ _atomicNumber; + int _elementCount; + List^ _massFraction; + double _molarMass; + double _totalAtomCount; + + public: + + /// Default constructor. + CompoundData() + { + _atomCount = gcnew List(); + _atomicNumber = gcnew List(); + _massFraction = gcnew List(); + + Clear(); + } + + /// Constructor. + /// The chemical formula of the compound. + CompoundData(String^ compound) + { + _atomCount = gcnew List(); + _atomicNumber = gcnew List(); + _massFraction = gcnew List(); + + Parse(compound); + } + + /// Constructor. + /// Will calculate the composition corresponding to the sum of the + /// compositions of A and B, taking into their weights, with + /// weightA + weightB typically less than 1.0. + /// The chemical formula of compound A. + /// The weight of compound A. + /// The chemical formula of compound B. + /// The weight of compound B. + CompoundData(String^ compoundA, double weightA, String^ compoundB, double weightB) + { + ::compoundData *cdA, *cdB; + ::compoundData *cd; + + _atomCount = gcnew List(); + _atomicNumber = gcnew List(); + _massFraction = gcnew List(); + Clear(); + + if (String::IsNullOrEmpty(compoundA) || String::IsNullOrEmpty(compoundB) || (weightA < 0.0) || (weightB < 0.0)) + return; + + IntPtr p = Marshal::StringToHGlobalAnsi(compoundA); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + cdA = ::CompoundParser(pCompound, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + if (cdA == nullptr) + return; + + p = Marshal::StringToHGlobalAnsi(compoundB); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + cdB = ::CompoundParser(pCompound, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + if (cdB == nullptr) + { + ::FreeCompoundData(cdA); + return; + } + + cd = ::add_compound_data(*cdA, weightA, *cdB, weightB); + if (cd != nullptr) + { + _elementCount = cd->nElements; + if (_elementCount > 0) + { + for (int i = 0; i < _elementCount; i++) + { + _atomCount->Add(cd->nAtoms[i]); + _atomicNumber->Add(cd->Elements[i]); + _massFraction->Add(cd->massFractions[i]); + } + } + _molarMass = cd->molarMass; + _totalAtomCount = cd->nAtomsAll; + + ::FreeCompoundData(cd); + } + + ::FreeCompoundData(cdA); + ::FreeCompoundData(cdB); + } + + /// Parses the chemical formula of the compound into its component elements. + /// The chemical formula of the compound. + void Parse(String^ compound) + { + struct ::compoundData *cd; + + if (String::IsNullOrEmpty(compound)) + return; + + Clear(); + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + cd = ::CompoundParser(pCompound, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + if (cd != nullptr) + { + _elementCount = cd->nElements; + if (_elementCount > 0) + { + for (int i = 0; i < _elementCount; i++) + { + _atomCount->Add(cd->nAtoms[i]); + _atomicNumber->Add(cd->Elements[i]); + _massFraction->Add(cd->massFractions[i]); + } + } + _molarMass = cd->molarMass; + _totalAtomCount = cd->nAtomsAll; + } + + ::FreeCompoundData(cd); + } + + /// Clears this object to its blank/initial state. + void Clear() + { + _elementCount = 0; + _atomCount->Clear(); + _atomicNumber->Clear(); + _massFraction->Clear(); + _totalAtomCount = 0; + } + + /// Gets the total number of atoms. + /// The total number of atoms. + property double TotalAtomCount + { + double get() + { + return _totalAtomCount; + } + } + + /// Gets the number of atoms of the component element with the specified index. + /// The number of atoms[int]. + property double AtomCount[int] + { + double get(int index) + { + return _atomCount[index]; + } + } + + /// Gets the number of elements. + /// The number of elements. + property double ElementCount + { + double get() + { + return _elementCount; + } + } + + /// Gets the atomic number of the component element with the specified index. + /// The atomic number[int]. + property int AtomicNumber[int] + { + int get(int index) + { + return _atomicNumber[index]; + } + } + + /// Gets the mass fraction of the component element with the specified index. + /// The mass fraction[int]. + property double MassFraction[int] + { + double get(int index) + { + return _massFraction[index]; + } + } + + /// Convert this object into a string representation. + /// Null if it fails, else a string representation of this object. + virtual String^ ToString() override + { + StringBuilder^ sb = gcnew StringBuilder(); + sb->AppendLine(String::Format("ElementCount: {0}", _elementCount)); + sb->AppendLine(String::Format("AtomicNumber, AtomCount, MassFraction")); + for (int i=0; i<_elementCount; i++) + sb->AppendLine(String::Format("{0}, {1}, {2}", _atomicNumber[i], _atomCount[i], _massFraction[i])); + sb->AppendLine(String::Format("MolarMass: {0}", _molarMass)); + sb->AppendLine(String::Format("TotalAtomCount: {0}", _totalAtomCount)); + + return sb->ToString(); + } + + /// Returns the atomic symbol for the specified element. + /// Atomic number of the element. + /// Atomic symbol, else null if it fails. + static String^ AtomicNumberToSymbol(int Z) + { + ::xrl_error *error = nullptr; + char* pSymbol = ::AtomicNumberToSymbol(Z, &error); + Errors::HandleError(error); + + String^ symbol = gcnew String(pSymbol); + + ::xrlFree(pSymbol); + + return symbol; + } + + /// Returns the atomic number for the specified element. + /// Atomic symbol of the element. + /// Atomic number, else zero if it fails. + static int SymbolToAtomicNumber(String^ symbol) + { + int result = 0; + + IntPtr p = Marshal::StringToHGlobalAnsi(symbol); + try + { + ::xrl_error *error = nullptr; + char* pSymbol = static_cast(p.ToPointer()); + result = ::SymbolToAtomicNumber(pSymbol, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; + } + + }; +} + + + diff --git a/csharp/Diffraction.h b/csharp/Diffraction.h new file mode 100644 index 00000000..4ede67e4 --- /dev/null +++ b/csharp/Diffraction.h @@ -0,0 +1,701 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: Diffraction.h + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: July 17, 2012 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains a managed class for basic X-ray diffraction (XRD) calculations + from crystals for use with XrayLib.NET. + + "A library for X-ray�matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725�1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ + +#include "xraylib.h" +#include + +using namespace System; +using namespace System::Collections::Generic; +using namespace System::Numerics; +using namespace System::Runtime::InteropServices; +using namespace System::Text; + +/// +/// A namespace that contains scientific classes. +/// +namespace Science { + + /// A simple class for an atom in a crystal + public value class CrystalAtom + { + public: + /// Atomic number of atom + int Zatom; + /// Fractional contribution. Normally 1.0 + double fraction; + /// Atom position (fraction of the unit cell length) + double x; + /// Atom position (fraction of the unit cell length) + double y; + /// Atom position (fraction of the unit cell length) + double z; + }; + + /// + /// A managed wrapper for XrayLib's X-ray diffraction (XRD) functionality. + /// + public ref class Crystal + { + private: + List^ _atoms; // List of atoms in unit cell. + + double CosD(Double x) + { + return Math::Cos(x * PI / 180.0); + } + + double SinD(Double x) + { + return Math::Sin(x * PI / 180.0); + } + + ::Crystal_Struct* ToCrystal_Struct() + { + ::Crystal_Struct* result = new ::Crystal_Struct; + + result->name = new char[Name->Length]; + + IntPtr p = Marshal::StringToHGlobalAnsi(Name); + try + { + char* str = static_cast(p.ToPointer()); + + ::memcpy(result->name, str, Name->Length); + } + finally + { + Marshal::FreeHGlobal(p); + } + + result->a = A; + result->b = B; + result->c = C; + result->alpha = Alpha; + result->beta = Beta; + result->gamma = Gamma; + result->volume = Volume; + + int atomCount = _atoms->Count; + result->n_atom = atomCount; + + result->atom = new ::Crystal_Atom[atomCount]; + for (int i = 0; i < atomCount; i++) + { + ::Crystal_Atom* ca = &result->atom[i]; + ca->Zatom = _atoms[i].Zatom; + ca->fraction = _atoms[i].fraction; + ca->x = _atoms[i].x; + ca->y = _atoms[i].y; + ca->z = _atoms[i].z; + } + + return result; + } + + void DeleteCrystal_Struct(::Crystal_Struct* cs) + { + if (cs != nullptr) + { + delete cs->name; + delete cs->atom; + delete cs; + cs = nullptr; + } + } + + public: + + /// Name of crystal + property String^ Name; + /// Unit cell dimension (Angstrom) + property double A; + /// Unit cell dimension (Angstrom) + property double B; + /// Unit cell dimension (Angstrom) + property double C; + /// Unit cell angle (deg) + property double Alpha; + /// Unit cell angle (deg) + property double Beta; + /// Unit cell angle (deg) + property double Gamma; + /// Unit cell volume (Angstrom^3) + property double Volume; + /// List of atoms in the unit cell + property List^ Atoms + { + List^ get() + { + return _atoms; + } + } + + /// Default constructor. + Crystal() + { + _atoms = gcnew List(); + Clear(); + } + + /// Clears this object to its blank/initial state. + void Clear() + { + _atoms->Clear(); + + Name = ""; + A = 0.0; + B = 0.0; + C = 0.0; + Alpha = 0.0; + Beta = 0.0; + Gamma = 0.0; + Volume = 0.0; + } + + /// Calculates the Bragg angle for the specified reflection + /// Energy (keV) + /// Miller index, h + /// Miller index, k + /// Miller index, l + /// Bragg angle (rad) + double BraggAngle(double E, int h, int k, int l) + { + double result = 0.0; + + ::Crystal_Struct* cs = ToCrystal_Struct(); + try + { + ::xrl_error *error = nullptr; + result = ::Bragg_angle(cs, E, h, k, l, &error); + Errors::HandleError(error); + } + finally + { + DeleteCrystal_Struct(cs); + } + + return result; + } + + /// Calculates the components of the atomic scattering factor + /// Atomic number + /// Energy (keV) + /// Momentum transfer (1/Angstrom) + /// Debye temperature facotor + /// f0 + /// f' + /// f'' + void AtomicScatteringFactors(int Z, double E, double q, double debyeFactor, double %f0, double %fp, double %fpp) + { + double f0_ = f0; + double fp_ = fp; + double fpp_ = fpp; + + ::xrl_error *error = nullptr; + ::Atomic_Factors(Z, E, q, debyeFactor, &f0_, &fp_, &fpp_, &error); + Errors::HandleError(error); + + f0 = f0_; + fp = fp_; + fpp = fpp_; + } + + /// Calculates the structure factor of the crystal for the specified reflection + /// See also PartialStructureFactor + /// Energy (keV) + /// Miller index, h + /// Miller index, k + /// Miller index, l + /// Debye temperature factor + /// Relative angle, i.e. fraction of Bragg angle + /// Complex structure factor + Numerics::Complex StructureFactor(double E, int h, int k, int l, double debyeFactor, double relativeAngle) + { + Numerics::Complex result = 1.0; + + ::Crystal_Struct* cs = ToCrystal_Struct(); + try + { + //::xrlComplex z = ::Crystal_F_H_StructureFactor(cs, E, h, k, l, debyeFactor, relativeAngle); + + ::xrlComplex z; + ::xrl_error *error = nullptr; + ::Crystal_F_H_StructureFactor2(cs, E, h, k, l, debyeFactor, relativeAngle, &z, &error); + Errors::HandleError(error); + result = Numerics::Complex(z.re, z.im); + } + finally + { + DeleteCrystal_Struct(cs); + } + + return result; + } + + /// Calculates the partial structure factor of the crystal for the specified reflection + /// + /// See also StructureFactor + /// The Atomic structure factor has three terms: F_H = f0 + f' + i*f'' + /// For each of these three terms, there is a corresponding *_flag argument which controls the numerical value used in computing F_H + /// ...Flag = 0 --> Set this term to 0. + /// ...Flag = 1 --> Set this term to 1. Only used for f0. + /// ...Flag = 2 --> Set this term to the value given + /// + /// Energy (keV) + /// Miller index, h + /// Miller index, k + /// Miller index, l + /// Debye temperature factor + /// Relative angle, i.e. fraction of Bragg angle + /// f0 flag. + /// f' flag. + /// f'' flag. + /// Complex structure factor + Numerics::Complex PartialStructureFactor(double E, int h, int k, int l, double debyeFactor, double relativeAngle, int f0Flag, int fpFlag, int fppFlag) + { + Numerics::Complex result = -1.0; + + ::Crystal_Struct* cs = ToCrystal_Struct(); + try + { + //::xrlComplex z = ::Crystal_F_H_StructureFactor_Partial(cs, E, h, k, l, debyeFactor, relativeAngle, f0Flag, fpFlag, fppFlag); + + ::xrlComplex z; + ::xrl_error *error = nullptr; + ::Crystal_F_H_StructureFactor_Partial2(cs, E, h, k, l, debyeFactor, relativeAngle, f0Flag, fpFlag, fppFlag, &z, &error); + Errors::HandleError(error); + result = Numerics::Complex(z.re, z.im); + } + finally + { + DeleteCrystal_Struct(cs); + } + + return result; + } + + /// Calculates the unit cell volume of the crystal (using XrayLib) + /// Unit cell volume (Angstrom^3) + double UnitCellVolume() + { + double result = -1.0; + + ::Crystal_Struct* cs = ToCrystal_Struct(); + try + { + ::xrl_error *error = nullptr; + result = ::Crystal_UnitCellVolume(cs, &error); + Errors::HandleError(error); + } + finally + { + DeleteCrystal_Struct(cs); + } + + return result; + } + + /// Calculates the inter-planar spacing (d-spacing) specified crystal planes + /// + /// This routine assumes that if crystal.volume is nonzero then it holds a valid value. + /// If (i, j, k) = (0, 0, 0) then zero is returned. + /// + /// Miller index, h + /// Miller index, k + /// Miller index, l + /// Inter-planar distance (Angstrom) + double DSpacing(int h, int k, int l) + { + double result = -1.0; + + ::Crystal_Struct* cs = ToCrystal_Struct(); + try + { + ::xrl_error *error = nullptr; + result = ::Crystal_dSpacing(cs, h, k, l, &error); + Errors::HandleError(error); + } + finally + { + DeleteCrystal_Struct(cs); + } + + return result; + } + + /// Calculates the unit cell volume of the crystal + /// + /// Uses the triclinic formulas taken from Crystals And Crystal Structures, R.J.D. Tilley (Wiley, 2006) pp36-37 + /// + /// Unit cell volume (Angstrom^3) + double UnitCellVolume2() + { + double V = 0.0; + + double cosAlpha = CosD(Alpha); + double cosBeta = CosD(Beta); + double cosGamma = CosD(Gamma); + + V = A*B*C*Math::Sqrt(1-cosAlpha*cosAlpha-cosBeta*cosBeta-cosGamma*cosGamma+2*cosAlpha*cosBeta*cosGamma); + + return V; + } + + /// Calculates the inter-planar spacing (d-spacing) specified crystal planes + /// + /// If (i, j, k) = (0, 0, 0) then zero is returned. + /// Uses the triclinic formulas taken from Crystals And Crystal Structures, R.J.D. Tilley (Wiley, 2006) pp36-37 + /// + /// Miller index, h + /// Miller index, k + /// Miller index, l + /// Inter-planar distance (Angstrom) + double InterplanarSpacing(int h, int k, int l) + { + double d = 0.0; + + if (A >= 0 && B > 0 && C > 0) + { + double cosAlpha = CosD(Alpha); + double cosBeta = CosD(Beta); + double cosGamma = CosD(Gamma); + double sinAlpha = SinD(Alpha); + double sinBeta = SinD(Beta); + double sinGamma = SinD(Gamma); + + double S11 = B*B*C*C*sinAlpha*sinAlpha; + double S22 = A*A*C*C*sinBeta*sinBeta; + double S33 = A*A*B*B*sinGamma*sinGamma; + double S12 = A*B*C*C*(cosAlpha*cosBeta-cosGamma); + double S23 = A*A*B*C*(cosBeta*cosGamma-cosAlpha); + double S13 = A*B*B*C*(cosGamma*cosAlpha-cosBeta); + + double V = UnitCellVolume2(); + + d = Math::Sqrt((V*V)/(S11*h*h + S22*k*k + S33*l*l + 2*S12*k*l + 2*S23*k*l + 2*S13*h*l)); + } + + return d; + } + + /// Calculates the inter-planar angle between the two specified crystal planes (h1,k1,l1) and (h2,k2,l2) + /// + /// If (i, j, k) = (0, 0, 0) then zero is returned. + /// Uses the triclinic formulas taken from Crystals And Crystal Structures, R.J.D. Tilley (Wiley, 2006) pp36-37 + /// + /// Miller index, h1 + /// Miller index, k1 + /// Miller index, l1 + /// Miller index, h2 + /// Miller index, k2 + /// Miller index, l2 + /// Inter-planar distance (Angstrom) + double InterplanarAngle(int h1, int k1, int l1, int h2, int k2, int l2) + { + double phi = 0.0; + + if (A >= 0 && B > 0 && C > 0) + { + double d1 = InterplanarSpacing(h1, k1, l1); + double d2 = InterplanarSpacing(h2, k2, l2); + + double cosAlpha = CosD(Alpha); + double cosBeta = CosD(Beta); + double cosGamma = CosD(Gamma); + double sinAlpha = SinD(Alpha); + double sinBeta = SinD(Beta); + double sinGamma = SinD(Gamma); + + double S11 = B*B*C*C*sinAlpha*sinAlpha; + double S22 = A*A*C*C*sinBeta*sinBeta; + double S33 = A*A*B*B*sinGamma*sinGamma; + double S12 = A*B*C*C*(cosAlpha*cosBeta-cosGamma); + double S23 = A*A*B*C*(cosBeta*cosGamma-cosAlpha); + double S13 = A*B*B*C*(cosGamma*cosAlpha-cosBeta); + + double V = UnitCellVolume2(); + + phi = Math::Acos(d1*d2/(V*V)*(S11*h1*h2 + S22*k1*k2 + S33*l1*l2 + + S23*(k1*l2+k2*l1) + S13*(l1*h2+l2*h1) + S12*(h1*k2+h2*k1))); + } + + return phi; + } + + /// Calculates the magnitude of the scattering vector Q relative to the Bragg angle of the specified reflection + /// Q = Sin(ThetaB*relativeAngle) / Wavelength + /// Energy (keV) + /// Miller index, h + /// Miller index, k + /// Miller index, l + /// Relative angle, i.e. fraction of Bragg angle + /// The magnitude of the scattering vector (1/Angstrom) + double ScatteringVectorMagnitide(double E, int h, int k, int l, double relativeAngle) + { + double result = -1.0; + + ::Crystal_Struct* cs = ToCrystal_Struct(); + try + { + ::xrl_error *error = nullptr; + result = ::Q_scattering_amplitude(cs, E, h, k, l, relativeAngle, &error); + Errors::HandleError(error); + } + finally + { + DeleteCrystal_Struct(cs); + } + + return result; + } + + /// Convert this object into a string representation. + /// Null if it fails, else a string representation of this object. + virtual String^ ToString() override + { + StringBuilder^ sb = gcnew StringBuilder(); + sb->AppendLine(String::Format("Name: {0}", Name)); + sb->AppendLine("Unit cell lengths (�):"); + sb->AppendLine(String::Format(" a = {0:F6}\n b = {1:F6}\n c = {2:F6}", A, B, C)); + sb->AppendLine("Unit cell angles (deg):"); + sb->AppendLine(String::Format(" alpha = {0:F6}\n beta = {1:F6}\n gamma = {2:F6}", Alpha, Beta, Gamma)); + sb->AppendLine("Atoms:"); + sb->AppendLine(String::Format(" Count: {0}", Atoms->Count)); + sb->AppendLine(" Z Fraction X Y Z"); + for (int i = 0; i < Atoms->Count; i++) + { + CrystalAtom atom = Atoms[i]; + sb->AppendLine(String::Format(" {0} {1:F6} {2:F6} {3:F6} {4:F6}", atom.Zatom, atom.fraction, atom.x, atom.y, atom.z)); + } + return sb->ToString(); + } + }; + + /// + /// A class containing an array of Crystals. + /// + public ref class CrystalArray + { + private: + ::Crystal_Array* ca; + public: + CrystalArray() + { + ca = nullptr; + } + + ~CrystalArray() + { + if (ca != nullptr) + ::Crystal_ArrayFree(ca); + } + + /// Loads from the crystals from an appropriately formatted text file. + /// + /// #UCOMMENT comment + /// #UCELL a b c alpha beta gamma + /// The unit cell dimensions (A and deg) (*MANDATORY, IT MUST EXIST*) + /// #UTEMP temperature in Kelvin at which UCELL is given + /// #UREF reference + /// #USYSTEM : 7 crystal system, i.e., triclinic monoclinic orthorhombic + /// tetragonal rhombohedral(trigonal) + /// hexagonal cubic + /// #ULATTICE the lattice centering: + /// P: Primitive centering: lattice points on the cell corners only + /// I: Body centered: one additional lattice point at the center of the cell + /// F: Face centered: one additional lattice point at center of each + /// of the faces of the cell + /// A,B,C Centered on a single face (A, B or C centering): one + /// additional lattice point at the center of one of the + /// cell faces. + /// The 14 Bravais lattices are, then: + /// 1 triclinic (P) + /// 2 monoclinic (P,C) + /// 3 orthorhombic (P,C,I,F) + /// 2 tetragonal (P,I) + /// 1 rhombohedral (P) + /// 1 hexagonal (P) + /// 3 cubic (P,I,F) + /// #USTRUCTURE Model for structure (e.g., diamond, fcc) + /// Data columns: + /// 4 or 5: + /// AtomicNumber Fraction X Y Z Biso + /// The Biso one is optional + /// + /// [in,out] If non-null, filename of the file. + /// A value that indicates whether the file was loaded + int LoadFromFile(String^ fileName, int capacity) + { + int result = -1; + + if (ca != nullptr) + ::Crystal_ArrayFree(ca); + + ::xrl_error *error = nullptr; + ca = ::Crystal_ArrayInit(capacity, &error); + Errors::HandleError(error); + + IntPtr p = Marshal::StringToHGlobalAnsi(fileName); + try + { + char* pFileName = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::Crystal_ReadFile(pFileName, ca, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; + } + + /// Gets a Crystal object from the array using the specified name + /// [in,out] If non-null, the crystal name. + /// Null if it fails, else the crystal. + Crystal^ GetCrystal(String^ name) + { + Crystal^ result = gcnew Crystal(); + Crystal_Struct* cs; + + IntPtr p = Marshal::StringToHGlobalAnsi(name); + try + { + char* name = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + cs = ::Crystal_GetCrystal(name, ca, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + if (cs != nullptr) + { + result->Name = gcnew String(cs->name); + + result->A = cs->a; + result->B = cs->b; + result->C = cs->c; + result->Alpha = cs->alpha; + result->Beta = cs->beta; + result->Gamma = cs->gamma; + result->Volume = cs->volume; + + int atomCount = cs->n_atom; + for (int i = 0; i < atomCount; i++) + { + ::Crystal_Atom* ca = &cs->atom[i]; + CrystalAtom item; + + item.Zatom = ca->Zatom; + item.fraction = ca->fraction; + item.x = ca->x; + item.y = ca->y; + item.z = ca->z; + + result->Atoms->Add(item); + } + } + + return result; + } + + /// Gets the names of crystals within within the CrystalArray object. + /// A list of strings containing the names. + List^ GetNames() + { + int i; + List^ result; + + result = gcnew List; + + if (ca != NULL) + { + for (i = 0; i < ca->n_crystal; i++) + { + result->Add(gcnew String(ca->crystal[i].name)); + } + } + + return result; + } + + /// Gets the names of default crystals defined within the XrayLib library. + /// A list of strings containing the names. + static List^ GetDefaultNames() + { + char **names; + int i; + List^ result; + + result = gcnew List; + + ::xrl_error *error = nullptr; + names = ::Crystal_GetCrystalsList(NULL, 0, &error); + Errors::HandleError(error); + for (i = 0; names[i] != NULL; i++) + { + result->Add(gcnew String(names[i])); + ::xrlFree(names[i]); + } + ::xrlFree(names); + + return result; + } + }; +} diff --git a/csharp/Element.h b/csharp/Element.h new file mode 100644 index 00000000..7c186d6b --- /dev/null +++ b/csharp/Element.h @@ -0,0 +1,220 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: Element.h + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: September 4, 2010 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains a managed class containing element data for use with XrayLib.NET. + + "A library for X-ray–matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725–1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ + +using namespace System; +using namespace System::Collections::Generic; +using namespace System::Text; + +/// +/// A namespace that contains scientific classes. +/// +namespace Science { + + /// A structure that contains data for an element in the Periodic Table. + public value struct ElementData + { + /// Atomic number + int Number; + /// Name + String^ Name; + /// Atomic symbol + String^ Symbol; + /// Atomic weight + double Weight; + /// Group in Periodic Table + int Group; + /// Period in Periodic Table + int Period; + /// Density (g/cm^3) + double Density; + public: + virtual String^ ToString() override + { + return String::Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}", + Number, Name, Symbol, Weight, Group, Period, Density); + } + }; + + private ref class Elements + { + private: + static array ^_elementData = { + {0, "", "", 0.0, 0, 0, 0.0}, + {1, "Hydrogen", "H", 1.00794, 1, 1, 0.00008988}, + {2, "Helium", "He", 4.002602, 1, 18, 0.0001785}, + {3, "Lithium", "Li", 6.941, 2, 1, 0.534}, + {4, "Beryllium", "Be", 9.012182, 2, 2, 1.8477}, + {5, "Boron", "B", 10.811, 2, 13, 2.34}, + {6, "Carbon", "C", 12.0107, 2, 14, 2.26}, + {7, "Nitrogen", "N", 14.0067, 2, 15, 0.0012506}, + {8, "Oxygen", "O", 15.9994, 2, 16, 0.001429}, + {9, "Fluorine", "F", 18.9984032, 2, 17, 0.001696}, + {10, "Neon", "Ne", 20.1797, 2, 18, 0.00089994}, + {11, "Sodium", "Na", 22.98977, 3, 1, 0.971}, + {12, "Magnesium", "Mg", 24.305, 3, 2, 1.738}, + {13, "Aluminum", "Al", 26.981538, 3, 13, 2.698}, + {14, "Silicon", "Si", 28.0855, 3, 14, 2.329}, + {15, "Phosphorus", "P", 30.973761, 3, 15, 1.82}, + {16, "Sulfur", "S", 32.065, 3, 16, 1.957}, + {17, "Chlorine", "Cl", 35.453, 3, 17, 0.003214}, + {18, "Argon", "Ar", 39.948, 3, 18, 0.001784}, + {19, "Potassium", "K", 39.0983, 4, 1, 0.862}, + {20, "Calcium", "Ca", 40.078, 4, 2, 1.55}, + {21, "Scandium", "Sc", 44.95591, 4, 3, 2.989}, + {22, "Titanium", "Ti", 47.867, 4, 4, 4.54}, + {23, "Vanadium", "V", 50.9415, 4, 5, 6.11}, + {24, "Chromium", "Cr", 51.9961, 4, 6, 7.19}, + {25, "Manganese", "Mn", 54.938049, 4, 7, 7.44}, + {26, "Iron", "Fe", 55.845, 4, 8, 7.874}, + {27, "Cobalt", "Co", 58.9332, 4, 9, 8.9}, + {28, "Nickel", "Ni", 58.6934, 4, 10, 8.902}, + {29, "Copper", "Cu", 63.546, 4, 11, 8.96}, + {30, "Zinc", "Zn", 65.39, 4, 12, 7.133}, + {31, "Gallium", "Ga", 69.723, 4, 13, 5.907}, + {32, "Germanium", "Ge", 72.64, 4, 14, 5.323}, + {33, "Arsenic", "As", 74.9216, 4, 15, 5.78}, + {34, "Selenium", "Se", 78.96, 4, 16, 4.79}, + {35, "Bromine", "Br", 79.904, 4, 17, 3.1226}, + {36, "Krypton", "Kr", 83.8, 4, 18, 0.0037493}, + {37, "Rubidium", "Rb", 85.4678, 5, 1, 1.532}, + {38, "Strontium", "Sr", 87.62, 5, 2, 2.54}, + {39, "Yttrium", "Y", 88.90585, 5, 3, 4.469}, + {40, "Zirconium", "Zr", 91.224, 5, 4, 6.506}, + {41, "Niobium", "Nb", 92.90638, 5, 5, 8.57}, + {42, "Molybdenum", "Mo", 95.94, 5, 6, 10.22}, + {43, "Technetium", "Tc", 98, 5, 7, 11.5}, + {44, "Ruthenium", "Ru", 101.07, 5, 8, 12.37}, + {45, "Rhodium", "Rh", 102.9055, 5, 9, 12.41}, + {46, "Palladium", "Pd", 106.42, 5, 10, 12.02}, + {47, "Silver", "Ag", 107.8682, 5, 11, 10.5}, + {48, "Cadmium", "Cd", 112.411, 5, 12, 8.65}, + {49, "Indium", "In", 114.818, 5, 13, 7.31}, + {50, "Tin", "Sn", 118.71, 5, 14, 7.31}, + {51, "Antimony", "Sb", 121.76, 5, 15, 6.691}, + {52, "Tellurium", "Te", 127.6, 5, 16, 6.24}, + {53, "Iodine", "I", 126.90447, 5, 17, 4.93}, + {54, "Xenon", "Xe", 131.293, 5, 18, 0.0058971}, + {55, "Cesium", "Cs", 132.90545, 6, 1, 1.873}, + {56, "Barium", "Ba", 137.327, 6, 2, 3.594}, + {57, "Lanthanum", "La", 138.9055, 6, 3, 6.145}, + {58, "Cerium", "Ce", 140.116, 6, 3, 6.689}, + {59, "Praseodymium", "Pr", 140.90765, 6, 3, 6.773}, + {60, "Neodumium", "Nd", 144.24, 6, 3, 7.007}, + {61, "Promethium", "Pm", 145, 6, 3, 7.22}, + {62, "Samarium", "Sm", 150.36, 6, 3, 7.52}, + {63, "Europium", "Eu", 151.964, 6, 3, 5.243}, + {64, "Gadolinium", "Gd", 157.25, 6, 3, 7.9004}, + {65, "Terbium", "Tb", 158.92534, 6, 3, 8.229}, + {66, "Dysprosium", "Dy", 162.5, 6, 3, 8.55}, + {67, "Holmium", "Ho", 164.93032, 6, 3, 8.795}, + {68, "Erbium", "Er", 167.259, 6, 3, 9.066}, + {69, "Thulium", "Tm", 168.93421, 6, 3, 9.321}, + {70, "Ytterbium", "Yb", 173.04, 6, 3, 6.965}, + {71, "Lutetium", "Lu", 174.967, 6, 3, 9.84}, + {72, "Hafnium", "Hf", 178.49, 6, 4, 13.31}, + {73, "Tantalum", "Ta", 180.9479, 6, 5, 16.654}, + {74, "Tungsten", "W", 183.84, 6, 6, 19.3}, + {75, "Rhenium", "Re", 186.207, 6, 7, 21.02}, + {76, "Osmium", "Os", 190.23, 6, 8, 22.59}, + {77, "Iridium", "Ir", 192.217, 6, 9, 22.42}, + {78, "Platinum", "Pt", 195.078, 6, 10, 21.45}, + {79, "Gold", "Au", 196.96655, 6, 11, 19.32}, + {80, "Mercury", "Hg", 200.59, 6, 12, 13.546}, + {81, "Thallium", "Tl", 204.3833, 6, 13, 11.85}, + {82, "Lead", "Pb", 207.2, 6, 14, 11.35}, + {83, "Bismuth", "Bi", 208.98038, 6, 15, 9.747}, + {84, "Polonium", "Po", 209, 6, 16, 9.32}, + {85, "Astatine", "At", 210, 6, 17, -9999}, + {86, "Radon", "Rn", 222, 6, 18, 0.00973}, + {87, "Francium", "Fr", 223, 7, 1, -9999}, + {88, "Radium", "Ra", 226, 7, 2, 5}, + {89, "Actinium", "Ac", 227, 7, 3, 10.06}, + {90, "Thorium", "Th", 232.0381, 7, 3, 11.72}, + {91, "Protactnium", "Pa", 231.03588, 7, 3, 15.37}, + {92, "Uranium", "U", 238.02891, 7, 3, 18.95}, + {93, "Neptunium", "Np", 237, 7, 3, 20.25}, + {94, "Plutonium", "Pu", 244, 7, 3, 19.84}, + {95, "Americium", "Am", 243, 7, 3, 13.67}, + {96, "Curium", "Cm", 247, 7, 3, 13.3}, + {97, "Berkelium", "Bk", 247, 7, 3, 14.79}, + {98, "Californium", "Cf", 251, 7, 3, -9999}, + {99, "Einsteinium", "Es", 252, 7, 3, -9999}, + {100, "Fermium", "Fm", 257, 7, 3, -9999}, + {101, "Mendelevium", "Md", 258, 7, 3, -9999}, + {102, "Nobelium", "No", 259, 7, 3, -9999}, + {103, "Lawrencium", "Lr", 262, 7, 3, -9999}, + {104, "Rutherfordium", "Rf", 261, 7, 4, -9999}, + {105, "Dubnium", "Db", 262, 7, 5, -9999}, + {106, "Seaborgium", "Sg", 266, 7, 6, -9999}, + {107, "Bohrium", "Bh", 264, 7, 7, -9999}, + {108, "Hassium", "Hs", 277, 7, 8, -9999}, + {109, "Meitnerium", "Mt", 268, 7, 9, -9999}, + {110, "Darmstadtium", "Ds", 271, 7, 10, -9999}, + {111, "Roentgenium", "Rg", 272, 7, 11, -9999}}; + + public: + /// Gets the element data for the specified element. + /// Atomic number. + /// Element data. + static ElementData GetData(int Z) + { + if (Z < 1 || Z > 110) + { + return _elementData[0]; + } + + return _elementData[Z]; + } + }; +} diff --git a/csharp/Errors.h b/csharp/Errors.h new file mode 100644 index 00000000..502341c1 --- /dev/null +++ b/csharp/Errors.h @@ -0,0 +1,155 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: Errors.h + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: January 15, 2019 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains a managed class containing element data for use with XrayLib.NET. + + "A library for X-ray�matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725�1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ + + +#pragma once + +using namespace System::IO; + +#include "xraylib.h" + +/// +/// A namespace that contains scientific classes. +/// +namespace Science { + + /// + /// A managed wrapper for XrayLib's error functions. + /// + public ref class Errors + { + public: + + /// + /// Handles library errors by raising a .NET exception. + /// + /// The error. + static void HandleError(::xrl_error *error) + { + if (error == nullptr) + { + return; + } + + int code = error->code; + String^ message = gcnew String(error->message); + switch (code) + { + case ::XRL_ERROR_MEMORY : + throw gcnew OutOfMemoryException(message); + case ::XRL_ERROR_INVALID_ARGUMENT: + throw gcnew ArgumentException(message); + case ::XRL_ERROR_IO : + throw gcnew IOException(message); + case ::XRL_ERROR_TYPE: + throw gcnew InvalidCastException(message); + case ::XRL_ERROR_UNSUPPORTED : + throw gcnew NotImplementedException(message); + case ::XRL_ERROR_RUNTIME : + throw gcnew Exception(message); + default: + throw gcnew Exception("Unknown exception type raised!"); + } + + ::xrl_clear_error(&error); + + String^ s = String::Format("Error {0}: {1}", code, message); + throw gcnew Science::XrayLibException(s); + } + + // Error Handling + /// + /// Sets the hard error exit code. + /// + /// Hard exit code + static void SetHardExit(int hard_exit) + { + ::SetHardExit(hard_exit); + } + + /// + /// Sets the exit status code. + /// + /// Exit status code + static void SetExitStatus(int exit_status) + { + ::SetExitStatus(exit_status); + } + + /// + /// Gets the exit status code. + /// + /// Exit status code + static int GetExitStatus() + { + return ::GetExitStatus(); + } + + /// + /// Sets whether, or not, error messages are displayed. + /// + /// status is non-zero to display messages + static void SetErrorMessages(int status) + { + ::SetErrorMessages(status); + } + + /// Gets whether, or now, error messages are displayed. + /// Returns a non-zero if messages are displayed + static int GetErrorMessages(void) + { + return ::GetErrorMessages(); + } + }; +} \ No newline at end of file diff --git a/csharp/Program.cs b/csharp/Program.cs new file mode 100644 index 00000000..e8967c4b --- /dev/null +++ b/csharp/Program.cs @@ -0,0 +1,249 @@ +using System; +using System.Diagnostics; +using System.Numerics; +using Science; +using System.Collections.Generic; + +namespace Test +{ + class Program + { + static void Main(string[] args) + { + try + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + + Console.Title = String.Format("XrayLib.NET v{0}.{1}", + XrayLib.VERSION_MAJOR, XrayLib.VERSION_MINOR); + Console.WriteLine("Example C# program using XrayLib.NET\n"); + Console.WriteLine("Atomic weight of pure Al: {0} g/cm3", + XrayLib.AtomicWeight(13)); + Console.WriteLine("Density of pure Al: {0} g/cm3", + XrayLib.ElementDensity(13)); + Console.WriteLine("Ca K-alpha Fluorescence Line Energy: {0}", + XrayLib.LineEnergy(20, XrayLib.KA_LINE)); + Console.WriteLine("Fe partial photoionization cs of L3 at 6.0 keV: {0}", + XrayLib.CS_Photo_Partial(26, XrayLib.L3_SHELL, 6.0)); + Console.WriteLine("Zr L1 edge energy: {0}", + XrayLib.EdgeEnergy(40, XrayLib.L1_SHELL)); + Console.WriteLine("Pb Lalpha XRF production cs at 20.0 keV (jump approx): {0}", + XrayLib.CS_FluorLine(82, XrayLib.LA_LINE, 20.0)); + Console.WriteLine("Pb Lalpha XRF production cs at 20.0 keV (Kissel): {0}", + XrayLib.CS_FluorLine_Kissel(82, XrayLib.LA_LINE, 20.0)); + Console.WriteLine("Bi M1N2 radiative rate: {0}", + XrayLib.RadRate(83, XrayLib.M1N2_LINE)); + Console.WriteLine("U M3O3 Fluorescence Line Energy: {0}", + XrayLib.LineEnergy(92, XrayLib.M3O3_LINE)); + Console.WriteLine("Pb information: {0}", + XrayLib.GetElementData(82).ToString()); + + // Parser test for Ca(HCO3)2 (calcium bicarbonate) + CompoundData cd = new CompoundData("Ca(HCO3)2"); + Console.WriteLine("Ca(HCO3)2 contains:"); + Console.Write(cd.ToString()); + + // Parser test for SiO2 (quartz) + cd.Parse("SiO2"); + Console.WriteLine("SiO2 contains:"); + Console.Write(cd.ToString()); + + Console.WriteLine("Ca(HCO3)2 Rayleigh cs at 10.0 keV: {0}", + XrayLib.CS_Rayl_CP("Ca(HCO3)2", 10.0)); + Console.WriteLine("CS2 Refractive Index at 10.0 keV : {0} - {1} i", + XrayLib.Refractive_Index_Re("CS2", 10.0, 1.261), XrayLib.Refractive_Index_Im("CS2", 10.0, 1.261)); + Console.WriteLine("C16H14O3 Refractive Index at 1 keV : {0} - {1} i", + XrayLib.Refractive_Index_Re("C16H14O3", 1.0, 1.2), XrayLib.Refractive_Index_Im("C16H14O3", 1.0, 1.2)); + Console.WriteLine("SiO2 Refractive Index at 5 keV : {0} - {1} i", + XrayLib.Refractive_Index_Re("SiO2", 5.0, 2.65), XrayLib.Refractive_Index_Im("SiO2", 5.0, 2.65)); + + Complex n = XrayLib.Refractive_Index("SiO2", 5.0, 2.65); + Console.WriteLine("SiO2 Refractive Index at 5 keV : {0} - {1} i", n.Real, n.Imaginary); + + Console.WriteLine("Compton profile for Fe at pz = 1.1 : {0}", + XrayLib.ComptonProfile(26, 1.1f)); + Console.WriteLine("M5 Compton profile for Fe at pz = 1.1 : {0}", + XrayLib.ComptonProfile_Partial(26, XrayLib.M5_SHELL, 1.1)); + Console.WriteLine("M1->M5 Coster-Kronig transition probability for Au : {0}", + XrayLib.CosKronTransProb(79, XrayLib.FM15_TRANS)); + Console.WriteLine("L1->L3 Coster-Kronig transition probability for Fe : {0}", + XrayLib.CosKronTransProb(26, XrayLib.FL13_TRANS)); + Console.WriteLine("Au Ma1 XRF production cs at 10.0 keV (Kissel): {0}", + XrayLib.CS_FluorLine_Kissel(79, XrayLib.MA1_LINE, 10.0)); + Console.WriteLine("Au Mb XRF production cs at 10.0 keV (Kissel): {0}", + XrayLib.CS_FluorLine_Kissel(79, XrayLib.MB_LINE, 10.0)); + Console.WriteLine("Au Mg XRF production cs at 10.0 keV (Kissel): {0}", + XrayLib.CS_FluorLine_Kissel(79, XrayLib.MG_LINE, 10.0)); + + Console.WriteLine("K atomic level width for Fe: {0}", + XrayLib.AtomicLevelWidth(26, XrayLib.K_SHELL)); + Console.WriteLine("Bi L2-M5M5 Auger non-radiative rate: {0}", + XrayLib.AugerRate(86, XrayLib.L2_M5M5_AUGER)); + + cd = new CompoundData("SiO2", 0.4, "Ca(HCO3)2", 0.6); + Console.WriteLine("Compound contains:"); + Console.Write(cd.ToString()); + + String symbol = CompoundData.AtomicNumberToSymbol(26); + Console.WriteLine("Symbol of element 26 is: {0}", symbol); + Console.WriteLine("Number of element Fe is: {0}", CompoundData.SymbolToAtomicNumber("Fe")); + + Console.WriteLine("Pb Malpha XRF production cs at 20.0 keV with cascade effect: {0}", + XrayLib.CS_FluorLine_Kissel(82, XrayLib.MA1_LINE, 20.0)); + Console.WriteLine("Pb Malpha XRF production cs at 20.0 keV with radiative cascade effect: {0}", + XrayLib.CS_FluorLine_Kissel_Radiative_Cascade(82, XrayLib.MA1_LINE, 20.0)); + Console.WriteLine("Pb Malpha XRF production cs at 20.0 keV with non-radiative cascade effect: {0}", + XrayLib.CS_FluorLine_Kissel_Nonradiative_Cascade(82, XrayLib.MA1_LINE, 20.0)); + Console.WriteLine("Pb Malpha XRF production cs at 20.0 keV without cascade effect: {0}", + XrayLib.CS_FluorLine_Kissel_No_Cascade(82, XrayLib.MA1_LINE, 20.0)); + + Console.WriteLine("Al mass energy-absorption cs at 20.0 keV: {0}", + XrayLib.CS_Energy(13, 20.0)); + Console.WriteLine("Pb mass energy-absorption cs at 40.0 keV: {0}", + XrayLib.CS_Energy(82, 40.0)); + Console.WriteLine("CdTe mass energy-absorption cs at 40.0 keV: {0}", + XrayLib.CS_Energy_CP("CdTe", 40.0)); + + double energy = 8.0; + double debyeFactor = 1.0; + double relativeAngle = 1.0; + + // Si crystal structure + CrystalArray ca = new CrystalArray(); + + Crystal cryst = ca.GetCrystal("Si"); + if (cryst != null) + { + Console.WriteLine(cryst.ToString()); + + // Si diffraction parameters + Console.WriteLine("Si 111 at 8 KeV. Incidence at the Bragg angle:"); + double bragg = cryst.BraggAngle(energy, 1, 1, 1); + Console.WriteLine(" Bragg angle: {0} rad, {1} deg", bragg, bragg * 180.0 / Math.PI); + + double q = cryst.ScatteringVectorMagnitide(energy, 1, 1, 1, relativeAngle); + Console.WriteLine(" Magnitude of scattering vector, Q: {0}", q); + + double f0 = 0.0, fp = 0.0, fpp = 0.0; + cryst.AtomicScatteringFactors(14, energy, q, debyeFactor, ref f0, ref fp, ref fpp); + Console.WriteLine(" Atomic scattering factors (Z = 14) f0, fp, fpp: {0}, {1}, i{2}", f0, fp, fpp); + + Complex FH, F0; + FH = cryst.StructureFactor(energy, 1, 1, 1, debyeFactor, relativeAngle); + Console.WriteLine(" FH(1,1,1) structure factor: ({0}, {1})", FH.Real, FH.Imaginary); + + F0 = cryst.StructureFactor(energy, 0, 0, 0, debyeFactor, relativeAngle); + Console.WriteLine(" F0=FH(0,0,0) structure factor: ({0}, {1})", F0.Real, F0.Imaginary); + Console.WriteLine(); + } + + // Diamond diffraction parameters + cryst = ca.GetCrystal("Diamond"); + if (cryst != null) + { + Console.WriteLine("Diamond 111 at 8 KeV. Incidence at the Bragg angle:"); + double bragg = cryst.BraggAngle(energy, 1, 1, 1); + Console.WriteLine(" Bragg angle: {0} rad, {1} deg", bragg, bragg * 180.0 / Math.PI); + + double q = cryst.ScatteringVectorMagnitide(energy, 1, 1, 1, relativeAngle); + Console.WriteLine(" Magnitude of scattering vector, Q: {0}", q); + + double f0 = 0.0, fp = 0.0, fpp = 0.0; + cryst.AtomicScatteringFactors(6, energy, q, debyeFactor, ref f0, ref fp, ref fpp); + Console.WriteLine(" Atomic scattering factors (Z = 6) f0, fp, fpp: {0}, {1}, i{2}", f0, fp, fpp); + + Complex FH, F0; + FH = cryst.StructureFactor(energy, 1, 1, 1, debyeFactor, relativeAngle); + Console.WriteLine(" FH(1,1,1) structure factor: ({0}, {1})", FH.Real, FH.Imaginary); + + F0 = cryst.StructureFactor(energy, 0, 0, 0, debyeFactor, relativeAngle); + Console.WriteLine(" F0=FH(0,0,0) structure factor: ({0}, {1})", F0.Real, F0.Imaginary); + + Complex FHbar = cryst.StructureFactor(energy, -1, -1, -1, debyeFactor, relativeAngle); + double dw = 1e10 * 2 * (XrayLib.R_E / cryst.Volume) * (XrayLib.KEV2ANGST * XrayLib.KEV2ANGST / (energy * energy)) * + Math.Sqrt(Complex.Abs(FH * FHbar)) / Math.PI / Math.Sin(2 * bragg); + Console.WriteLine(" Darwin width: {0} uRad", 1e6 * dw); + Console.WriteLine(); + } + + // Alpha Quartz diffraction parameters + cryst = ca.GetCrystal("AlphaQuartz"); + if (cryst != null) + { + Console.WriteLine("AlphaQuartz 020 at 8 KeV. Incidence at the Bragg angle:"); + double bragg = cryst.BraggAngle(energy, 0, 2, 0); + Console.WriteLine(" Bragg angle: {0} rad, {1} deg", bragg, bragg * 180.0 / Math.PI); + + double q = cryst.ScatteringVectorMagnitide(energy, 0, 2, 0, relativeAngle); + Console.WriteLine(" Magnitude of scattering vector, Q: {0}", q); + + double f0 = 0.0, fp = 0.0, fpp = 0.0; + cryst.AtomicScatteringFactors(8, energy, q, debyeFactor, ref f0, ref fp, ref fpp); + Console.WriteLine(" Atomic scattering factors (Z = 8) f0, fp, fpp: {0}, {1}, i{2}", f0, fp, fpp); + + Complex FH, F0; + FH = cryst.StructureFactor(energy, 0, 2, 0, debyeFactor, relativeAngle); + Console.WriteLine(" FH(0,2,0) structure factor: ({0}, {1})", FH.Real, FH.Imaginary); + + F0 = cryst.StructureFactor(energy, 0, 0, 0, debyeFactor, relativeAngle); + Console.WriteLine(" F0=FH(0,0,0) structure factor: ({0}, {1})", F0.Real, F0.Imaginary); + Console.WriteLine(); + } + + // Muscovite diffraction parameters + cryst = ca.GetCrystal("Muscovite"); + if (cryst != null) + { + Console.WriteLine("Muskovite 331 at 8 KeV. Incidence at the Bragg angle:"); + double bragg = cryst.BraggAngle(energy, 3, 3, 1); + Console.WriteLine(" Bragg angle: {0} rad, {1} deg", bragg, bragg * 180.0 / Math.PI); + + double q = cryst.ScatteringVectorMagnitide(energy, 3, 3, 1, relativeAngle); + Console.WriteLine(" Magnitude of scattering vector, Q: {0}", q); + + double f0 = 0.0, fp = 0.0, fpp = 0.0; + cryst.AtomicScatteringFactors(19, energy, q, debyeFactor, ref f0, ref fp, ref fpp); + Console.WriteLine(" Atomic scattering factors (Z = 19) f0, fp, fpp: {0}, {1}, i{2}", f0, fp, fpp); + + Complex FH, F0; + FH = cryst.StructureFactor(energy, 3, 3, 1, debyeFactor, relativeAngle); + Console.WriteLine(" FH(3,3,1) structure factor: ({0}, {1})", FH.Real, FH.Imaginary); + + F0 = cryst.StructureFactor(energy, 0, 0, 0, debyeFactor, relativeAngle); + Console.WriteLine(" F0=FH(0,0,0) structure factor: ({0}, {1})", F0.Real, F0.Imaginary); + Console.WriteLine(); + } + + List crystalNames; + crystalNames = CrystalArray.GetDefaultNames(); + foreach (string name in crystalNames) + Console.WriteLine(name); + Console.WriteLine(); + + // RadionuclideData tests + RadionuclideData rd = new RadionuclideData("109Cd"); + Console.WriteLine(rd.ToString()); + Console.WriteLine(); + + rd = new RadionuclideData(XrayLib.RADIONUCLIDE_125I); + Console.WriteLine(rd.ToString()); + Console.WriteLine(); + + rd = new RadionuclideData(); + string namesCsv = string.Join(", ", rd.Names.ToArray()); + Console.WriteLine(namesCsv); + Console.WriteLine(); + + sw.Stop(); + Console.WriteLine("Time: {0} ms", sw.ElapsedMilliseconds); + } + catch (XrayLibException e) + { + Console.WriteLine(e.Message); + } + + } + } +} + diff --git a/csharp/Radionuclides.h b/csharp/Radionuclides.h new file mode 100644 index 00000000..a21ad0f5 --- /dev/null +++ b/csharp/Radionuclides.h @@ -0,0 +1,278 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: Radionuclides.h + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: October 8, 2014 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains a managed class for radionuclide data for use with XrayLib.NET. + + "A library for X-ray�matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725�1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ + +#include "xraylib.h" +#include + +using namespace System; +using namespace System::Collections::Generic; +using namespace System::Numerics; +using namespace System::Runtime::InteropServices; +using namespace System::Text; + +/// +/// A namespace that contains scientific classes. +/// +namespace Science { + + /// + /// A managed wrapper for XrayLib's radionuclide data. + /// + public ref class RadionuclideData + { + private: + List^ _xrayLines; + List^ _xrayIntensities; + List^ _gammaEnergies; + List^ _gammaIntensities; + List^ _names; + + void GetNames() + { + char **names; + int i; + String^ name; + + _names->Clear(); + + ::xrl_error *error = nullptr; + names = GetRadioNuclideDataList(NULL, &error); + Errors::HandleError(error); + + for (i = 0; names[i] != NULL; i++) + { + name = gcnew String(names[i]); + _names->Add(name); + xrlFree(names[i]); + } + xrlFree(names); + } + + void Initialize(::radioNuclideData* rd) + { + _xrayLines = gcnew List(); + _xrayIntensities = gcnew List(); + _gammaEnergies = gcnew List(); + _gammaIntensities = gcnew List(); + _names = gcnew List(); + Clear(); + + if (rd != nullptr) + { + Name = gcnew String(rd->name); + Z = rd->Z; + A = rd->A; + N = rd->N; + XrayCount = rd->nXrays; + for (int i = 0; i < XrayCount; i++) + { + _xrayLines->Add(rd->XrayLines[i]); + _xrayIntensities->Add(rd->XrayIntensities[i]); + } + GammaCount = rd->nGammas; + for (int i = 0; i < GammaCount; i++) + { + _gammaEnergies->Add(rd->GammaEnergies[i]); + _gammaIntensities->Add(rd->GammaIntensities[i]); + } + + GammaCount = rd->nGammas; + } + } + + public: + /// A string containing the mass number (A), followed by the chemical element (e.g. 55Fe) + property String^ Name; + /// Atomic number of the radionuclide + property int Z; + /// Mass number of the radionuclide + property int A; + /// Number of neutrons of the radionuclide + property int N; + /// Atomic number of the nuclide after decay, and which should be used in calculating the energy of the emitted X-ray lines + property int ZXray; + /// Number of emitted characteristic X-rays + property int XrayCount; + /// Number of emitted gamma-rays + property int GammaCount; + + /// List of *_LINE macros, identifying the emitted X-rays + property List^ XrayLines + { + List^ get() + { + return _xrayLines; + } + } + + /// List of photons per disintegration, one value per emitted X-ray + property List^ XrayIntensities + { + List^ get() + { + return _xrayIntensities; + } + } + + /// List of all available radionuclide names + property List^ Names + { + List^ get() + { + return _names; + } + } + + /// List of emitted gamma-ray energies + property List^ GammaEnergies + { + List^ get() + { + return _gammaEnergies; + } + } + + /// List of emitted gamma-ray photons per disintegration + property List^ GammaIntensities + { + List^ get() + { + return _gammaIntensities; + } + } + + /// Default constructor. + RadionuclideData() + { + Initialize(nullptr); + } + + /// Constructor. + /// Index of the radionuclide in the internal table + RadionuclideData(int index) + { + ::radioNuclideData* rd; + ::xrl_error *error = nullptr; + rd = GetRadioNuclideDataByIndex(index, &error); + Errors::HandleError(error); + Initialize(rd); + if (rd != nullptr) + FreeRadioNuclideData(rd); + } + + /// Constructor. + /// Name of the radionuclide + RadionuclideData(String^ name) + { + ::radioNuclideData* rd; + + char* cName = new char[name->Length]; + IntPtr p = Marshal::StringToHGlobalAnsi(name); + try + { + cName = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + rd = GetRadioNuclideDataByName(cName, &error); + Errors::HandleError(error); + Initialize(rd); + if (rd != nullptr) + FreeRadioNuclideData(rd); + } + finally + { + Marshal::FreeHGlobal(p); + } + } + + /// Clears this object to its blank/initial state. + void Clear() + { + Name = ""; + Z = 0; + A = 0; + N = 0; + ZXray = 0; + XrayCount = 0; + GammaCount = 0; + _xrayLines->Clear(); + _xrayIntensities->Clear(); + _gammaEnergies->Clear(); + _gammaIntensities->Clear(); + + GetNames(); + } + + /// Convert this object into a string representation. + /// Null if it fails, else a string representation of this object. + virtual String^ ToString() override + { + StringBuilder^ sb = gcnew StringBuilder(); + sb->AppendLine(String::Format("Name: {0}", Name)); + sb->AppendLine(String::Format("Z: {0}", Z)); + sb->AppendLine(String::Format("A: {0}", A)); + sb->AppendLine(String::Format("N: {0}", N)); + sb->AppendLine(String::Format("ZXray: {0}", ZXray)); + sb->AppendLine(String::Format("XrayCount: {0}", XrayCount)); + sb->AppendLine(String::Format("XrayLine, XrayIntensity")); + for (int i = 0; i < XrayCount; i++) + sb->AppendLine(String::Format("{0}, {1}", _xrayLines[i], _xrayIntensities[i])); + sb->AppendLine(String::Format("GammaCount: {0}", GammaCount)); + sb->AppendLine(String::Format("GammaEnergy, GammaIntensity")); + for (int i = 0; i < GammaCount; i++) + sb->AppendLine(String::Format("{0}, {1}", _gammaEnergies[i], _gammaIntensities[i])); + + return sb->ToString(); + } + }; +} \ No newline at end of file diff --git a/csharp/Stdafx.cpp b/csharp/Stdafx.cpp new file mode 100644 index 00000000..16913fe9 --- /dev/null +++ b/csharp/Stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// XrayLib.NET.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/csharp/Stdafx.h b/csharp/Stdafx.h new file mode 100644 index 00000000..3cc4c24e --- /dev/null +++ b/csharp/Stdafx.h @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + + diff --git a/csharp/XrayLib.NET.cpp b/csharp/XrayLib.NET.cpp new file mode 100644 index 00000000..bc7e9397 --- /dev/null +++ b/csharp/XrayLib.NET.cpp @@ -0,0 +1,1225 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: XrfLibNET.cpp + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: September 4, 2010 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains the implementation of a managed wrapper class around the native + XrayLib API. + + "A library for X-ray�matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725�1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ +#using "System.Numerics.dll" + + +#include "stdafx.h" +#include "Element.h" +#include "XrayLib.NET.h" +#include "xraylib.h" +#include "Errors.h" +#include "Compound.h" +#include "Diffraction.h" +#include "Radionuclides.h" + +using namespace System::Runtime::InteropServices; + +void Science::XrayLib::XrayInit() +{ + ::XRayInit(); +} + +double Science::XrayLib::AtomicWeight( int Z ) +{ + ::xrl_error *error = nullptr; + double result = ::AtomicWeight(Z, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::ElementDensity(int Z) +{ + ::xrl_error *error = nullptr; + double result = ::ElementDensity(Z, &error); + Errors::HandleError(error); + return result; +} + +Science::ElementData Science::XrayLib::GetElementData( int Z ) +{ + return Elements::GetData(Z); +} + +// Cross sections (cm2/g) +double Science::XrayLib::CS_Total(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Total(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Photo(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Photo(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Rayl(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Rayl(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Compt(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Compt(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Energy(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Energy(Z, E, &error); + Errors::HandleError(error); + return result; +} + +// barn/atom +double Science::XrayLib::CSb_Total(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Total(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_Photo(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Photo(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_Rayl(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Rayl(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_Compt(int Z, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Compt(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_KN(double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_KN(E, &error); + Errors::HandleError(error); + return result; +} + +// Unpolarized differential scattering cross sections +double Science::XrayLib::DCS_Thoms(double theta) +{ + ::xrl_error *error = nullptr; + double result = ::DCS_Thoms(theta, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCS_KN(double E, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::DCS_KN(E, theta, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCS_Rayl(int Z, double E, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::DCS_Rayl(Z, E, theta, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCS_Compt(int Z, double E, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::DCS_Compt(Z, E, theta, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSb_Rayl(int Z, double E, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::DCSb_Rayl(Z, E, theta, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSb_Compt(int Z, double E, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::DCSb_Compt(Z, E, theta, &error); + Errors::HandleError(error); + return result; +} + +// Polarized differential scattering cross sections +double Science::XrayLib::DCSP_Thoms(double theta, double phi) +{ + ::xrl_error *error = nullptr; + double result = ::DCSP_Thoms(theta, phi, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSP_KN(double E, double theta, double phi) +{ + ::xrl_error *error = nullptr; + double result = ::DCSP_KN(E, theta, phi, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSP_Rayl(int Z, double E, double theta, double phi) +{ + ::xrl_error *error = nullptr; + double result = ::DCSP_Rayl(Z, E, theta, phi, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSP_Compt(int Z, double E, double theta, double phi) +{ + ::xrl_error *error = nullptr; + double result = ::DCSP_Compt(Z, E, theta, phi, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSPb_Rayl(int Z, double E, double theta, double phi) +{ + ::xrl_error *error = nullptr; + double result = ::DCSPb_Rayl(Z, E, theta, phi, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::DCSPb_Compt(int Z, double E, double theta, double phi) +{ + ::xrl_error *error = nullptr; + double result = ::DCSPb_Compt(Z, E, theta, phi, &error); + Errors::HandleError(error); + return result; +} + +// Scattering factors +double Science::XrayLib::FF_Rayl(int Z, double q) +{ + ::xrl_error *error = nullptr; + double result = ::FF_Rayl(Z, q, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::SF_Compt(int Z, double q) +{ + ::xrl_error *error = nullptr; + double result = ::SF_Compt(Z, q, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::MomentTransf(double E, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::MomentTransf(E, theta, &error); + Errors::HandleError(error); + return result; +} + +// X-ray fluorescent line energy +double Science::XrayLib::LineEnergy(int Z, int line) +{ + ::xrl_error *error = nullptr; + double result = ::LineEnergy(Z, line, &error); + Errors::HandleError(error); + return result; +} + +// Fluorescence yield +double Science::XrayLib::FluorYield(int Z, int shell) +{ + ::xrl_error *error = nullptr; + double result = ::FluorYield(Z, shell, &error); + Errors::HandleError(error); + return result; +} + +// Coster-Kronig transition Probability +double Science::XrayLib::CosKronTransProb(int Z, int trans) +{ + ::xrl_error *error = nullptr; + double result = ::CosKronTransProb(Z, trans, &error); + Errors::HandleError(error); + return result; +} + +// Absorption-edge energies +double Science::XrayLib::EdgeEnergy(int Z, int shell) +{ + ::xrl_error *error = nullptr; + double result = ::EdgeEnergy(Z, shell, &error); + Errors::HandleError(error); + return result; +} + +// Jump ratio +double Science::XrayLib::JumpFactor(int Z, int shell) +{ + ::xrl_error *error = nullptr; + double result = ::JumpFactor(Z, shell, &error); + Errors::HandleError(error); + return result; +} + +// Fluorescent-lines cross sections +double Science::XrayLib::CS_FluorLine(int Z, int line, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CS_FluorLine(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_FluorLine(int Z, int line, double E) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_FluorLine(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +// Fractional radiative rate +double Science::XrayLib::RadRate(int Z, int line) +{ + ::xrl_error *error = nullptr; + double result = ::RadRate(Z, line, &error); + Errors::HandleError(error); + return result; +} + +// Photon energy after Compton scattering +double Science::XrayLib::ComptonEnergy(double E0, double theta) +{ + ::xrl_error *error = nullptr; + double result = ::ComptonEnergy(E0, theta, &error); + Errors::HandleError(error); + return result; +} + +// Anomalous scattering factors +double Science::XrayLib::Fi( int Z, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::Fi(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::Fii( int Z, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::Fii(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Photo_Total( int Z, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Photo_Total(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_Photo_Total( int Z, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Photo_Total(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Photo_Partial( int Z, int shell, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Photo_Partial(Z, shell, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_Photo_Partial( int Z, int shell, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Photo_Partial(Z, shell, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_FluorLine_Kissel( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_FluorLine_Kissel(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_FluorLine_Kissel( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_FluorLine_Kissel(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Total_Kissel( int Z, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_Total_Kissel(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_Total_Kissel( int Z, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_Total_Kissel(Z, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_FluorLine_Kissel_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_FluorLine_Kissel_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_FluorLine_Kissel_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_FluorLine_Kissel_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_FluorLine_Kissel_Nonradiative_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_FluorLine_Kissel_Nonradiative_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_FluorLine_Kissel_Nonradiative_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_FluorLine_Kissel_Nonradiative_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_FluorLine_Kissel_Radiative_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_FluorLine_Kissel_Radiative_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_FluorLine_Kissel_Radiative_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_FluorLine_Kissel_Radiative_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_FluorLine_Kissel_No_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CS_FluorLine_Kissel_no_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CSb_FluorLine_Kissel_No_Cascade( int Z, int line, double E ) +{ + ::xrl_error *error = nullptr; + double result = ::CSb_FluorLine_Kissel_no_Cascade(Z, line, E, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::CS_Total_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Total_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CS_Photo_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Photo_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CS_Rayl_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Rayl_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CS_Compt_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Compt_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CSb_Total_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CSb_Total_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CSb_Photo_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CSb_Photo_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CSb_Rayl_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CSb_Rayl_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CSb_Compt_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CSb_Compt_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCS_Rayl_CP( String^ compound, double E, double theta ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCS_Rayl_CP(pCompound, E, theta, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCS_Compt_CP( String^ compound, double E, double theta ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCS_Compt_CP(pCompound, E, theta, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCSb_Rayl_CP( String^ compound, double E, double theta ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCSb_Rayl_CP(pCompound, E, theta, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCSb_Compt_CP( String^ compound, double E, double theta ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCSb_Compt_CP(pCompound, E, theta, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCSP_Rayl_CP( String^ compound, double E, double theta, double phi ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCSP_Rayl_CP(pCompound, E, theta, phi, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCSP_Compt_CP( String^ compound, double E, double theta, double phi ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCSP_Compt_CP(pCompound, E, theta, phi, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCSPb_Rayl_CP( String^ compound, double E, double theta, double phi ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCSPb_Rayl_CP(pCompound, E, theta, phi, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::DCSPb_Compt_CP( String^ compound, double E, double theta, double phi ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::DCSPb_Compt_CP(pCompound, E, theta, phi, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CS_Photo_Total_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Photo_Total_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CSb_Photo_Total_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CSb_Photo_Total_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CS_Total_Kissel_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Total_Kissel_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CSb_Total_Kissel_CP( String^ compound, double E ) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CSb_Total_Kissel_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + +double Science::XrayLib::CS_Energy_CP(String^ compound, double E) +{ + double result = -1.0; + + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + result = ::CS_Energy_CP(pCompound, E, &error); + Errors::HandleError(error); + } + finally + { + Marshal::FreeHGlobal(p); + } + + return result; +} + + +double Science::XrayLib::ElectronConfig( int Z, int shell ) +{ + ::xrl_error *error = nullptr; + double result = ::ElectronConfig(Z, shell, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::ComptonProfile( int Z, double pz ) +{ + ::xrl_error *error = nullptr; + double result = ::ComptonProfile(Z, pz, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::ComptonProfile_Partial( int Z, int shell, double pz ) +{ + ::xrl_error *error = nullptr; + double result = ::ComptonProfile_Partial(Z, shell, pz, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::Refractive_Index_Re( String^ compound, double E, double density ) +{ + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + double result = ::Refractive_Index_Re(pCompound, E, density, &error); + Errors::HandleError(error); + return result; + } + finally + { + Marshal::FreeHGlobal(p); + } +} + +double Science::XrayLib::Refractive_Index_Im( String^ compound, double E, double density ) +{ + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrl_error *error = nullptr; + double result = ::Refractive_Index_Im(pCompound, E, density, &error); + Errors::HandleError(error); + return result; + } + finally + { + Marshal::FreeHGlobal(p); + } +} + + +Numerics::Complex Science::XrayLib::Refractive_Index( String^ compound, double E, double density ) +{ + IntPtr p = Marshal::StringToHGlobalAnsi(compound); + try + { + char* pCompound = static_cast(p.ToPointer()); + ::xrlComplex z; + ::xrl_error *error = nullptr; + ::Refractive_Index2(pCompound, E, density, &z, &error); + Errors::HandleError(error); + + return Numerics::Complex(z.re, z.im); + } + finally + { + Marshal::FreeHGlobal(p); + } +} + +double Science::XrayLib::AtomicLevelWidth( int Z, int shell ) +{ + ::xrl_error *error = nullptr; + double result = ::AtomicLevelWidth(Z, shell, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::AugerRate( int Z, int auger_trans ) +{ + ::xrl_error *error = nullptr; + double result = ::AugerRate(Z, auger_trans, &error); + Errors::HandleError(error); + return result; +} + +double Science::XrayLib::AugerYield(int Z, int shell) +{ + ::xrl_error *error = nullptr; + double result = ::AugerYield(Z, shell, &error); + Errors::HandleError(error); + return result; +} + +System::String ^ Science::XrayLib::IUPACToSiegbahnLineName( System::String ^name ) +{ + System::String ^result = ""; + + for (int i = 0; i < IUPACLineNames->Length; i++) + { + if (String::Compare(name, IUPACLineNames[i], StringComparison::InvariantCultureIgnoreCase) == 0) + { + result = SiegbahnLineNames[i]; + break; + } + } + return result; +} + +System::String ^ Science::XrayLib::SiegbahnToIUPACLineName( System::String ^name ) +{ + System::String ^result = ""; + + for(int i = 0; i < SiegbahnLineNames->Length; i++) + { + if (String::Compare(name, SiegbahnLineNames[i], StringComparison::InvariantCultureIgnoreCase) == 0) + { + result = IUPACLineNames[i]; + break; + } + } + return result; +} + + +void Science::XrayLib::ElementAndLineFromName( System::String ^elementLine, int %Z, int %line ) +{ + System::String ^delimitersStr = " "; + array ^delimiters = delimitersStr->ToCharArray(); + System::String ^symbol; + System::String ^lineName; + ElementData^ ed; + + double result = -1.0; + + // Split the name into a element symbol and line name + array ^tokens = elementLine->Split(delimiters, StringSplitOptions::RemoveEmptyEntries); + if (tokens->Length != 2) + throw gcnew XrayLibException(System::String::Format("Invalid X-ray fluorescence line {0}", elementLine)); + + symbol = tokens[0]->ToLower(); + lineName = tokens[1]->ToLower(); + + // Find the atomic number of the specified symbol or throw an + // exception if the symbol is unknown + Z = -99; + for(int i = 1; i <= 100; i++) + { + ed = GetElementData(i); + if (String::Compare(symbol, ed->Symbol, StringComparison::InvariantCultureIgnoreCase) == 0) + { + Z = i; + break; + } + } + if (Z == -99) + throw gcnew XrayLibException(System::String::Format("Unknown atomic symbol {0}", tokens[0])); + + // Find the line number of the specified symbol or throw an + // exception if the line is unknown + line = -99; + if (lineName == "ka") + line = KA_LINE; + else if (lineName == "kb") + line = KB_LINE; + else if (lineName == "la") + line = LA_LINE; + else if (lineName == "lb") + line = LB_LINE; + else if (lineName == "lg") + line = LG1_LINE; + else + { + for(int i = 0; i < 17; i++) + { + if (String::Compare(lineName, SiegbahnLineNames[i], StringComparison::InvariantCultureIgnoreCase) == 0) + { + line = SiegbahnLines[i]; + break; + } + } + } + if (line == -99) + throw gcnew XrayLibException(System::String::Format("Unknown emission line {0}", tokens[1])); +} + +double Science::XrayLib::LineEnergyFromName( System::String ^lineName ) +{ + int Z; + int line; + + ElementAndLineFromName( lineName, Z, line ); + + // Return the X-ray fluorescence energy (keV) + return LineEnergy(Z, line); +} + +int Science::XrayLib::SiegbahnLineIndex( System::String ^name ) +{ + System::String ^lineName = name->Trim()->ToLower(); + + // Find the identifier of the specified line + int line = -99; + if (lineName == "ka") + line = KA_LINE; + else if (lineName == "kb") + line = KB_LINE; + else if (lineName == "la") + line = LA_LINE; + else if (lineName == "lb") + line = LB_LINE; + else if (lineName == "lg") + line = LG1_LINE; + else + { + for(int i = 0; i < 17; i++) + { + if (String::Compare(lineName, SiegbahnLineNames[i], StringComparison::InvariantCultureIgnoreCase) == 0) + { + line = SiegbahnLines[i]; + break; + } + } + } + + return line; +} + +int Science::XrayLib::AtomicNumber( System::String ^name ) +{ + int Z; + ElementData^ ed; + + System::String ^symbol = name->Trim()->ToLower(); + + // Find the atomic number of the specified symbol + Z = -99; + for (int i = 1; i <= 100; i++) + { + ed = GetElementData(i); + if (String::Compare(symbol, ed->Symbol, StringComparison::InvariantCultureIgnoreCase) == 0) + { + Z = i; + break; + } + } + + return Z; +} + +double Science::XrayLib::SiEscapeEnergy( double energy ) +{ + double result = energy - 1.750; + return result; +} + +double Science::XrayLib::SiEscapeFraction( double energy ) +{ + const double rho = 2.329; + const double omegaK = 0.047; + const double r = 10.8; + int Z; + double muI; + double muK; + + Z = 14; // Si + muI = CS_Total(Z, energy)*rho; + muK = CS_Total(Z, 1.750)*rho; + + double result = 0.5*omegaK*(1-1/r)*(1-muK/muI*Math::Log(1+muI/muK)); + return result; +} \ No newline at end of file diff --git a/csharp/XrayLib.NET.h b/csharp/XrayLib.NET.h new file mode 100644 index 00000000..efad19c8 --- /dev/null +++ b/csharp/XrayLib.NET.h @@ -0,0 +1,2413 @@ +/* + XrayLib.NET copyright (c) 2010-2019 Matthew Wormington. All rights reserved. + + File: XrayLib.NET.h + Author: Matthew Wormington + Language: C++/CLI + Compiler: Microsoft Visual Studio 2017 + Created: September 4, 2010 + $Version:$ + $Revision:$ + $RevDate:$ + + Description: + Contains the definition of a managed wrapper class around the native + XrayLib API. + + "A library for X-ray�matter interaction cross sections for + X-ray fluorescence applications". + A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + Spectrochimica Acta Part B 59 (2004) 1725�1731 + http://ftp.esrf.fr/pub/scisoft/xraylib/ + + Notes: + A singleton pattern has been used so that only one instance of the class is ever + created. The Instance property provides a global point of access to the instance. + The implementation is based on the Static Initialization example in the following + Microsoft article: http://msdn.microsoft.com/en-us/library/ms998558.aspx + + + XrayLib copyright (c) 2009, Bruno Golosio, Antonio Brunetti, Manuel Sanchez del + Rio, Tom Schoonjans and Teemu Ikonen. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del Rio, + Tom Schoonjans, Teemu Ikonen and Matthew Wormington ''AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruno Golosio, Antonio + Brunetti, Manuel Sanchez del Rio, Tom Schoonjans and Teemu Ikonen BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + OF SUCH DAMAGE. +*/ + +#pragma once + +using namespace System; +using namespace System::Numerics; + +/// +/// A namespace that contains scientific classes. +/// +namespace Science { + + /// + /// A custom exception that inherits from Exception and is thrown by the XrayLib class. + /// + public ref class XrayLibException: Exception + { + public: + // Overloading the constructor for passing the message associated with the exception + XrayLibException(System::String ^message) : Exception(message) { } + }; + + /// + /// A managed wrapper around the XrayLib library for X-ray matter interaction cross sections + /// for X-ray fluorescence applications. + /// The XrayLib is a library of X-ray matter interaction data for X-ray fluorescence, + /// and other, applications. + /// Notes: + /// Version 3.4 contains improved error handling for the library functions and exposes the functions + /// as static methods of the XrayLib class. + /// References: + /// 1) A library for X-ray matter interaction cross sections for X-ray fluorescence applications. + /// A. Brunetti, M. Sanchez del Rio, B. Golosio, A. Simionovici, A. Somogyi, + /// Spectrochimica Acta Part B 59 (2004) 1725�1731 + /// 2) The xraylib library for X-ray�matter interactions.Recent developments. + /// T.Schoonjans, A.Brunetti, B.Golosio, M.Sanchez del Rio, V.A.Sol�, C.Ferrero, L.Vincze, + /// Spectrochimica Acta Part B 66 (2011) 776�784 + /// https://github.com/tschoonj/xraylib/ + + /// + public ref class XrayLib + { + private: + // Only the main lines are included in the following arrays + static array ^IUPACLineNames = + {"KL3","KL2","KM3","KN2","KM2","L3M5","L3M4","L2M4","L3N5", + "L1M3","L1M2","L3N1","L2N4","L1N2","L1N3","L2M1","L3M1"}; + + // In the SiegbahnLineName array, the following notation is used: + // a - alpha, b - beta, g - gamma, n - Nu, l - eta + static array ^SiegbahnLineNames = + {"Ka1","Ka2","Kb1","Kb2","Kb3","La1","La2","Lb1","Lb2", + "Lb3","Lb4","Lb6","Lg1","Lg2","Lg3","Ln","Ll"}; + static array ^SiegbahnLines = + {KA1_LINE,KA2_LINE,KB1_LINE,KB2_LINE,KB3_LINE,LA1_LINE,LA2_LINE,LB1_LINE,LB2_LINE, + LB3_LINE,LB4_LINE,LB6_LINE,LG1_LINE,LG2_LINE,LG3_LINE,LN_LINE,LL_LINE}; + + public: + #pragma region Constants + literal int VERSION_MAJOR = 4; + literal int VERSION_MINOR = 0; + literal double PI = 3.14159265359; + + // Values taken from physics.nist.gov + literal double AVOGNUM = 0.602214129; // Avogadro number (mol-1 * barn-1 * cm2) + literal double KEV2ANGST = 12.39841930; // keV to Angstrom-1 conversion factor + literal double MEC2 = 510.998928; // Electron rest mass (keV) + literal double RE2 = 0.079407877; // Square of classical electron radius (barn) + literal double R_E = 2.8179403267e-15; // Classical electron radius (m) + + // IUPAC lines + literal int KL1_LINE = -1; + literal int KL2_LINE = -2; + literal int KL3_LINE = -3; + literal int KM1_LINE = -4; + literal int KM2_LINE = -5; + literal int KM3_LINE = -6; + literal int KM4_LINE = -7; + literal int KM5_LINE = -8; + literal int KN1_LINE = -9; + literal int KN2_LINE = -10; + literal int KN3_LINE = -11; + literal int KN4_LINE = -12; + literal int KN5_LINE = -13; + literal int KN6_LINE = -14; + literal int KN7_LINE = -15; + literal int KO_LINE = -16; + literal int KO1_LINE = -17; + literal int KO2_LINE = -18; + literal int KO3_LINE = -19; + literal int KO4_LINE = -20; + literal int KO5_LINE = -21; + literal int KO6_LINE = -22; + literal int KO7_LINE = -23; + literal int KP_LINE = -24; + literal int KP1_LINE = -25; + literal int KP2_LINE = -26; + literal int KP3_LINE = -27; + literal int KP4_LINE = -28; + literal int KP5_LINE = -29; + literal int L1L2_LINE = -30; + literal int L1L3_LINE = -31; + literal int L1M1_LINE = -32; + literal int L1M2_LINE = -33; + literal int L1M3_LINE = -34; + literal int L1M4_LINE = -35; + literal int L1M5_LINE = -36; + literal int L1N1_LINE = -37; + literal int L1N2_LINE = -38; + literal int L1N3_LINE = -39; + literal int L1N4_LINE = -40; + literal int L1N5_LINE = -41; + literal int L1N6_LINE = -42; + literal int L1N67_LINE = -43; + literal int L1N7_LINE = -44; + literal int L1O1_LINE = -45; + literal int L1O2_LINE = -46; + literal int L1O3_LINE = -47; + literal int L1O4_LINE = -48; + literal int L1O45_LINE = -49; + literal int L1O5_LINE = -50; + literal int L1O6_LINE = -51; + literal int L1O7_LINE = -52; + literal int L1P1_LINE = -53; + literal int L1P2_LINE = -54; + literal int L1P23_LINE = -55; + literal int L1P3_LINE = -56; + literal int L1P4_LINE = -57; + literal int L1P5_LINE = -58; + literal int L2L3_LINE = -59; + literal int L2M1_LINE = -60; + literal int L2M2_LINE = -61; + literal int L2M3_LINE = -62; + literal int L2M4_LINE = -63; + literal int L2M5_LINE = -64; + literal int L2N1_LINE = -65; + literal int L2N2_LINE = -66; + literal int L2N3_LINE = -67; + literal int L2N4_LINE = -68; + literal int L2N5_LINE = -69; + literal int L2N6_LINE = -70; + literal int L2N7_LINE = -71; + literal int L2O1_LINE = -72; + literal int L2O2_LINE = -73; + literal int L2O3_LINE = -74; + literal int L2O4_LINE = -75; + literal int L2O5_LINE = -76; + literal int L2O6_LINE = -77; + literal int L2O7_LINE = -78; + literal int L2P1_LINE = -79; + literal int L2P2_LINE = -80; + literal int L2P23_LINE = -81; + literal int L2P3_LINE = -82; + literal int L2P4_LINE = -83; + literal int L2P5_LINE = -84; + literal int L2Q1_LINE = -85; + literal int L3M1_LINE = -86; + literal int L3M2_LINE = -87; + literal int L3M3_LINE = -88; + literal int L3M4_LINE = -89; + literal int L3M5_LINE = -90; + literal int L3N1_LINE = -91; + literal int L3N2_LINE = -92; + literal int L3N3_LINE = -93; + literal int L3N4_LINE = -94; + literal int L3N5_LINE = -95; + literal int L3N6_LINE = -96; + literal int L3N7_LINE = -97; + literal int L3O1_LINE = -98; + literal int L3O2_LINE = -99; + literal int L3O3_LINE = -100; + literal int L3O4_LINE = -101; + literal int L3O45_LINE = -102; + literal int L3O5_LINE = -103; + literal int L3O6_LINE = -104; + literal int L3O7_LINE = -105; + literal int L3P1_LINE = -106; + literal int L3P2_LINE = -107; + literal int L3P23_LINE = -108; + literal int L3P3_LINE = -109; + literal int L3P4_LINE = -110; + literal int L3P45_LINE = -111; + literal int L3P5_LINE = -112; + literal int L3Q1_LINE = -113; + literal int M1M2_LINE = -114; + literal int M1M3_LINE = -115; + literal int M1M4_LINE = -116; + literal int M1M5_LINE = -117; + literal int M1N1_LINE = -118; + literal int M1N2_LINE = -119; + literal int M1N3_LINE = -120; + literal int M1N4_LINE = -121; + literal int M1N5_LINE = -122; + literal int M1N6_LINE = -123; + literal int M1N7_LINE = -124; + literal int M1O1_LINE = -125; + literal int M1O2_LINE = -126; + literal int M1O3_LINE = -127; + literal int M1O4_LINE = -128; + literal int M1O5_LINE = -129; + literal int M1O6_LINE = -130; + literal int M1O7_LINE = -131; + literal int M1P1_LINE = -132; + literal int M1P2_LINE = -133; + literal int M1P3_LINE = -134; + literal int M1P4_LINE = -135; + literal int M1P5_LINE = -136; + literal int M2M3_LINE = -137; + literal int M2M4_LINE = -138; + literal int M2M5_LINE = -139; + literal int M2N1_LINE = -140; + literal int M2N2_LINE = -141; + literal int M2N3_LINE = -142; + literal int M2N4_LINE = -143; + literal int M2N5_LINE = -144; + literal int M2N6_LINE = -145; + literal int M2N7_LINE = -146; + literal int M2O1_LINE = -147; + literal int M2O2_LINE = -148; + literal int M2O3_LINE = -149; + literal int M2O4_LINE = -150; + literal int M2O5_LINE = -151; + literal int M2O6_LINE = -152; + literal int M2O7_LINE = -153; + literal int M2P1_LINE = -154; + literal int M2P2_LINE = -155; + literal int M2P3_LINE = -156; + literal int M2P4_LINE = -157; + literal int M2P5_LINE = -158; + literal int M3M4_LINE = -159; + literal int M3M5_LINE = -160; + literal int M3N1_LINE = -161; + literal int M3N2_LINE = -162; + literal int M3N3_LINE = -163; + literal int M3N4_LINE = -164; + literal int M3N5_LINE = -165; + literal int M3N6_LINE = -166; + literal int M3N7_LINE = -167; + literal int M3O1_LINE = -168; + literal int M3O2_LINE = -169; + literal int M3O3_LINE = -170; + literal int M3O4_LINE = -171; + literal int M3O5_LINE = -172; + literal int M3O6_LINE = -173; + literal int M3O7_LINE = -174; + literal int M3P1_LINE = -175; + literal int M3P2_LINE = -176; + literal int M3P3_LINE = -177; + literal int M3P4_LINE = -178; + literal int M3P5_LINE = -179; + literal int M3Q1_LINE = -180; + literal int M4M5_LINE = -181; + literal int M4N1_LINE = -182; + literal int M4N2_LINE = -183; + literal int M4N3_LINE = -184; + literal int M4N4_LINE = -185; + literal int M4N5_LINE = -186; + literal int M4N6_LINE = -187; + literal int M4N7_LINE = -188; + literal int M4O1_LINE = -189; + literal int M4O2_LINE = -190; + literal int M4O3_LINE = -191; + literal int M4O4_LINE = -192; + literal int M4O5_LINE = -193; + literal int M4O6_LINE = -194; + literal int M4O7_LINE = -195; + literal int M4P1_LINE = -196; + literal int M4P2_LINE = -197; + literal int M4P3_LINE = -198; + literal int M4P4_LINE = -199; + literal int M4P5_LINE = -200; + literal int M5N1_LINE = -201; + literal int M5N2_LINE = -202; + literal int M5N3_LINE = -203; + literal int M5N4_LINE = -204; + literal int M5N5_LINE = -205; + literal int M5N6_LINE = -206; + literal int M5N7_LINE = -207; + literal int M5O1_LINE = -208; + literal int M5O2_LINE = -209; + literal int M5O3_LINE = -210; + literal int M5O4_LINE = -211; + literal int M5O5_LINE = -212; + literal int M5O6_LINE = -213; + literal int M5O7_LINE = -214; + literal int M5P1_LINE = -215; + literal int M5P2_LINE = -216; + literal int M5P3_LINE = -217; + literal int M5P4_LINE = -218; + literal int M5P5_LINE = -219; + literal int N1N2_LINE = -220; + literal int N1N3_LINE = -221; + literal int N1N4_LINE = -222; + literal int N1N5_LINE = -223; + literal int N1N6_LINE = -224; + literal int N1N7_LINE = -225; + literal int N1O1_LINE = -226; + literal int N1O2_LINE = -227; + literal int N1O3_LINE = -228; + literal int N1O4_LINE = -229; + literal int N1O5_LINE = -230; + literal int N1O6_LINE = -231; + literal int N1O7_LINE = -232; + literal int N1P1_LINE = -233; + literal int N1P2_LINE = -234; + literal int N1P3_LINE = -235; + literal int N1P4_LINE = -236; + literal int N1P5_LINE = -237; + literal int N2N3_LINE = -238; + literal int N2N4_LINE = -239; + literal int N2N5_LINE = -240; + literal int N2N6_LINE = -241; + literal int N2N7_LINE = -242; + literal int N2O1_LINE = -243; + literal int N2O2_LINE = -244; + literal int N2O3_LINE = -245; + literal int N2O4_LINE = -246; + literal int N2O5_LINE = -247; + literal int N2O6_LINE = -248; + literal int N2O7_LINE = -249; + literal int N2P1_LINE = -250; + literal int N2P2_LINE = -251; + literal int N2P3_LINE = -252; + literal int N2P4_LINE = -253; + literal int N2P5_LINE = -254; + literal int N3N4_LINE = -255; + literal int N3N5_LINE = -256; + literal int N3N6_LINE = -257; + literal int N3N7_LINE = -258; + literal int N3O1_LINE = -259; + literal int N3O2_LINE = -260; + literal int N3O3_LINE = -261; + literal int N3O4_LINE = -262; + literal int N3O5_LINE = -263; + literal int N3O6_LINE = -264; + literal int N3O7_LINE = -265; + literal int N3P1_LINE = -266; + literal int N3P2_LINE = -267; + literal int N3P3_LINE = -268; + literal int N3P4_LINE = -269; + literal int N3P5_LINE = -270; + literal int N4N5_LINE = -271; + literal int N4N6_LINE = -272; + literal int N4N7_LINE = -273; + literal int N4O1_LINE = -274; + literal int N4O2_LINE = -275; + literal int N4O3_LINE = -276; + literal int N4O4_LINE = -277; + literal int N4O5_LINE = -278; + literal int N4O6_LINE = -279; + literal int N4O7_LINE = -280; + literal int N4P1_LINE = -281; + literal int N4P2_LINE = -282; + literal int N4P3_LINE = -283; + literal int N4P4_LINE = -284; + literal int N4P5_LINE = -285; + literal int N5N6_LINE = -286; + literal int N5N7_LINE = -287; + literal int N5O1_LINE = -288; + literal int N5O2_LINE = -289; + literal int N5O3_LINE = -290; + literal int N5O4_LINE = -291; + literal int N5O5_LINE = -292; + literal int N5O6_LINE = -293; + literal int N5O7_LINE = -294; + literal int N5P1_LINE = -295; + literal int N5P2_LINE = -296; + literal int N5P3_LINE = -297; + literal int N5P4_LINE = -298; + literal int N5P5_LINE = -299; + literal int N6N7_LINE = -300; + literal int N6O1_LINE = -301; + literal int N6O2_LINE = -302; + literal int N6O3_LINE = -303; + literal int N6O4_LINE = -304; + literal int N6O5_LINE = -305; + literal int N6O6_LINE = -306; + literal int N6O7_LINE = -307; + literal int N6P1_LINE = -308; + literal int N6P2_LINE = -309; + literal int N6P3_LINE = -310; + literal int N6P4_LINE = -311; + literal int N6P5_LINE = -312; + literal int N7O1_LINE = -313; + literal int N7O2_LINE = -314; + literal int N7O3_LINE = -315; + literal int N7O4_LINE = -316; + literal int N7O5_LINE = -317; + literal int N7O6_LINE = -318; + literal int N7O7_LINE = -319; + literal int N7P1_LINE = -320; + literal int N7P2_LINE = -321; + literal int N7P3_LINE = -322; + literal int N7P4_LINE = -323; + literal int N7P5_LINE = -324; + literal int O1O2_LINE = -325; + literal int O1O3_LINE = -326; + literal int O1O4_LINE = -327; + literal int O1O5_LINE = -328; + literal int O1O6_LINE = -329; + literal int O1O7_LINE = -330; + literal int O1P1_LINE = -331; + literal int O1P2_LINE = -332; + literal int O1P3_LINE = -333; + literal int O1P4_LINE = -334; + literal int O1P5_LINE = -335; + literal int O2O3_LINE = -336; + literal int O2O4_LINE = -337; + literal int O2O5_LINE = -338; + literal int O2O6_LINE = -339; + literal int O2O7_LINE = -340; + literal int O2P1_LINE = -341; + literal int O2P2_LINE = -342; + literal int O2P3_LINE = -343; + literal int O2P4_LINE = -344; + literal int O2P5_LINE = -345; + literal int O3O4_LINE = -346; + literal int O3O5_LINE = -347; + literal int O3O6_LINE = -348; + literal int O3O7_LINE = -349; + literal int O3P1_LINE = -350; + literal int O3P2_LINE = -351; + literal int O3P3_LINE = -352; + literal int O3P4_LINE = -353; + literal int O3P5_LINE = -354; + literal int O4O5_LINE = -355; + literal int O4O6_LINE = -356; + literal int O4O7_LINE = -357; + literal int O4P1_LINE = -358; + literal int O4P2_LINE = -359; + literal int O4P3_LINE = -360; + literal int O4P4_LINE = -361; + literal int O4P5_LINE = -362; + literal int O5O6_LINE = -363; + literal int O5O7_LINE = -364; + literal int O5P1_LINE = -365; + literal int O5P2_LINE = -366; + literal int O5P3_LINE = -367; + literal int O5P4_LINE = -368; + literal int O5P5_LINE = -369; + literal int O6O7_LINE = -370; + literal int O6P4_LINE = -371; + literal int O6P5_LINE = -372; + literal int O7P4_LINE = -373; + literal int O7P5_LINE = -374; + literal int P1P2_LINE = -375; + literal int P1P3_LINE = -376; + literal int P1P4_LINE = -377; + literal int P1P5_LINE = -378; + literal int P2P3_LINE = -379; + literal int P2P4_LINE = -380; + literal int P2P5_LINE = -381; + literal int P3P4_LINE = -382; + literal int P3P5_LINE = -383; + + // Siegbahn notation + // according to Table VIII.2 from Nomenclature system for X-ray spectroscopy + // Linegroups -> usage is discouraged + literal int KA_LINE = 0; // Weighted average of KA1 & KA2 + literal int KB_LINE = 1; // Weighted average of KB1 & KB3 + literal int LA_LINE = 2; // LA1 + literal int LB_LINE = 3; // LB1 + + // Single lines + literal int KA1_LINE = KL3_LINE; + literal int KA2_LINE = KL2_LINE; + literal int KA3_LINE = KL1_LINE; + literal int KB1_LINE = KM3_LINE; + literal int KB2_LINE = KN3_LINE; + literal int KB3_LINE = KM2_LINE; + literal int KB4_LINE = KN5_LINE; + literal int KB5_LINE = KM5_LINE; + + literal int LA1_LINE = L3M5_LINE; + literal int LA2_LINE = L3M4_LINE; + literal int LB1_LINE = L2M4_LINE; + literal int LB2_LINE = L3N5_LINE; + literal int LB3_LINE = L1M3_LINE; + literal int LB4_LINE = L1M2_LINE; + literal int LB5_LINE = L3O45_LINE; + literal int LB6_LINE = L3N1_LINE; + literal int LB7_LINE = L3O1_LINE; + literal int LB9_LINE = L1M5_LINE; + literal int LB10_LINE = L1M4_LINE; + literal int LB15_LINE = L3N4_LINE; + literal int LB17_LINE = L2M3_LINE; + literal int LG1_LINE = L2N4_LINE; + literal int LG2_LINE = L1N2_LINE; + literal int LG3_LINE = L1N3_LINE; + literal int LG4_LINE = L1O3_LINE; + literal int LG5_LINE = L2N1_LINE; + literal int LG6_LINE = L2O4_LINE; + literal int LG8_LINE = L2O1_LINE; + literal int LE_LINE = L2M1_LINE; + literal int LH_LINE = L2M1_LINE; + literal int LN_LINE = L2M1_LINE; + literal int LL_LINE = L3M1_LINE; + literal int LS_LINE = L3M3_LINE; + literal int LT_LINE = L3M2_LINE; + literal int LU_LINE = L3N6_LINE; + literal int LV_LINE = L2N6_LINE; + + literal int MA1_LINE = M5N7_LINE; + literal int MA2_LINE = M5N6_LINE; + literal int MB_LINE = M4N6_LINE; + literal int MG_LINE = M3N5_LINE; + + // Shells + literal int K_SHELL = 0; + literal int L1_SHELL = 1; + literal int L2_SHELL = 2; + literal int L3_SHELL = 3; + literal int M1_SHELL = 4; + literal int M2_SHELL = 5; + literal int M3_SHELL = 6; + literal int M4_SHELL = 7; + literal int M5_SHELL = 8; + literal int N1_SHELL = 9; + literal int N2_SHELL = 10; + literal int N3_SHELL = 11; + literal int N4_SHELL = 12; + literal int N5_SHELL = 13; + literal int N6_SHELL = 14; + literal int N7_SHELL = 15; + literal int O1_SHELL = 16; + literal int O2_SHELL = 17; + literal int O3_SHELL = 18; + literal int O4_SHELL = 19; + literal int O5_SHELL = 20; + literal int O6_SHELL = 21; + literal int O7_SHELL = 22; + literal int P1_SHELL = 23; + literal int P2_SHELL = 24; + literal int P3_SHELL = 25; + literal int P4_SHELL = 26; + literal int P5_SHELL = 27; + literal int Q1_SHELL = 28; + literal int Q2_SHELL = 29; + literal int Q3_SHELL = 30; + + // Transitions + literal int F1_TRANS = 0; + literal int F12_TRANS = 1; + literal int F13_TRANS = 2; + literal int FP13_TRANS = 3; + literal int F23_TRANS = 4; + + literal int FL12_TRANS = 1; + literal int FL13_TRANS = 2; + literal int FLP13_TRANS = 3; + literal int FL23_TRANS = 4; + literal int FM12_TRANS = 5; + literal int FM13_TRANS = 6; + literal int FM14_TRANS = 7; + literal int FM15_TRANS = 8; + literal int FM23_TRANS = 9; + literal int FM24_TRANS = 10; + literal int FM25_TRANS = 11; + literal int FM34_TRANS = 12; + literal int FM35_TRANS = 13; + literal int FM45_TRANS = 14; + + // Auger transitions + literal int K_L1L1_AUGER = 0; + literal int K_L1L2_AUGER = 1; + literal int K_L1L3_AUGER = 2; + literal int K_L1M1_AUGER = 3; + literal int K_L1M2_AUGER = 4; + literal int K_L1M3_AUGER = 5; + literal int K_L1M4_AUGER = 6; + literal int K_L1M5_AUGER = 7; + literal int K_L1N1_AUGER = 8; + literal int K_L1N2_AUGER = 9; + literal int K_L1N3_AUGER = 10; + literal int K_L1N4_AUGER = 11; + literal int K_L1N5_AUGER = 12; + literal int K_L1N6_AUGER = 13; + literal int K_L1N7_AUGER = 14; + literal int K_L1O1_AUGER = 15; + literal int K_L1O2_AUGER = 16; + literal int K_L1O3_AUGER = 17; + literal int K_L1O4_AUGER = 18; + literal int K_L1O5_AUGER = 19; + literal int K_L1O6_AUGER = 20; + literal int K_L1O7_AUGER = 21; + literal int K_L1P1_AUGER = 22; + literal int K_L1P2_AUGER = 23; + literal int K_L1P3_AUGER = 24; + literal int K_L1P4_AUGER = 25; + literal int K_L1P5_AUGER = 26; + literal int K_L1Q1_AUGER = 27; + literal int K_L1Q2_AUGER = 28; + literal int K_L1Q3_AUGER = 29; + literal int K_L2L1_AUGER = 30; + literal int K_L2L2_AUGER = 31; + literal int K_L2L3_AUGER = 32; + literal int K_L2M1_AUGER = 33; + literal int K_L2M2_AUGER = 34; + literal int K_L2M3_AUGER = 35; + literal int K_L2M4_AUGER = 36; + literal int K_L2M5_AUGER = 37; + literal int K_L2N1_AUGER = 38; + literal int K_L2N2_AUGER = 39; + literal int K_L2N3_AUGER = 40; + literal int K_L2N4_AUGER = 41; + literal int K_L2N5_AUGER = 42; + literal int K_L2N6_AUGER = 43; + literal int K_L2N7_AUGER = 44; + literal int K_L2O1_AUGER = 45; + literal int K_L2O2_AUGER = 46; + literal int K_L2O3_AUGER = 47; + literal int K_L2O4_AUGER = 48; + literal int K_L2O5_AUGER = 49; + literal int K_L2O6_AUGER = 50; + literal int K_L2O7_AUGER = 51; + literal int K_L2P1_AUGER = 52; + literal int K_L2P2_AUGER = 53; + literal int K_L2P3_AUGER = 54; + literal int K_L2P4_AUGER = 55; + literal int K_L2P5_AUGER = 56; + literal int K_L2Q1_AUGER = 57; + literal int K_L2Q2_AUGER = 58; + literal int K_L2Q3_AUGER = 59; + literal int K_L3L1_AUGER = 60; + literal int K_L3L2_AUGER = 61; + literal int K_L3L3_AUGER = 62; + literal int K_L3M1_AUGER = 63; + literal int K_L3M2_AUGER = 64; + literal int K_L3M3_AUGER = 65; + literal int K_L3M4_AUGER = 66; + literal int K_L3M5_AUGER = 67; + literal int K_L3N1_AUGER = 68; + literal int K_L3N2_AUGER = 69; + literal int K_L3N3_AUGER = 70; + literal int K_L3N4_AUGER = 71; + literal int K_L3N5_AUGER = 72; + literal int K_L3N6_AUGER = 73; + literal int K_L3N7_AUGER = 74; + literal int K_L3O1_AUGER = 75; + literal int K_L3O2_AUGER = 76; + literal int K_L3O3_AUGER = 77; + literal int K_L3O4_AUGER = 78; + literal int K_L3O5_AUGER = 79; + literal int K_L3O6_AUGER = 80; + literal int K_L3O7_AUGER = 81; + literal int K_L3P1_AUGER = 82; + literal int K_L3P2_AUGER = 83; + literal int K_L3P3_AUGER = 84; + literal int K_L3P4_AUGER = 85; + literal int K_L3P5_AUGER = 86; + literal int K_L3Q1_AUGER = 87; + literal int K_L3Q2_AUGER = 88; + literal int K_L3Q3_AUGER = 89; + literal int K_M1L1_AUGER = 90; + literal int K_M1L2_AUGER = 91; + literal int K_M1L3_AUGER = 92; + literal int K_M1M1_AUGER = 93; + literal int K_M1M2_AUGER = 94; + literal int K_M1M3_AUGER = 95; + literal int K_M1M4_AUGER = 96; + literal int K_M1M5_AUGER = 97; + literal int K_M1N1_AUGER = 98; + literal int K_M1N2_AUGER = 99; + literal int K_M1N3_AUGER = 100; + literal int K_M1N4_AUGER = 101; + literal int K_M1N5_AUGER = 102; + literal int K_M1N6_AUGER = 103; + literal int K_M1N7_AUGER = 104; + literal int K_M1O1_AUGER = 105; + literal int K_M1O2_AUGER = 106; + literal int K_M1O3_AUGER = 107; + literal int K_M1O4_AUGER = 108; + literal int K_M1O5_AUGER = 109; + literal int K_M1O6_AUGER = 110; + literal int K_M1O7_AUGER = 111; + literal int K_M1P1_AUGER = 112; + literal int K_M1P2_AUGER = 113; + literal int K_M1P3_AUGER = 114; + literal int K_M1P4_AUGER = 115; + literal int K_M1P5_AUGER = 116; + literal int K_M1Q1_AUGER = 117; + literal int K_M1Q2_AUGER = 118; + literal int K_M1Q3_AUGER = 119; + literal int K_M2L1_AUGER = 120; + literal int K_M2L2_AUGER = 121; + literal int K_M2L3_AUGER = 122; + literal int K_M2M1_AUGER = 123; + literal int K_M2M2_AUGER = 124; + literal int K_M2M3_AUGER = 125; + literal int K_M2M4_AUGER = 126; + literal int K_M2M5_AUGER = 127; + literal int K_M2N1_AUGER = 128; + literal int K_M2N2_AUGER = 129; + literal int K_M2N3_AUGER = 130; + literal int K_M2N4_AUGER = 131; + literal int K_M2N5_AUGER = 132; + literal int K_M2N6_AUGER = 133; + literal int K_M2N7_AUGER = 134; + literal int K_M2O1_AUGER = 135; + literal int K_M2O2_AUGER = 136; + literal int K_M2O3_AUGER = 137; + literal int K_M2O4_AUGER = 138; + literal int K_M2O5_AUGER = 139; + literal int K_M2O6_AUGER = 140; + literal int K_M2O7_AUGER = 141; + literal int K_M2P1_AUGER = 142; + literal int K_M2P2_AUGER = 143; + literal int K_M2P3_AUGER = 144; + literal int K_M2P4_AUGER = 145; + literal int K_M2P5_AUGER = 146; + literal int K_M2Q1_AUGER = 147; + literal int K_M2Q2_AUGER = 148; + literal int K_M2Q3_AUGER = 149; + literal int K_M3L1_AUGER = 150; + literal int K_M3L2_AUGER = 151; + literal int K_M3L3_AUGER = 152; + literal int K_M3M1_AUGER = 153; + literal int K_M3M2_AUGER = 154; + literal int K_M3M3_AUGER = 155; + literal int K_M3M4_AUGER = 156; + literal int K_M3M5_AUGER = 157; + literal int K_M3N1_AUGER = 158; + literal int K_M3N2_AUGER = 159; + literal int K_M3N3_AUGER = 160; + literal int K_M3N4_AUGER = 161; + literal int K_M3N5_AUGER = 162; + literal int K_M3N6_AUGER = 163; + literal int K_M3N7_AUGER = 164; + literal int K_M3O1_AUGER = 165; + literal int K_M3O2_AUGER = 166; + literal int K_M3O3_AUGER = 167; + literal int K_M3O4_AUGER = 168; + literal int K_M3O5_AUGER = 169; + literal int K_M3O6_AUGER = 170; + literal int K_M3O7_AUGER = 171; + literal int K_M3P1_AUGER = 172; + literal int K_M3P2_AUGER = 173; + literal int K_M3P3_AUGER = 174; + literal int K_M3P4_AUGER = 175; + literal int K_M3P5_AUGER = 176; + literal int K_M3Q1_AUGER = 177; + literal int K_M3Q2_AUGER = 178; + literal int K_M3Q3_AUGER = 179; + literal int K_M4L1_AUGER = 180; + literal int K_M4L2_AUGER = 181; + literal int K_M4L3_AUGER = 182; + literal int K_M4M1_AUGER = 183; + literal int K_M4M2_AUGER = 184; + literal int K_M4M3_AUGER = 185; + literal int K_M4M4_AUGER = 186; + literal int K_M4M5_AUGER = 187; + literal int K_M4N1_AUGER = 188; + literal int K_M4N2_AUGER = 189; + literal int K_M4N3_AUGER = 190; + literal int K_M4N4_AUGER = 191; + literal int K_M4N5_AUGER = 192; + literal int K_M4N6_AUGER = 193; + literal int K_M4N7_AUGER = 194; + literal int K_M4O1_AUGER = 195; + literal int K_M4O2_AUGER = 196; + literal int K_M4O3_AUGER = 197; + literal int K_M4O4_AUGER = 198; + literal int K_M4O5_AUGER = 199; + literal int K_M4O6_AUGER = 200; + literal int K_M4O7_AUGER = 201; + literal int K_M4P1_AUGER = 202; + literal int K_M4P2_AUGER = 203; + literal int K_M4P3_AUGER = 204; + literal int K_M4P4_AUGER = 205; + literal int K_M4P5_AUGER = 206; + literal int K_M4Q1_AUGER = 207; + literal int K_M4Q2_AUGER = 208; + literal int K_M4Q3_AUGER = 209; + literal int K_M5L1_AUGER = 210; + literal int K_M5L2_AUGER = 211; + literal int K_M5L3_AUGER = 212; + literal int K_M5M1_AUGER = 213; + literal int K_M5M2_AUGER = 214; + literal int K_M5M3_AUGER = 215; + literal int K_M5M4_AUGER = 216; + literal int K_M5M5_AUGER = 217; + literal int K_M5N1_AUGER = 218; + literal int K_M5N2_AUGER = 219; + literal int K_M5N3_AUGER = 220; + literal int K_M5N4_AUGER = 221; + literal int K_M5N5_AUGER = 222; + literal int K_M5N6_AUGER = 223; + literal int K_M5N7_AUGER = 224; + literal int K_M5O1_AUGER = 225; + literal int K_M5O2_AUGER = 226; + literal int K_M5O3_AUGER = 227; + literal int K_M5O4_AUGER = 228; + literal int K_M5O5_AUGER = 229; + literal int K_M5O6_AUGER = 230; + literal int K_M5O7_AUGER = 231; + literal int K_M5P1_AUGER = 232; + literal int K_M5P2_AUGER = 233; + literal int K_M5P3_AUGER = 234; + literal int K_M5P4_AUGER = 235; + literal int K_M5P5_AUGER = 236; + literal int K_M5Q1_AUGER = 237; + literal int K_M5Q2_AUGER = 238; + literal int K_M5Q3_AUGER = 239; + literal int L1_L2L2_AUGER = 240; + literal int L1_L2L3_AUGER = 241; + literal int L1_L2M1_AUGER = 242; + literal int L1_L2M2_AUGER = 243; + literal int L1_L2M3_AUGER = 244; + literal int L1_L2M4_AUGER = 245; + literal int L1_L2M5_AUGER = 246; + literal int L1_L2N1_AUGER = 247; + literal int L1_L2N2_AUGER = 248; + literal int L1_L2N3_AUGER = 249; + literal int L1_L2N4_AUGER = 250; + literal int L1_L2N5_AUGER = 251; + literal int L1_L2N6_AUGER = 252; + literal int L1_L2N7_AUGER = 253; + literal int L1_L2O1_AUGER = 254; + literal int L1_L2O2_AUGER = 255; + literal int L1_L2O3_AUGER = 256; + literal int L1_L2O4_AUGER = 257; + literal int L1_L2O5_AUGER = 258; + literal int L1_L2O6_AUGER = 259; + literal int L1_L2O7_AUGER = 260; + literal int L1_L2P1_AUGER = 261; + literal int L1_L2P2_AUGER = 262; + literal int L1_L2P3_AUGER = 263; + literal int L1_L2P4_AUGER = 264; + literal int L1_L2P5_AUGER = 265; + literal int L1_L2Q1_AUGER = 266; + literal int L1_L2Q2_AUGER = 267; + literal int L1_L2Q3_AUGER = 268; + literal int L1_L3L2_AUGER = 269; + literal int L1_L3L3_AUGER = 270; + literal int L1_L3M1_AUGER = 271; + literal int L1_L3M2_AUGER = 272; + literal int L1_L3M3_AUGER = 273; + literal int L1_L3M4_AUGER = 274; + literal int L1_L3M5_AUGER = 275; + literal int L1_L3N1_AUGER = 276; + literal int L1_L3N2_AUGER = 277; + literal int L1_L3N3_AUGER = 278; + literal int L1_L3N4_AUGER = 279; + literal int L1_L3N5_AUGER = 280; + literal int L1_L3N6_AUGER = 281; + literal int L1_L3N7_AUGER = 282; + literal int L1_L3O1_AUGER = 283; + literal int L1_L3O2_AUGER = 284; + literal int L1_L3O3_AUGER = 285; + literal int L1_L3O4_AUGER = 286; + literal int L1_L3O5_AUGER = 287; + literal int L1_L3O6_AUGER = 288; + literal int L1_L3O7_AUGER = 289; + literal int L1_L3P1_AUGER = 290; + literal int L1_L3P2_AUGER = 291; + literal int L1_L3P3_AUGER = 292; + literal int L1_L3P4_AUGER = 293; + literal int L1_L3P5_AUGER = 294; + literal int L1_L3Q1_AUGER = 295; + literal int L1_L3Q2_AUGER = 296; + literal int L1_L3Q3_AUGER = 297; + literal int L1_M1L2_AUGER = 298; + literal int L1_M1L3_AUGER = 299; + literal int L1_M1M1_AUGER = 300; + literal int L1_M1M2_AUGER = 301; + literal int L1_M1M3_AUGER = 302; + literal int L1_M1M4_AUGER = 303; + literal int L1_M1M5_AUGER = 304; + literal int L1_M1N1_AUGER = 305; + literal int L1_M1N2_AUGER = 306; + literal int L1_M1N3_AUGER = 307; + literal int L1_M1N4_AUGER = 308; + literal int L1_M1N5_AUGER = 309; + literal int L1_M1N6_AUGER = 310; + literal int L1_M1N7_AUGER = 311; + literal int L1_M1O1_AUGER = 312; + literal int L1_M1O2_AUGER = 313; + literal int L1_M1O3_AUGER = 314; + literal int L1_M1O4_AUGER = 315; + literal int L1_M1O5_AUGER = 316; + literal int L1_M1O6_AUGER = 317; + literal int L1_M1O7_AUGER = 318; + literal int L1_M1P1_AUGER = 319; + literal int L1_M1P2_AUGER = 320; + literal int L1_M1P3_AUGER = 321; + literal int L1_M1P4_AUGER = 322; + literal int L1_M1P5_AUGER = 323; + literal int L1_M1Q1_AUGER = 324; + literal int L1_M1Q2_AUGER = 325; + literal int L1_M1Q3_AUGER = 326; + literal int L1_M2L2_AUGER = 327; + literal int L1_M2L3_AUGER = 328; + literal int L1_M2M1_AUGER = 329; + literal int L1_M2M2_AUGER = 330; + literal int L1_M2M3_AUGER = 331; + literal int L1_M2M4_AUGER = 332; + literal int L1_M2M5_AUGER = 333; + literal int L1_M2N1_AUGER = 334; + literal int L1_M2N2_AUGER = 335; + literal int L1_M2N3_AUGER = 336; + literal int L1_M2N4_AUGER = 337; + literal int L1_M2N5_AUGER = 338; + literal int L1_M2N6_AUGER = 339; + literal int L1_M2N7_AUGER = 340; + literal int L1_M2O1_AUGER = 341; + literal int L1_M2O2_AUGER = 342; + literal int L1_M2O3_AUGER = 343; + literal int L1_M2O4_AUGER = 344; + literal int L1_M2O5_AUGER = 345; + literal int L1_M2O6_AUGER = 346; + literal int L1_M2O7_AUGER = 347; + literal int L1_M2P1_AUGER = 348; + literal int L1_M2P2_AUGER = 349; + literal int L1_M2P3_AUGER = 350; + literal int L1_M2P4_AUGER = 351; + literal int L1_M2P5_AUGER = 352; + literal int L1_M2Q1_AUGER = 353; + literal int L1_M2Q2_AUGER = 354; + literal int L1_M2Q3_AUGER = 355; + literal int L1_M3L2_AUGER = 356; + literal int L1_M3L3_AUGER = 357; + literal int L1_M3M1_AUGER = 358; + literal int L1_M3M2_AUGER = 359; + literal int L1_M3M3_AUGER = 360; + literal int L1_M3M4_AUGER = 361; + literal int L1_M3M5_AUGER = 362; + literal int L1_M3N1_AUGER = 363; + literal int L1_M3N2_AUGER = 364; + literal int L1_M3N3_AUGER = 365; + literal int L1_M3N4_AUGER = 366; + literal int L1_M3N5_AUGER = 367; + literal int L1_M3N6_AUGER = 368; + literal int L1_M3N7_AUGER = 369; + literal int L1_M3O1_AUGER = 370; + literal int L1_M3O2_AUGER = 371; + literal int L1_M3O3_AUGER = 372; + literal int L1_M3O4_AUGER = 373; + literal int L1_M3O5_AUGER = 374; + literal int L1_M3O6_AUGER = 375; + literal int L1_M3O7_AUGER = 376; + literal int L1_M3P1_AUGER = 377; + literal int L1_M3P2_AUGER = 378; + literal int L1_M3P3_AUGER = 379; + literal int L1_M3P4_AUGER = 380; + literal int L1_M3P5_AUGER = 381; + literal int L1_M3Q1_AUGER = 382; + literal int L1_M3Q2_AUGER = 383; + literal int L1_M3Q3_AUGER = 384; + literal int L1_M4L2_AUGER = 385; + literal int L1_M4L3_AUGER = 386; + literal int L1_M4M1_AUGER = 387; + literal int L1_M4M2_AUGER = 388; + literal int L1_M4M3_AUGER = 389; + literal int L1_M4M4_AUGER = 390; + literal int L1_M4M5_AUGER = 391; + literal int L1_M4N1_AUGER = 392; + literal int L1_M4N2_AUGER = 393; + literal int L1_M4N3_AUGER = 394; + literal int L1_M4N4_AUGER = 395; + literal int L1_M4N5_AUGER = 396; + literal int L1_M4N6_AUGER = 397; + literal int L1_M4N7_AUGER = 398; + literal int L1_M4O1_AUGER = 399; + literal int L1_M4O2_AUGER = 400; + literal int L1_M4O3_AUGER = 401; + literal int L1_M4O4_AUGER = 402; + literal int L1_M4O5_AUGER = 403; + literal int L1_M4O6_AUGER = 404; + literal int L1_M4O7_AUGER = 405; + literal int L1_M4P1_AUGER = 406; + literal int L1_M4P2_AUGER = 407; + literal int L1_M4P3_AUGER = 408; + literal int L1_M4P4_AUGER = 409; + literal int L1_M4P5_AUGER = 410; + literal int L1_M4Q1_AUGER = 411; + literal int L1_M4Q2_AUGER = 412; + literal int L1_M4Q3_AUGER = 413; + literal int L1_M5L2_AUGER = 414; + literal int L1_M5L3_AUGER = 415; + literal int L1_M5M1_AUGER = 416; + literal int L1_M5M2_AUGER = 417; + literal int L1_M5M3_AUGER = 418; + literal int L1_M5M4_AUGER = 419; + literal int L1_M5M5_AUGER = 420; + literal int L1_M5N1_AUGER = 421; + literal int L1_M5N2_AUGER = 422; + literal int L1_M5N3_AUGER = 423; + literal int L1_M5N4_AUGER = 424; + literal int L1_M5N5_AUGER = 425; + literal int L1_M5N6_AUGER = 426; + literal int L1_M5N7_AUGER = 427; + literal int L1_M5O1_AUGER = 428; + literal int L1_M5O2_AUGER = 429; + literal int L1_M5O3_AUGER = 430; + literal int L1_M5O4_AUGER = 431; + literal int L1_M5O5_AUGER = 432; + literal int L1_M5O6_AUGER = 433; + literal int L1_M5O7_AUGER = 434; + literal int L1_M5P1_AUGER = 435; + literal int L1_M5P2_AUGER = 436; + literal int L1_M5P3_AUGER = 437; + literal int L1_M5P4_AUGER = 438; + literal int L1_M5P5_AUGER = 439; + literal int L1_M5Q1_AUGER = 440; + literal int L1_M5Q2_AUGER = 441; + literal int L1_M5Q3_AUGER = 442; + literal int L2_L3L3_AUGER = 443; + literal int L2_L3M1_AUGER = 444; + literal int L2_L3M2_AUGER = 445; + literal int L2_L3M3_AUGER = 446; + literal int L2_L3M4_AUGER = 447; + literal int L2_L3M5_AUGER = 448; + literal int L2_L3N1_AUGER = 449; + literal int L2_L3N2_AUGER = 450; + literal int L2_L3N3_AUGER = 451; + literal int L2_L3N4_AUGER = 452; + literal int L2_L3N5_AUGER = 453; + literal int L2_L3N6_AUGER = 454; + literal int L2_L3N7_AUGER = 455; + literal int L2_L3O1_AUGER = 456; + literal int L2_L3O2_AUGER = 457; + literal int L2_L3O3_AUGER = 458; + literal int L2_L3O4_AUGER = 459; + literal int L2_L3O5_AUGER = 460; + literal int L2_L3O6_AUGER = 461; + literal int L2_L3O7_AUGER = 462; + literal int L2_L3P1_AUGER = 463; + literal int L2_L3P2_AUGER = 464; + literal int L2_L3P3_AUGER = 465; + literal int L2_L3P4_AUGER = 466; + literal int L2_L3P5_AUGER = 467; + literal int L2_L3Q1_AUGER = 468; + literal int L2_L3Q2_AUGER = 469; + literal int L2_L3Q3_AUGER = 470; + literal int L2_M1L3_AUGER = 471; + literal int L2_M1M1_AUGER = 472; + literal int L2_M1M2_AUGER = 473; + literal int L2_M1M3_AUGER = 474; + literal int L2_M1M4_AUGER = 475; + literal int L2_M1M5_AUGER = 476; + literal int L2_M1N1_AUGER = 477; + literal int L2_M1N2_AUGER = 478; + literal int L2_M1N3_AUGER = 479; + literal int L2_M1N4_AUGER = 480; + literal int L2_M1N5_AUGER = 481; + literal int L2_M1N6_AUGER = 482; + literal int L2_M1N7_AUGER = 483; + literal int L2_M1O1_AUGER = 484; + literal int L2_M1O2_AUGER = 485; + literal int L2_M1O3_AUGER = 486; + literal int L2_M1O4_AUGER = 487; + literal int L2_M1O5_AUGER = 488; + literal int L2_M1O6_AUGER = 489; + literal int L2_M1O7_AUGER = 490; + literal int L2_M1P1_AUGER = 491; + literal int L2_M1P2_AUGER = 492; + literal int L2_M1P3_AUGER = 493; + literal int L2_M1P4_AUGER = 494; + literal int L2_M1P5_AUGER = 495; + literal int L2_M1Q1_AUGER = 496; + literal int L2_M1Q2_AUGER = 497; + literal int L2_M1Q3_AUGER = 498; + literal int L2_M2L3_AUGER = 499; + literal int L2_M2M1_AUGER = 500; + literal int L2_M2M2_AUGER = 501; + literal int L2_M2M3_AUGER = 502; + literal int L2_M2M4_AUGER = 503; + literal int L2_M2M5_AUGER = 504; + literal int L2_M2N1_AUGER = 505; + literal int L2_M2N2_AUGER = 506; + literal int L2_M2N3_AUGER = 507; + literal int L2_M2N4_AUGER = 508; + literal int L2_M2N5_AUGER = 509; + literal int L2_M2N6_AUGER = 510; + literal int L2_M2N7_AUGER = 511; + literal int L2_M2O1_AUGER = 512; + literal int L2_M2O2_AUGER = 513; + literal int L2_M2O3_AUGER = 514; + literal int L2_M2O4_AUGER = 515; + literal int L2_M2O5_AUGER = 516; + literal int L2_M2O6_AUGER = 517; + literal int L2_M2O7_AUGER = 518; + literal int L2_M2P1_AUGER = 519; + literal int L2_M2P2_AUGER = 520; + literal int L2_M2P3_AUGER = 521; + literal int L2_M2P4_AUGER = 522; + literal int L2_M2P5_AUGER = 523; + literal int L2_M2Q1_AUGER = 524; + literal int L2_M2Q2_AUGER = 525; + literal int L2_M2Q3_AUGER = 526; + literal int L2_M3L3_AUGER = 527; + literal int L2_M3M1_AUGER = 528; + literal int L2_M3M2_AUGER = 529; + literal int L2_M3M3_AUGER = 530; + literal int L2_M3M4_AUGER = 531; + literal int L2_M3M5_AUGER = 532; + literal int L2_M3N1_AUGER = 533; + literal int L2_M3N2_AUGER = 534; + literal int L2_M3N3_AUGER = 535; + literal int L2_M3N4_AUGER = 536; + literal int L2_M3N5_AUGER = 537; + literal int L2_M3N6_AUGER = 538; + literal int L2_M3N7_AUGER = 539; + literal int L2_M3O1_AUGER = 540; + literal int L2_M3O2_AUGER = 541; + literal int L2_M3O3_AUGER = 542; + literal int L2_M3O4_AUGER = 543; + literal int L2_M3O5_AUGER = 544; + literal int L2_M3O6_AUGER = 545; + literal int L2_M3O7_AUGER = 546; + literal int L2_M3P1_AUGER = 547; + literal int L2_M3P2_AUGER = 548; + literal int L2_M3P3_AUGER = 549; + literal int L2_M3P4_AUGER = 550; + literal int L2_M3P5_AUGER = 551; + literal int L2_M3Q1_AUGER = 552; + literal int L2_M3Q2_AUGER = 553; + literal int L2_M3Q3_AUGER = 554; + literal int L2_M4L3_AUGER = 555; + literal int L2_M4M1_AUGER = 556; + literal int L2_M4M2_AUGER = 557; + literal int L2_M4M3_AUGER = 558; + literal int L2_M4M4_AUGER = 559; + literal int L2_M4M5_AUGER = 560; + literal int L2_M4N1_AUGER = 561; + literal int L2_M4N2_AUGER = 562; + literal int L2_M4N3_AUGER = 563; + literal int L2_M4N4_AUGER = 564; + literal int L2_M4N5_AUGER = 565; + literal int L2_M4N6_AUGER = 566; + literal int L2_M4N7_AUGER = 567; + literal int L2_M4O1_AUGER = 568; + literal int L2_M4O2_AUGER = 569; + literal int L2_M4O3_AUGER = 570; + literal int L2_M4O4_AUGER = 571; + literal int L2_M4O5_AUGER = 572; + literal int L2_M4O6_AUGER = 573; + literal int L2_M4O7_AUGER = 574; + literal int L2_M4P1_AUGER = 575; + literal int L2_M4P2_AUGER = 576; + literal int L2_M4P3_AUGER = 577; + literal int L2_M4P4_AUGER = 578; + literal int L2_M4P5_AUGER = 579; + literal int L2_M4Q1_AUGER = 580; + literal int L2_M4Q2_AUGER = 581; + literal int L2_M4Q3_AUGER = 582; + literal int L2_M5L3_AUGER = 583; + literal int L2_M5M1_AUGER = 584; + literal int L2_M5M2_AUGER = 585; + literal int L2_M5M3_AUGER = 586; + literal int L2_M5M4_AUGER = 587; + literal int L2_M5M5_AUGER = 588; + literal int L2_M5N1_AUGER = 589; + literal int L2_M5N2_AUGER = 590; + literal int L2_M5N3_AUGER = 591; + literal int L2_M5N4_AUGER = 592; + literal int L2_M5N5_AUGER = 593; + literal int L2_M5N6_AUGER = 594; + literal int L2_M5N7_AUGER = 595; + literal int L2_M5O1_AUGER = 596; + literal int L2_M5O2_AUGER = 597; + literal int L2_M5O3_AUGER = 598; + literal int L2_M5O4_AUGER = 599; + literal int L2_M5O5_AUGER = 600; + literal int L2_M5O6_AUGER = 601; + literal int L2_M5O7_AUGER = 602; + literal int L2_M5P1_AUGER = 603; + literal int L2_M5P2_AUGER = 604; + literal int L2_M5P3_AUGER = 605; + literal int L2_M5P4_AUGER = 606; + literal int L2_M5P5_AUGER = 607; + literal int L2_M5Q1_AUGER = 608; + literal int L2_M5Q2_AUGER = 609; + literal int L2_M5Q3_AUGER = 610; + literal int L3_M1M1_AUGER = 611; + literal int L3_M1M2_AUGER = 612; + literal int L3_M1M3_AUGER = 613; + literal int L3_M1M4_AUGER = 614; + literal int L3_M1M5_AUGER = 615; + literal int L3_M1N1_AUGER = 616; + literal int L3_M1N2_AUGER = 617; + literal int L3_M1N3_AUGER = 618; + literal int L3_M1N4_AUGER = 619; + literal int L3_M1N5_AUGER = 620; + literal int L3_M1N6_AUGER = 621; + literal int L3_M1N7_AUGER = 622; + literal int L3_M1O1_AUGER = 623; + literal int L3_M1O2_AUGER = 624; + literal int L3_M1O3_AUGER = 625; + literal int L3_M1O4_AUGER = 626; + literal int L3_M1O5_AUGER = 627; + literal int L3_M1O6_AUGER = 628; + literal int L3_M1O7_AUGER = 629; + literal int L3_M1P1_AUGER = 630; + literal int L3_M1P2_AUGER = 631; + literal int L3_M1P3_AUGER = 632; + literal int L3_M1P4_AUGER = 633; + literal int L3_M1P5_AUGER = 634; + literal int L3_M1Q1_AUGER = 635; + literal int L3_M1Q2_AUGER = 636; + literal int L3_M1Q3_AUGER = 637; + literal int L3_M2M1_AUGER = 638; + literal int L3_M2M2_AUGER = 639; + literal int L3_M2M3_AUGER = 640; + literal int L3_M2M4_AUGER = 641; + literal int L3_M2M5_AUGER = 642; + literal int L3_M2N1_AUGER = 643; + literal int L3_M2N2_AUGER = 644; + literal int L3_M2N3_AUGER = 645; + literal int L3_M2N4_AUGER = 646; + literal int L3_M2N5_AUGER = 647; + literal int L3_M2N6_AUGER = 648; + literal int L3_M2N7_AUGER = 649; + literal int L3_M2O1_AUGER = 650; + literal int L3_M2O2_AUGER = 651; + literal int L3_M2O3_AUGER = 652; + literal int L3_M2O4_AUGER = 653; + literal int L3_M2O5_AUGER = 654; + literal int L3_M2O6_AUGER = 655; + literal int L3_M2O7_AUGER = 656; + literal int L3_M2P1_AUGER = 657; + literal int L3_M2P2_AUGER = 658; + literal int L3_M2P3_AUGER = 659; + literal int L3_M2P4_AUGER = 660; + literal int L3_M2P5_AUGER = 661; + literal int L3_M2Q1_AUGER = 662; + literal int L3_M2Q2_AUGER = 663; + literal int L3_M2Q3_AUGER = 664; + literal int L3_M3M1_AUGER = 665; + literal int L3_M3M2_AUGER = 666; + literal int L3_M3M3_AUGER = 667; + literal int L3_M3M4_AUGER = 668; + literal int L3_M3M5_AUGER = 669; + literal int L3_M3N1_AUGER = 670; + literal int L3_M3N2_AUGER = 671; + literal int L3_M3N3_AUGER = 672; + literal int L3_M3N4_AUGER = 673; + literal int L3_M3N5_AUGER = 674; + literal int L3_M3N6_AUGER = 675; + literal int L3_M3N7_AUGER = 676; + literal int L3_M3O1_AUGER = 677; + literal int L3_M3O2_AUGER = 678; + literal int L3_M3O3_AUGER = 679; + literal int L3_M3O4_AUGER = 680; + literal int L3_M3O5_AUGER = 681; + literal int L3_M3O6_AUGER = 682; + literal int L3_M3O7_AUGER = 683; + literal int L3_M3P1_AUGER = 684; + literal int L3_M3P2_AUGER = 685; + literal int L3_M3P3_AUGER = 686; + literal int L3_M3P4_AUGER = 687; + literal int L3_M3P5_AUGER = 688; + literal int L3_M3Q1_AUGER = 689; + literal int L3_M3Q2_AUGER = 690; + literal int L3_M3Q3_AUGER = 691; + literal int L3_M4M1_AUGER = 692; + literal int L3_M4M2_AUGER = 693; + literal int L3_M4M3_AUGER = 694; + literal int L3_M4M4_AUGER = 695; + literal int L3_M4M5_AUGER = 696; + literal int L3_M4N1_AUGER = 697; + literal int L3_M4N2_AUGER = 698; + literal int L3_M4N3_AUGER = 699; + literal int L3_M4N4_AUGER = 700; + literal int L3_M4N5_AUGER = 701; + literal int L3_M4N6_AUGER = 702; + literal int L3_M4N7_AUGER = 703; + literal int L3_M4O1_AUGER = 704; + literal int L3_M4O2_AUGER = 705; + literal int L3_M4O3_AUGER = 706; + literal int L3_M4O4_AUGER = 707; + literal int L3_M4O5_AUGER = 708; + literal int L3_M4O6_AUGER = 709; + literal int L3_M4O7_AUGER = 710; + literal int L3_M4P1_AUGER = 711; + literal int L3_M4P2_AUGER = 712; + literal int L3_M4P3_AUGER = 713; + literal int L3_M4P4_AUGER = 714; + literal int L3_M4P5_AUGER = 715; + literal int L3_M4Q1_AUGER = 716; + literal int L3_M4Q2_AUGER = 717; + literal int L3_M4Q3_AUGER = 718; + literal int L3_M5M1_AUGER = 719; + literal int L3_M5M2_AUGER = 720; + literal int L3_M5M3_AUGER = 721; + literal int L3_M5M4_AUGER = 722; + literal int L3_M5M5_AUGER = 723; + literal int L3_M5N1_AUGER = 724; + literal int L3_M5N2_AUGER = 725; + literal int L3_M5N3_AUGER = 726; + literal int L3_M5N4_AUGER = 727; + literal int L3_M5N5_AUGER = 728; + literal int L3_M5N6_AUGER = 729; + literal int L3_M5N7_AUGER = 730; + literal int L3_M5O1_AUGER = 731; + literal int L3_M5O2_AUGER = 732; + literal int L3_M5O3_AUGER = 733; + literal int L3_M5O4_AUGER = 734; + literal int L3_M5O5_AUGER = 735; + literal int L3_M5O6_AUGER = 736; + literal int L3_M5O7_AUGER = 737; + literal int L3_M5P1_AUGER = 738; + literal int L3_M5P2_AUGER = 739; + literal int L3_M5P3_AUGER = 740; + literal int L3_M5P4_AUGER = 741; + literal int L3_M5P5_AUGER = 742; + literal int L3_M5Q1_AUGER = 743; + literal int L3_M5Q2_AUGER = 744; + literal int L3_M5Q3_AUGER = 745; + literal int M1_M2M2_AUGER = 746; + literal int M1_M2M3_AUGER = 747; + literal int M1_M2M4_AUGER = 748; + literal int M1_M2M5_AUGER = 749; + literal int M1_M2N1_AUGER = 750; + literal int M1_M2N2_AUGER = 751; + literal int M1_M2N3_AUGER = 752; + literal int M1_M2N4_AUGER = 753; + literal int M1_M2N5_AUGER = 754; + literal int M1_M2N6_AUGER = 755; + literal int M1_M2N7_AUGER = 756; + literal int M1_M2O1_AUGER = 757; + literal int M1_M2O2_AUGER = 758; + literal int M1_M2O3_AUGER = 759; + literal int M1_M2O4_AUGER = 760; + literal int M1_M2O5_AUGER = 761; + literal int M1_M2O6_AUGER = 762; + literal int M1_M2O7_AUGER = 763; + literal int M1_M2P1_AUGER = 764; + literal int M1_M2P2_AUGER = 765; + literal int M1_M2P3_AUGER = 766; + literal int M1_M2P4_AUGER = 767; + literal int M1_M2P5_AUGER = 768; + literal int M1_M2Q1_AUGER = 769; + literal int M1_M2Q2_AUGER = 770; + literal int M1_M2Q3_AUGER = 771; + literal int M1_M3M2_AUGER = 772; + literal int M1_M3M3_AUGER = 773; + literal int M1_M3M4_AUGER = 774; + literal int M1_M3M5_AUGER = 775; + literal int M1_M3N1_AUGER = 776; + literal int M1_M3N2_AUGER = 777; + literal int M1_M3N3_AUGER = 778; + literal int M1_M3N4_AUGER = 779; + literal int M1_M3N5_AUGER = 780; + literal int M1_M3N6_AUGER = 781; + literal int M1_M3N7_AUGER = 782; + literal int M1_M3O1_AUGER = 783; + literal int M1_M3O2_AUGER = 784; + literal int M1_M3O3_AUGER = 785; + literal int M1_M3O4_AUGER = 786; + literal int M1_M3O5_AUGER = 787; + literal int M1_M3O6_AUGER = 788; + literal int M1_M3O7_AUGER = 789; + literal int M1_M3P1_AUGER = 790; + literal int M1_M3P2_AUGER = 791; + literal int M1_M3P3_AUGER = 792; + literal int M1_M3P4_AUGER = 793; + literal int M1_M3P5_AUGER = 794; + literal int M1_M3Q1_AUGER = 795; + literal int M1_M3Q2_AUGER = 796; + literal int M1_M3Q3_AUGER = 797; + literal int M1_M4M2_AUGER = 798; + literal int M1_M4M3_AUGER = 799; + literal int M1_M4M4_AUGER = 800; + literal int M1_M4M5_AUGER = 801; + literal int M1_M4N1_AUGER = 802; + literal int M1_M4N2_AUGER = 803; + literal int M1_M4N3_AUGER = 804; + literal int M1_M4N4_AUGER = 805; + literal int M1_M4N5_AUGER = 806; + literal int M1_M4N6_AUGER = 807; + literal int M1_M4N7_AUGER = 808; + literal int M1_M4O1_AUGER = 809; + literal int M1_M4O2_AUGER = 810; + literal int M1_M4O3_AUGER = 811; + literal int M1_M4O4_AUGER = 812; + literal int M1_M4O5_AUGER = 813; + literal int M1_M4O6_AUGER = 814; + literal int M1_M4O7_AUGER = 815; + literal int M1_M4P1_AUGER = 816; + literal int M1_M4P2_AUGER = 817; + literal int M1_M4P3_AUGER = 818; + literal int M1_M4P4_AUGER = 819; + literal int M1_M4P5_AUGER = 820; + literal int M1_M4Q1_AUGER = 821; + literal int M1_M4Q2_AUGER = 822; + literal int M1_M4Q3_AUGER = 823; + literal int M1_M5M2_AUGER = 824; + literal int M1_M5M3_AUGER = 825; + literal int M1_M5M4_AUGER = 826; + literal int M1_M5M5_AUGER = 827; + literal int M1_M5N1_AUGER = 828; + literal int M1_M5N2_AUGER = 829; + literal int M1_M5N3_AUGER = 830; + literal int M1_M5N4_AUGER = 831; + literal int M1_M5N5_AUGER = 832; + literal int M1_M5N6_AUGER = 833; + literal int M1_M5N7_AUGER = 834; + literal int M1_M5O1_AUGER = 835; + literal int M1_M5O2_AUGER = 836; + literal int M1_M5O3_AUGER = 837; + literal int M1_M5O4_AUGER = 838; + literal int M1_M5O5_AUGER = 839; + literal int M1_M5O6_AUGER = 840; + literal int M1_M5O7_AUGER = 841; + literal int M1_M5P1_AUGER = 842; + literal int M1_M5P2_AUGER = 843; + literal int M1_M5P3_AUGER = 844; + literal int M1_M5P4_AUGER = 845; + literal int M1_M5P5_AUGER = 846; + literal int M1_M5Q1_AUGER = 847; + literal int M1_M5Q2_AUGER = 848; + literal int M1_M5Q3_AUGER = 849; + literal int M2_M3M3_AUGER = 850; + literal int M2_M3M4_AUGER = 851; + literal int M2_M3M5_AUGER = 852; + literal int M2_M3N1_AUGER = 853; + literal int M2_M3N2_AUGER = 854; + literal int M2_M3N3_AUGER = 855; + literal int M2_M3N4_AUGER = 856; + literal int M2_M3N5_AUGER = 857; + literal int M2_M3N6_AUGER = 858; + literal int M2_M3N7_AUGER = 859; + literal int M2_M3O1_AUGER = 860; + literal int M2_M3O2_AUGER = 861; + literal int M2_M3O3_AUGER = 862; + literal int M2_M3O4_AUGER = 863; + literal int M2_M3O5_AUGER = 864; + literal int M2_M3O6_AUGER = 865; + literal int M2_M3O7_AUGER = 866; + literal int M2_M3P1_AUGER = 867; + literal int M2_M3P2_AUGER = 868; + literal int M2_M3P3_AUGER = 869; + literal int M2_M3P4_AUGER = 870; + literal int M2_M3P5_AUGER = 871; + literal int M2_M3Q1_AUGER = 872; + literal int M2_M3Q2_AUGER = 873; + literal int M2_M3Q3_AUGER = 874; + literal int M2_M4M3_AUGER = 875; + literal int M2_M4M4_AUGER = 876; + literal int M2_M4M5_AUGER = 877; + literal int M2_M4N1_AUGER = 878; + literal int M2_M4N2_AUGER = 879; + literal int M2_M4N3_AUGER = 880; + literal int M2_M4N4_AUGER = 881; + literal int M2_M4N5_AUGER = 882; + literal int M2_M4N6_AUGER = 883; + literal int M2_M4N7_AUGER = 884; + literal int M2_M4O1_AUGER = 885; + literal int M2_M4O2_AUGER = 886; + literal int M2_M4O3_AUGER = 887; + literal int M2_M4O4_AUGER = 888; + literal int M2_M4O5_AUGER = 889; + literal int M2_M4O6_AUGER = 890; + literal int M2_M4O7_AUGER = 891; + literal int M2_M4P1_AUGER = 892; + literal int M2_M4P2_AUGER = 893; + literal int M2_M4P3_AUGER = 894; + literal int M2_M4P4_AUGER = 895; + literal int M2_M4P5_AUGER = 896; + literal int M2_M4Q1_AUGER = 897; + literal int M2_M4Q2_AUGER = 898; + literal int M2_M4Q3_AUGER = 899; + literal int M2_M5M3_AUGER = 900; + literal int M2_M5M4_AUGER = 901; + literal int M2_M5M5_AUGER = 902; + literal int M2_M5N1_AUGER = 903; + literal int M2_M5N2_AUGER = 904; + literal int M2_M5N3_AUGER = 905; + literal int M2_M5N4_AUGER = 906; + literal int M2_M5N5_AUGER = 907; + literal int M2_M5N6_AUGER = 908; + literal int M2_M5N7_AUGER = 909; + literal int M2_M5O1_AUGER = 910; + literal int M2_M5O2_AUGER = 911; + literal int M2_M5O3_AUGER = 912; + literal int M2_M5O4_AUGER = 913; + literal int M2_M5O5_AUGER = 914; + literal int M2_M5O6_AUGER = 915; + literal int M2_M5O7_AUGER = 916; + literal int M2_M5P1_AUGER = 917; + literal int M2_M5P2_AUGER = 918; + literal int M2_M5P3_AUGER = 919; + literal int M2_M5P4_AUGER = 920; + literal int M2_M5P5_AUGER = 921; + literal int M2_M5Q1_AUGER = 922; + literal int M2_M5Q2_AUGER = 923; + literal int M2_M5Q3_AUGER = 924; + literal int M3_M4M4_AUGER = 925; + literal int M3_M4M5_AUGER = 926; + literal int M3_M4N1_AUGER = 927; + literal int M3_M4N2_AUGER = 928; + literal int M3_M4N3_AUGER = 929; + literal int M3_M4N4_AUGER = 930; + literal int M3_M4N5_AUGER = 931; + literal int M3_M4N6_AUGER = 932; + literal int M3_M4N7_AUGER = 933; + literal int M3_M4O1_AUGER = 934; + literal int M3_M4O2_AUGER = 935; + literal int M3_M4O3_AUGER = 936; + literal int M3_M4O4_AUGER = 937; + literal int M3_M4O5_AUGER = 938; + literal int M3_M4O6_AUGER = 939; + literal int M3_M4O7_AUGER = 940; + literal int M3_M4P1_AUGER = 941; + literal int M3_M4P2_AUGER = 942; + literal int M3_M4P3_AUGER = 943; + literal int M3_M4P4_AUGER = 944; + literal int M3_M4P5_AUGER = 945; + literal int M3_M4Q1_AUGER = 946; + literal int M3_M4Q2_AUGER = 947; + literal int M3_M4Q3_AUGER = 948; + literal int M3_M5M4_AUGER = 949; + literal int M3_M5M5_AUGER = 950; + literal int M3_M5N1_AUGER = 951; + literal int M3_M5N2_AUGER = 952; + literal int M3_M5N3_AUGER = 953; + literal int M3_M5N4_AUGER = 954; + literal int M3_M5N5_AUGER = 955; + literal int M3_M5N6_AUGER = 956; + literal int M3_M5N7_AUGER = 957; + literal int M3_M5O1_AUGER = 958; + literal int M3_M5O2_AUGER = 959; + literal int M3_M5O3_AUGER = 960; + literal int M3_M5O4_AUGER = 961; + literal int M3_M5O5_AUGER = 962; + literal int M3_M5O6_AUGER = 963; + literal int M3_M5O7_AUGER = 964; + literal int M3_M5P1_AUGER = 965; + literal int M3_M5P2_AUGER = 966; + literal int M3_M5P3_AUGER = 967; + literal int M3_M5P4_AUGER = 968; + literal int M3_M5P5_AUGER = 969; + literal int M3_M5Q1_AUGER = 970; + literal int M3_M5Q2_AUGER = 971; + literal int M3_M5Q3_AUGER = 972; + literal int M4_M5M5_AUGER = 973; + literal int M4_M5N1_AUGER = 974; + literal int M4_M5N2_AUGER = 975; + literal int M4_M5N3_AUGER = 976; + literal int M4_M5N4_AUGER = 977; + literal int M4_M5N5_AUGER = 978; + literal int M4_M5N6_AUGER = 979; + literal int M4_M5N7_AUGER = 980; + literal int M4_M5O1_AUGER = 981; + literal int M4_M5O2_AUGER = 982; + literal int M4_M5O3_AUGER = 983; + literal int M4_M5O4_AUGER = 984; + literal int M4_M5O5_AUGER = 985; + literal int M4_M5O6_AUGER = 986; + literal int M4_M5O7_AUGER = 987; + literal int M4_M5P1_AUGER = 988; + literal int M4_M5P2_AUGER = 989; + literal int M4_M5P3_AUGER = 990; + literal int M4_M5P4_AUGER = 991; + literal int M4_M5P5_AUGER = 992; + literal int M4_M5Q1_AUGER = 993; + literal int M4_M5Q2_AUGER = 994; + literal int M4_M5Q3_AUGER = 995; + + // Radionuclides + literal int RADIONUCLIDE_55FE = 0; + literal int RADIONUCLIDE_57CO = 1; + literal int RADIONUCLIDE_109CD = 2; + literal int RADIONUCLIDE_125I = 3; + literal int RADIONUCLIDE_137CS = 4; + literal int RADIONUCLIDE_133BA = 5; + literal int RADIONUCLIDE_153GD = 6; + literal int RADIONUCLIDE_238PU = 7; + literal int RADIONUCLIDE_241AM = 8; + literal int RADIONUCLIDE_244CM = 9; + #pragma endregion + + /// + /// Initialize the library. + /// + static void XrayInit(); + + /// + /// Gets the atomic weight of the element with the specified atomic number. + /// + /// Atomic number + /// Atomic weight + static double AtomicWeight(int Z); + + /// + /// Gets the density of a pure atomic element. + /// + /// Atomic number + /// Density (g/cm3) + static double ElementDensity(int Z); + + /// + /// Gets element information for the specified atomic number. + /// + /// Atomic number + /// Element information + static Science::ElementData GetElementData(int Z); + + // Cross sections + /// + /// Calculates the total cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Total(int Z, double E); + + /// + /// Calculates the photoelectric absorption cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Photo(int Z, double E); + + /// + /// Calculates the Rayleigh scattering cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Rayl(int Z, double E); + + /// + /// Calculates the Compton scattering cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Compt(int Z, double E); + + /// + /// Calculates the mass energy-absorption coefficient. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Energy(int Z, double E); + + /// + /// Calculates the total cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (barn) + static double CSb_Total(int Z, double E); + + /// + /// Calculates the photoelectric absorption cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (barn) + static double CSb_Photo(int Z, double E); + + /// + /// Calculates the Rayleigh scattering cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (barn) + static double CSb_Rayl(int Z, double E); + + /// + /// Calculates the Compton scattering cross section. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (barn) + static double CSb_Compt(int Z, double E); + + /// + /// Calculates the total Klein-Nishina cross section. + /// + /// Energy (keV) + /// Cross section (barn) + static double CS_KN(double E); + + // Unpolarized differential scattering cross sections + /// + /// Calculates the Thomson differential scattering cross section. + /// + /// Scattering polar angle (rad) + /// Cross section (barn) + static double DCS_Thoms(double theta); + + /// + /// Calculates the Klein-Nishina differential scattering cross section. + /// + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (barn) + static double DCS_KN(double E, double theta); + + /// + /// Calculates the Rayleigh differential scattering cross section. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (cm2/g/sterad) + static double DCS_Rayl(int Z, double E, double theta); + + /// + /// Calculates the Compton differential scattering cross section. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (cm2/g/sterad) + static double DCS_Compt(int Z, double E, double theta); + + /// + /// Calculates the Rayleigh differential scattering cross section. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (barn) + static double DCSb_Rayl(int Z, double E, double theta); + + /// + /// Calculates the Compton differential scattering cross section. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (barn) + static double DCSb_Compt(int Z, double E, double theta); + + // Polarized differential scattering cross sections + /// + /// Calculates the Thomson differential scattering cross section for polarized beam. + /// + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (barn) + static double DCSP_Thoms(double theta, double phi); + + // Polarized differential scattering cross sections + /// + /// Calculates the Klein-Nishina differential scattering cross section for polarized beam. + /// + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (barn) + static double DCSP_KN(double E, double theta, double phi); + + /// + /// Calculates the Rayleigh differential scattering cross section for polarized beam. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (cm2/g/sterad) + static double DCSP_Rayl(int Z, double E, double theta, double phi); + + /// + /// Calculates the Compton differential scattering cross section for polarized beam. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (cm2/g/sterad) + static double DCSP_Compt(int Z, double E, double theta, double phi); + + /// + /// Calculates the Rayleigh differential scattering cross section for polarized beam. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (barn) + static double DCSPb_Rayl(int Z, double E, double theta, double phi); + + /// + /// Calculates the Compton differential scattering cross section for polarized beam. + /// + /// Atomic number + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (barn) + static double DCSPb_Compt(int Z, double E, double theta, double phi); + + // Scattering factors + /// + /// Calculates the Atomic form factor for Rayleigh scattering. + /// + /// Atomic number + /// Momentum transfer + /// Form factor + static double FF_Rayl(int Z, double q); + + /// + /// Calculates the Incoherent scattering function for Compton scattering. + /// + /// Atomic number + /// Momentum transfer + /// Form factor + static double SF_Compt(int Z, double q); + + /// + /// Calculates the Momentum transfer for X-ray photon scattering. + /// + /// Energy (keV) + /// Scattering polar angle (rad) + /// Momentum transfer (1/A) + static double MomentTransf(double E, double theta); + + /// + /// Gets X-ray fluorescent line energy. + /// + /// Atomic number + /// Emission line ID + /// X-ray fluorescent line energy (keV) + static double LineEnergy(int Z, int line); + + /// + /// Gets the fluorescence yield + /// + /// Atomic number of the element + /// Atomic shell ID + /// Fluorescence yield + static double FluorYield(int Z, int shell); + + /// + /// Gets the Coster-Kronig transition probability + /// + /// Atomic number + /// Atomic transition ID + /// Transition probability + static double CosKronTransProb(int Z, int trans); + + /// + /// Gets the absorption-edge energy + /// + /// Atomic number + /// Atomic shell ID + /// Edge energy (keV) + static double EdgeEnergy(int Z, int shell); + + /// + /// Gets the jump ratio + /// + /// Atomic number + /// Atomic shell ID + /// Jump ratio + static double JumpFactor(int Z, int shell); + + /// + /// Calculates the fluorescent line cross section + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_FluorLine(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_FluorLine(int Z, int line, double E); + + /// + /// Gets the fractional radiative rate + /// + /// Atomic number + /// Atomic line ID + /// Fractional radiative rate + static double RadRate(int Z, int line); + + /// + /// Calculates the photon energy after Compton scattering + /// + /// Photon energy before scattering (keV) + /// Scattering polar angle (rad) + /// Energy after scattering (keV) + static double ComptonEnergy(double E0, double theta); + + // Anomalous scattering factors + /// + /// Calculates the real-part of the anomalous scattering factor + /// + /// Atomic number + /// Energy (keV) + /// Real-part of anomalous scattering factor + static double Fi(int Z, double E); + + /// + /// Calculates the imaginary-part of the anomalous scattering factor + /// + /// Atomic number + /// Energy (keV) + /// Imaginary-part of anomalous scattering factor + static double Fii(int Z, double E); + + // Kissel Photoelectric cross sections + /// + /// Calculates the total photoelectric absorption cross section using Kissel partial photoelectric cross sections. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Photo_Total(int Z, double E); + + /// + /// Calculates the total photoelectric absorption cross section using Kissel partial photoelectric cross sections. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (barn) + static double CSb_Photo_Total(int Z, double E); + + /// + /// Calculates the partial photoelectric absorption cross section using Kissel partial photoelectric cross sections. + /// + /// Atomic number of the element + /// Atomic shell ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Photo_Partial(int Z, int shell, double E); + + /// + /// Calculates the partial photoelectric absorption cross section using Kissel partial photoelectric cross sections. + /// + /// Atomic number of the element + /// Atomic shell ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_Photo_Partial(int Z, int shell, double E); + + // XRF cross sections using Kissel partial photoelectric cross sections + /// + /// Calculates the fluorescent line cross section using Kissel partial photoelectric cross sections + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_FluorLine_Kissel(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section using Kissel partial photoelectric cross sections + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_FluorLine_Kissel(int Z, int line, double E); + + // Total cross sections (photoionization + Rayleigh + Compton) using Kissel total photoelectric cross sections + /// + /// Calculates the total cross section using Kissel partial photoelectric cross sections. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Total_Kissel(int Z, double E); + + // Total cross sections (photoionization + Rayleigh + Compton) using Kissel total photoelectric cross sections + /// + /// Calculates the total cross section using Kissel partial photoelectric cross sections. + /// + /// Atomic number of the element + /// Energy (keV) + /// Cross section (barn) + static double CSb_Total_Kissel(int Z, double E); + + /// + /// Calculates the fluorescent line cross section including cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_FluorLine_Kissel_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section including cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_FluorLine_Kissel_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section with non-radiative cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_FluorLine_Kissel_Nonradiative_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section with non-radiative cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_FluorLine_Kissel_Nonradiative_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section with radiative cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_FluorLine_Kissel_Radiative_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section with non-radiative cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_FluorLine_Kissel_Radiative_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section without cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_FluorLine_Kissel_No_Cascade(int Z, int line, double E); + + /// + /// Calculates the fluorescent line cross section without cascade effects. + /// + /// Atomic number + /// Atomic line ID + /// Energy (keV) + /// Cross section (barn) + static double CSb_FluorLine_Kissel_No_Cascade(int Z, int line, double E); + + //Cross Section functions using the compound parser + /// + /// Calculates the total cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Total_CP(String^ compound, double E); + + /// + /// Calculates the photoelectric absorption cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Photo_CP(String^ compound, double E); + + /// + /// Calculates the Rayleigh scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Rayl_CP(String^ compound, double E); + + /// + /// Calculates the Compton scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Compt_CP(String^ compound, double E); + + /// + /// Calculates the total cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CSb_Total_CP(String^ compound, double E); + + /// + /// Calculates the photoelectric absorption cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CSb_Photo_CP(String^ compound, double E); + + /// + /// Calculates the Rayleigh scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CSb_Rayl_CP(String^ compound, double E); + + /// + /// Calculates the Compton scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CSb_Compt_CP(String^ compound, double E); + + /// + /// Calculates the Rayleigh differential scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (cm2/g/sterad) + static double DCS_Rayl_CP(String^ compound, double E, double theta); + + /// + /// Calculates the Compton differential scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (cm2/g/sterad) + static double DCS_Compt_CP(String^ compound, double E, double theta); + + /// + /// Calculates the Rayleigh differential scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (barn/sterad) + static double DCSb_Rayl_CP(String^ compound, double E, double theta); + + /// + /// Calculates the Compton differential scattering cross section of a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Cross section (barn/sterad) + static double DCSb_Compt_CP(String^ compound, double E, double theta); + + /// + /// Calculates the Rayleigh differential scattering cross section for polarized beam for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (cm2/g/sterad) + static double DCSP_Rayl_CP(String^ compound, double E, double theta, double phi); + + /// + /// Calculates the Compton differential scattering cross section for polarized beam for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (cm2/g/sterad) + static double DCSP_Compt_CP(String^ compound, double E, double theta, double phi); + + /// + /// Calculates the Rayleigh differential scattering cross section for polarized beam for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (barn/sterad) + static double DCSPb_Rayl_CP(String^ compound, double E, double theta, double phi); + + /// + /// Calculates the Compton differential scattering cross section for polarized beam for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Scattering polar angle (rad) + /// Scattering azimuthal angle (rad) + /// Cross section (barn/sterad) + static double DCSPb_Compt_CP(String^ compound, double E, double theta, double phi); + + /// + /// Calculates the total photoelectric absorption cross section for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Photo_Total_CP(String^ compound, double E); + + /// + /// Calculates the total photoelectric absorption cross section for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CSb_Photo_Total_CP(String^ compound, double E); + + /// + /// Calculates the total photoelectric absorption cross section for a compound + /// using Kissel partial photoelectric cross sections. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (cm2/g) + static double CS_Total_Kissel_CP(String^ compound, double E); + + /// + /// Calculates the total photoelectric absorption cross section for a compound + /// using Kissel partial photoelectric cross sections. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CSb_Total_Kissel_CP(String^ compound, double E); + + /// + /// Calculates the mass energy-absorption coefficient for a compound. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Cross section (barn) + static double CS_Energy_CP(String^ compound, double E); + + //Refractive indices functions + /// + /// Calculates the real part of the refractive index. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Real part of refractive index (electrons) + static double Refractive_Index_Re(String^ compound, double E, double density); + + /// + /// Calculates the imaginary part of the refractive index. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Imaginary part of refractive index (electrons) + static double Refractive_Index_Im(String^ compound, double E, double density); + + /// + /// Calculates the refractive index. + /// + /// Chemical formula of the compound + /// Energy (keV) + /// Refractive index (electrons) + static Numerics::Complex Refractive_Index(String^ compound, double E, double density); + + /// + /// Calculates the electron configuration according to Kissel. + /// + /// Atomic number of the element + /// Atomic shell ID + /// Electron configuration + static double ElectronConfig(int Z, int shell); + + //ComptonProfiles + /// + /// Calculates the total Compton scattering profile. + /// + /// Atomic number of the element + /// Momentum + /// Compton profile + static double ComptonProfile(int Z, double pz); + + /// + /// Calculates the sub-shell Compton scattering profile. + /// + /// Atomic number of the element + /// Atomic shell ID + /// Momentum + /// Compton profile + static double ComptonProfile_Partial(int Z, int shell, double pz); + + /// Calculates the atomic level width. + /// Atomic number of the element. + /// Atomic shell ID. + /// Level width (keV) + static double AtomicLevelWidth(int Z, int shell); + + /// Calculates the Auger non-radiative rate. + /// Atomic number of the element. + /// Value identifying initial ionized shell and two resulting ejected electrons + /// Non-radiative rate + static double AugerRate(int Z, int auger_trans); + + /// Calculates the Auger non-radiative yeild. + /// Atomic number of the element. + /// Atomic shell ID. + /// Non-radiative yeild + static double AugerYield(int Z, int shell); + + /// + /// Returns the Siegbahn line name corresponding to the specified IUPAC name. + /// + /// IUPAC line name + /// Siegbahn line name + static System::String ^IUPACToSiegbahnLineName(System::String ^name); + + /// + /// Returns IUPAC line name corresponding to the specified Siegbahn name. + /// + /// Siegbahn line name + /// IUPAC line name + static System::String ^SiegbahnToIUPACLineName(System::String ^name); + + /// + /// Returns the energy of the specified fluorescent line string. + /// + /// String containing the element and emission line, e.g. Cu Ka1 + /// Fluorescent line energy (keV) + static double LineEnergyFromName(System::String ^lineName); + + /// + /// Returns the atomic number and line ID of the specified fluorescent line string. + /// + /// String containing the element and emission line, e.g. Cu Ka1 + /// Atomic number + /// Emission line ID + static void ElementAndLineFromName(System::String ^elementLine, int %Z, int %line); + + /// + /// Returns the line ID of the specified emission line name. + /// + /// String containing the emission line name, e.g. Ka1 + /// ID of the emission line + static int SiegbahnLineIndex(System::String ^name); + + /// + /// Returns the atomic number from the specified element name. + /// + /// Element name, e.g. Cu + /// Atomic number + static int AtomicNumber(System::String ^name); + + /// + /// Calculates the energy of the escape peak for a Si detector. + /// + /// Energy of the incident X-ray peak (keV) + /// Energy of the escape peak (keV) + static double SiEscapeEnergy(double energy); + + /// + /// Calculates the fraction of photons in the escape peak for a Si detector. + /// + /// Energy of the incident X-ray peak (keV) + /// Fraction of incident photons in the escape peak + static double SiEscapeFraction(double energy); + }; + +} diff --git a/csharp/app.ico b/csharp/app.ico new file mode 100644 index 00000000..3a5525fd Binary files /dev/null and b/csharp/app.ico differ diff --git a/csharp/app.rc b/csharp/app.rc new file mode 100644 index 00000000..807aa896 --- /dev/null +++ b/csharp/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/csharp/meson.build b/csharp/meson.build new file mode 100644 index 00000000..ab8f636f --- /dev/null +++ b/csharp/meson.build @@ -0,0 +1,40 @@ +windows = import('windows') + +win_res = windows.compile_resources('app.rc', depend_files: files('app.ico', 'resource.h')) + +libxrl_cs_sources = files( + 'AssemblyInfo.cpp', + 'Compound.h', + 'Diffraction.h', + 'Element.h', + 'Errors.h', + 'Radionuclides.h', + 'Stdafx.cpp', + 'Stdafx.h', + 'XrayLib.NET.cpp', + 'XrayLib.NET.h', +) + +xraylib_cs_lib = shared_library( + 'XrayLib.NET', + win_res, + libxrl_cs_sources, + dependencies: xraylib_lib_dep, + cpp_args: ['/clr', '/Zc:twoPhase-',], + override_options: ['cpp_eh=none'], +) + +xraylib_cs_dep = declare_dependency( + link_with: xraylib_cs_lib, +) + +csharp_source_dir = meson.current_source_dir() +csharp_build_dir = meson.current_build_dir() + +# Note: to avoid the executable not finding the assembly at run-time, +# ensure they are created in the same folder... +_test_exec = executable( + 'Program', ['Program.cs', 'AssemblyInfo.cs'], + dependencies: [xraylib_cs_dep], + cs_args: ['-r:System.Numerics.dll',]) +test('cs-Program', _test_exec,) \ No newline at end of file diff --git a/csharp/resource.h b/csharp/resource.h new file mode 100644 index 00000000..d5ac7c42 --- /dev/null +++ b/csharp/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/include/xraylib-crystal-diffraction.h b/include/xraylib-crystal-diffraction.h index ab4e8df6..86c5a9a0 100644 --- a/include/xraylib-crystal-diffraction.h +++ b/include/xraylib-crystal-diffraction.h @@ -98,6 +98,11 @@ XRL_EXTERN xrlComplex Crystal_F_H_StructureFactor (Crystal_Struct* crystal, double energy, int i_miller, int j_miller, int k_miller, double debye_factor, double rel_angle, xrl_error **error); +#ifndef SWIG +XRL_EXTERN +void Crystal_F_H_StructureFactor2(Crystal_Struct* crystal, double energy, int i_miller, int j_miller, int k_miller, double debye_factor, double rel_angle, xrlComplex* result, xrl_error **error); +#endif + /*-------------------------------------------------------------------------------------------------- * Compute F_H * See also Crystal_F_H_StructureFactor @@ -113,6 +118,13 @@ xrlComplex Crystal_F_H_StructureFactor_Partial (Crystal_Struct* crystal, double int i_miller, int j_miller, int k_miller, double debye_factor, double rel_angle, int f0_flag, int f_prime_flag, int f_prime2_flag, xrl_error **error); +#ifndef SWIG +XRL_EXTERN +void Crystal_F_H_StructureFactor_Partial2(Crystal_Struct* crystal, double energy, + int i_miller, int j_miller, int k_miller, double debye_factor, double rel_angle, + int f0_flag, int f_prime_flag, int f_prime2_flag, xrlComplex* result, xrl_error **error); +#endif + /*-------------------------------------------------------------------------------- * Compute unit cell volume. * Note: Structures obtained from crystal array will have their volume in .volume. diff --git a/include/xraylib.h b/include/xraylib.h index 47bca89f..55f77c7f 100644 --- a/include/xraylib.h +++ b/include/xraylib.h @@ -371,6 +371,11 @@ double Refractive_Index_Im(const char compound[], double E, double density, xrl_ XRL_EXTERN xrlComplex Refractive_Index(const char compound[], double E, double density, xrl_error **error); +#ifndef SWIG +XRL_EXTERN +void Refractive_Index2(const char compound[], double E, double density, xrlComplex* result, xrl_error **error); +#endif + /* ComptonProfiles */ XRL_EXTERN double ComptonProfile(int Z, double pz, xrl_error **error); diff --git a/meson.build b/meson.build index 40d834f2..d2454542 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project('xraylib', meson_version: '>= 0.56.0', version: '4.0.0', license: 'BSD', - default_options: ['cpp_std=c++11',] + default_options: ['cpp_std=c++11'] ) @@ -186,4 +186,10 @@ ENDPROGRAM f2003_main endif endif +endif + +if not get_option('csharp-bindings').disabled() and cc.get_id() == 'msvc' + if add_languages('cpp', 'cs', required: get_option('csharp-bindings'), native: false) + subdir('csharp') + endif endif \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt index f4a74db5..4a7b4b64 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,7 @@ option('fortran-bindings', type: 'feature', value: 'auto', description: 'Build Fortran 2003 bindings') option('python-bindings', type: 'feature', value: 'auto', description: 'Build classic Python bindings') option('python-numpy-bindings', type: 'feature', value: 'auto', description: 'Build numpy Python bindings') +option('csharp-bindings', type: 'feature', value: 'disabled', description: 'Build C# bindings (MSVC only)') option('swig', type : 'string', value : 'swig', description: 'Path to swig executable') option('python', type : 'string', value : 'python3', description: 'Python interpreter to compile bindings for') -option('cython', type : 'string', value : 'cython', description: 'Cython to use for generating C glue code') +option('cython', type : 'string', value : 'cython', description: 'Cython to use for generating C glue code') \ No newline at end of file diff --git a/src/crystal_diffraction.c b/src/crystal_diffraction.c index b931e467..29d90f95 100644 --- a/src/crystal_diffraction.c +++ b/src/crystal_diffraction.c @@ -412,11 +412,6 @@ xrlComplex Crystal_F_H_StructureFactor_Partial (Crystal_Struct* crystal, double return F_H; } -XRL_EXTERN -void Crystal_F_H_StructureFactor_Partial2(Crystal_Struct* crystal, double energy, - int i_miller, int j_miller, int k_miller, double debye_factor, double rel_angle, - int f0_flag, int f_prime_flag, int f_prime2_flag, xrlComplex* result, xrl_error **error); - void Crystal_F_H_StructureFactor_Partial2(Crystal_Struct* crystal, double energy, int i_miller, int j_miller, int k_miller, double debye_factor, double rel_angle, int f0_flag, int f_prime_flag, int f_prime2_flag, xrlComplex* result, xrl_error **error) { diff --git a/src/refractive_indices.c b/src/refractive_indices.c index 7ff0f7aa..ddab5e49 100644 --- a/src/refractive_indices.c +++ b/src/refractive_indices.c @@ -146,9 +146,6 @@ xrlComplex Refractive_Index(const char compound[], double E, double density, xrl return rv; } -XRL_EXTERN -void Refractive_Index2(const char compound[], double E, double density, xrlComplex* result, xrl_error **error); - void Refractive_Index2(const char compound[], double E, double density, xrlComplex* result, xrl_error **error) { xrlComplex z = Refractive_Index(compound, E, density, error);