#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include enum { POET_SOL = 0, POET_EXCH, POET_KIN, POET_EQUIL, POET_SURF }; class IPhreeqcPOET : public IPhreeqc { public: std::vector get_essential_values(std::size_t cell_number, const std::vector &order); void set_essential_values(std::size_t cell_number, const std::vector &order, std::vector &values); IPhreeqcPOET(const std::string &database, const std::string &input_script) : IPhreeqc() { this->LoadDatabase(database.c_str()); this->RunFile(input_script.c_str()); this->parseInit(); } IPhreeqcPOET(const std::string &database, const std::string &input_script, const std::vector &solutionInitVector, std::uint32_t n_cells) : IPhreeqc(), n_cells(n_cells), solutionInitVector(solutionInitVector) { this->LoadDatabase(database.c_str()); this->RunFile(input_script.c_str()); if (n_cells > 1) { std::string copy_string = "COPY cell 1 2-" + std::to_string(n_cells) + "\n"; } } struct PhreeqcMat { std::vector names; std::vector ids; std::vector> values; }; PhreeqcMat getPhreeqcMat(); PhreeqcMat getPhreeqcMat(const std::vector &ids); std::map raw_dumps() { std::map dumps; this->SetDumpStringOn(true); for (const auto &[sol_id, unused] : this->raw_initials) { std::string call_string = "DUMP\n -cells " + std::to_string(sol_id); this->RunString(call_string.c_str()); dumps[sol_id] = this->GetDumpString(); } this->SetDumpStringOn(false); return dumps; } using essential_names = std::array, 5>; using ModulesArray = std::array; ModulesArray getModuleSizes() const { ModulesArray module_sizes; for (std::uint8_t i = 0; i < 5; i++) { module_sizes[i] = this->initial_names[i].size(); } return module_sizes; } private: // required only for simulation essential_names initial_names; std::uint32_t n_cells; std::vector solutionInitVector; void parseInitValues(); void parseInit(); essential_names dump_essential_names(std::size_t cell_number); cxxSolution *Get_solution(std::size_t n) { return Utilities::Rxn_find(this->PhreeqcPtr->Get_Rxn_solution_map(), n); } cxxExchange *Get_exchange(std::size_t n) { return Utilities::Rxn_find(this->PhreeqcPtr->Get_Rxn_exchange_map(), n); } cxxKinetics *Get_kinetic(std::size_t n) { return Utilities::Rxn_find(this->PhreeqcPtr->Get_Rxn_kinetics_map(), n); } cxxPPassemblage *Get_equilibrium(std::size_t n) { return Utilities::Rxn_find(this->PhreeqcPtr->Get_Rxn_pp_assemblage_map(), n); } cxxSurface *Get_surface(std::size_t n) { return Utilities::Rxn_find(this->PhreeqcPtr->Get_Rxn_surface_map(), n); } using RawMap = std::map>>; essential_names union_raws(const RawMap &raws); std::vector> conc_from_essentials(const RawMap &raws, const essential_names &names); // void valuesFromModule(const std::string &module_name, int cell_number, // essential_names &names, std::vector &values); std::string subExchangeName(std::string name) { for (const auto &species : this->PhreeqcPtr->Get_species_list()) { const std::string &species_name = species.s->name; // check if `name` is a prefix of `species_name` if (species_name.compare(0, name.size(), name) == 0) { return species_name; } } return name; }; RawMap raw_initials; };