forked from mutationpp/Mutationpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign of Millikan-White model classes and OmegaVT
- Loading branch information
Showing
17 changed files
with
913 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2014-2021 von Karman Institute for Fluid Dynamics (VKI) | ||
* | ||
* This file is part of MUlticomponent Thermodynamic And Transport | ||
* properties for IONized gases in C++ (Mutation++) software package. | ||
* | ||
* Mutation++ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* Mutation++ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with Mutation++. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "HarmonicOscillator.h" | ||
#include "Utilities.h" | ||
|
||
#include <cassert> | ||
#include <cmath> | ||
#include <iterator> | ||
#include <sstream> | ||
|
||
namespace Mutation { | ||
namespace Thermodynamics { | ||
|
||
double HarmonicOscillator::energy(double T) const | ||
{ | ||
assert(T > 0.0); | ||
|
||
double energy = 0.0; | ||
for (auto theta: m_characteristic_temps) | ||
energy += theta / (std::exp(theta/T) - 1.0); | ||
return energy; | ||
} | ||
|
||
|
||
struct HarmonicOscillatorDB::Data | ||
{ | ||
Utilities::IO::XmlDocument document; | ||
|
||
Data(std::string file_path) : document(file_path) { } | ||
}; | ||
|
||
HarmonicOscillatorDB::HarmonicOscillatorDB() : | ||
HarmonicOscillatorDB(Utilities::databaseFileName("species.xml", "thermo")) | ||
{ } | ||
|
||
HarmonicOscillatorDB::HarmonicOscillatorDB(std::string file_path) : | ||
m_data(std::make_shared<Data>(file_path)) | ||
{ } | ||
|
||
HarmonicOscillator HarmonicOscillatorDB::create( | ||
std::string species_name) const | ||
{ | ||
auto& root = m_data->document.root(); | ||
auto iter = root.findTagWithAttribute("species", "name", species_name); | ||
|
||
if (iter == root.end()) | ||
return {}; | ||
|
||
// Find thermodynamic data | ||
auto thermo_iter = iter->findTagWithAttribute("thermodynamics", "type", "RRHO"); | ||
if (thermo_iter == iter->end()) | ||
return {}; | ||
|
||
// Find vibrational temperature data | ||
iter = thermo_iter->findTag("vibrational_temperatures"); | ||
if (iter == thermo_iter->end()) | ||
return {}; | ||
|
||
// Split into individual temperatures | ||
std::istringstream ss(iter->text()); | ||
std::vector<double> temps; | ||
|
||
std::copy( | ||
std::istream_iterator<double>(ss), std::istream_iterator<double>(), | ||
std::back_inserter(temps) | ||
); | ||
|
||
return { temps }; | ||
} | ||
|
||
} // namespace Thermodynamics | ||
} // namespace Mutation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2014-2021 von Karman Institute for Fluid Dynamics (VKI) | ||
* | ||
* This file is part of MUlticomponent Thermodynamic And Transport | ||
* properties for IONized gases in C++ (Mutation++) software package. | ||
* | ||
* Mutation++ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* Mutation++ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with Mutation++. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef THERMO_HARMONIC_OSCILLATOR_H | ||
#define THERMO_HARMONIC_OSCILLATOR_H | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace Mutation { | ||
namespace Thermodynamics { | ||
|
||
/** | ||
* Computes vibrator energy based on harmonic-oscillator model. | ||
*/ | ||
class HarmonicOscillator | ||
{ | ||
public: | ||
/// Default oscillator with zero energy. | ||
HarmonicOscillator() { } | ||
|
||
/// Construct with list of characteristic temperatures in K. | ||
template <typename Container> | ||
HarmonicOscillator(const Container&); | ||
|
||
/// Returns energy of vibrator in K at given temperature in K. | ||
double energy(double T) const; | ||
|
||
/// Convience function to access characteristic temperatures in K. | ||
const std::vector<double>& characteristicTemperatures() const { | ||
return m_characteristic_temps; | ||
} | ||
|
||
private: | ||
std::vector<double> m_characteristic_temps; | ||
}; | ||
|
||
template <typename Container> | ||
HarmonicOscillator::HarmonicOscillator(const Container& temps) : | ||
m_characteristic_temps(std::begin(temps), std::end(temps)) | ||
{ } | ||
|
||
|
||
class HarmonicOscillatorDB | ||
{ | ||
public: | ||
/// Constructs the database using default file path. | ||
HarmonicOscillatorDB(); | ||
|
||
/// Constructs the database using given file path. | ||
HarmonicOscillatorDB(std::string file_path); | ||
|
||
/// Creates a new harmonic oscillator associated with given species name. | ||
HarmonicOscillator create(std::string species_name) const; | ||
|
||
private: | ||
struct Data; | ||
std::shared_ptr<Data> m_data; | ||
}; | ||
|
||
} // namespace Thermodynamics | ||
} // namespace Mutation | ||
|
||
|
||
#endif // THERMO_HARMONIC_OSCILLATOR_H |
Oops, something went wrong.