void OSDocument::exportIdf() { QString fileName = QFileDialog::getSaveFileName( this->mainWindow(), tr("Export Idf"), QDir::homePath(), tr("(*.idf)") ); if( ! fileName.isEmpty() ) { model::Model m = this->model(); energyplus::ForwardTranslator trans; Workspace workspace = trans.translateModel(m); openstudio::path outDir = toPath(fileName); boost::filesystem::ofstream ofs(outDir); workspace.toIdfFile().print(ofs); ofs.close(); } }
TEST_F(IdfFixture,ValidityReport_WithCustomIdd) { Workspace workspace; EXPECT_EQ(IddFileType::OpenStudio, workspace.iddFileType().value()); EXPECT_TRUE(workspace.isValid(StrictnessLevel::Draft)); workspace.addObject(IdfObject(IddObjectType::OS_Building)); EXPECT_TRUE(workspace.isValid(StrictnessLevel::Draft)); std::stringstream ss; workspace.iddFile().print(ss); boost::optional<IddFile> iddFile = IddFile::load(ss); ASSERT_TRUE(iddFile); Workspace workspace2(*iddFile, StrictnessLevel::None); EXPECT_EQ(IddFileType::UserCustom, workspace2.iddFileType().value()); workspace2.addObjects(workspace.toIdfFile().objects()); EXPECT_EQ(workspace.objects().size(), workspace2.objects().size()); EXPECT_TRUE(workspace2.isValid(StrictnessLevel::Draft)); ValidityReport report = workspace2.validityReport(StrictnessLevel::Draft); LOG(Debug,"Validity report for workspace2: " << std::endl << report); }
TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateCoolingCoil) { Model model; ScheduleCompact scheduleCompact(model); scheduleCompact.setName("Daytime Ventilation For Cooling Coil Test"); scheduleCompact.setString(1,"Fraction"); scheduleCompact.setString(2,"Through: 12/31"); scheduleCompact.setString(3,"For: Weekdays SummerDesignDay"); scheduleCompact.setString(4,"Until: 08:00"); scheduleCompact.setString(5,"0.0"); scheduleCompact.setString(6,"Until: 18:00"); scheduleCompact.setString(7,"1.0"); scheduleCompact.setString(8,"Until: 24:00"); scheduleCompact.setString(9,"0.0"); scheduleCompact.setString(10,"For: Weekends WinterDesignDay"); scheduleCompact.setString(11,"Until: 10:00"); scheduleCompact.setString(12,"0.0"); scheduleCompact.setString(13,"Until: 16:00"); scheduleCompact.setString(14,"1.0"); scheduleCompact.setString(15,"Until: 24:00"); scheduleCompact.setString(16,"0.0"); scheduleCompact.setString(17,"For: Holidays AllOtherDays"); scheduleCompact.setString(18,"Until: 24:00"); scheduleCompact.setString(19,"0.0"); CurveBiquadratic ccFofT(model); CurveBiquadratic eirFofT(model); CurveQuadratic ccFofF(model); CurveQuadratic eirFofF(model); CurveQuadratic plf(model); ccFofT.setCoefficient1Constant(1.0); ccFofT.setCoefficient2x(2.0); ccFofT.setCoefficient3xPOW2(3.0); ccFofT.setCoefficient4y(4.0); ccFofT.setCoefficient5yPOW2(5.0); ccFofT.setCoefficient6xTIMESY(6.0); ccFofT.setMinimumValueofx(-10.0); ccFofT.setMaximumValueofx(100.03); ccFofT.setMinimumValueofy(-99999); ccFofT.setMaximumValueofy(100232); ccFofT.setMinimumCurveOutput(-1000); ccFofT.setMaximumCurveOutput(99999); ccFofT.setInputUnitTypeforX("Temperature"); ccFofT.setInputUnitTypeforY("MassFlow"); eirFofT.setCoefficient1Constant(10.0); // eirFofT.setCoefficient2x(20.0); check default eirFofT.setCoefficient3xPOW2(30.0); eirFofT.setCoefficient4y(40.0); eirFofT.setCoefficient5yPOW2(50.0); eirFofT.setCoefficient6xTIMESY(60.0); eirFofT.setInputUnitTypeforX("VolumetricFlow"); eirFofT.setInputUnitTypeforY("Power"); plf.setCoefficient1Constant(5.50); plf.setCoefficient2x(55.50); plf.setCoefficient3xPOW2(23.50); CoilCoolingDXSingleSpeed cool(model, scheduleCompact, ccFofT, ccFofF, eirFofT, eirFofF, plf); ForwardTranslator trans; Workspace workspace = trans.translateModel(model); EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Version).size()); EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Coil_Cooling_DX_SingleSpeed).size()); EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Schedule_Compact).size()); EXPECT_EQ(2u,workspace.getObjectsByType(IddObjectType::Curve_Biquadratic).size()); EXPECT_EQ(3u,workspace.getObjectsByType(IddObjectType::Curve_Quadratic).size()); path outDir = resourcesPath() / openstudio::toPath("CoolingCoilDXSingleSpeed.idf"); boost::filesystem::ofstream ofs(outDir); workspace.toIdfFile().print(ofs); ofs.close(); openstudio::path idfPath = resourcesPath() / openstudio::toPath("CoolingCoilDXSingleSpeed.idf"); OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); ASSERT_TRUE(idfFile); Workspace inWorkspace(*idfFile); // Get the Model by calling the translator ReverseTranslator trans2; ASSERT_NO_THROW(trans2.translateWorkspace(inWorkspace)); Model model2 = trans2.translateWorkspace(inWorkspace); }