iphreeqc/System.cxx
Darth Vader ed1fbe9491 Squashed 'phreeqcpp/' changes from bd2e2b6..625f6f1
625f6f1 Fixed bugs in inverse
ea9e0ef strcpy_safe and strcat_safe
9b06157 trying different header files
e890269 added <cstring>
c370c7b warnings, strcat, strcpy
14ed59f Try using goto(s)
d2d31d2 Try updated logical expression
d2a3eac Turn off optimizing on k_temp

git-subtree-dir: phreeqcpp
git-subtree-split: 625f6f14905e41a1130a3d0a217b8de478631aca
2023-11-16 05:06:27 +00:00

104 lines
2.4 KiB
C++

#include <algorithm> // std::replace
#include "Phreeqc.h"
#include "System.h"
#include "SSassemblage.h"
#include "Solution.h"
#include "Exchange.h"
#include "GasPhase.h"
#include "cxxKinetics.h"
#include "PPassemblage.h"
#include "SS.h"
#include "SSassemblage.h"
#include "Surface.h"
#include "cxxMix.h"
#include "Reaction.h"
#include "Temperature.h"
#include "Utils.h"
#if defined(PHREEQCI_GUI)
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#endif
cxxSystem::cxxSystem(PHRQ_io *io)
:
PHRQ_base(io)
{
this->solution = NULL;
this->exchange = NULL;
this->ppassemblage = NULL;
this->gasphase = NULL;
this->ssassemblage = NULL;
this->kinetics = NULL;
this->surface = NULL;
this->mix = NULL;
this->reaction = NULL;
this->temperature = NULL;
this->pressure = NULL;
}
cxxSystem::~cxxSystem(void)
{
}
void
cxxSystem::Initialize(void)
{
this->solution = NULL;
this->exchange = NULL;
this->ppassemblage = NULL;
this->gasphase = NULL;
this->ssassemblage = NULL;
this->kinetics = NULL;
this->surface = NULL;
this->mix = NULL;
this->reaction = NULL;
this->temperature = NULL;
this->pressure = NULL;
}
void
cxxSystem::totalize(Phreeqc * phreeqc_ptr)
{
//initialize
this->totals.clear();
//add solution
if (this->solution != NULL)
{
char token[MAX_LENGTH];
Utilities::strcpy_safe(token, MAX_LENGTH, "O");
this->totals[token] = this->solution->Get_total_o();
Utilities::strcpy_safe(token, MAX_LENGTH, "H");
this->totals[token] = this->solution->Get_total_h();
Utilities::strcpy_safe(token, MAX_LENGTH, "Charge");
this->totals[token] = this->solution->Get_cb();
this->totals.add_extensive(this->solution->Get_totals(), 1.0);
}
if (this->exchange != NULL)
{
this->exchange->totalize();
this->totals.add_extensive(this->exchange->Get_totals(), 1.0);
}
if (this->ppassemblage != NULL)
{
this->ppassemblage->totalize(phreeqc_ptr);
this->totals.add_extensive(this->ppassemblage->Get_assemblage_totals(), 1.0);
}
if (this->gasphase != NULL)
{
this->gasphase->totalize(phreeqc_ptr);
this->totals.add_extensive(this->gasphase->Get_totals(), 1.0);
}
if (this->ssassemblage != NULL)
{
this->ssassemblage->totalize(phreeqc_ptr);
this->totals.add_extensive(this->ssassemblage->Get_totals(), 1.0);
}
if (this->surface != NULL)
{
this->surface->totalize();
this->totals.add_extensive(this->surface->Get_totals(), 1.0);
}
return;
}