• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ vector_fp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中vector_fp的典型用法代码示例。如果您正苦于以下问题:C++ vector_fp类的具体用法?C++ vector_fp怎么用?C++ vector_fp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了vector_fp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: init

void Phase::init(const vector_fp& mw)
{
    m_kk = mw.size();
    m_rmolwts.resize(m_kk);
    m_y.resize(m_kk, 0.0);
    m_ym.resize(m_kk, 0.0);
    copy(mw.begin(), mw.end(), m_molwts.begin());
    for (size_t k = 0; k < m_kk; k++) {
        if (m_molwts[k] < 0.0) {
            throw CanteraError("Phase::init",
                               "negative molecular weight for species number "
                               + int2str(k));
        }

        // Some surface phases may define species representing empty sites
        // that have zero molecular weight. Give them a very small molecular
        // weight to avoid dividing by zero.
        if (m_molwts[k] < Tiny) {
            m_molwts[k] = Tiny;
        }
        m_rmolwts[k] = 1.0/m_molwts[k];
    }

    // Now that we have resized the State object, let's fill it with a valid
    // mass fraction vector that sums to one. The Phase object should never
    // have a mass fraction vector that doesn't sum to one. We will assume that
    // species 0 has a mass fraction of 1.0 and mass fraction of all other
    // species is 0.0.
    m_y[0] = 1.0;
    m_ym[0] = m_y[0] * m_rmolwts[0];
    m_mmw = 1.0 / m_ym[0];
}
开发者ID:anujg1991,项目名称:cantera,代码行数:32,代码来源:Phase.cpp


示例2: molecularWeights

void Phase::getMolecularWeights(vector_fp& weights) const
{
    const vector_fp& mw = molecularWeights();
    if (weights.size() < mw.size()) {
        weights.resize(mw.size());
    }
    copy(mw.begin(), mw.end(), weights.begin());
}
开发者ID:anujg1991,项目名称:cantera,代码行数:8,代码来源:Phase.cpp


示例3: setElementPotentials

void ThermoPhase::setElementPotentials(const vector_fp& lambda)
{
    size_t mm = nElements();
    if (lambda.size() < mm) {
        throw CanteraError("setElementPotentials", "lambda too small");
    }
    if (!m_hasElementPotentials) {
        m_lambdaRRT.resize(mm);
    }
    scale(lambda.begin(), lambda.end(), m_lambdaRRT.begin(), 1.0/RT());
    m_hasElementPotentials = true;
}
开发者ID:Niemeyer-Research-Group,项目名称:cantera,代码行数:12,代码来源:ThermoPhase.cpp


示例4: vec2str

std::string vec2str(const vector_fp& v, const std::string& fmt,
                    const std::string& sep)
{
    char buf[64];
    std::stringstream o;
    for (size_t i = 0; i < v.size(); i++) {
        SNPRINTF(buf, 63, fmt.c_str(), v[i]);
        o << v[i];
        if (i != v.size() - 1) {
            o << sep;
        }
    }
    return o.str();
}
开发者ID:eburke90,项目名称:Turbulent-Cantera,代码行数:14,代码来源:stringUtils.cpp


示例5: linearInterp

  /*
   * Vector xpts contains a monotonic sequence of grid points, and 
   * vector fpts contains function values defined at these points.
   * The value returned is the linear interpolate at point x.
   * If x is outside the range of xpts, the value of fpts at the 
   * nearest end is returned.
   *
   * @param x value of the x coordinate
   * @param xpts value of the grid points
   * @param fpts value of the interpolant at the grid points
   *
   * @return Returned value is the value of of the interpolated
   *         function at x.
   */
  doublereal linearInterp(doublereal x, const vector_fp& xpts, 
			  const vector_fp& fpts) {
    if (x <= xpts[0]) 
      return fpts[0];
    if (x >= xpts.back()) 
      return fpts.back();
    vector_fp::const_iterator loc = 
      lower_bound(xpts.begin(), xpts.end(), x);
    int iloc = int(loc - xpts.begin()) - 1;
    doublereal ff = fpts[iloc] + 
      (x - xpts[iloc])*(fpts[iloc + 1] 
			- fpts[iloc])/(xpts[iloc + 1] - xpts[iloc]);
    return ff;
  }
开发者ID:hkmoffat,项目名称:cantera,代码行数:28,代码来源:funcs.cpp


示例6: w

void IonFlow::setElectronTransport(vector_fp& tfix, vector_fp& diff_e,
                                   vector_fp& mobi_e)
{
    m_import_electron_transport = true;
    size_t degree = 5;
    size_t n = tfix.size();
    vector_fp tlog;
    for (size_t i = 0; i < n; i++) {
        tlog.push_back(log(tfix[i]));
    }
    vector_fp w(n, -1.0);
    m_diff_e_fix.resize(degree + 1);
    m_mobi_e_fix.resize(degree + 1);
    polyfit(n, degree, tlog.data(), diff_e.data(), w.data(), m_diff_e_fix.data());
    polyfit(n, degree, tlog.data(), mobi_e.data(), w.data(), m_mobi_e_fix.data());
}
开发者ID:CSM-Offenburg,项目名称:cantera,代码行数:16,代码来源:IonFlow.cpp


示例7: add

/*!
 * @param rxn  Reaction index of the current reaction. This is used
 *             as an index into vectors which have length n_total_rxn.
 * @param k    This is a vector of integer values specifying the
 *             species indices. The length of this vector species
 *             the number of different species in the description.
 *             The value of the entries are the species indices.
 *             These are used as indexes into vectors which have
 *             length n_total_species.
 *  @param order This is a vector of the same length as vector k.
 *         The order is used for the routine power(), which produces
 *         a power law expression involving the species vector.
 *  @param stoich  This is used to handle fractional stoichiometric coefficients
 *                 on the product side of irreversible reactions.
 */
void StoichManagerN::add(size_t rxn, const std::vector<size_t>& k, const vector_fp& order,
                         const vector_fp& stoich) {
    //printf ("add called\n");
    if (order.size() != k.size()) {
        throw CanteraError("StoichManagerN::add()", "size of order and species arrays differ");
    }
    if (stoich.size() != k.size()) {
        throw CanteraError("StoichManagerN::add()", "size of stoich and species arrays differ");
    }
    bool frac = false;
    for (size_t n = 0; n < stoich.size(); n++) {
        if (fmod(stoich[n], 1.0) || fmod(order[n], 1.0)) {
            frac = true;
            break;
        }
    }
    if (frac || k.size() > 3) {
        m_cn_list.push_back(C_AnyN(rxn, k, order, stoich));
    } else {
        // Try to express the reaction with unity stoichiometric
        // coefficients (by repeating species when necessary) so that the
        // simpler 'multiply' function can be used to compute the rate
        // instead of 'power'.
        std::vector<size_t> kRep;
        for (size_t n = 0; n < k.size(); n++) {
            for (size_t i = 0; i < stoich[n]; i++)
                kRep.push_back(k[n]);
        }

        switch (kRep.size()) {
        case 1:
            m_c1_list.push_back(C1(rxn, kRep[0]));
            break;
        case 2:
            m_c2_list.push_back(C2(rxn, kRep[0], kRep[1]));
            break;
        case 3:
            m_c3_list.push_back(C3(rxn, kRep[0], kRep[1], kRep[2]));
            break;
        default:
            m_cn_list.push_back(C_AnyN(rxn, k, order, stoich));
        }
    }
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:59,代码来源:StoichManager.cpp


示例8: checkNASA9Temps

  /**
   *  Check validity of the temperatures defining the 
   *  temperature ranges for the NASA9 polynomial species thermodynamic
   *  property fits. 
   *  @param log     log file output stream
   *  @param temp    Vector of temperatures
   */
  static void checkNASA9Temps(std::ostream& log, vector_fp &temp) {
    int i;
    for (i = 1; i <= (int) temp.size(); i++) {
      double tlow = temp[i-1];
      double thigh = temp[i];
      if (thigh <= tlow) {
	string sss =  "error reading temperature";
	throw CK_SyntaxError(log, sss);
      }
    }
  }
开发者ID:anujg1991,项目名称:cantera,代码行数:18,代码来源:NASA9Parser.cpp


示例9: printProgress

static void printProgress(const vector<string> &spName,
                          const vector_fp &soln,
                          const vector_fp &ff)
{
    double sum = 0.0;
    plogf(" --- Summary of current progress:\n");
    plogf(" ---                   Name           Moles  -       SSGibbs \n");
    plogf(" -------------------------------------------------------------------------------------\n");
    for (size_t k = 0; k < soln.size(); k++) {
        plogf(" ---      %20s %12.4g  - %12.4g\n", spName[k], soln[k], ff[k]);
        sum += soln[k] * ff[k];
    }
    plogf(" ---  Total sum to be minimized = %g\n", sum);
}
开发者ID:thomasfiala,项目名称:cantera,代码行数:14,代码来源:vcs_setMolesLinProg.cpp


示例10: writeFalloff

    /// print the falloff parameters for a pressure-dependent reaction
    bool writeFalloff(int type, const vector_fp& c, std::ostream& log) {

        log.precision(6);
        log.width(0);
        log.flags(ios::uppercase);

        //    bool ok = true;
        switch (type) {

        case Lindemann:
            log << "   Lindemann falloff function" << endl;
            return true;

        case Troe:
            log << "   Troe falloff function: " << endl;
            if (c.size() == 3) {
                log << "      alpha, T***, T* = (" << c[0] << ", " << c[1] 
                    << ", " << c[2] << ")" << endl;
            }
            else if (c.size() == 4) {
                log << "      alpha, T***, T*, T** = (" << c[0] << ", " << c[1] 
                    << ", " << c[2] << ", " << c[3] << ")" << endl;
            }
            else {
				for (size_t n = 0; n < c.size(); n++) {
					log << c[n] << ", "; log << endl;
				}
                log << "###### ERROR #####   incorrect number of parameters" << endl;
                return false;
            }
            return true;

        case SRI:
            log << "   SRI falloff function: " << endl;
            if (c.size() == 3) {
                log << "      a, b, c = (" << c[0] << ", " << c[1] 
                    << ", " << c[2] << ")" << endl;
            }
            else if (c.size() == 5) {
                log << "      a, b, c, d, e = (" << c[0] << ", " << c[1] 
                    << ", " << c[2] << ", " << c[3] << ", " << c[4] 
                    << ")" << endl;
            }
            else {
				for (size_t n = 0; n < c.size(); n++) {
					log << c[n] << ", "; log << endl;
				}
                log << "##### ERROR #####  incorrect number of parameters" << endl;
                return false;
            }
            return true;

        default:
            log << "unknown falloff type: " << type << endl;
            return false;
        }
    }
开发者ID:hkmoffat,项目名称:cantera,代码行数:58,代码来源:writelog.cpp


示例11: restoreState

void Phase::restoreState(const vector_fp& state)
{
    restoreState(state.size(),&state[0]);
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:4,代码来源:Phase.cpp


示例12: mean_X

doublereal Phase::mean_X(const vector_fp& Q) const
{
    return m_mmw*std::inner_product(m_ym.begin(), m_ym.end(), Q.begin(), 0.0);
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:4,代码来源:Phase.cpp


示例13: CK_SyntaxError

  /**
   *
   * Read species data from THERMO section records. 
   * 
   * @param names        List of species names (input).
   * @param species      Table of species objects holding data from records
   *                     in THERMO section (output). 
   * @param temp         Devault vector of temperature region boundaries
   *                     There are one more temperatures than there are
   *                     temperature regions.
   * @param allowExtThermoData   True if 'THERMO' specified, false if 
   *                             'THERMO ALL' specified.
   *
   * @return            True, if the THERMO section exists and the species
   *                    have all been successfully processed. False, if
   *                    the THERMO section doesn't exist or there were
   *                    additional problems.
   */
  bool CKParser::readNASA9ThermoSection(std::vector<string>& names, 
					speciesTable& species, vector_fp& temp, 
					int& optionFlag, std::ostream& log) {
    // String buffer for lines
    string s;
    vector<string> toks;
    string defaultDate="";
    int nreg = 2;
    int i;

    int nsp = static_cast<int>(names.size());

    // Comment string
    string comment;


    // if "THERMO ALL" specified, or if optionFlag is set to HasTempRange,
    // then the next line must be the default temperatures for the database.
    //
    //  This line will have nreg+2 tokens on it
    //    The last token is a date.
    if (0) {
      if (optionFlag == NoThermoDatabase || optionFlag == HasTempRange) {
	getCKLine(s, comment);
	getTokens(s, static_cast<int>(s.size()), toks);
	nreg = toks.size();
	if (nreg >= 1) {
	  temp.resize(nreg+1);
	  for (i = 0; i <= nreg; i++) {
	    temp[i] = de_atof(toks[i]);
	  }
	  defaultDate = toks[nreg+1];
	}
      
	if (verbose) {
	  log.flags(ios::showpoint | ios::fixed);
	  log.precision(2);
	  log << endl << " Default # of temperature regions: " << nreg << endl;
	  log << "          ";
	  for (i = 0; i <= nreg; i++) {
	    log << temp[i] << "  ";
	  }
	  log << endl;
	}
	checkNASA9Temps(log, temp);
      }
    }
    
    // Check to see that we expect to be reading a NASA9 formatted file
    if (!m_nasa9fmt) {
      throw CK_SyntaxError(log, 
			   "In NASA9 parser. However, we expect a different file format",
			   -1);
    }

    // now read in all species records that have names in list 'names'

    bool getAllSpecies = (nsp > 0 && match(names[0], "<ALL>"));
    if (getAllSpecies) names.clear();

    // Map between the number of times a species name appears in the database
    map<string, int> dup; // used to check for duplicate THERMO records
    bool already_read;

    while (1 > 0) {
      // If we don't have any more species to read, break
      if (nsp == 0) break;
      already_read = false;

      // Read a new species record from the section
      Species spec;
      readNASA9ThermoRecord(spec);

      // we signal the end of the section by putting <END> as a
      // species name. Break if you find the end of the section.
      if (spec.name == "<END>") {
	break;
      }
        
      // check for duplicate thermo data
      if (dup[spec.name] == 2) {
	log << "Warning: more than one THERMO record for "
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:NASA9Parser.cpp


示例14: saveState

void Phase::saveState(vector_fp& state) const
{
    state.resize(nSpecies() + 2);
    saveState(state.size(), &state[0]);
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:5,代码来源:Phase.cpp


示例15: writelog

/*
 * Choose the optimum basis for the calculations. This is done by
 * choosing the species with the largest mole fraction
 * not currently a linear combination of the previous components.
 * Then, calculate the stoichiometric coefficient matrix for that
 * basis.
 *
 * Calculates the identity of the component species in the mechanism.
 * Rearranges the solution data to put the component data at the
 * front of the species list.
 *
 * Then, calculates SC(J,I) the formation reactions for all noncomponent
 * species in the mechanism.
 *
 * Input
 * ---------
 * mphase          Pointer to the multiphase object. Contains the
 *                 species mole fractions, which are used to pick the
 *                 current optimal species component basis.
 * orderVectorElement
 *                 Order vector for the elements. The element rows
 *                 in the formula matrix are
 *                 rearranged according to this vector.
 * orderVectorSpecies
 *                 Order vector for the species. The species are
 *                 rearranged according to this formula. The first
 *                 nCompoments of this vector contain the calculated
 *                 species components on exit.
 * doFormRxn       If true, the routine calculates the formation
 *                 reaction matrix based on the calculated
 *                 component species. If false, this step is skipped.
 *
 * Output
 * ---------
 * usedZeroedSpecies = If true, then a species with a zero concentration
 *                     was used as a component. The problem may be
 *                     converged.
 * formRxnMatrix
 *
 * Return
 * --------------
 * returns the number of components.
 *
 *
 */
size_t Cantera::BasisOptimize(int* usedZeroedSpecies, bool doFormRxn,
                              MultiPhase* mphase, std::vector<size_t>& orderVectorSpecies,
                              std::vector<size_t>& orderVectorElements,
                              vector_fp& formRxnMatrix)
{

    size_t  j, jj, k=0, kk, l, i, jl, ml;
    bool lindep;
    std::string ename;
    std::string sname;
    /*
     * Get the total number of elements defined in the multiphase object
     */
    size_t ne = mphase->nElements();
    /*
     * Get the total number of species in the multiphase object
     */
    size_t nspecies = mphase->nSpecies();
    doublereal tmp;
    doublereal const USEDBEFORE = -1;

    /*
     * Perhaps, initialize the element ordering
     */
    if (orderVectorElements.size() < ne) {
        orderVectorElements.resize(ne);
        for (j = 0; j < ne; j++) {
            orderVectorElements[j] = j;
        }
    }

    /*
     * Perhaps, initialize the species ordering
     */
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        for (k = 0; k < nspecies; k++) {
            orderVectorSpecies[k] = k;
        }
    }

#ifdef DEBUG_MODE
    double molSave = 0.0;
    if (BasisOptimize_print_lvl >= 1) {
        writelog("   ");
        for (i=0; i<77; i++) {
            writelog("-");
        }
        writelog("\n");
        writelog("   --- Subroutine BASOPT called to ");
        writelog("calculate the number of components and ");
        writelog("evaluate the formation matrix\n");
        if (BasisOptimize_print_lvl > 0) {
            writelog("   ---\n");

//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:BasisOptimize.cpp


示例16: restoreState

void Phase::restoreState(const vector_fp& state)
{
    restoreState(state.size(),&state[0]);
    compositionChanged();
}
开发者ID:CSM-Offenburg,项目名称:cantera,代码行数:5,代码来源:Phase.cpp


示例17: ElemRearrange

void ElemRearrange(size_t nComponents, const vector_fp& elementAbundances,
                   MultiPhase* mphase,
                   std::vector<size_t>& orderVectorSpecies,
                   std::vector<size_t>& orderVectorElements)
{
    size_t nelements = mphase->nElements();
    // Get the total number of species in the multiphase object
    size_t nspecies = mphase->nSpecies();

    if (BasisOptimize_print_lvl > 0) {
        writelog("   ");
        writeline('-', 77);
        writelog("   --- Subroutine ElemRearrange() called to ");
        writelog("check stoich. coefficient matrix\n");
        writelog("   ---    and to rearrange the element ordering once\n");
    }

    // Perhaps, initialize the element ordering
    if (orderVectorElements.size() < nelements) {
        orderVectorElements.resize(nelements);
        for (size_t j = 0; j < nelements; j++) {
            orderVectorElements[j] = j;
        }
    }

    // Perhaps, initialize the species ordering. However, this is dangerous, as
    // this ordering is assumed to yield the component species for the problem
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        for (size_t k = 0; k < nspecies; k++) {
            orderVectorSpecies[k] = k;
        }
    }

    // If the elementAbundances aren't input, just create a fake one based on
    // summing the column of the stoich matrix. This will force elements with
    // zero species to the end of the element ordering.
    vector_fp eAbund(nelements,0.0);
    if (elementAbundances.size() != nelements) {
        for (size_t j = 0; j < nelements; j++) {
            eAbund[j] = 0.0;
            for (size_t k = 0; k < nspecies; k++) {
                eAbund[j] += fabs(mphase->nAtoms(k, j));
            }
        }
    } else {
        copy(elementAbundances.begin(), elementAbundances.end(),
             eAbund.begin());
    }

    vector_fp sa(nelements,0.0);
    vector_fp ss(nelements,0.0);
    vector_fp sm(nelements*nelements,0.0);

    // Top of a loop of some sort based on the index JR. JR is the current
    // number independent elements found.
    size_t jr = 0;
    while (jr < nComponents) {
        // Top of another loop point based on finding a linearly independent
        // element
        size_t k = nelements;
        while (true) {
            // Search the element vector. We first locate elements that are
            // present in any amount. Then, we locate elements that are not
            // present in any amount. Return its identity in K.
            size_t kk;
            for (size_t ielem = jr; ielem < nelements; ielem++) {
                kk = orderVectorElements[ielem];
                if (eAbund[kk] != USEDBEFORE && eAbund[kk] > 0.0) {
                    k = ielem;
                    break;
                }
            }
            for (size_t ielem = jr; ielem < nelements; ielem++) {
                kk = orderVectorElements[ielem];
                if (eAbund[kk] != USEDBEFORE) {
                    k = ielem;
                    break;
                }
            }

            if (k == nelements) {
                // When we are here, there is an error usually.
                // We haven't found the number of elements necessary.
                if (BasisOptimize_print_lvl > 0) {
                    writelogf("Error exit: returning with nComponents = %d\n", jr);
                }
                throw CanteraError("ElemRearrange", "Required number of elements not found.");
            }

            // Assign a large negative number to the element that we have
            // just found, in order to take it out of further consideration.
            eAbund[kk] = USEDBEFORE;

            // CHECK LINEAR INDEPENDENCE OF CURRENT FORMULA MATRIX
            // LINE WITH PREVIOUS LINES OF THE FORMULA MATRIX

            // Modified Gram-Schmidt Method, p. 202 Dalquist
            // QR factorization of a matrix without row pivoting.
            size_t jl = jr;
//.........这里部分代码省略.........
开发者ID:MrKingKong,项目名称:cantera,代码行数:101,代码来源:BasisOptimize.cpp


示例18: BasisOptimize

size_t BasisOptimize(int* usedZeroedSpecies, bool doFormRxn, MultiPhase* mphase,
                     std::vector<size_t>& orderVectorSpecies,
                     std::vector<size_t>& orderVectorElements,
                     vector_fp& formRxnMatrix)
{
    // Get the total number of elements defined in the multiphase object
    size_t ne = mphase->nElements();

    // Get the total number of species in the multiphase object
    size_t nspecies = mphase->nSpecies();

    // Perhaps, initialize the element ordering
    if (orderVectorElements.size() < ne) {
        orderVectorElements.resize(ne);
        iota(orderVectorElements.begin(), orderVectorElements.end(), 0);
    }

    // Perhaps, initialize the species ordering
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        iota(orderVectorSpecies.begin(), orderVectorSpecies.end(), 0);
    }

    if (BasisOptimize_print_lvl >= 1) {
        writelog("   ");
        writeline('-', 77);
        writelog("   --- Subroutine BASOPT called to ");
        writelog("calculate the number of components and ");
        writelog("evaluate the formation matrix\n");
        if (BasisOptimize_print_lvl > 0) {
            writelog("   ---\n");

            writelog("   ---      Formula Matrix used in BASOPT calculation\n");
            writelog("   ---      Species | Order | ");
            for (size_t j = 0; j < ne; j++) {
                size_t jj = orderVectorElements[j];
                writelog(" {:>4.4s}({:1d})", mphase->elementName(jj), j);
            }
            writelog("\n");
            for (size_t k = 0; k < nspecies; k++) {
                size_t kk = orderVectorSpecies[k];
                writelog("   --- {:>11.11s} |   {:4d} |",
                         mphase->speciesName(kk), k);
                for (size_t j = 0; j < ne; j++) {
                    size_t jj = orderVectorElements[j];
                    double num = mphase->nAtoms(kk,jj);
                    writelogf("%6.1g  ", num);
                }
                writelog("\n");
            }
            writelog("   --- \n");
        }
    }

    // Calculate the maximum value of the number of components possible. It's
    // equal to the minimum of the number of elements and the number of total
    // species.
    size_t nComponents = std::min(ne, nspecies);
    size_t nNonComponents = nspecies - nComponents;

    // Set this return variable to false
    *usedZeroedSpecies = false;

    // Create an array of mole numbers
    vector_fp molNum(nspecies,0.0);
    mphase->getMoles(molNum.data());

    // Other workspace
    vector_fp sm(ne*ne, 0.0);
    vector_fp ss(ne, 0.0);
    vector_fp sa(ne, 0.0);
    if (formRxnMatrix.size() < nspecies*ne) {
        formRxnMatrix.resize(nspecies*ne, 0.0);
    }

    // For debugging purposes keep an unmodified copy of the array.
    vector_fp molNumBase = molNum;
    double molSave = 0.0;
    size_t jr = 0;

    // Top of a loop of some sort based on the index JR. JR is the current
    // number of component species found.
    while (jr < nComponents) {
        // Top of another loop point based on finding a linearly independent
        // species
        size_t k = npos;
        while (true) {
            // Search the remaining part of the mole number vector, molNum for
            // the largest remaining species. Return its identity. kk is the raw
            // number. k is the orderVectorSpecies index.
            size_t kk = max_element(molNum.begin(), molNum.end()) - molNum.begin();
            size_t j;
            for (j = 0; j < nspecies; j++) {
                if (orderVectorSpecies[j] == kk) {
                    k = j;
                    break;
                }
            }
            if (j == nspecies) {
                throw CanteraError("BasisOptimize", "orderVectorSpecies contains an error");
//.........这里部分代码省略.........
开发者ID:MrKingKong,项目名称:cantera,代码行数:101,代码来源:BasisOptimize.cpp


示例19: getMolecularWeights

 /*
  * Copy the vector of molecular weights into vector weights.
  */
 void Phase::getMolecularWeights(vector_fp& weights) const {
   const array_fp& mw = Constituents::molecularWeights();
   if (weights.size() < mw.size()) weights.resize(mw.size());
   copy(mw.begin(), mw.end(), weights.begin());
 }
开发者ID:anujg1991,项目名称:cantera,代码行数:8,代码来源:Phase.cpp


示例20: getFloatArray

  /*
   *   This function will read a child node to the current XML node, with the
   *   name "floatArray". It will have a title attribute, and the body
   *   of the XML node will be filled out with a comma separated list of
   *   doublereals.
   *     Get an array of floats from the XML Node. The argument field
   *   is assumed to consist of an arbitrary number of comma
   *   separated floats, with an arbitrary amount of white space
   *   separating each field.
   *      If the node array has an units attribute field, then
   *   the units are used to convert the floats, iff convert is true.
   *
   *  Example:  
   *
   * Code snipet:
   *       @verbatum
     const XML_Node &State_XMLNode;
     vector_fp v;
     bool convert = true;
     unitsString = "";
     nodeName="floatArray";
     getFloatArray(State_XMLNode, v, convert, unitsString, nodeName);
   @endverbatum
   *
   *  reads the corresponding XML file:
   *
   *  @verbatum
   <state>
     <floatArray  units="m3">   32.4, 1, 100. <\floatArray>
   <\state>
   @endverbatum
   *
   *  Will produce the vector
   *
   *         v[0] = 32.4
   *         v[1] = 1.0
   *         v[2] = 100.
   *
   *
   *   @param  node         XML parent node of the floatArray
   *   @param  v            Output vector of floats containing the floatArray information.
   *   @param  convert      Conversion to SI is carried out if this boolean is
   *                        True. The default is true.
   *   @param  typeString   String name of the type attribute. This is an optional 
   *                        parameter. The default is to have an empty string.
   *                        The only string that is recognized is actEnergy. 
   *                        Anything else has no effect. This affects what
   *                        units converter is used.
   *   @param  nodeName     XML Name of the XML node to read. 
   *                        The default value for the node name is floatArray
   */
  void getFloatArray(const Cantera::XML_Node& node, vector_fp& v, const bool convert,
		     const std::string unitsString, const std::string nodeName) {
    string::size_type icom;
    string numstr;
    doublereal dtmp;
    string nn = node.name();
    if (nn != nodeName) 
      throw CanteraError("getFloatArray",
			 "wrong xml element type/name: was expecting "
			 + nodeName + "but accessed " + node.name());

    v.clear();
    doublereal vmin = Undef, vmax = Undef;

    doublereal funit = 1.0;
    /*
     * Get the attributes field, units, from the XML node
     */
    std::string units = node["units"];
    if (units != "" && convert) {
      if (unitsString == "actEnergy" && units != "") {
	funit = actEnergyToSI(units);
      } else if (unitsString != "" && units != "") {
	funit = toSI(units);
      }
    }

    if (node["min"] != "") 
      vmin = atofCheck(node["min"].c_str());
    if (node["max"] != "") 
      vmax = atofCheck(node["max"].c_str());

    doublereal vv;
    std::string val = node.value();
    while (1 > 0) {
      icom = val.find(',');
      if (icom != string::npos) {
	numstr = val.substr(0,icom);
	val = val.substr(icom+1,val.size());
	dtmp = atofCheck(numstr.c_str());
	v.push_back(dtmp);
      }
      else {
	/*
	 * This little bit of code is to allow for the
	 * possibility of a comma being the last 
	 * item in the value text. This was allowed in
	 * previous versions of Cantera, even though it
	 * would appear to be odd. So, we keep the
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:ctml.cpp



注:本文中的vector_fp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ vector_t类代码示例发布时间:2022-05-31
下一篇:
C++ vector_float类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap