当前位置: 首页>>代码示例>>C++>>正文


C++ Units::obolluminosity方法代码示例

本文整理汇总了C++中Units::obolluminosity方法的典型用法代码示例。如果您正苦于以下问题:C++ Units::obolluminosity方法的具体用法?C++ Units::obolluminosity怎么用?C++ Units::obolluminosity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Units的用法示例。


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

示例1: setupSelfBefore


//.........这里部分代码省略.........
    // cache the random generator
    _random = find<Random>();

    // local constant for units
    const double pc = Units::pc();

    // vectors storing the particle attributes (r and h are data members since we need those after setup)
    std::vector<double> SFRv;
    std::vector<double> Zv;
    std::vector<double> logCv;
    std::vector<double> Pv;
    std::vector<double> fPDRv;

    // load the SPH star particles
    QString filepath = find<FilePaths>()->input(_filename);
    QFile infile(filepath);
    if (!infile.open(QIODevice::ReadOnly|QIODevice::Text))
        throw FATALERROR("Could not open the SPH HII region data file " + filepath);
    find<Log>()->info("Reading SPH HII region particles from file " + filepath + "...");
    int Nparts = 0;
    double SFRtot = 0;
    while (!infile.atEnd())
    {
        // read a line, split it in columns, and skip empty and comment lines
        QList<QByteArray> columns = infile.readLine().simplified().split(' ');
        if (!columns.isEmpty() && !columns[0].startsWith('#'))
        {
            // get the column values; missing or illegal values default to zero
            _rv.push_back(Vec(columns.value(0).toDouble()*pc,
                              columns.value(1).toDouble()*pc,
                              columns.value(2).toDouble()*pc));
            _hv.push_back(columns.value(3).toDouble()*pc);
            SFRv.push_back(columns.value(4).toDouble());  // star formation rate in Msun / yr
            Zv.push_back(columns.value(5).toDouble());    // metallicity as dimensionless fraction
            logCv.push_back(columns.value(6).toDouble()); // log compactness (Groves 2008) as dimensionless value
            Pv.push_back(columns.value(7).toDouble());    // ISM pressure in Pa
            fPDRv.push_back(columns.value(8).toDouble()); // dimensionless photo-dissociation region covering fraction

            Nparts++;
            SFRtot += columns.value(4).toDouble();
        }
    }
    infile.close();

    double Mtot = SFRtot * 1.e7;  // total stellar mass from total sfr over the last 10 Myr

    find<Log>()->info("  Total number of SPH HII region particles: " + QString::number(Nparts));
    find<Log>()->info("  Total stellar mass: " + QString::number(Mtot) + " Msun");

    find<Log>()->info("Filling the vectors with the SEDs of the particles... ");

    // construct the library of SED models
    MappingsSEDFamily map(this);

    // construct a temporary matrix Lvv with the luminosity of each particle at each wavelength
    // and also the permanent vector _Ltotv with the total luminosity for every wavelength bin
    int Nlambda = find<WavelengthGrid>()->Nlambda();
    ArrayTable<2> Lvv(Nlambda,Nparts);
    _Ltotv.resize(Nlambda);
    double Ltot = 0;
    for (int i=0; i<Nparts; i++)
    {
        const Array& Lv = map.luminosities(SFRv[i], Zv[i], logCv[i], Pv[i], fPDRv[i]);
        for (int ell=0; ell<Nlambda; ell++)
        {
            Lvv[ell][i] = Lv[ell];
            _Ltotv[ell] += Lv[ell];
            Ltot += Lv[ell];
        }
    }
    find<Log>()->info("  HII luminosity: " + QString::number(Ltot/Units::Lsun()) + " Lsun");

    // construct the permanent vectors _Xvv with the normalized cumulative luminosities (per wavelength bin)
    _Xvv.resize(Nlambda,0);
    for (int ell=0; ell<Nlambda; ell++)
    {
        NR::cdf(_Xvv[ell], Lvv[ell]);
    }

    // if requested, write a data file with the luminosities per wavelength
    if (_writeLuminosities)
    {
        Units* units = find<Units>();
        WavelengthGrid* lambdagrid = find<WavelengthGrid>();

        // Create a text file
        TextOutFile file(this, "HII_luminosities", "HII luminosities");

        // Write the header
        file.addColumn("lambda (" + units->uwavelength() + ")");
        file.addColumn("luminosity (" + units->ubolluminosity() + ")");

        // Write the body
        for (int ell=0; ell<Nlambda; ell++)
        {
            file.writeRow(QList<double>() << units->owavelength(lambdagrid->lambda(ell))
                                          << units->obolluminosity(_Ltotv[ell]));
        }
    }
}
开发者ID:DukhangLee,项目名称:SKIRT,代码行数:101,代码来源:SPHStarburstComp.cpp


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