diff --git a/ruby/test/ElectricLoadCenterDistribution_Test.rb b/ruby/test/ElectricLoadCenterDistribution_Test.rb index 66f93d18298..ffed1b55fda 100644 --- a/ruby/test/ElectricLoadCenterDistribution_Test.rb +++ b/ruby/test/ElectricLoadCenterDistribution_Test.rb @@ -42,7 +42,7 @@ def test_ElectricLoadCenterDistribution_Photovoltaics assert(elcd.inverter.empty?) simple_panel = OpenStudio::Model::GeneratorPhotovoltaic::simple(model) - assert(!simple_panel.electricLoadCenterDistribution.empty?) + assert(simple_panel.electricLoadCenterDistribution.empty?) elcd.addGenerator(simple_panel) assert(!simple_panel.electricLoadCenterDistribution.empty?) @@ -50,7 +50,7 @@ def test_ElectricLoadCenterDistribution_Photovoltaics assert(elcd.inverter.empty?) eod_panel = OpenStudio::Model::GeneratorPhotovoltaic::equivalentOneDiode(model) - assert(!eod_panel.electricLoadCenterDistribution.empty?) + assert(eod_panel.electricLoadCenterDistribution.empty?) elcd.addGenerator(eod_panel) assert(!eod_panel.electricLoadCenterDistribution.empty?) diff --git a/src/energyplus/CMakeLists.txt b/src/energyplus/CMakeLists.txt index 579501a9f1f..f06e96b61ca 100644 --- a/src/energyplus/CMakeLists.txt +++ b/src/energyplus/CMakeLists.txt @@ -615,6 +615,7 @@ set(${target_name}_test_src Test/DesignSpecificationOutdoorAir_GTest.cpp Test/ElectricEquipment_GTest.cpp Test/ElectricEquipmentITEAirCooled_GTest.cpp + Test/ElectricLoadCenterDistribution_GTest.cpp Test/ElectricLoadCenterTransformer_GTest.cpp Test/EMS_GTest.cpp Test/EvaporativeCoolerDirectResearchSpecial_GTest.cpp diff --git a/src/energyplus/ForwardTranslator.cpp b/src/energyplus/ForwardTranslator.cpp index 7bffd0131ae..9b7f0e30982 100644 --- a/src/energyplus/ForwardTranslator.cpp +++ b/src/energyplus/ForwardTranslator.cpp @@ -419,20 +419,7 @@ namespace energyplus { } } - // Remove empty electric load center distribution objects (e.g. with no generators) - // requested by jmarrec, https://github.com/NREL/OpenStudio/pull/1927 - // add check for transformers - for (auto& elcd : model.getConcreteModelObjects()) { - if ((elcd.generators().empty()) && (!elcd.transformer())) { - LOG(Warn, "ElectricLoadCenterDistribution " << elcd.name().get() - << " is not referenced by any generators or transformers, it will not be translated."); - if (auto inverter = elcd.inverter()) { - inverter->remove(); - } - elcd.remove(); - } - } - + // Remove orphan Inverters for (auto& inverter : model.getModelObjects()) { if (!inverter.electricLoadCenterDistribution()) { LOG(Warn, "Inverter " << inverter.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateElectricLoadCenterDistribution.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateElectricLoadCenterDistribution.cpp index 9f0dca492d9..0687152272a 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateElectricLoadCenterDistribution.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateElectricLoadCenterDistribution.cpp @@ -63,64 +63,71 @@ namespace energyplus { IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ElectricLoadCenter_Distribution, modelObject); - IdfObject generatorsIdf(openstudio::IddObjectType::ElectricLoadCenter_Generators); - generatorsIdf.setName(idfObject.name().get() + " Generators"); - m_idfObjects.push_back(generatorsIdf); + /// Generator Fields + if (!modelObject.generators().empty()) { + IdfObject generatorsIdf(openstudio::IddObjectType::ElectricLoadCenter_Generators); - idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorListName, generatorsIdf.name().get()); + m_idfObjects.push_back(generatorsIdf); - idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType, modelObject.generatorOperationSchemeType()); + generatorsIdf.setName(idfObject.name().get() + " Generators"); - if ((optD = modelObject.demandLimitSchemePurchasedElectricDemandLimit())) { - idfObject.setDouble(ElectricLoadCenter_DistributionFields::GeneratorDemandLimitSchemePurchasedElectricDemandLimit, optD.get()); - } + idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorListName, generatorsIdf.name().get()); - if ((schedule = modelObject.trackScheduleSchemeSchedule())) { - idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorTrackScheduleNameSchemeScheduleName, schedule->name().get()); - } + idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType, modelObject.generatorOperationSchemeType()); - if ((optS = modelObject.trackMeterSchemeMeterName())) { - idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorTrackMeterSchemeMeterName, (*optS)); - } + if ((optD = modelObject.demandLimitSchemePurchasedElectricDemandLimit())) { + idfObject.setDouble(ElectricLoadCenter_DistributionFields::GeneratorDemandLimitSchemePurchasedElectricDemandLimit, optD.get()); + } - boost::optional transformer = modelObject.transformer(); - if (transformer) { - boost::optional transformerIdf = translateAndMapModelObject(transformer.get()); - if (transformerIdf) { - idfObject.setString(ElectricLoadCenter_DistributionFields::TransformerObjectName, transformerIdf->name().get()); + if ((schedule = modelObject.trackScheduleSchemeSchedule())) { + idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorTrackScheduleNameSchemeScheduleName, schedule->name().get()); } - } - for (auto& generator : modelObject.generators()) { - boost::optional generatorIdf = translateAndMapModelObject(generator); + if ((optS = modelObject.trackMeterSchemeMeterName())) { + idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorTrackMeterSchemeMeterName, (*optS)); + } - if (generatorIdf) { - IdfExtensibleGroup generatorGroup = generatorsIdf.pushExtensibleGroup(); + /// ElectricLoadCenter:Generators + for (auto& generator : modelObject.generators()) { + boost::optional generatorIdf = translateAndMapModelObject(generator); - generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorName, generatorIdf->name().get()); + if (generatorIdf) { + IdfExtensibleGroup generatorGroup = generatorsIdf.pushExtensibleGroup(); - generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorObjectType, generator.generatorObjectType()); + generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorName, generatorIdf->name().get()); - optD = generator.ratedElectricPowerOutput(); - if (optD) { - generatorGroup.setDouble(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorRatedElectricPowerOutput, *optD); - } + generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorObjectType, generator.generatorObjectType()); - schedule = generator.availabilitySchedule(); - if (schedule) { - boost::optional scheduleIdf = translateAndMapModelObject(*schedule); - if (scheduleIdf) { - generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorAvailabilityScheduleName, scheduleIdf->name().get()); + optD = generator.ratedElectricPowerOutput(); + if (optD) { + generatorGroup.setDouble(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorRatedElectricPowerOutput, *optD); } - } - optD = generator.ratedThermaltoElectricalPowerRatio(); - if (optD) { - generatorGroup.setDouble(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorRatedThermaltoElectricalPowerRatio, *optD); + schedule = generator.availabilitySchedule(); + if (schedule) { + boost::optional scheduleIdf = translateAndMapModelObject(*schedule); + if (scheduleIdf) { + generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorAvailabilityScheduleName, scheduleIdf->name().get()); + } + } + + optD = generator.ratedThermaltoElectricalPowerRatio(); + if (optD) { + generatorGroup.setDouble(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorRatedThermaltoElectricalPowerRatio, *optD); + } + } else { + LOG(Warn, "Could not translate generator '" << generator.name().get() << "' on ElectricLoadCenter:Distribution '" << idfObject.name().get() + << "'") } - } else { - LOG(Warn, - "Could not translate generator '" << generator.name().get() << "' on ElectricLoadCenter:Distribution '" << idfObject.name().get() << "'") + } + } + + /// Transformer Object + boost::optional transformer = modelObject.transformer(); + if (transformer) { + boost::optional transformerIdf = translateAndMapModelObject(transformer.get()); + if (transformerIdf) { + idfObject.setString(ElectricLoadCenter_DistributionFields::TransformerObjectName, transformerIdf->name().get()); } } @@ -156,7 +163,7 @@ namespace energyplus { } // Case 4: there's no inverter and a buss type without inverter: nothing needs to be done - /// Storage & Buss Type + /// Storage and Buss Type boost::optional electricalStorage = modelObject.electricalStorage(); bool bussWithStorage = (bussType == "AlternatingCurrentWithStorage" || bussType == "DirectCurrentWithInverterDCStorage" || bussType == "DirectCurrentWithInverterACStorage"); @@ -298,7 +305,7 @@ namespace energyplus { LOG(Error, modelObject.briefDescription() << ": Your Electric Buss Type '" << bussType << "' Requires an electrical Storage object but you didn't specify one"); } - // Case 4: there's no inverter and a buss type without inverter: nothing needs to be done + // Case 4: there's no Storage object and the buss is not compatible: nothing needs to be done return idfObject; } diff --git a/src/energyplus/Test/ElectricLoadCenterDistribution_GTest.cpp b/src/energyplus/Test/ElectricLoadCenterDistribution_GTest.cpp new file mode 100644 index 00000000000..c63e0df4211 --- /dev/null +++ b/src/energyplus/Test/ElectricLoadCenterDistribution_GTest.cpp @@ -0,0 +1,145 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ErrorFile.hpp" +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/Model_Impl.hpp" +#include "../../model/Building.hpp" +#include "../../model/Building_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" + +#include "../../model/ThermalZone.hpp" + +#include "../../model/ElectricLoadCenterDistribution.hpp" +#include "../../model/ElectricLoadCenterDistribution_Impl.hpp" +#include "../../model/GeneratorPVWatts.hpp" +#include "../../model/GeneratorPVWatts_Impl.hpp" +#include "../../model/ElectricLoadCenterInverterPVWatts.hpp" +#include "../../model/ElectricLoadCenterInverterPVWatts_Impl.hpp" + +#include "../../model/Version.hpp" +#include "../../model/Version_Impl.hpp" + +#include "../../utilities/core/Optional.hpp" +#include "../../utilities/core/Checksum.hpp" +#include "../../utilities/core/UUID.hpp" +#include "../../utilities/core/Logger.hpp" +#include "../../utilities/sql/SqlFile.hpp" +#include "../../utilities/idf/IdfFile.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include + +#include + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +TEST_F(EnergyPlusFixture, ForwardTranslator_ElectricLoadCenterDistribution_NoInverter) { + + Model model; + + ElectricLoadCenterDistribution elcd(model); + + EXPECT_EQ(1u, model.getObjectsByType(ElectricLoadCenterDistribution::iddObjectType()).size()); + + GeneratorPVWatts gntr(model, 1); + elcd.addGenerator(gntr); + + EXPECT_EQ(1u, model.getObjectsByType(ElectricLoadCenterDistribution::iddObjectType()).size()); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution).size()); + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Generators).size()); + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::Generator_PVWatts).size()); + EXPECT_EQ(0u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Inverter_PVWatts).size()); + + WorkspaceObject distribution = workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution)[0]; + WorkspaceObject generators = workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Generators)[0]; + WorkspaceObject generator = workspace.getObjectsByType(IddObjectType::Generator_PVWatts)[0]; + + EXPECT_EQ(generators.nameString(), distribution.getString(ElectricLoadCenter_DistributionFields::GeneratorListName, false).get()); + + ASSERT_EQ(1u, generators.extensibleGroups().size()); + WorkspaceExtensibleGroup w_eg = generators.extensibleGroups()[0].cast(); + EXPECT_EQ(generator.nameString(), w_eg.getString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorName, false).get()); +} + +TEST_F(EnergyPlusFixture, ForwardTranslator_ElectricLoadCenterDistribution_NoGenerators) { + + Model model; + + ElectricLoadCenterDistribution elcd(model); + elcd.setElectricalBussType("DirectCurrentWithInverter"); + + EXPECT_EQ(1u, model.getObjectsByType(ElectricLoadCenterDistribution::iddObjectType()).size()); + + ElectricLoadCenterInverterPVWatts invtr(model); + elcd.setInverter(invtr); + + EXPECT_EQ(1u, model.getObjectsByType(ElectricLoadCenterDistribution::iddObjectType()).size()); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution).size()); + EXPECT_EQ(0u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Generators).size()); + EXPECT_EQ(0u, workspace.getObjectsByType(IddObjectType::Generator_PVWatts).size()); + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Inverter_PVWatts).size()); + + WorkspaceObject distribution = workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution)[0]; + WorkspaceObject inverter = workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Inverter_PVWatts)[0]; + + EXPECT_EQ(inverter.nameString(), distribution.getString(ElectricLoadCenter_DistributionFields::InverterName, false).get()); +} \ No newline at end of file diff --git a/src/energyplus/Test/FuelCell_GTest.cpp b/src/energyplus/Test/FuelCell_GTest.cpp index 7f60232cb2b..215c864df5d 100644 --- a/src/energyplus/Test/FuelCell_GTest.cpp +++ b/src/energyplus/Test/FuelCell_GTest.cpp @@ -173,6 +173,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorFuelCell) { boost::optional fSC = fuelcell.stackCooler(); EXPECT_FALSE(fSC); + ElectricLoadCenterDistribution elcd(model); + elcd.setElectricalBussType("AlternatingCurrent"); + elcd.addGenerator(fuelcell); + ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -212,9 +216,13 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorFuelCell2) { GeneratorFuelSupply fuelSupply(model); // create default fuelcell GeneratorFuelCell fuelcell(model, powerModule, airSupply, waterSupply, auxHeater, exhaustHX, elecStorage, inverter, fuelSupply); - // Stack cooler is optional. For it to be transalted, it needs to be linked to a fuelcell parent + // Stack cooler is optional. For it to be translated, it needs to be linked to a fuelcell parent fuelcell.setStackCooler(stackCooler); + ElectricLoadCenterDistribution elcd(model); + elcd.setElectricalBussType("AlternatingCurrent"); + elcd.addGenerator(fuelcell); + ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -310,7 +318,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorFuelCell4) { // remove the ELCD boost::optional elcd = fuelcell.electricLoadCenterDistribution(); - elcd.get().remove(); + //elcd.get().remove(); EXPECT_FALSE(fuelcell.electricLoadCenterDistribution()); ForwardTranslator forwardTranslator; diff --git a/src/model/GeneratorFuelCell.cpp b/src/model/GeneratorFuelCell.cpp index 6deb281b20a..1e3cac1a4e8 100644 --- a/src/model/GeneratorFuelCell.cpp +++ b/src/model/GeneratorFuelCell.cpp @@ -50,8 +50,6 @@ #include "GeneratorFuelCellStackCooler_Impl.hpp" #include "GeneratorFuelSupply.hpp" #include "GeneratorFuelSupply_Impl.hpp" -#include "ElectricLoadCenterDistribution.hpp" -#include "ElectricLoadCenterDistribution_Impl.hpp" #include "CurveQuadratic.hpp" #include "CurveQuadratic_Impl.hpp" #include "CurveCubic.hpp" @@ -488,10 +486,6 @@ namespace model { remove(); LOG_AND_THROW("Unable to set " << briefDescription() << "'s GeneratorFuelCellInverter to " << fCInverter.briefDescription() << "."); } - //Add ElectricLoadCenterDistribution to get ElectricLoadCenterGenerators - ElectricLoadCenterDistribution elcd(model); - elcd.addGenerator(*this); - elcd.setElectricalBussType("AlternatingCurrent"); } GeneratorFuelCell::GeneratorFuelCell(const Model& model) : Generator(GeneratorFuelCell::iddObjectType(), model) { @@ -553,10 +547,6 @@ namespace model { remove(); LOG_AND_THROW("Unable to set " << briefDescription() << "'s GeneratorFuelCellInverter"); } - //Add ElectricLoadCenterDistribution to get ElectricLoadCenterGenerators - ElectricLoadCenterDistribution elcd(model); - elcd.addGenerator(*this); - elcd.setElectricalBussType("AlternatingCurrent"); } IddObjectType GeneratorFuelCell::iddObjectType() { diff --git a/src/model/GeneratorMicroTurbine.cpp b/src/model/GeneratorMicroTurbine.cpp index f62081a9b80..e1b7a84e5f0 100644 --- a/src/model/GeneratorMicroTurbine.cpp +++ b/src/model/GeneratorMicroTurbine.cpp @@ -31,8 +31,6 @@ #include "GeneratorMicroTurbine_Impl.hpp" #include "GeneratorMicroTurbineHeatRecovery.hpp" #include "GeneratorMicroTurbineHeatRecovery_Impl.hpp" -#include "ElectricLoadCenterDistribution.hpp" -#include "ElectricLoadCenterDistribution_Impl.hpp" // Need model to check if curve is part of model when setting #include "Model.hpp" @@ -790,10 +788,6 @@ namespace model { elecEffFPLR.setMinimumValueofx(0.03); elecEffFPLR.setMaximumValueofx(1.0); setElectricalEfficiencyFunctionofPartLoadRatioCurve(elecEffFPLR); - - //Add ElectricLoadCenterDistribution to get ElectricLoadCenterGenerators - ElectricLoadCenterDistribution elcd(model); - elcd.addGenerator(*this); } IddObjectType GeneratorMicroTurbine::iddObjectType() { diff --git a/src/model/GeneratorPVWatts.cpp b/src/model/GeneratorPVWatts.cpp index bd906c3525c..9695f14f015 100644 --- a/src/model/GeneratorPVWatts.cpp +++ b/src/model/GeneratorPVWatts.cpp @@ -282,9 +282,6 @@ namespace model { this->remove(); LOG_AND_THROW("Cannot create a pvwatts generator with dc system capacity " << dcSystemCapacity); } - //Add ElectricLoadCenterDistribution to get ElectricLoadCenterGenerators - ElectricLoadCenterDistribution elcd(model); - elcd.addGenerator(*this); } GeneratorPVWatts::GeneratorPVWatts(const Model& model, const PlanarSurface& surface, double dcSystemCapacity) @@ -304,9 +301,6 @@ namespace model { this->remove(); LOG_AND_THROW("Cannot create a pvwatts generator with dc system capacity " << dcSystemCapacity); } - //Add ElectricLoadCenterDistribution to get ElectricLoadCenterGenerators - ElectricLoadCenterDistribution elcd(model); - elcd.addGenerator(*this); } IddObjectType GeneratorPVWatts::iddObjectType() { diff --git a/src/model/GeneratorPhotovoltaic.cpp b/src/model/GeneratorPhotovoltaic.cpp index 776ce8839d2..332bf4424a0 100644 --- a/src/model/GeneratorPhotovoltaic.cpp +++ b/src/model/GeneratorPhotovoltaic.cpp @@ -272,9 +272,6 @@ namespace model { bool ok = setPointer(OS_Generator_PhotovoltaicFields::ModulePerformanceName, performance.handle()); OS_ASSERT(ok); - //Add ElectricLoadCenterDistribution to get ElectricLoadCenterGenerators - ElectricLoadCenterDistribution elcd(model); - elcd.addGenerator(*this); } IddObjectType GeneratorPhotovoltaic::iddObjectType() { diff --git a/src/model/test/GeneratorFuelCell_GTest.cpp b/src/model/test/GeneratorFuelCell_GTest.cpp index 29a42b3766c..e602c37eaa3 100644 --- a/src/model/test/GeneratorFuelCell_GTest.cpp +++ b/src/model/test/GeneratorFuelCell_GTest.cpp @@ -135,20 +135,20 @@ TEST_F(ModelFixture, FuelCell2) { EXPECT_EQ(elecStorage, fuelcell.electricalStorage()); EXPECT_EQ(inverter, fuelcell.inverter()); EXPECT_EQ(fuelSupply, fuelcell.fuelSupply()); - //should be 1 default ELCD attached to FC + //should be 0 default ELCD attached to FC std::vector elcd = model.getModelObjects(); - EXPECT_EQ(1u, elcd.size()); - EXPECT_EQ(1u, elcd[0].generators().size()); - std::vector generators = elcd[0].generators(); - EXPECT_EQ(generators[0].handle(), fuelcell.handle()); - EXPECT_TRUE(fuelcell.electricLoadCenterDistribution()); - EXPECT_EQ(elcd[0].handle(), fuelcell.electricLoadCenterDistribution().get().handle()); + EXPECT_EQ(0u, elcd.size()); + EXPECT_FALSE(fuelcell.electricLoadCenterDistribution()); + //Add a ELCD + ElectricLoadCenterDistribution elcd1(model); + EXPECT_TRUE(elcd1.addGenerator(fuelcell)); + EXPECT_EQ(elcd1.handle(), fuelcell.electricLoadCenterDistribution().get().handle()); //Add another ELCD ElectricLoadCenterDistribution elcd2(model); EXPECT_EQ(2, model.getModelObjects().size()); //Add the FC to it which should remove the existing one attached to FC EXPECT_TRUE(elcd2.addGenerator(fuelcell)); - EXPECT_EQ(0, elcd[0].generators().size()); + EXPECT_EQ(0, elcd1.generators().size()); EXPECT_EQ(elcd2.handle(), fuelcell.electricLoadCenterDistribution().get().handle()); } diff --git a/src/model/test/GeneratorMicroTurbine_GTest.cpp b/src/model/test/GeneratorMicroTurbine_GTest.cpp index 8026b579080..6977e606be8 100644 --- a/src/model/test/GeneratorMicroTurbine_GTest.cpp +++ b/src/model/test/GeneratorMicroTurbine_GTest.cpp @@ -543,19 +543,19 @@ TEST_F(ModelFixture, GeneratorMicroTurbine_ElectricLoadCenterDistribution) { GeneratorMicroTurbineHeatRecovery mchpHR = GeneratorMicroTurbineHeatRecovery(model, mchp); - //should be 1 default ELCD attached to mchp + //should be 0 default ELCD attached to mchp std::vector elcd = model.getModelObjects(); - EXPECT_EQ(1u, elcd.size()); - EXPECT_EQ(1u, elcd[0].generators().size()); - std::vector generators = elcd[0].generators(); - EXPECT_EQ(generators[0].handle(), mchp.handle()); - EXPECT_TRUE(mchp.electricLoadCenterDistribution()); - EXPECT_EQ(elcd[0].handle(), mchp.electricLoadCenterDistribution().get().handle()); + EXPECT_EQ(0u, elcd.size()); + EXPECT_FALSE(mchp.electricLoadCenterDistribution()); + //Add a ELCD + ElectricLoadCenterDistribution elcd1(model); + EXPECT_TRUE(elcd1.addGenerator(mchp)); + EXPECT_EQ(elcd1.handle(), mchp.electricLoadCenterDistribution().get().handle()); //Add another ELCD ElectricLoadCenterDistribution elcd2(model); EXPECT_EQ(2, model.getModelObjects().size()); //Add the mchp to it which should remove the existing one attached to mchp EXPECT_TRUE(elcd2.addGenerator(mchp)); - EXPECT_EQ(0, elcd[0].generators().size()); + EXPECT_EQ(0, elcd1.generators().size()); EXPECT_EQ(elcd2.handle(), mchp.electricLoadCenterDistribution().get().handle()); } diff --git a/src/model/test/GeneratorPVWatts_GTest.cpp b/src/model/test/GeneratorPVWatts_GTest.cpp index b0df889e0cb..d0c20c6ff1b 100644 --- a/src/model/test/GeneratorPVWatts_GTest.cpp +++ b/src/model/test/GeneratorPVWatts_GTest.cpp @@ -245,19 +245,19 @@ TEST_F(ModelFixture, GeneratorPVWatts_ElectricLoadCenterDistribution2) { GeneratorPVWatts generator(model, 1); - //should be 1 default ELCD attached to pvwatts + //should be 0 default ELCD attached to pvwatts std::vector elcd = model.getModelObjects(); - EXPECT_EQ(1u, elcd.size()); - EXPECT_EQ(1u, elcd[0].generators().size()); - std::vector generators = elcd[0].generators(); - EXPECT_EQ(generators[0].handle(), generator.handle()); - EXPECT_TRUE(generator.electricLoadCenterDistribution()); - EXPECT_EQ(elcd[0].handle(), generator.electricLoadCenterDistribution().get().handle()); + EXPECT_EQ(0u, elcd.size()); + EXPECT_FALSE(generator.electricLoadCenterDistribution()); + //Add a ELCD + ElectricLoadCenterDistribution elcd1(model); + EXPECT_TRUE(elcd1.addGenerator(generator)); + EXPECT_EQ(elcd1.handle(), generator.electricLoadCenterDistribution().get().handle()); //Add another ELCD ElectricLoadCenterDistribution elcd2(model); EXPECT_EQ(2, model.getModelObjects().size()); //Add the pvwatts to it which should remove the existing one attached to pvwatts EXPECT_TRUE(elcd2.addGenerator(generator)); - EXPECT_EQ(0, elcd[0].generators().size()); + EXPECT_EQ(0, elcd1.generators().size()); EXPECT_EQ(elcd2.handle(), generator.electricLoadCenterDistribution().get().handle()); } \ No newline at end of file diff --git a/src/model/test/GeneratorPhotovoltaic_GTest.cpp b/src/model/test/GeneratorPhotovoltaic_GTest.cpp index b7a7de257eb..31fccdafc5a 100644 --- a/src/model/test/GeneratorPhotovoltaic_GTest.cpp +++ b/src/model/test/GeneratorPhotovoltaic_GTest.cpp @@ -61,8 +61,8 @@ TEST_F(ModelFixture, GeneratorPhotovoltaic_Simple) { EXPECT_FALSE(panel.ratedElectricPowerOutput()); EXPECT_FALSE(panel.availabilitySchedule()); EXPECT_FALSE(panel.ratedThermaltoElectricalPowerRatio()); - //should be true now that ELDC is in ctor - EXPECT_TRUE(panel.electricLoadCenterDistribution()); + //should be false now that ELDC is not in ctor + EXPECT_FALSE(panel.electricLoadCenterDistribution()); Point3dVector points; points.push_back(Point3d(0, 1, 0)); @@ -118,8 +118,8 @@ TEST_F(ModelFixture, GeneratorPhotovoltaic_OneDiode) { EXPECT_FALSE(panel.ratedElectricPowerOutput()); EXPECT_FALSE(panel.availabilitySchedule()); EXPECT_FALSE(panel.ratedThermaltoElectricalPowerRatio()); - //should be true now that ELDC is in ctor - EXPECT_TRUE(panel.electricLoadCenterDistribution()); + //should be false now that ELDC is not in ctor + EXPECT_FALSE(panel.electricLoadCenterDistribution()); Point3dVector points; points.push_back(Point3d(0, 1, 0)); @@ -193,19 +193,19 @@ TEST_F(ModelFixture, GeneratorPhotovoltaic_ElectricLoadCenterDistribution) { GeneratorPhotovoltaic panel = GeneratorPhotovoltaic::simple(model); - //should be 1 default ELCD attached to panel + //should be 0 default ELCD attached to panel std::vector elcd = model.getModelObjects(); - EXPECT_EQ(1u, elcd.size()); - EXPECT_EQ(1u, elcd[0].generators().size()); - std::vector generators = elcd[0].generators(); - EXPECT_EQ(generators[0].handle(), panel.handle()); - EXPECT_TRUE(panel.electricLoadCenterDistribution()); - EXPECT_EQ(elcd[0].handle(), panel.electricLoadCenterDistribution().get().handle()); + EXPECT_EQ(0u, elcd.size()); + EXPECT_FALSE(panel.electricLoadCenterDistribution()); + //Add a ELCD + ElectricLoadCenterDistribution elcd1(model); + EXPECT_TRUE(elcd1.addGenerator(panel)); + EXPECT_EQ(elcd1.handle(), panel.electricLoadCenterDistribution().get().handle()); //Add another ELCD ElectricLoadCenterDistribution elcd2(model); EXPECT_EQ(2, model.getModelObjects().size()); //Add the panel to it which should remove the existing one attached to panel EXPECT_TRUE(elcd2.addGenerator(panel)); - EXPECT_EQ(0, elcd[0].generators().size()); + EXPECT_EQ(0, elcd1.generators().size()); EXPECT_EQ(elcd2.handle(), panel.electricLoadCenterDistribution().get().handle()); }