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


C++ OptionalQuantity::standardUnitsString方法代码示例

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


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

示例1: oneKg

TEST_F(UnitsFixture,QuantityConverter_CFMandSIUsingSystem)
{
    LOG(Debug, "QuantityConverter_CFMandSIUsingSystem");

    SIUnit siu1(openstudio::SIExpnt(1));
    Quantity oneKg(1.0, siu1);
    OptionalQuantity intermediate = QuantityConverter::instance().convert(oneKg, UnitSystem(UnitSystem::CFM));
    ASSERT_TRUE(intermediate);
    OptionalQuantity copyOfCopy = QuantityConverter::instance().convert(*intermediate, UnitSystem(UnitSystem::SI));
    ASSERT_TRUE(copyOfCopy);
    EXPECT_NEAR(oneKg.value(),copyOfCopy->value(),tol);
    EXPECT_EQ(oneKg.standardUnitsString(false),copyOfCopy->standardUnitsString(false));
}
开发者ID:urbanengr,项目名称:OpenStudio,代码行数:13,代码来源:QuantityConverter_GTest.cpp

示例2: createQuantity

TEST_F(ModelFixture, PlanarSurface_FilmResistanceConversions)
{
  Quantity q;
  OptionalQuantity qc;

  q = createQuantity(0.61,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::StillAir_HorizontalSurface_HeatFlowsUpward),1.0E-8);

  q = createQuantity(0.62,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::StillAir_45DegreeSurface_HeatFlowsUpward),1.0E-8);

  q = createQuantity(0.68,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::StillAir_VerticalSurface),1.0E-8);

  q = createQuantity(0.76,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::StillAir_45DegreeSurface_HeatFlowsDownward),1.0E-8);

  q = createQuantity(0.92,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::StillAir_HorizontalSurface_HeatFlowsDownward),1.0E-8);

  q = createQuantity(0.17,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::MovingAir_15mph),1.0E-8);

  q = createQuantity(0.25,"ft^2*R*h/Btu").get();
  qc = QuantityConverter::instance().convert(q,UnitSystem(UnitSystem::SI));
  ASSERT_TRUE(qc);
  EXPECT_EQ("s^3*K/kg",qc->standardUnitsString());
  EXPECT_NEAR(qc->value(),PlanarSurface::filmResistance(FilmResistanceType::MovingAir_7p5mph),1.0E-8);
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:47,代码来源:PlanarSurface_GTest.cpp

示例3: siSys

TEST_F(UnitsFixture,QuantityConverter_BTUandIPUsingSystem)
{
    LOG(Debug, "QuantityConverter_BTUandIPUsingSystem");

    UnitSystem siSys(UnitSystem::SI);
    UnitSystem ipSys(UnitSystem::IP);
    UnitSystem btuSys(UnitSystem::BTU);

    // uses BTU to SI, SI to IP
    BTUUnit btuu1(openstudio::BTUExpnt(1,-2,0,0), 3);
    Quantity bQ( 67.5, btuu1 );
    testStreamOutput("67.5 kBtu/ft^2",bQ);
    OptionalQuantity ipQ = QuantityConverter::instance().convert( bQ, ipSys);
    EXPECT_TRUE(ipQ);
    if (ipQ) {
        EXPECT_EQ("lb_m/s^2",ipQ->standardUnitsString(false));
        EXPECT_EQ("klb_m/s^2",ipQ->standardUnitsString());
        SCOPED_TRACE("btu1 to IP");
        testNumbersEqual(1689985.20448, ipQ->value());
    }

    BTUUnit btuu2(openstudio::BTUExpnt(0,0,-1));
    bQ = Quantity(5000.0, btuu2);
    ipQ = QuantityConverter::instance().convert( bQ, ipSys);
    EXPECT_TRUE(ipQ);
    if (ipQ) {
        SCOPED_TRACE("bQ to IP, 1");
        testStreamOutput("1.3889 1/s",*ipQ,4);
    }

    bQ *= bQ; // 25E6/h^2
    ipQ = QuantityConverter::instance().convert( bQ, ipSys);
    EXPECT_TRUE(ipQ);
    if (ipQ) {
        SCOPED_TRACE("bQ to IP, 2");
        testStreamOutput("1.9290 1/s^2",*ipQ,4);
    }

    BTUUnit btuu3(openstudio::BTUExpnt(-1),-3);
    bQ = Quantity(1.0, btuu3);
    testStreamOutput("1 1/kBtu",bQ);
    OptionalQuantity siQ = QuantityConverter::instance().convert(bQ,siSys);
    EXPECT_TRUE(siQ);
    if (siQ) {
        EXPECT_EQ("1/J",siQ->prettyUnitsString(false));
        SCOPED_TRACE("btu3 to SI");
        testNumbersEqual(9.478171203133172e-4,siQ->value());
        siQ->setScale(0);
        SCOPED_TRACE("rescaled btu3 to SI");
        testNumbersEqual(9.478171203133172e-7,siQ->value());
    }

    // uses IP to SI, SI to BTU
    IPUnit ipu1(openstudio::IPExpnt(0,1,0,-1,0,0,0,1), -2);
    Quantity ipQ2( 2.0, ipu1);
    OptionalQuantity bQ2 = QuantityConverter::instance().convert( ipQ2, btuSys);
    EXPECT_TRUE(bQ2);
    if (bQ2) {
        EXPECT_EQ("Btu/R", bQ2->standardUnitsString(false));
        EXPECT_EQ("cBtu/R", bQ2->standardUnitsString());
        SCOPED_TRACE("ipu1 to BTU");
        testNumbersEqual(0.002570134927, bQ2->value(),1.0e-5);
        bQ2->setScale(0);
        EXPECT_EQ("Btu/R", bQ2->standardUnitsString());
        testNumbersEqual(2.570134927e-5, bQ2->value(),1.0e-5);
    }
}
开发者ID:urbanengr,项目名称:OpenStudio,代码行数:67,代码来源:QuantityConverter_GTest.cpp


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