mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
#include "SurfaceWrapper.hpp"
|
|
|
|
SurfaceWrapper::SurfaceCompWrapper::SurfaceCompWrapper(cxxSurfaceComp &comp)
|
|
: surface_comp(comp) {
|
|
num_elements = NUM_NOT_TOTALS + comp.Get_totals().size();
|
|
|
|
for (const auto &[name, value] : comp.Get_totals()) {
|
|
total_names.push_back(name);
|
|
}
|
|
}
|
|
|
|
void SurfaceWrapper::SurfaceCompWrapper::get(std::span<LDBLE> &surface) const {
|
|
surface[0] = this->surface_comp.Get_moles();
|
|
surface[1] = this->surface_comp.Get_la();
|
|
surface[2] = this->surface_comp.Get_charge_balance();
|
|
|
|
const auto &totals = this->surface_comp.Get_totals();
|
|
for (std::size_t i = 0; i < this->total_names.size(); i++) {
|
|
surface[NUM_NOT_TOTALS + i] = totals.at(this->total_names[i]);
|
|
}
|
|
}
|
|
|
|
void SurfaceWrapper::SurfaceCompWrapper::set(const std::span<LDBLE> &surface) {
|
|
this->surface_comp.Set_moles(surface[0]);
|
|
this->surface_comp.Set_la(surface[1]);
|
|
this->surface_comp.Set_charge_balance(surface[2]);
|
|
|
|
auto &totals = this->surface_comp.Get_totals();
|
|
totals.clear();
|
|
|
|
for (std::size_t i = 0; i < this->total_names.size(); i++) {
|
|
const std::size_t index = NUM_NOT_TOTALS + i;
|
|
|
|
totals[this->total_names[i]] = surface[index];
|
|
}
|
|
}
|
|
|
|
std::vector<std::string>
|
|
SurfaceWrapper::SurfaceCompWrapper::names(cxxSurfaceComp &comp) {
|
|
std::vector<std::string> names;
|
|
|
|
const std::string &phase_name = comp.Get_formula();
|
|
names.push_back(phase_name + "_moles");
|
|
names.push_back(phase_name + "_la");
|
|
names.push_back(phase_name + "_cb");
|
|
|
|
for (const auto &tot : comp.Get_totals()) {
|
|
names.push_back(phase_name + "_" + tot.first);
|
|
}
|
|
|
|
return names;
|
|
} |