mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 00:28:23 +01:00
Apply patches from GFZ
This commit is contained in:
parent
ba475ee488
commit
68f4e7723f
@ -169,6 +169,60 @@ cxxExchange::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxExchange::dump_essential_names(
|
||||
std::vector<std::string> &e_names) const {
|
||||
e_names.clear();
|
||||
e_names.reserve(this->exchange_comps.size() *
|
||||
this->exchange_comps.at(0).Get_totals().size());
|
||||
|
||||
for (const auto &comp : this->exchange_comps) {
|
||||
const std::string formular = comp.Get_formula();
|
||||
e_names.push_back(formular);
|
||||
for (const auto &total : comp.Get_totals()) {
|
||||
if (total.first == formular) {
|
||||
continue;
|
||||
}
|
||||
e_names.push_back(total.first + formular);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cxxExchange::get_essential_values(std::vector<LDBLE> &e_values) const {
|
||||
e_values.clear();
|
||||
e_values.reserve(this->exchange_comps.size() *
|
||||
this->exchange_comps.at(0).Get_totals().size());
|
||||
|
||||
for (const auto &comp : this->exchange_comps) {
|
||||
const std::string formular = comp.Get_formula();
|
||||
e_values.push_back(comp.Get_totals().find(formular)->second);
|
||||
for (const auto &total : comp.Get_totals()) {
|
||||
if (total.first == formular) {
|
||||
continue;
|
||||
}
|
||||
e_values.push_back(total.second);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxExchange::set_essential_values(std::vector<LDBLE>::iterator &it) {
|
||||
for (auto &comp : this->exchange_comps) {
|
||||
const std::string formular = comp.Get_formula();
|
||||
auto formular_total = comp.Get_totals();
|
||||
formular_total[formular] = *(it++);
|
||||
for (auto &total : comp.Get_totals()) {
|
||||
if (total.first == formular) {
|
||||
continue;
|
||||
}
|
||||
total.second = *(it++);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
cxxExchange::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
|
||||
@ -21,8 +21,12 @@ public:
|
||||
~cxxExchange();
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const;
|
||||
void dump_essential_names(std::vector<std::string> &e_names) const;
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
void get_essential_values(std::vector<LDBLE> &e_values) const;
|
||||
void set_essential_values(std::vector<LDBLE>::iterator &it);
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
|
||||
bool Get_related_phases(void) const;
|
||||
|
||||
|
||||
@ -131,6 +131,40 @@ cxxPPassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
|
||||
this->assemblage_totals.dump_raw(s_oss, indent + 1);
|
||||
}
|
||||
|
||||
void cxxPPassemblage::dump_essential_names(
|
||||
std::vector<std::string> &e_names) const {
|
||||
e_names.clear();
|
||||
e_names.reserve(this->pp_assemblage_comps.size() * 2);
|
||||
|
||||
for (const auto &pp_comp : this->pp_assemblage_comps) {
|
||||
e_names.push_back(pp_comp.first);
|
||||
e_names.push_back(pp_comp.first + "_si");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxPPassemblage::get_essential_values(std::vector<LDBLE> &e_values) const {
|
||||
e_values.clear();
|
||||
e_values.reserve(this->pp_assemblage_comps.size() * 2);
|
||||
|
||||
for (const auto &pp_comp : this->pp_assemblage_comps) {
|
||||
e_values.push_back(pp_comp.second.Get_moles());
|
||||
e_values.push_back(pp_comp.second.Get_si());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxPPassemblage::set_essential_values(std::vector<LDBLE>::iterator &it) {
|
||||
for (auto &pp_comp : this->pp_assemblage_comps) {
|
||||
pp_comp.second.Set_moles(*(it++));
|
||||
pp_comp.second.Set_si(*(it++));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
#if !defined(PPASSEMBLAGE_H_INCLUDED)
|
||||
#define PPASSEMBLAGE_H_INCLUDED
|
||||
|
||||
#include <cassert> // assert
|
||||
#include <map> // std::map
|
||||
#include <string> // std::string
|
||||
#include <list> // std::list
|
||||
#include <vector> // std::vector
|
||||
#include <cassert> // assert
|
||||
#include <list> // std::list
|
||||
#include <map> // std::map
|
||||
#include <set> // std::set
|
||||
#include <string> // std::string
|
||||
#include <vector> // std::vector
|
||||
|
||||
#include "NumKeyword.h"
|
||||
#include "PPassemblageComp.h"
|
||||
@ -22,9 +23,13 @@ class cxxPPassemblage:public cxxNumKeyword
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const;
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
void dump_essential_names(std::vector<std::string> &e_names) const;
|
||||
void get_essential_values(std::vector<LDBLE> &e_values) const;
|
||||
void set_essential_values(std::vector<LDBLE>::iterator &it);
|
||||
|
||||
const cxxNameDouble & Get_assemblage_totals() const
|
||||
void read_raw(CParser &parser, bool check = true);
|
||||
|
||||
const cxxNameDouble & Get_assemblage_totals() const
|
||||
{
|
||||
return this->assemblage_totals;
|
||||
};
|
||||
|
||||
@ -1233,10 +1233,17 @@ protected:
|
||||
*---------------------------------------------------------------------- */
|
||||
std::vector<class species_list> species_list;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Jacobian and Mass balance lists
|
||||
*---------------------------------------------------------------------- */
|
||||
std::vector<class list0> sum_jacob0; /* array of pointers to targets and coefficients for array */
|
||||
public:
|
||||
std::vector<class species_list> &Get_species_list() {
|
||||
return this->species_list;
|
||||
}
|
||||
|
||||
protected:
|
||||
/*----------------------------------------------------------------------
|
||||
* Jacobian and Mass balance lists
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
std::vector<class list0> sum_jacob0; /* array of pointers to targets and coefficients for array */
|
||||
|
||||
std::vector<class list1> sum_mb1; /* array of pointers to sources and targets for mass
|
||||
balance summations with coef = 1.0 */
|
||||
|
||||
@ -367,6 +367,70 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxSolution::dump_essential_names(
|
||||
std::vector<std::string> &e_names) const {
|
||||
e_names.clear();
|
||||
e_names.reserve(this->totals.size() + 3);
|
||||
|
||||
// e_names.push_back("H20");
|
||||
e_names.push_back("H");
|
||||
e_names.push_back("O");
|
||||
e_names.push_back("Charge");
|
||||
|
||||
for (const auto &total : this->totals) {
|
||||
if ((total.first == "O(0)") || (total.first == "H(0)")) {
|
||||
continue;
|
||||
}
|
||||
e_names.push_back(total.first);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxSolution::get_essential_values(
|
||||
std::vector<LDBLE> &e_values, const std::vector<std::string> &order) const {
|
||||
e_values.clear();
|
||||
e_values.reserve(this->totals.size() + 4);
|
||||
|
||||
// e_values.push_back(mass_water);
|
||||
e_values.push_back(total_h);
|
||||
e_values.push_back(total_o);
|
||||
e_values.push_back(cb);
|
||||
|
||||
for (int i = 3; i < order.size(); i++) {
|
||||
const auto tot = totals.find(order[i]);
|
||||
if (tot == totals.end()) {
|
||||
e_values.push_back(0);
|
||||
continue;
|
||||
}
|
||||
e_values.push_back((tot->second));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxSolution::set_essential_values(std::vector<LDBLE>::iterator &it,
|
||||
const std::vector<std::string> &order) {
|
||||
// skip first field of moles H2O
|
||||
// it++;
|
||||
|
||||
double t_h = *(it++);
|
||||
double t_o = *(it++);
|
||||
double c_b = *(it++);
|
||||
|
||||
cxxNameDouble nd;
|
||||
for (int i = 3; i < order.size(); i++) {
|
||||
double curr_val = *(it++);
|
||||
|
||||
if (curr_val < 0) {
|
||||
curr_val = 0;
|
||||
}
|
||||
nd.add(order[i].c_str(), curr_val);
|
||||
}
|
||||
|
||||
this->Update(t_h, t_o, c_b, nd);
|
||||
}
|
||||
|
||||
#ifdef USE_REVISED_READ_RAW
|
||||
void
|
||||
cxxSolution::read_raw(CParser & parser, bool check)
|
||||
|
||||
@ -105,7 +105,14 @@ class cxxSolution:public cxxNumKeyword
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const;
|
||||
|
||||
LDBLE Get_master_activity(char *string) const;
|
||||
void dump_essential_names(std::vector<std::string> &e_names) const;
|
||||
|
||||
void get_essential_values(std::vector<LDBLE> &e_values,
|
||||
const std::vector<std::string> &order) const;
|
||||
void set_essential_values(std::vector<LDBLE>::iterator &it,
|
||||
const std::vector<std::string> &order);
|
||||
|
||||
LDBLE Get_master_activity(char *string) const;
|
||||
void Set_master_activity(char *string, LDBLE value);
|
||||
LDBLE Get_total(const char *string) const;
|
||||
LDBLE Get_total_element(const char *string) const;
|
||||
|
||||
@ -178,6 +178,105 @@ cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) cons
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxSurface::dump_essential_names(std::vector<std::string> &e_names) {
|
||||
// this is just some reserve size, might be changed in the future
|
||||
const int reserve_size =
|
||||
surface_comps.size() * 4 + surface_charges.size() * 100;
|
||||
e_names.clear();
|
||||
e_names.reserve(reserve_size);
|
||||
|
||||
for (auto &comp : this->surface_comps) {
|
||||
const std::string phase_name = comp.Get_formula();
|
||||
e_names.push_back(phase_name + "_moles");
|
||||
e_names.push_back(phase_name + "_la");
|
||||
e_names.push_back(phase_name + "_cb");
|
||||
|
||||
for (const auto &tot : comp.Get_totals()) {
|
||||
e_names.push_back(phase_name + "_" + tot.first);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &charge : this->surface_charges) {
|
||||
const std::string component = charge.Get_name() + "_charge";
|
||||
e_names.push_back(component + "_area");
|
||||
e_names.push_back(component + "_grams");
|
||||
e_names.push_back(component + "_cb");
|
||||
e_names.push_back(component + "_mw");
|
||||
e_names.push_back(component + "_la");
|
||||
|
||||
for (const auto &tot : charge.Get_diffuse_layer_totals()) {
|
||||
e_names.push_back(component + "_tot_" + tot.first);
|
||||
}
|
||||
// for (const auto &dl_layer : charge.Get_dl_species_map()) {
|
||||
// e_names.push_back(component + "_dls_" +
|
||||
// std::to_string(dl_layer.first));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void cxxSurface::get_essential_values(std::vector<LDBLE> &e_values) {
|
||||
// this is just some reserve size, might be changed in the future
|
||||
const int reserve_size =
|
||||
surface_comps.size() * 4 + surface_charges.size() * 100;
|
||||
e_values.clear();
|
||||
e_values.reserve(reserve_size);
|
||||
|
||||
for (auto &comp : this->surface_comps) {
|
||||
e_values.push_back(comp.Get_moles());
|
||||
e_values.push_back(comp.Get_la());
|
||||
e_values.push_back(comp.Get_charge_balance());
|
||||
|
||||
for (const auto &tot : comp.Get_totals()) {
|
||||
e_values.push_back(tot.second);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &charge : this->surface_charges) {
|
||||
e_values.push_back(charge.Get_specific_area());
|
||||
e_values.push_back(charge.Get_grams());
|
||||
e_values.push_back(charge.Get_charge_balance());
|
||||
e_values.push_back(charge.Get_mass_water());
|
||||
e_values.push_back(charge.Get_la_psi());
|
||||
|
||||
for (const auto &tot : charge.Get_diffuse_layer_totals()) {
|
||||
e_values.push_back(tot.second);
|
||||
}
|
||||
// for (const auto &dl_layer : charge.Get_dl_species_map()) {
|
||||
// e_values.push_back(dl_layer.second);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void cxxSurface::set_essential_values(std::vector<LDBLE>::iterator &it) {
|
||||
for (auto &comp : this->surface_comps) {
|
||||
comp.Set_moles(*(it++));
|
||||
comp.Set_la(*(it++));
|
||||
comp.Set_charge_balance(*(it++));
|
||||
|
||||
for (auto &tot : comp.Get_totals()) {
|
||||
tot.second = *(it++);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &charge : this->surface_charges) {
|
||||
charge.Set_specific_area(*(it++));
|
||||
charge.Set_grams(*(it++));
|
||||
charge.Set_charge_balance(*(it++));
|
||||
charge.Set_mass_water(*(it++));
|
||||
charge.Set_la_psi(*(it++));
|
||||
|
||||
for (auto &tot : charge.Get_diffuse_layer_totals()) {
|
||||
tot.second = *(it++);
|
||||
}
|
||||
|
||||
charge.Get_dl_species_map().clear();
|
||||
|
||||
// for (auto &dl_layer : charge.Get_dl_species_map()) {
|
||||
// dl_layer.second = *(it++);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cxxSurface::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
|
||||
@ -30,7 +30,13 @@ public:
|
||||
|
||||
//void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const;
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
|
||||
void dump_essential_names(std::vector<std::string> &e_names);
|
||||
|
||||
void get_essential_values(std::vector<LDBLE> &e_values);
|
||||
void set_essential_values(std::vector<LDBLE>::iterator &it);
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
bool Get_related_phases(void) const;
|
||||
bool Get_related_rate(void) const;
|
||||
void totalize();
|
||||
|
||||
@ -158,6 +158,46 @@ cxxKinetics::dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out) co
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxKinetics::dump_essential_names(
|
||||
std::vector<std::string> &e_names) const {
|
||||
e_names.clear();
|
||||
e_names.reserve(this->kinetics_comps.size() * 2);
|
||||
|
||||
for (const auto &comp : this->kinetics_comps) {
|
||||
const std::string name = comp.Get_rate_name();
|
||||
e_names.push_back(name);
|
||||
for (int i = 0; i < comp.Get_d_params().size(); i++) {
|
||||
e_names.push_back(name + "_p" + std::to_string(i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cxxKinetics::get_essential_values(std::vector<LDBLE> &e_values) const {
|
||||
e_values.clear();
|
||||
e_values.reserve(this->kinetics_comps.size() * 2);
|
||||
|
||||
for (const auto &comp : this->kinetics_comps) {
|
||||
e_values.push_back(comp.Get_m());
|
||||
for (const auto ¶m : comp.Get_d_params()) {
|
||||
e_values.push_back(param);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxKinetics::set_essential_values(std::vector<LDBLE>::iterator &it) {
|
||||
for (auto &comp : this->kinetics_comps) {
|
||||
comp.Set_m(*(it++));
|
||||
for (auto ¶m : comp.Get_d_params()) {
|
||||
param = *(it++);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
|
||||
@ -25,7 +25,12 @@ class cxxKinetics:public cxxNumKeyword
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out=NULL) const;
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
void dump_essential_names(std::vector<std::string> &e_names) const;
|
||||
|
||||
void get_essential_values(std::vector<LDBLE> &e_values) const;
|
||||
void set_essential_values(std::vector<LDBLE>::iterator &it);
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
|
||||
std::vector < LDBLE > &Get_steps(void) {return steps;}
|
||||
const std::vector < LDBLE > &Get_steps(void)const {return steps;}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user