<commit_before>/**
 * @file equilibrate.cpp Driver routines for the chemical equilibrium solvers.
 */

#include "cantera/equil/equil.h"
#include "cantera/equil/ChemEquil.h"
#include "cantera/equil/MultiPhaseEquil.h"
#include "cantera/equil/vcs_MultiPhaseEquil.h"
#include "cantera/base/global.h"

namespace Cantera
{

doublereal equilibrate(MultiPhase& s, const char* XY,
                       doublereal tol, int maxsteps, int maxiter,
                       int loglevel)
{
    s.init();
    int ixy = _equilflag(XY);
    if (ixy == TP || ixy == HP || ixy == SP || ixy == TV) {
        try {
            double err = s.equilibrate(ixy, tol, maxsteps, maxiter, loglevel);
            return err;
        } catch (CanteraError& err) {
            err.save();
            throw err;
        }
    } else {
        throw CanteraError("equilibrate","unsupported option");
        return -1.0;
    }
    return 0.0;
}

int equilibrate(thermo_t& s, const char* XY, int solver,
                doublereal rtol, int maxsteps, int maxiter, int loglevel)
{
    bool redo = true;
    int retn = -1;
    int nAttempts = 0;
    int retnSub = 0;

    while (redo) {
        if (solver >= 2) {
            int printLvlSub = 0;
            int estimateEquil = 0;
            try {
                MultiPhase m;
                m.addPhase(&s, 1.0);
                m.init();
                nAttempts++;
                vcs_equilibrate(m, XY, estimateEquil, printLvlSub, solver,
                                rtol, maxsteps, maxiter, loglevel-1);
                redo = false;
                retn = nAttempts;
            } catch (CanteraError& err) {
                err.save();
                if (nAttempts < 2) {
                    solver = -1;
                } else {
                    throw err;
                }
            }
        } else if (solver == 1) {
            try {
                MultiPhase m;
                m.addPhase(&s, 1.0);
                m.init();
                nAttempts++;
                equilibrate(m, XY, rtol, maxsteps, maxiter, loglevel-1);
                redo = false;
                retn = nAttempts;
            } catch (CanteraError& err) {
                err.save();
                if (nAttempts < 2) {
                    solver = -1;<commit_msg>Set printLvl = loglevel for VCS solver since it doesn't use loglevel<commit_after>/**
 * @file equilibrate.cpp Driver routines for the chemical equilibrium solvers.
 */

#include "cantera/equil/equil.h"
#include "cantera/equil/ChemEquil.h"
#include "cantera/equil/MultiPhaseEquil.h"
#include "cantera/equil/vcs_MultiPhaseEquil.h"
#include "cantera/base/global.h"

namespace Cantera
{

doublereal equilibrate(MultiPhase& s, const char* XY,
                       doublereal tol, int maxsteps, int maxiter,
                       int loglevel)
{
    s.init();
    int ixy = _equilflag(XY);
    if (ixy == TP || ixy == HP || ixy == SP || ixy == TV) {
        try {
            double err = s.equilibrate(ixy, tol, maxsteps, maxiter, loglevel);
            return err;
        } catch (CanteraError& err) {
            err.save();
            throw err;
        }
    } else {
        throw CanteraError("equilibrate","unsupported option");
        return -1.0;
    }
    return 0.0;
}

int equilibrate(thermo_t& s, const char* XY, int solver,
                doublereal rtol, int maxsteps, int maxiter, int loglevel)
{
    bool redo = true;
    int retn = -1;
    int nAttempts = 0;
    int retnSub = 0;

    while (redo) {
        if (solver >= 2) {
            int printLvlSub = loglevel;
            int estimateEquil = 0;
            try {
                MultiPhase m;
                m.addPhase(&s, 1.0);
                m.init();
                nAttempts++;
                vcs_equilibrate(m, XY, estimateEquil, printLvlSub, solver,
                                rtol, maxsteps, maxiter, loglevel-1);
                redo = false;
                retn = nAttempts;
            } catch (CanteraError& err) {
                err.save();
                if (nAttempts < 2) {
                    solver = -1;
                } else {
                    throw err;
                }
            }
        } else if (solver == 1) {
            try {
                MultiPhase m;
                m.addPhase(&s, 1.0);
                m.init();
                nAttempts++;
                equilibrate(m, XY, rtol, maxsteps, maxiter, loglevel-1);
                redo = false;
                retn = nAttempts;
            } catch (CanteraError& err) {
                err.save();
                if (nAttempts < 2) {
                    solver = -1;
{'fraction_non_alphanumeric': 0.10952996981457525, 'fraction_numerical': 0.008840017248814143, 'mean_word_length': 1.3548223350253807, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4979493', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1407, 'n_words': 357}