libatomprobe
Library for Atom Probe Tomography (APT) computation
massconvert.h
Go to the documentation of this file.
1 /* massconvert.h : Simple mass-mole input conversion
2  * Copyright (C) 2020 Daniel Haley
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <map>
19 #include <vector>
20 
21 namespace AtomProbe
22 {
23 
24 
26 enum
27 {
28  COMPPARSE_BAD_INPUT_FORMAT=1, //could not parse input format
29  COMPPARSE_BAD_COMP_VALUE, //could not parse composition data
30  COMPPARSE_BAD_BAL_USAGE, // "bal" tag used more than once
31  COMPPARSE_BAD_SYMBOL, // Atomic symbol not understood
32  COMPPARSE_DUPLICATE_SYMBOL, // Atomic symbol used more than once
33  COMPPARSE_BAD_TOTAL_COMP, //Negative balance required to match total
34 };
35 
37 
42 unsigned int parseCompositionData(const std::vector<std::string> &s,
43  const AbundanceData &atomTable, std::map<unsigned int, double> &atomData);
44 
46 
55 void convertMolToMass( const AbundanceData &atomTable,
56  const std::map<unsigned int, double> &compositionMols,
57  std::map<unsigned int, double> &compositionMass);
58 
59 
61 
66 void convertMassToMol( const AbundanceData &atomTable,
67  const std::map<unsigned int, double> &compositionMass,
68  std::map<unsigned int, double> &compositionMols);
69 
70 #ifdef DEBUG
71 bool testMassMolConversion();
72 #endif
73 
74 }
75 
void convertMolToMass(const AbundanceData &atomTable, const std::map< unsigned int, double > &compositionMols, std::map< unsigned int, double > &compositionMass)
Convert the given composition from molar fraction data to mass fraction.
Definition: massconvert.cpp:41
void convertMassToMol(const AbundanceData &atomTable, const std::map< unsigned int, double > &compositionMass, std::map< unsigned int, double > &compositionMols)
Convert the given composition from mass fraction data to molar fraction.
Definition: massconvert.cpp:74
Class to load abundance information for natural isotopes.
Definition: abundance.h:54
unsigned int parseCompositionData(const std::vector< std::string > &s, const AbundanceData &atomTable, std::map< unsigned int, double > &atomData)
Convert atomic string label data, in the form "Fe 0.81" to fraction map.