4    for (std::set<std::size_t>::const_iterator itisgi = unique_groups.begin(); itisgi != unique_groups.end(); ++itisgi) {
 
    5        for (std::set<std::size_t>::const_iterator itjsgi = unique_groups.begin(); itjsgi != unique_groups.end(); ++itjsgi) {
 
    6            if (*itjsgi >= *itisgi) {
 
    9            int mgi1 = 
static_cast<int>(m_sgi_to_mgi.find(*itisgi)->second);
 
   10            int mgi2 = 
static_cast<int>(m_sgi_to_mgi.find(*itjsgi)->second);
 
   14            interaction.insert(m_pair);
 
   19                interaction.insert(m_pair);
 
   27    if (parameter == 
"aij") {
 
   28        this->interaction[std::pair<int, int>(
static_cast<int>(mgi1), 
static_cast<int>(mgi2))].a_ij = value;
 
   29    } 
else if (parameter == 
"bij") {
 
   30        this->interaction[std::pair<int, int>(
static_cast<int>(mgi1), 
static_cast<int>(mgi2))].b_ij = value;
 
   31    } 
else if (parameter == 
"cij") {
 
   32        this->interaction[std::pair<int, int>(
static_cast<int>(mgi1), 
static_cast<int>(mgi2))].c_ij = value;
 
   39    if (it == this->interaction.end()) {
 
   42        if (parameter == 
"aij") {
 
   43            return it->second.a_ij;
 
   44        } 
else if (parameter == 
"bij") {
 
   45            return it->second.b_ij;
 
   46        } 
else if (parameter == 
"cij") {
 
   47            return it->second.c_ij;
 
   60    this->mole_fractions = z;
 
   61    if (this->N != z.size()) {
 
   65    std::map<std::size_t, double>&Xg = m_Xg, &thetag = m_thetag;
 
   71    for (std::size_t i = 0; i < this->mole_fractions.size(); ++i) {
 
   72        X_summer += this->mole_fractions[i] * pure_data[i].group_count;
 
   75    for (std::set<std::size_t>::iterator itsgi = unique_groups.begin(); itsgi != unique_groups.end(); ++itsgi) {
 
   78        for (std::size_t i = 0; i < this->mole_fractions.size(); ++i) {
 
   79            X += this->mole_fractions[i] * group_count(i, *itsgi);
 
   81        Xg.insert(std::pair<std::size_t, double>(*itsgi, 
X));
 
   84    for (std::map<std::size_t, double>::iterator it = Xg.begin(); it != Xg.end(); ++it) {
 
   85        it->second /= X_summer;
 
   88    double theta_summer = 0;
 
   89    for (std::set<std::size_t>::iterator itsgi = unique_groups.begin(); itsgi != unique_groups.end(); ++itsgi) {
 
   90        double cont = Xg.find(*itsgi)->second * m_Q.find(*itsgi)->second;
 
   92        thetag.insert(std::pair<std::size_t, double>(*itsgi, cont));
 
   95    for (std::map<std::size_t, double>::iterator it = thetag.begin(); it != thetag.end(); ++it) {
 
   96        it->second /= theta_summer;
 
  103    if (this->interaction.size() == 0) {
 
  106    std::size_t mgi1 = m_sgi_to_mgi.find(sgi1)->second;
 
  107    std::size_t mgi2 = m_sgi_to_mgi.find(sgi2)->second;
 
  112          this->interaction.find(std::pair<int, int>(
static_cast<int>(mgi1), 
static_cast<int>(mgi2)));
 
  113        if (it != this->interaction.end()) {
 
  114            return exp(-(it->second.a_ij / this->m_T + it->second.b_ij + it->second.c_ij * this->m_T));
 
  117              format(
"Could not match mgi[%d]-mgi[%d] interaction in UNIFAC", 
static_cast<int>(mgi1), 
static_cast<int>(mgi2)));
 
  124    for (std::vector<UNIFACLibrary::ComponentGroup>::const_iterator it = c.
groups.begin(); it != c.
groups.end(); ++it) {
 
  125        if (it->group.sgi == sgi) {
 
  133    return pure_data[i].theta.find(sgi)->second;
 
  144    if (this->mole_fractions.empty()) {
 
  149    for (std::set<std::size_t>::iterator itk = unique_groups.begin(); itk != unique_groups.end(); ++itk) {
 
  150        for (std::set<std::size_t>::iterator itm = unique_groups.begin(); itm != unique_groups.end(); ++itm) {
 
  151            Psi_[std::pair<std::size_t, std::size_t>(*itk, *itm)] = Psi(*itk, *itm);
 
  155    for (std::size_t i = 0; i < this->mole_fractions.size(); ++i) {
 
  157        for (std::size_t k = 0; k < c.
groups.size(); ++k) {
 
  158            double Q = c.
groups[k].group.Q_k;
 
  159            int sgik = c.
groups[k].group.sgi;
 
  161            for (std::size_t m = 0; m < c.
groups.size(); ++m) {
 
  162                int sgim = c.
groups[m].group.sgi;
 
  163                sum1 += theta_pure(i, sgim) * Psi_.find(std::pair<std::size_t, std::size_t>(sgim, sgik))->second;
 
  165            double s = 1 - log(sum1);
 
  166            for (std::size_t m = 0; m < c.
groups.size(); ++m) {
 
  167                int sgim = c.
groups[m].group.sgi;
 
  169                for (std::size_t n = 0; n < c.
groups.size(); ++n) {
 
  170                    int sgin = c.
groups[n].group.sgi;
 
  171                    sum2 += theta_pure(i, sgin) * Psi_.find(std::pair<std::size_t, std::size_t>(sgin, sgim))->second;
 
  173                s -= theta_pure(i, sgim) * Psi_.find(std::pair<std::size_t, std::size_t>(sgik, sgim))->second / sum2;
 
  175            pure_data[i].lnGamma[sgik] = Q * s;
 
  180    std::map<std::size_t, double>&thetag = m_thetag, &lnGammag = m_lnGammag;
 
  183    for (std::set<std::size_t>::iterator itksgi = unique_groups.begin(); itksgi != unique_groups.end(); ++itksgi) {
 
  185        for (std::set<std::size_t>::iterator itmsgi = unique_groups.begin(); itmsgi != unique_groups.end(); ++itmsgi) {
 
  186            sum1 += thetag.find(*itmsgi)->second * Psi_.find(std::pair<std::size_t, std::size_t>(*itmsgi, *itksgi))->second;
 
  188        double s = 1 - log(sum1);
 
  189        for (std::set<std::size_t>::iterator itmsgi = unique_groups.begin(); itmsgi != unique_groups.end(); ++itmsgi) {
 
  191            for (std::set<std::size_t>::iterator itnsgi = unique_groups.begin(); itnsgi != unique_groups.end(); ++itnsgi) {
 
  192                sum3 += thetag.find(*itnsgi)->second * Psi_.find(std::pair<std::size_t, std::size_t>(*itnsgi, *itmsgi))->second;
 
  194            s -= thetag.find(*itmsgi)->second * Psi_.find(std::pair<std::size_t, std::size_t>(*itksgi, *itmsgi))->second / sum3;
 
  196        lnGammag.insert(std::pair<std::size_t, double>(*itksgi, m_Q.find(*itksgi)->second * s));
 
  203        set_temperature(T_r / tau);
 
  205        for (std::set<std::size_t>::const_iterator itsgi = unique_groups.begin(); itsgi != unique_groups.end(); ++itsgi) {
 
  206            std::size_t count = group_count(i, *itsgi);
 
  208                summer += count * (m_lnGammag.find(*itsgi)->second - pure_data[i].lnGamma.find(*itsgi)->second);
 
  214        double dtau = 0.01 * tau;
 
  215        return (ln_gamma_R(tau + dtau, i, itau - 1) - ln_gamma_R(tau - dtau, i, itau - 1)) / (2 * dtau);
 
  219    if (this->N != z.size()) {
 
  222    std::vector<double> r(N), q(N), l(N), phi(N), theta(N), ln_Gamma_C(N);
 
  223    double summerzr = 0, summerzq = 0, summerzl = 0;
 
  224    for (std::size_t i = 0; i < N; ++i) {
 
  225        double summerr = 0, summerq = 0;
 
  227        for (std::size_t j = 0; j < c.
groups.size(); ++j) {
 
  234        summerzr += z[i] * r[i];
 
  235        summerzq += z[i] * q[i];
 
  237    for (std::size_t i = 0; i < N; ++i) {
 
  238        phi[i] = z[i] * r[i] / summerzr;
 
  239        theta[i] = z[i] * q[i] / summerzq;
 
  240        l[i] = 10.0 / 2.0 * (r[i] - q[i]) - (r[i] - 1);
 
  241        summerzl += z[i] * l[i];
 
  243    for (std::size_t i = 0; i < N; ++i) {
 
  244        ln_Gamma_C[i] = log(phi[i] / z[i]) + 10.0 / 2.0 * q[i] * log(theta[i] / phi[i]) + l[i] - phi[i] / z[i] * summerzl;
 
  245        gamma[i] = exp(ln_gamma_R(tau, i, 0) + ln_Gamma_C[i]);
 
  251    components.push_back(comp);
 
  252    for (std::vector<UNIFACLibrary::ComponentGroup>::const_iterator it = comp.
groups.begin(); it != comp.
groups.end(); ++it) {
 
  253        m_sgi_to_mgi.insert(std::pair<std::size_t, std::size_t>(it->group.sgi, it->group.mgi));
 
  259    N = identifiers.size();
 
  260    if (identifier_type == 
"name") {
 
  262        for (std::vector<std::string>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it) {
 
  277    unique_groups.clear();
 
  279    for (std::size_t i = 0; i < N; ++i) {
 
  284        for (std::size_t j = 0; j < c.
groups.size(); ++j) {
 
  286            double x = 
static_cast<double>(cg.
count);
 
  288            cd.
X.insert(std::pair<int, double>(cg.
group.
sgi, x));
 
  289            cd.
theta.insert(std::pair<int, double>(cg.
group.
sgi, theta));
 
  296        for (std::map<std::size_t, double>::iterator it = cd.
X.begin(); it != cd.
X.end(); ++it) {
 
  301        for (std::map<std::size_t, double>::iterator it = cd.
theta.begin(); it != cd.
theta.end(); ++it) {
 
  302            it->second /= summerxq;
 
  305        pure_data.push_back(cd);
 
  311    for (std::size_t i = 0; i < N; ++i) {
 
  312        for (std::size_t j = 0; j < components[i].groups.size(); ++j) {
 
  313            if (components[i].groups[j].group.sgi == sgi) {
 
  314                components[i].groups[j].group.Q_k = value;
 
  325    for (std::size_t i = 0; i < N; ++i) {
 
  326        for (std::size_t j = 0; j < components[i].groups.size(); ++j) {
 
  327            if (components[i].groups[j].group.sgi == sgi) {
 
  328                return components[i].groups[j].group.Q_k;