diff --git a/resources/model/OpenStudio.idd b/resources/model/OpenStudio.idd index 4df440f2c78..77780e00c44 100644 --- a/resources/model/OpenStudio.idd +++ b/resources/model/OpenStudio.idd @@ -29912,10 +29912,10 @@ OS:PhotovoltaicPerformance:EquivalentOne-Diode, \minimum 0.0 OS:Generator:FuelCell, - \memo This generator model is the FC model from IEA Annex 42 + \memo This generator model is the FC model from IEA Annex 42 A1, \field Handle - \type handle - \required-field + \type handle + \required-field A2, \field Name \required-field \reference GeneratorNames @@ -30348,8 +30348,8 @@ OS:Generator:FuelSupply, \max-fields 38 \memo Used only with Generator:FuelCell and Generator:MicroCHP A1, \field Handle - \type handle - \required-field + \type handle + \required-field A2, \field Name \required-field \reference GenFuelSupNames @@ -30405,6 +30405,156 @@ OS:Generator:FuelSupply, \minimum 0.0 \maximum 1.0 +OS:Generator:WindTurbine, + \memo Wind turbine generator. + \min-fields 27 + A1, \field Handle + \type handle + \required-field + A2, \field Name + \required-field + \reference GeneratorNames + A3, \field Availability Schedule Name + \note Availability schedule name for this system. Schedule value > 0 means the system is available. + \note If this field is blank, the system is always available. + \type object-list + \object-list ScheduleNames + \required-field + A4, \field Rotor Type + \note allowed values are: Horizontal Axis Wind Turbine or Vertical Axis Wind Turbine + \type choice + \key HorizontalAxisWindTurbine + \key VerticalAxisWindTurbine + \required-field + A5, \field Power Control + \note Constant power output is obtained in the last three control types + \note when the wind speed exceeds the rated wind speed. + \note allowed values are: Fixed Speed Fixed Pitch, Fixed Speed Variable Pitch, + \note Variable Speed Fixed Pitch or Variable Speed Variable Pitch + \type choice + \key FixedSpeedFixedPitch + \key FixedSpeedVariablePitch + \key VariableSpeedFixedPitch + \key VariableSpeedVariablePitch + \required-field + N1, \field Rated Rotor Speed + \required-field + \type real + \minimum> 0.0 + \units rev/min + N2, \field Rotor Diameter + \note This field is the diameter of the perpendicular circle of the Vertical Axis Wind Turbine system + \note from the upright pole on the ground. + \required-field + \type real + \minimum> 0.0 + \units m + N3, \field Overall Height + \note This field is the height of the hub for the Horizontal Axis Wind Turbines and + \note of the pole for the Vertical Axis Wind Turbines. + \required-field + \type real + \minimum> 0.0 + \units m + N4, \field Number of Blades + \minimum 2 + \required-field + N5, \field Rated Power + \required-field + \note This field is the nominal power at the rated wind speed. + \note Users should input maximum power in case of Fixed Speed Fixed Pitch control type. + \type real + \minimum> 0.0 + \units W + N6, \field Rated Wind Speed + \required-field + \type real + \minimum> 0.0 + \units m/s + N7, \field Cut In Wind Speed + \required-field + \type real + \minimum> 0.0 + \units m/s + N8, \field Cut Out Wind Speed + \required-field + \type real + \minimum> 0.0 + \units m/s + N9, \field Fraction system Efficiency + \type real + \minimum> 0.0 + \maximum 1.0 + \required-field + N10,\field Maximum Tip Speed Ratio + \type real + \minimum> 0.0 + \maximum 12.0 + \required-field + N11,\field Maximum Power Coefficient + \note This field should be input if the rotor type is Horizontal Axis Wind Turbine + \type real + \minimum> 0.0 + \maximum 0.59 + \required-field + N12,\field Annual Local Average Wind Speed + \type real + \units m/s + \minimum> 0.0 + N13,\field Height for Local Average Wind Speed + \type real + \units m + \minimum> 0.0 + \required-field + N14,\field Blade Chord Area + \type real + \units m2 + \required-field + \minimum 0.0 + N15,\field Blade Drag Coefficient + \note This field is only for Vertical Axis Wind Turbine.. + \note The user must input this field if the rotor type is Vertical Axis Wind Turbine. + \type real + \required-field + \minimum 0.0 + N16,\field Blade Lift Coefficient + \note This field is only for Vertical Axis Wind Turbine.. + \note The user must input this field if the rotor type is Vertical Axis Wind Turbine. + \type real + \required-field + \minimum 0.0 + N17,\field Power Coefficient C1 + \note This field is only available for Horizontal Axis Wind Turbine. + \note The user should input all six parameters + \note so that the analytic approximation is assumed. + \note The simple approximation will be assumed, + \note if any field C1 through C6 is not input. + \note Leave this field blank, if the manufacturer's data is unavailable + \note so that the simple approximation will be assumed. + \minimum> 0.0 + \type real + \required-field + N18,\field Power Coefficient C2 + \minimum> 0.0 + \type real + \required-field + N19,\field Power Coefficient C3 + \minimum> 0.0 + \type real + \required-field + N20,\field Power Coefficient C4 + \minimum 0.0 + \type real + \required-field + N21,\field Power Coefficient C5 + \minimum> 0.0 + \type real + \required-field + N22;\field Power Coefficient C6 + \minimum> 0.0 + \type real + \required-field + OS:Generator:PVWatts, \min-fields 4 \memo Describes a simple set of inputs for an array of photovoltaic (PV) modules as described diff --git a/src/energyplus/CMakeLists.txt b/src/energyplus/CMakeLists.txt index 1364844b943..d1cd6c23e65 100644 --- a/src/energyplus/CMakeLists.txt +++ b/src/energyplus/CMakeLists.txt @@ -200,6 +200,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateGeneratorFuelCellStackCooler.cpp ForwardTranslator/ForwardTranslateGeneratorFuelCellWaterSupply.cpp ForwardTranslator/ForwardTranslateGeneratorFuelSupply.cpp + ForwardTranslator/ForwardTranslateGeneratorWindTurbine.cpp ForwardTranslator/ForwardTranslateGroundHeatExchangerHorizontalTrench.cpp ForwardTranslator/ForwardTranslateGroundHeatExchangerVertical.cpp ForwardTranslator/ForwardTranslateHeaderedPumpsConstantSpeed.cpp @@ -479,6 +480,7 @@ set(${target_name}_src ReverseTranslator/ReverseTranslateFoundationKivaSettings.cpp ReverseTranslator/ReverseTranslateGasEquipment.cpp ReverseTranslator/ReverseTranslateGeneratorMicroTurbine.cpp + ReverseTranslator/ReverseTranslateGeneratorWindTurbine.cpp ReverseTranslator/ReverseTranslateHeatBalanceAlgorithm.cpp ReverseTranslator/ReverseTranslateHotWaterEquipment.cpp ReverseTranslator/ReverseTranslateInternalMass.cpp @@ -631,6 +633,7 @@ set(${target_name}_test_src Test/FuelCell_GTest.cpp Test/GasEquipment_GTest.cpp Test/GeneratorMicroTurbine_GTest.cpp + Test/GeneratorWindTurbine_GTest.cpp Test/HeatPumpWaterToWaterEquationFit_GTest.cpp Test/HotWaterEquipment_GTest.cpp Test/IlluminanceMap_GTest.cpp diff --git a/src/energyplus/ForwardTranslator.cpp b/src/energyplus/ForwardTranslator.cpp index 3d38d83e4e8..319615e10a1 100644 --- a/src/energyplus/ForwardTranslator.cpp +++ b/src/energyplus/ForwardTranslator.cpp @@ -358,75 +358,6 @@ namespace energyplus { } } - // remove orphan Generator:MicroTurbine - for (auto& chp : model.getConcreteModelObjects()) { - if (!chp.electricLoadCenterDistribution()) { - LOG(Warn, - "GeneratorMicroTurbine " << chp.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); - chp.remove(); - continue; - } - } - - // remove orphan photovoltaics - for (auto& pv : model.getConcreteModelObjects()) { - if (!pv.electricLoadCenterDistribution()) { - LOG(Warn, - "GeneratorPhotovoltaic " << pv.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); - pv.remove(); - continue; - } - if (!pv.surface()) { - LOG(Warn, "GeneratorPhotovoltaic " << pv.name().get() << " is not referenced by any surface, it will not be translated."); - pv.remove(); - } - } - - // remove orphan Generator:PVWatts - for (auto& pv : model.getConcreteModelObjects()) { - if (!pv.electricLoadCenterDistribution()) { - LOG(Warn, "GeneratorPVWatts " << pv.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); - pv.remove(); - continue; - } - } - - // remove orphan Generator:FuelCell - for (auto& fc : model.getConcreteModelObjects()) { - if (!fc.electricLoadCenterDistribution()) { - //get the HX from the FC since that is the parent and remove it, thus removing the FC - LOG(Warn, "GeneratorFuelCell " << fc.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); - fc.heatExchanger().remove(); - //fc.remove(); - continue; - } - } - - // Remove orphan Storage - for (auto& storage : model.getModelObjects()) { - if (!storage.electricLoadCenterDistribution()) { - LOG(Warn, - "Electrical Storage " << storage.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); - storage.remove(); - } - } - - // Remove orphan Converters - for (auto& converter : model.getConcreteModelObjects()) { - if (!converter.electricLoadCenterDistribution()) { - LOG(Warn, "Converter " << converter.name().get() << " is not referenced by any ElectricLoadCenterDistribution, it will not be translated."); - converter.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."); - inverter.remove(); - } - } - // TODO: Is this still needed? // ensure shading controls only reference windows in a single zone and determine control sequence number // DLM: ideally E+ would not need to know the zone, shading controls could work across zones @@ -1794,6 +1725,11 @@ namespace energyplus { retVal = translateGeneratorPVWatts(temp); break; } + case openstudio::IddObjectType::OS_Generator_WindTurbine: { + model::GeneratorWindTurbine temp = modelObject.cast(); + retVal = translateGeneratorWindTurbine(temp); + break; + } case openstudio::IddObjectType::OS_Glare_Sensor: { // no-op break; @@ -3233,8 +3169,12 @@ namespace energyplus { result.push_back(IddObjectType::OS_Refrigeration_TranscriticalSystem); result.push_back(IddObjectType::OS_ElectricLoadCenter_Distribution); - result.push_back(IddObjectType::OS_Generator_MicroTurbine); - result.push_back(IddObjectType::OS_Generator_FuelCell); + // ElectricLoadCenterDistribution is responsible for translating its generators/inverters/storages + // result.push_back(IddObjectType::OS_Generator_MicroTurbine); + // result.push_back(IddObjectType::OS_Generator_FuelCell); + // result.push_back(IddObjectType::OS_Generator_Photovoltaic); + // result.push_back(IddObjectType::OS_Generator_PVWatts); + // result.push_back(IddObjectType::OS_Generator_WindTurbine); // Fuel Cell is responsible for translating these // result.push_back(IddObjectType::OS_Generator_FuelCell_AirSupply); // result.push_back(IddObjectType::OS_Generator_FuelCell_AuxiliaryHeater); @@ -3246,16 +3186,17 @@ namespace energyplus { // result.push_back(IddObjectType::OS_Generator_FuelCell_WaterSupply); // Fuel Cell (and MicroCHP when implemented) are responsible for translating this one // result.push_back(IddObjectType::OS_Generator_FuelSupply); + // result.push_back(IddObjectType::OS_ElectricLoadCenter_Inverter_LookUpTable); + // result.push_back(IddObjectType::OS_ElectricLoadCenter_Inverter_Simple); + // result.push_back(IddObjectType::OS_ElectricLoadCenter_Inverter_PVWatts); + // result.push_back(IddObjectType::OS_ElectricLoadCenter_Storage_Simple); + // result.push_back(IddObjectType::OS_ElectricLoadCenter_Storage_Converter); + + // Generator_Photovoltaic is responsible for translating these two + // result.push_back(IddObjectType::OS_PhotovoltaicPerformance_EquivalentOneDiode); + // result.push_back(IddObjectType::OS_PhotovoltaicPerformance_Simple); - result.push_back(IddObjectType::OS_Generator_Photovoltaic); - result.push_back(IddObjectType::OS_Generator_PVWatts); - result.push_back(IddObjectType::OS_PhotovoltaicPerformance_EquivalentOneDiode); - result.push_back(IddObjectType::OS_PhotovoltaicPerformance_Simple); - result.push_back(IddObjectType::OS_ElectricLoadCenter_Inverter_LookUpTable); - result.push_back(IddObjectType::OS_ElectricLoadCenter_Inverter_Simple); - result.push_back(IddObjectType::OS_ElectricLoadCenter_Inverter_PVWatts); - result.push_back(IddObjectType::OS_ElectricLoadCenter_Storage_Simple); - result.push_back(IddObjectType::OS_ElectricLoadCenter_Storage_Converter); + // Transformer can be standalone, see ASHRAE9012016_OfficeMedium_Denver.idf for example result.push_back(IddObjectType::OS_ElectricLoadCenter_Transformer); // put these down here so they have a chance to be translated with their "parent" diff --git a/src/energyplus/ForwardTranslator.hpp b/src/energyplus/ForwardTranslator.hpp index c3f0fb8fecb..7c425417acc 100644 --- a/src/energyplus/ForwardTranslator.hpp +++ b/src/energyplus/ForwardTranslator.hpp @@ -254,6 +254,7 @@ namespace model { class GeneratorFuelSupply; class GeneratorPhotovoltaic; class GeneratorPVWatts; + class GeneratorWindTurbine; class GroundHeatExchangerHorizontalTrench; class GroundHeatExchangerVertical; class HeaderedPumpsConstantSpeed; @@ -981,6 +982,8 @@ namespace energyplus { boost::optional translateGeneratorPVWatts(model::GeneratorPVWatts& modelObject); + boost::optional translateGeneratorWindTurbine(model::GeneratorWindTurbine& modelObject); + boost::optional translateGroundHeatExchangerHorizontalTrench(model::GroundHeatExchangerHorizontalTrench& modelObject); boost::optional translateGroundHeatExchangerVertical(model::GroundHeatExchangerVertical& modelObject); diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorPhotovoltaic.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorPhotovoltaic.cpp index 1cae36e2e8e..399dedc78e8 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorPhotovoltaic.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorPhotovoltaic.cpp @@ -48,7 +48,12 @@ namespace openstudio { namespace energyplus { boost::optional ForwardTranslator::translateGeneratorPhotovoltaic(model::GeneratorPhotovoltaic& modelObject) { - IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Generator_Photovoltaic, modelObject); + + // We are going to check for required properties such as Surface before we register the object + // IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Generator_Photovoltaic, modelObject); + IdfObject idfObject(openstudio::IddObjectType::Generator_Photovoltaic); + // Name + idfObject.setName(modelObject.nameString()); PhotovoltaicPerformance performance = modelObject.photovoltaicPerformance(); boost::optional performanceIdf = translateAndMapModelObject(performance); @@ -56,7 +61,9 @@ namespace energyplus { idfObject.setString(Generator_PhotovoltaicFields::PhotovoltaicPerformanceObjectType, performanceIdf->iddObject().name()); idfObject.setString(Generator_PhotovoltaicFields::ModulePerformanceName, performanceIdf->name().get()); } else { - LOG(Warn, "Generator:Photovoltaic '" << idfObject.name().get() << "' missing required field 'Module Performance Name'") + LOG(Error, + "Generator:Photovoltaic '" << idfObject.name().get() << "' missing required field 'Module Performance Name', it will not be translated."); + return boost::none; } boost::optional surface = modelObject.surface(); @@ -69,9 +76,13 @@ namespace energyplus { } } if (!hasSurface) { - LOG(Warn, "Generator:Photovoltaic '" << idfObject.name().get() << "' missing required field 'Surface Name'") + LOG(Error, "Generator:Photovoltaic '" << idfObject.name().get() << "' missing required field 'Surface Name', it will not be translated."); + return boost::none; } + // at this point, we can register the new object + m_idfObjects.push_back(idfObject); + idfObject.setString(Generator_PhotovoltaicFields::HeatTransferIntegrationMode, modelObject.heatTransferIntegrationMode()); idfObject.setDouble(Generator_PhotovoltaicFields::NumberofSeriesStringsinParallel, modelObject.numberOfModulesInParallel()); diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorWindTurbine.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorWindTurbine.cpp new file mode 100644 index 00000000000..6e8ebc5f697 --- /dev/null +++ b/src/energyplus/ForwardTranslator/ForwardTranslateGeneratorWindTurbine.cpp @@ -0,0 +1,227 @@ +/*********************************************************************************************************************** +* 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 "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/GeneratorWindTurbine.hpp" +#include "../../model/GeneratorWindTurbine_Impl.hpp" +#include "../../model/Schedule.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + + /** This method forward translates the OS:Generator:WindTurbine as well the optional attached OS:Generator:WindTurbine:HeatRecovery + to the EnergyPlus Generator:WindTurbine object */ + boost::optional ForwardTranslator::translateGeneratorWindTurbine(GeneratorWindTurbine& modelObject) { + boost::optional s; + boost::optional d; + boost::optional i; + + // We are going to check for valid rotor type and blade fields before we register the object + IdfObject idfObject(openstudio::IddObjectType::Generator_WindTurbine); + + // Name + idfObject.setName(modelObject.nameString()); + + // Rotor Type + std::string rotorType = modelObject.rotorType(); + idfObject.setString(Generator_WindTurbineFields::RotorType, rotorType); + + // Blade Chord Area + double bladeChordArea = modelObject.bladeChordArea(); + idfObject.setDouble(Generator_WindTurbineFields::BladeChordArea, bladeChordArea); + + // Blade Drag Coefficient + double bladeDragCoefficient = modelObject.bladeDragCoefficient(); + idfObject.setDouble(Generator_WindTurbineFields::BladeDragCoefficient, bladeDragCoefficient); + + // Blade Lift Coefficient + double bladeLiftCoefficient = modelObject.bladeLiftCoefficient(); + idfObject.setDouble(Generator_WindTurbineFields::BladeLiftCoefficient, bladeLiftCoefficient); + + // Hard check instead of letting E+ crash for required fields depending on rotor type + if (openstudio::istringEqual("VerticalAxisWindTurbine", rotorType) + && ((bladeChordArea == 0) || (bladeDragCoefficient == 0) || (bladeLiftCoefficient == 0))) { + LOG(Error, modelObject.briefDescription() << ": When 'Rotor Type' == 'VerticalAxisWindTurbine'," + << "'Blade Chord Area', 'Blade Drag Coefficient' and 'Blade Lift Coefficient' cannot be zero." + << " It will not be translated'"); + return boost::none; + } + + // at this point, we can register the new object + m_idfObjects.push_back(idfObject); + + // Availability Schedule Name + boost::optional availabilitySchedule = modelObject.availabilitySchedule(); + + if (availabilitySchedule) { + boost::optional _availabilitySchedule = translateAndMapModelObject(availabilitySchedule.get()); + + if (_availabilitySchedule && _availabilitySchedule->name()) { + idfObject.setString(Generator_WindTurbineFields::AvailabilityScheduleName, _availabilitySchedule->name().get()); + } + } + + // Power Control + s = modelObject.powerControl(); + if (s) { + idfObject.setString(Generator_WindTurbineFields::PowerControl, s.get()); + } + + // Rated Rotor Speed + d = modelObject.ratedRotorSpeed(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::RatedRotorSpeed, d.get()); + } + + // Rotor Diameter + d = modelObject.rotorDiameter(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::RotorDiameter, d.get()); + } + + // Overall Height + d = modelObject.overallHeight(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::OverallHeight, d.get()); + } + + // Number of Blades + i = modelObject.numberofBlades(); + if (i) { + idfObject.setInt(Generator_WindTurbineFields::NumberofBlades, i.get()); + } + + // Rated Power + d = modelObject.ratedPower(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::RatedPower, d.get()); + } + + // Rated Wind Speed + d = modelObject.ratedWindSpeed(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::RatedWindSpeed, d.get()); + } + + // Cut In Wind Speed + d = modelObject.cutInWindSpeed(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::CutInWindSpeed, d.get()); + } + + // Cut Out Wind Speed + d = modelObject.cutOutWindSpeed(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::CutOutWindSpeed, d.get()); + } + + // Fraction system Efficiency + d = modelObject.fractionSystemEfficiency(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::FractionsystemEfficiency, d.get()); + } + + // Maximum Tip Speed Ratio + d = modelObject.maximumTipSpeedRatio(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::MaximumTipSpeedRatio, d.get()); + } + + // Maximum Power Coefficient + d = modelObject.maximumPowerCoefficient(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::MaximumPowerCoefficient, d.get()); + } + + // Annual Local Average Wind Speed + d = modelObject.annualLocalAverageWindSpeed(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::AnnualLocalAverageWindSpeed, d.get()); + } + + // Height for Local Average Wind Speed + d = modelObject.heightforLocalAverageWindSpeed(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::HeightforLocalAverageWindSpeed, d.get()); + } + + // Power Coefficient C1 + d = modelObject.powerCoefficientC1(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::PowerCoefficientC1, d.get()); + } + + // Power Coefficient C2 + d = modelObject.powerCoefficientC2(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::PowerCoefficientC2, d.get()); + } + + // Power Coefficient C3 + d = modelObject.powerCoefficientC3(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::PowerCoefficientC3, d.get()); + } + + // Power Coefficient C4 + d = modelObject.powerCoefficientC4(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::PowerCoefficientC4, d.get()); + } + + // Power Coefficient C5 + d = modelObject.powerCoefficientC5(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::PowerCoefficientC5, d.get()); + } + + // Power Coefficient C6 + d = modelObject.powerCoefficientC6(); + if (d) { + idfObject.setDouble(Generator_WindTurbineFields::PowerCoefficientC6, d.get()); + } + + return idfObject; + } + +} // namespace energyplus + +} // namespace openstudio diff --git a/src/energyplus/ReverseTranslator.cpp b/src/energyplus/ReverseTranslator.cpp index 30a36d1da48..6a6390d4cb9 100644 --- a/src/energyplus/ReverseTranslator.cpp +++ b/src/energyplus/ReverseTranslator.cpp @@ -567,6 +567,10 @@ namespace energyplus { modelObject = translateGeneratorMicroTurbine(workspaceObject); break; } + case openstudio::IddObjectType::Generator_WindTurbine: { + modelObject = translateGeneratorWindTurbine(workspaceObject); + break; + } case openstudio::IddObjectType::GlobalGeometryRules: { // added by geometry translator, do not add to untranslated objects addToUntranslated = false; diff --git a/src/energyplus/ReverseTranslator.hpp b/src/energyplus/ReverseTranslator.hpp index 6d8cbefc4cf..5c9335bf955 100644 --- a/src/energyplus/ReverseTranslator.hpp +++ b/src/energyplus/ReverseTranslator.hpp @@ -209,6 +209,8 @@ namespace energyplus { boost::optional translateGeneratorMicroTurbine(const WorkspaceObject& workspaceObject); + boost::optional translateGeneratorWindTurbine(const WorkspaceObject& workspaceObject); + boost::optional translateGroundHeatExchangerVertical(const WorkspaceObject& workspaceObject); boost::optional translateHeatBalanceAlgorithm(const WorkspaceObject& workspaceObject); diff --git a/src/energyplus/ReverseTranslator/ReverseTranslateGeneratorWindTurbine.cpp b/src/energyplus/ReverseTranslator/ReverseTranslateGeneratorWindTurbine.cpp new file mode 100644 index 00000000000..41ecb9df998 --- /dev/null +++ b/src/energyplus/ReverseTranslator/ReverseTranslateGeneratorWindTurbine.cpp @@ -0,0 +1,226 @@ +/*********************************************************************************************************************** +* 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 "../ReverseTranslator.hpp" + +#include "../../model/GeneratorWindTurbine.hpp" +#include "../../model/GeneratorWindTurbine_Impl.hpp" + +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + + OptionalModelObject ReverseTranslator::translateGeneratorWindTurbine(const WorkspaceObject& workspaceObject) { + if (workspaceObject.iddObject().type() != IddObjectType::Generator_WindTurbine) { + LOG(Error, "WorkspaceObject is not IddObjectType: GeneratorWindTurbine"); + return boost::none; + } + + OptionalDouble d; + OptionalString s; + OptionalInt i; + OptionalWorkspaceObject target; + + openstudio::model::GeneratorWindTurbine wind(m_model); + + // Name + s = workspaceObject.name(); + if (s) { + wind.setName(*s); + } + + // Availability Schedule Name + if ((target = workspaceObject.getTarget(Generator_WindTurbineFields::AvailabilityScheduleName))) { + OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); + if (modelObject) { + if (auto optSch = modelObject->optionalCast()) { + wind.setAvailabilitySchedule(optSch.get()); + } + } + } + + // Rotor Type + s = workspaceObject.getString(Generator_WindTurbineFields::RotorType); + if (s) { + wind.setRotorType(*s); + } + + // Power Control + s = workspaceObject.getString(Generator_WindTurbineFields::PowerControl); + if (s) { + wind.setPowerControl(*s); + } + + // Rated Rotor Speed + d = workspaceObject.getDouble(Generator_WindTurbineFields::RatedRotorSpeed); + if (d) { + wind.setRatedRotorSpeed(*d); + } + + // Rotor Diameter + d = workspaceObject.getDouble(Generator_WindTurbineFields::RotorDiameter); + if (d) { + wind.setRotorDiameter(*d); + } + + // Overall Height + d = workspaceObject.getDouble(Generator_WindTurbineFields::OverallHeight); + if (d) { + wind.setOverallHeight(*d); + } + + // Number of Blades + i = workspaceObject.getInt(Generator_WindTurbineFields::NumberofBlades); + if (i) { + wind.setNumberofBlades(*i); + } + + // Rated Power + d = workspaceObject.getDouble(Generator_WindTurbineFields::RatedPower); + if (d) { + wind.setRatedPower(*d); + } + + // Rated Wind Speed + d = workspaceObject.getDouble(Generator_WindTurbineFields::RatedWindSpeed); + if (d) { + wind.setRatedWindSpeed(*d); + } + + // Cut In Wind Speed + d = workspaceObject.getDouble(Generator_WindTurbineFields::CutInWindSpeed); + if (d) { + wind.setCutInWindSpeed(*d); + } + + // Cut Out Wind Speed + d = workspaceObject.getDouble(Generator_WindTurbineFields::CutOutWindSpeed); + if (d) { + wind.setCutOutWindSpeed(*d); + } + + // Fraction system Efficiency + d = workspaceObject.getDouble(Generator_WindTurbineFields::FractionsystemEfficiency); + if (d) { + wind.setFractionSystemEfficiency(*d); + } + + // Maximum Tip Speed Ratio + d = workspaceObject.getDouble(Generator_WindTurbineFields::MaximumTipSpeedRatio); + if (d) { + wind.setMaximumTipSpeedRatio(*d); + } + + // Maximum Power Coefficient + d = workspaceObject.getDouble(Generator_WindTurbineFields::MaximumPowerCoefficient); + if (d) { + wind.setMaximumPowerCoefficient(*d); + } + + // Annual Local Average Wind Speed + d = workspaceObject.getDouble(Generator_WindTurbineFields::AnnualLocalAverageWindSpeed); + if (d) { + wind.setAnnualLocalAverageWindSpeed(*d); + } + + // Height for Local Average Wind Speed + d = workspaceObject.getDouble(Generator_WindTurbineFields::HeightforLocalAverageWindSpeed); + if (d) { + wind.setHeightforLocalAverageWindSpeed(*d); + } + + // Blade Chord Area + d = workspaceObject.getDouble(Generator_WindTurbineFields::BladeChordArea); + if (d) { + wind.setBladeChordArea(*d); + } + + // Blade Drag Coefficient + d = workspaceObject.getDouble(Generator_WindTurbineFields::BladeDragCoefficient); + if (d) { + wind.setBladeDragCoefficient(*d); + } + + // Blade Lift Coefficient + d = workspaceObject.getDouble(Generator_WindTurbineFields::BladeLiftCoefficient); + if (d) { + wind.setBladeLiftCoefficient(*d); + } + + // Power Coefficient C1 + d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC1); + if (d) { + wind.setPowerCoefficientC1(*d); + } + + // Power Coefficient C2 + d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC2); + if (d) { + wind.setPowerCoefficientC2(*d); + } + + // Power Coefficient C3 + d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC3); + if (d) { + wind.setPowerCoefficientC3(*d); + } + + // Power Coefficient C4 + d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC4); + if (d) { + wind.setPowerCoefficientC4(*d); + } + + // Power Coefficient C5 + d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC5); + if (d) { + wind.setPowerCoefficientC5(*d); + } + + // Power Coefficient C6 + d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC6); + if (d) { + wind.setPowerCoefficientC6(*d); + } + + return wind; + } + +} // namespace energyplus + +} // namespace openstudio diff --git a/src/energyplus/Test/FuelCell_GTest.cpp b/src/energyplus/Test/FuelCell_GTest.cpp index 215c864df5d..59d15432bba 100644 --- a/src/energyplus/Test/FuelCell_GTest.cpp +++ b/src/energyplus/Test/FuelCell_GTest.cpp @@ -316,15 +316,14 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorFuelCell4) { // create default fuelcell GeneratorFuelCell fuelcell(model, powerModule, airSupply, waterSupply, auxHeater, exhaustHX, elecStorage, inverter, fuelSupply); - // remove the ELCD + // check the ELCD boost::optional elcd = fuelcell.electricLoadCenterDistribution(); - //elcd.get().remove(); EXPECT_FALSE(fuelcell.electricLoadCenterDistribution()); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - EXPECT_EQ(1u, forwardTranslator.warnings().size()); + EXPECT_EQ(0u, forwardTranslator.warnings().size()); //NO FC components should FT now since it is orphaned EXPECT_EQ(0u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Generators).size()); diff --git a/src/energyplus/Test/GeneratorMicroTurbine_GTest.cpp b/src/energyplus/Test/GeneratorMicroTurbine_GTest.cpp index caa2859f135..9a9b88b7e50 100644 --- a/src/energyplus/Test/GeneratorMicroTurbine_GTest.cpp +++ b/src/energyplus/Test/GeneratorMicroTurbine_GTest.cpp @@ -69,6 +69,7 @@ #include // #include #include +#include #include #include @@ -227,3 +228,37 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorGeneratorMicroTurbine_ELCD_Orphan) { // model.save(toPath("./ForwardTranslatorGeneratorMicroTurbine_ELCD_orhpan.osm"), true); // workspace.save(toPath("./ForwardTranslatorGeneratorMicroTurbine_ELCD_orphan.idf"), true); } + +TEST_F(EnergyPlusFixture, ReverseTranslator_GeneratorMicroTurbine) { + openstudio::Workspace workspace(openstudio::StrictnessLevel::None, openstudio::IddFileType::EnergyPlus); + + // electric load center distribution + openstudio::IdfObject idfObject1(openstudio::IddObjectType::ElectricLoadCenter_Distribution); + idfObject1.setString(ElectricLoadCenter_DistributionFields::Name, "Electric Load Center Distribution 1"); + + openstudio::WorkspaceObject epELCD = workspace.addObject(idfObject1).get(); + + // generator micro turbine + openstudio::IdfObject idfObject2(openstudio::IddObjectType::Generator_MicroTurbine); + idfObject2.setString(Generator_MicroTurbineFields::Name, "Generator Micro Turbine 1"); + + openstudio::WorkspaceObject epGenerator = workspace.addObject(idfObject2).get(); + + ReverseTranslator trans; + ASSERT_NO_THROW(trans.translateWorkspace(workspace)); + Model model = trans.translateWorkspace(workspace); + + /* std::vector elcds = model.getModelObjects(); + ASSERT_EQ(1u, elcds.size()); + ElectricLoadCenterDistribution elcd = elcds[0]; + EXPECT_EQ("Electric Load Center Distribution 1", elcd.name().get()); + ASSERT_EQ(1u, elcd.generators().size()); */ + + std::vector generators = model.getModelObjects(); + ASSERT_EQ(1u, generators.size()); + GeneratorMicroTurbine generator = generators[0]; + EXPECT_EQ("Generator Micro Turbine 1", generator.name().get()); + EXPECT_FALSE(generator.availabilitySchedule()); + + /* EXPECT_EQ(generator.name().get(), elcd.generators()[0].name().get()); */ +} diff --git a/src/energyplus/Test/GeneratorWindTurbine_GTest.cpp b/src/energyplus/Test/GeneratorWindTurbine_GTest.cpp new file mode 100644 index 00000000000..988f197e1af --- /dev/null +++ b/src/energyplus/Test/GeneratorWindTurbine_GTest.cpp @@ -0,0 +1,139 @@ +/*********************************************************************************************************************** +* 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 "../ForwardTranslator.hpp" +#include "../ReverseTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/GeneratorWindTurbine.hpp" +#include "../../model/GeneratorWindTurbine_Impl.hpp" +#include "../../model/ScheduleConstant.hpp" + +#include "../../model/ElectricLoadCenterDistribution.hpp" +#include "../../model/ElectricLoadCenterDistribution_Impl.hpp" + +#include +#include +#include + +#include +#include +#include +#include + +// Debug +#include "../../utilities/core/Logger.hpp" + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +TEST_F(EnergyPlusFixture, ForwardTranslator_GeneratorWindTurbine) { + Model m; + + ElectricLoadCenterDistribution elcd(m); + GeneratorWindTurbine generator(m); + ScheduleConstant schedule(m); + + generator.setAvailabilitySchedule(schedule); + elcd.addGenerator(generator); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution).size()); + EXPECT_EQ(4u, w.getObjectsByType(IddObjectType::Schedule_Constant).size()); + + WorkspaceObjectVector idf_generators(w.getObjectsByType(IddObjectType::Generator_WindTurbine)); + EXPECT_EQ(1u, idf_generators.size()); + WorkspaceObject idf_generator(idf_generators[0]); + + EXPECT_EQ("Schedule Constant 1", idf_generator.getString(Generator_WindTurbineFields::AvailabilityScheduleName, false).get()); + EXPECT_EQ("HorizontalAxisWindTurbine", idf_generator.getString(Generator_WindTurbineFields::RotorType, false).get()); + EXPECT_EQ("VariableSpeedVariablePitch", idf_generator.getString(Generator_WindTurbineFields::PowerControl, false).get()); + EXPECT_EQ(41.0, idf_generator.getDouble(Generator_WindTurbineFields::RatedRotorSpeed, false).get()); + EXPECT_EQ(19.2, idf_generator.getDouble(Generator_WindTurbineFields::RotorDiameter, false).get()); + EXPECT_EQ(30.5, idf_generator.getDouble(Generator_WindTurbineFields::OverallHeight, false).get()); + EXPECT_EQ(3, idf_generator.getInt(Generator_WindTurbineFields::NumberofBlades, false).get()); + EXPECT_EQ(55000.0, idf_generator.getDouble(Generator_WindTurbineFields::RatedPower, false).get()); + EXPECT_EQ(11.0, idf_generator.getDouble(Generator_WindTurbineFields::RatedWindSpeed, false).get()); + EXPECT_EQ(3.5, idf_generator.getDouble(Generator_WindTurbineFields::CutInWindSpeed, false).get()); + EXPECT_EQ(25.0, idf_generator.getDouble(Generator_WindTurbineFields::CutOutWindSpeed, false).get()); + EXPECT_EQ(0.835, idf_generator.getDouble(Generator_WindTurbineFields::FractionsystemEfficiency, false).get()); + EXPECT_EQ(5.0, idf_generator.getDouble(Generator_WindTurbineFields::MaximumTipSpeedRatio, false).get()); + EXPECT_EQ(0.25, idf_generator.getDouble(Generator_WindTurbineFields::MaximumPowerCoefficient, false).get()); + EXPECT_EQ("", idf_generator.getString(Generator_WindTurbineFields::AnnualLocalAverageWindSpeed, false).get()); + EXPECT_EQ(50.0, idf_generator.getDouble(Generator_WindTurbineFields::HeightforLocalAverageWindSpeed, false).get()); + EXPECT_EQ(2.08, idf_generator.getDouble(Generator_WindTurbineFields::BladeChordArea, false).get()); + EXPECT_EQ(0.9, idf_generator.getDouble(Generator_WindTurbineFields::BladeDragCoefficient, false).get()); + EXPECT_EQ(0.05, idf_generator.getDouble(Generator_WindTurbineFields::BladeLiftCoefficient, false).get()); + EXPECT_EQ(0.5176, idf_generator.getDouble(Generator_WindTurbineFields::PowerCoefficientC1, false).get()); + EXPECT_EQ(116.0, idf_generator.getDouble(Generator_WindTurbineFields::PowerCoefficientC2, false).get()); + EXPECT_EQ(0.4, idf_generator.getDouble(Generator_WindTurbineFields::PowerCoefficientC3, false).get()); + EXPECT_EQ(0.0, idf_generator.getDouble(Generator_WindTurbineFields::PowerCoefficientC4, false).get()); + EXPECT_EQ(5.0, idf_generator.getDouble(Generator_WindTurbineFields::PowerCoefficientC5, false).get()); + EXPECT_EQ(21.0, idf_generator.getDouble(Generator_WindTurbineFields::PowerCoefficientC6, false).get()); +} + +TEST_F(EnergyPlusFixture, ReverseTranslator_GeneratorWindTurbine) { + openstudio::Workspace workspace(openstudio::StrictnessLevel::None, openstudio::IddFileType::EnergyPlus); + + // electric load center distribution + openstudio::IdfObject idfObject1(openstudio::IddObjectType::ElectricLoadCenter_Distribution); + idfObject1.setString(ElectricLoadCenter_DistributionFields::Name, "Electric Load Center Distribution 1"); + + openstudio::WorkspaceObject epELCD = workspace.addObject(idfObject1).get(); + + // generator wind turbine + openstudio::IdfObject idfObject2(openstudio::IddObjectType::Generator_WindTurbine); + idfObject2.setString(Generator_WindTurbineFields::Name, "Generator Wind Turbine 1"); + + openstudio::WorkspaceObject epGenerator = workspace.addObject(idfObject2).get(); + + ReverseTranslator trans; + ASSERT_NO_THROW(trans.translateWorkspace(workspace)); + Model model = trans.translateWorkspace(workspace); + + std::vector elcds = model.getModelObjects(); + /* ASSERT_EQ(1u, elcds.size()); + ElectricLoadCenterDistribution elcd = elcds[0]; + EXPECT_EQ("Electric Load Center Distribution 1", elcd.name().get()); + ASSERT_EQ(1u, elcd.generators().size()); */ + + std::vector generators = model.getModelObjects(); + ASSERT_EQ(1u, generators.size()); + GeneratorWindTurbine generator = generators[0]; + EXPECT_EQ("Generator Wind Turbine 1", generator.name().get()); + EXPECT_TRUE(generator.availabilitySchedule()); + + /* EXPECT_EQ(generator.name().get(), elcd.generators()[0].name().get()); */ +} \ No newline at end of file diff --git a/src/model/AdditionalProperties.cpp b/src/model/AdditionalProperties.cpp index 6dc3cc5db0e..6adfa7c4456 100644 --- a/src/model/AdditionalProperties.cpp +++ b/src/model/AdditionalProperties.cpp @@ -164,7 +164,7 @@ namespace model { if (strValue) { try { value = boost::lexical_cast(*strValue); - } catch (boost::bad_lexical_cast &) { + } catch (boost::bad_lexical_cast&) { LOG(Error, "Value: " + *strValue + ", not castable to type double.") value = boost::none; } @@ -180,7 +180,7 @@ namespace model { if (strValue) { try { value = boost::lexical_cast(*strValue); - } catch (boost::bad_lexical_cast &) { + } catch (boost::bad_lexical_cast&) { LOG(Error, "Value: " + *strValue + ", not castable to type integer.") value = boost::none; } diff --git a/src/model/CMakeLists.txt b/src/model/CMakeLists.txt index 46df94414d5..34e82aaa659 100644 --- a/src/model/CMakeLists.txt +++ b/src/model/CMakeLists.txt @@ -825,6 +825,9 @@ set(${target_name}_src GeneratorPVWatts.hpp GeneratorPVWatts_Impl.hpp GeneratorPVWatts.cpp + GeneratorWindTurbine.hpp + GeneratorWindTurbine_Impl.hpp + GeneratorWindTurbine.cpp GlareSensor.hpp GlareSensor_Impl.hpp GlareSensor.cpp @@ -1935,6 +1938,7 @@ set(${target_name}_test_src test/GeneratorPhotovoltaic_GTest.cpp test/GeneratorMicroTurbine_GTest.cpp test/GeneratorPVWatts_GTest.cpp + test/GeneratorWindTurbine_GTest.cpp test/GlareSensor_GTest.cpp test/GroundHeatExchangerHorizontalTrench_GTest.cpp test/GroundHeatExchangerVertical_GTest.cpp diff --git a/src/model/ConcreteModelObjects.hpp b/src/model/ConcreteModelObjects.hpp index 918d667c053..6b894dda22b 100644 --- a/src/model/ConcreteModelObjects.hpp +++ b/src/model/ConcreteModelObjects.hpp @@ -279,6 +279,7 @@ #include "GeneratorMicroTurbineHeatRecovery.hpp" #include "GeneratorPhotovoltaic.hpp" #include "GeneratorPVWatts.hpp" +#include "GeneratorWindTurbine.hpp" #include "GenericModelObject.hpp" #include "GlareSensor.hpp" #include "GroundHeatExchangerHorizontalTrench.hpp" @@ -776,6 +777,7 @@ #include "GeneratorMicroTurbineHeatRecovery_Impl.hpp" #include "GeneratorPhotovoltaic_Impl.hpp" #include "GeneratorPVWatts_Impl.hpp" +#include "GeneratorWindTurbine_Impl.hpp" #include "GenericModelObject_Impl.hpp" #include "GlareSensor_Impl.hpp" #include "GroundHeatExchangerHorizontalTrench_Impl.hpp" diff --git a/src/model/GeneratorPVWatts.cpp b/src/model/GeneratorPVWatts.cpp index 9695f14f015..796b625bf02 100644 --- a/src/model/GeneratorPVWatts.cpp +++ b/src/model/GeneratorPVWatts.cpp @@ -38,8 +38,6 @@ #include "Surface_Impl.hpp" #include "ShadingSurface.hpp" #include "ShadingSurface_Impl.hpp" -#include "ElectricLoadCenterDistribution.hpp" -#include "ElectricLoadCenterDistribution_Impl.hpp" #include "Schedule.hpp" #include "Schedule_Impl.hpp" diff --git a/src/model/GeneratorPhotovoltaic.cpp b/src/model/GeneratorPhotovoltaic.cpp index 332bf4424a0..61ecad1a2b7 100644 --- a/src/model/GeneratorPhotovoltaic.cpp +++ b/src/model/GeneratorPhotovoltaic.cpp @@ -45,8 +45,6 @@ #include "Schedule_Impl.hpp" #include "ScheduleTypeLimits.hpp" #include "ScheduleTypeRegistry.hpp" -#include "ElectricLoadCenterDistribution.hpp" -#include "ElectricLoadCenterDistribution_Impl.hpp" #include #include diff --git a/src/model/GeneratorWindTurbine.cpp b/src/model/GeneratorWindTurbine.cpp new file mode 100644 index 00000000000..48872927e38 --- /dev/null +++ b/src/model/GeneratorWindTurbine.cpp @@ -0,0 +1,622 @@ +/*********************************************************************************************************************** +* 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 "GeneratorWindTurbine.hpp" +#include "GeneratorWindTurbine_Impl.hpp" + +#include "Model.hpp" +#include "Model_Impl.hpp" +#include "Schedule.hpp" +#include "Schedule_Impl.hpp" +#include "ScheduleTypeLimits.hpp" +#include "ScheduleTypeRegistry.hpp" + +#include +#include +#include + +#include "../utilities/units/Unit.hpp" + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + + namespace detail { + + GeneratorWindTurbine_Impl::GeneratorWindTurbine_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) + : Generator_Impl(idfObject, model, keepHandle) { + OS_ASSERT(idfObject.iddObject().type() == GeneratorWindTurbine::iddObjectType()); + } + + GeneratorWindTurbine_Impl::GeneratorWindTurbine_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) + : Generator_Impl(other, model, keepHandle) { + OS_ASSERT(other.iddObject().type() == GeneratorWindTurbine::iddObjectType()); + } + + GeneratorWindTurbine_Impl::GeneratorWindTurbine_Impl(const GeneratorWindTurbine_Impl& other, Model_Impl* model, bool keepHandle) + : Generator_Impl(other, model, keepHandle) {} + + const std::vector& GeneratorWindTurbine_Impl::outputVariableNames() const { + static const std::vector result{"Generator Produced AC Electricity Rate", "Generator Produced AC Electricity Energy", + "Generator Turbine Local Wind Speed", "Generator Turbine Local Air Density", + "Generator Turbine Power Coefficient", "Generator Turbine Tip Speed Ratio", + "Generator Turbine Chordal Component Velocity", "Generator Turbine Normal Component Velocity", + "Generator Turbine Relative Flow Velocity", "Generator Turbine Attack Angle"}; + return result; + } + + IddObjectType GeneratorWindTurbine_Impl::iddObjectType() const { + return GeneratorWindTurbine::iddObjectType(); + } + + std::string GeneratorWindTurbine_Impl::generatorObjectType() const { + return "Generator:WindTurbine"; + } + + std::vector GeneratorWindTurbine_Impl::getScheduleTypeKeys(const Schedule& schedule) const { + std::vector result; + UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); + UnsignedVector::const_iterator b(fieldIndices.begin()), e(fieldIndices.end()); + if (std::find(b, e, OS_Generator_WindTurbineFields::AvailabilityScheduleName) != e) { + result.push_back(ScheduleTypeKey("GeneratorWindTurbine", "Availability")); + } + return result; + } + + // translated to ElectricLoadCenter:Generators 'Generator Rated Electric Power Output' + boost::optional GeneratorWindTurbine_Impl::ratedElectricPowerOutput() const { + return getDouble(OS_Generator_WindTurbineFields::RatedPower, true); + } + + boost::optional GeneratorWindTurbine_Impl::availabilitySchedule() const { + return getObject().getModelObjectTarget(OS_Generator_WindTurbineFields::AvailabilityScheduleName); + } + + // Convenience method to go fetch the connected GeneratorWindTurbine's 'Rated Thermal to Electrical Power Ratio' + boost::optional GeneratorWindTurbine_Impl::ratedThermaltoElectricalPowerRatio() const { + return boost::none; + } + + std::string GeneratorWindTurbine_Impl::rotorType() const { + boost::optional value = getString(OS_Generator_WindTurbineFields::RotorType, true); + OS_ASSERT(value); + return value.get(); + } + + std::string GeneratorWindTurbine_Impl::powerControl() const { + boost::optional value = getString(OS_Generator_WindTurbineFields::PowerControl, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::ratedRotorSpeed() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::RatedRotorSpeed, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::rotorDiameter() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::RotorDiameter, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::overallHeight() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::OverallHeight, true); + OS_ASSERT(value); + return value.get(); + } + + int GeneratorWindTurbine_Impl::numberofBlades() const { + boost::optional value = getInt(OS_Generator_WindTurbineFields::NumberofBlades, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::ratedPower() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::RatedPower, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::ratedWindSpeed() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::RatedWindSpeed, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::cutInWindSpeed() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::CutInWindSpeed, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::cutOutWindSpeed() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::CutOutWindSpeed, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::fractionSystemEfficiency() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::FractionsystemEfficiency, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::maximumTipSpeedRatio() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::MaximumTipSpeedRatio, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::maximumPowerCoefficient() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::MaximumPowerCoefficient, true); + OS_ASSERT(value); + return value.get(); + } + + boost::optional GeneratorWindTurbine_Impl::annualLocalAverageWindSpeed() const { + return getDouble(OS_Generator_WindTurbineFields::AnnualLocalAverageWindSpeed, true); + } + + double GeneratorWindTurbine_Impl::heightforLocalAverageWindSpeed() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::HeightforLocalAverageWindSpeed, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::bladeChordArea() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::BladeChordArea, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::bladeDragCoefficient() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::BladeDragCoefficient, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::bladeLiftCoefficient() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::BladeLiftCoefficient, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::powerCoefficientC1() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::PowerCoefficientC1, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::powerCoefficientC2() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::PowerCoefficientC2, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::powerCoefficientC3() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::PowerCoefficientC3, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::powerCoefficientC4() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::PowerCoefficientC4, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::powerCoefficientC5() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::PowerCoefficientC5, true); + OS_ASSERT(value); + return value.get(); + } + + double GeneratorWindTurbine_Impl::powerCoefficientC6() const { + boost::optional value = getDouble(OS_Generator_WindTurbineFields::PowerCoefficientC6, true); + OS_ASSERT(value); + return value.get(); + } + + bool GeneratorWindTurbine_Impl::setAvailabilitySchedule(Schedule& schedule) { + bool result = setSchedule(OS_Generator_WindTurbineFields::AvailabilityScheduleName, "GeneratorWindTurbine", "Availability", schedule); + return result; + } + + bool GeneratorWindTurbine_Impl::setRotorType(std::string rotorType) { + bool result = setString(OS_Generator_WindTurbineFields::RotorType, rotorType); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerControl(std::string powerControl) { + bool result = setString(OS_Generator_WindTurbineFields::PowerControl, powerControl); + return result; + } + + bool GeneratorWindTurbine_Impl::setRatedRotorSpeed(double ratedRotorSpeed) { + bool result = setDouble(OS_Generator_WindTurbineFields::RatedRotorSpeed, ratedRotorSpeed); + return result; + } + + bool GeneratorWindTurbine_Impl::setRotorDiameter(double rotorDiameter) { + bool result = setDouble(OS_Generator_WindTurbineFields::RotorDiameter, rotorDiameter); + return result; + } + + bool GeneratorWindTurbine_Impl::setOverallHeight(double overallHeight) { + bool result = setDouble(OS_Generator_WindTurbineFields::OverallHeight, overallHeight); + return result; + } + + bool GeneratorWindTurbine_Impl::setNumberofBlades(int numberofBlades) { + bool result = setInt(OS_Generator_WindTurbineFields::NumberofBlades, numberofBlades); + return result; + } + + bool GeneratorWindTurbine_Impl::setRatedPower(double ratedPower) { + bool result = setDouble(OS_Generator_WindTurbineFields::RatedPower, ratedPower); + return result; + } + + bool GeneratorWindTurbine_Impl::setRatedWindSpeed(double ratedWindSpeed) { + bool result = setDouble(OS_Generator_WindTurbineFields::RatedWindSpeed, ratedWindSpeed); + return result; + } + + bool GeneratorWindTurbine_Impl::setCutInWindSpeed(double cutInWindSpeed) { + bool result = setDouble(OS_Generator_WindTurbineFields::CutInWindSpeed, cutInWindSpeed); + return result; + } + + bool GeneratorWindTurbine_Impl::setCutOutWindSpeed(double cutOutWindSpeed) { + bool result = setDouble(OS_Generator_WindTurbineFields::CutOutWindSpeed, cutOutWindSpeed); + return result; + } + + bool GeneratorWindTurbine_Impl::setFractionSystemEfficiency(double fractionSystemEfficiency) { + bool result = setDouble(OS_Generator_WindTurbineFields::FractionsystemEfficiency, fractionSystemEfficiency); + return result; + } + + bool GeneratorWindTurbine_Impl::setMaximumTipSpeedRatio(double maximumTipSpeedRatio) { + bool result = setDouble(OS_Generator_WindTurbineFields::MaximumTipSpeedRatio, maximumTipSpeedRatio); + return result; + } + + bool GeneratorWindTurbine_Impl::setMaximumPowerCoefficient(double maximumPowerCoefficient) { + bool result = setDouble(OS_Generator_WindTurbineFields::MaximumPowerCoefficient, maximumPowerCoefficient); + return result; + } + + bool GeneratorWindTurbine_Impl::setAnnualLocalAverageWindSpeed(double annualLocalAverageWindSpeed) { + bool result = setDouble(OS_Generator_WindTurbineFields::AnnualLocalAverageWindSpeed, annualLocalAverageWindSpeed); + return result; + } + + void GeneratorWindTurbine_Impl::resetAnnualLocalAverageWindSpeed() { + bool result = setString(OS_Generator_WindTurbineFields::AnnualLocalAverageWindSpeed, ""); + OS_ASSERT(result); + } + + bool GeneratorWindTurbine_Impl::setHeightforLocalAverageWindSpeed(double heightforLocalAverageWindSpeed) { + bool result = setDouble(OS_Generator_WindTurbineFields::HeightforLocalAverageWindSpeed, heightforLocalAverageWindSpeed); + return result; + } + + bool GeneratorWindTurbine_Impl::setBladeChordArea(double bladeChordArea) { + bool result = setDouble(OS_Generator_WindTurbineFields::BladeChordArea, bladeChordArea); + return result; + } + + bool GeneratorWindTurbine_Impl::setBladeDragCoefficient(double bladeDragCoefficient) { + bool result = setDouble(OS_Generator_WindTurbineFields::BladeDragCoefficient, bladeDragCoefficient); + return result; + } + + bool GeneratorWindTurbine_Impl::setBladeLiftCoefficient(double bladeLiftCoefficient) { + bool result = setDouble(OS_Generator_WindTurbineFields::BladeLiftCoefficient, bladeLiftCoefficient); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerCoefficientC1(double powerCoefficientC1) { + bool result = setDouble(OS_Generator_WindTurbineFields::PowerCoefficientC1, powerCoefficientC1); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerCoefficientC2(double powerCoefficientC2) { + bool result = setDouble(OS_Generator_WindTurbineFields::PowerCoefficientC2, powerCoefficientC2); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerCoefficientC3(double powerCoefficientC3) { + bool result = setDouble(OS_Generator_WindTurbineFields::PowerCoefficientC3, powerCoefficientC3); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerCoefficientC4(double powerCoefficientC4) { + bool result = setDouble(OS_Generator_WindTurbineFields::PowerCoefficientC4, powerCoefficientC4); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerCoefficientC5(double powerCoefficientC5) { + bool result = setDouble(OS_Generator_WindTurbineFields::PowerCoefficientC5, powerCoefficientC5); + return result; + } + + bool GeneratorWindTurbine_Impl::setPowerCoefficientC6(double powerCoefficientC6) { + bool result = setDouble(OS_Generator_WindTurbineFields::PowerCoefficientC6, powerCoefficientC6); + return result; + } + + } // namespace detail + + GeneratorWindTurbine::GeneratorWindTurbine(const Model& model) : Generator(GeneratorWindTurbine::iddObjectType(), model) { + OS_ASSERT(getImpl()); + + { + auto schedule = model.alwaysOnDiscreteSchedule(); + setAvailabilitySchedule(schedule); + } + setRotorType("HorizontalAxisWindTurbine"); + setPowerControl("VariableSpeedVariablePitch"); + setRatedRotorSpeed(41.0); // from docs + setRotorDiameter(19.2); // from docs + setOverallHeight(30.5); // from docs + setNumberofBlades(3); + setRatedPower(55000.0); // from docs + setRatedWindSpeed(11.0); // from docs + setCutInWindSpeed(3.5); // from docs + setCutOutWindSpeed(25.0); // from docs + setFractionSystemEfficiency(0.835); + setMaximumTipSpeedRatio(5.0); + setMaximumPowerCoefficient(0.25); + setHeightforLocalAverageWindSpeed(50.0); + setBladeChordArea(2.08); // from docs + setBladeDragCoefficient(0.9); + setBladeLiftCoefficient(0.05); + setPowerCoefficientC1(0.5176); + setPowerCoefficientC2(116.0); + setPowerCoefficientC3(0.4); + setPowerCoefficientC4(0.0); + setPowerCoefficientC5(5.0); + setPowerCoefficientC6(21.0); + } + + IddObjectType GeneratorWindTurbine::iddObjectType() { + return IddObjectType(IddObjectType::OS_Generator_WindTurbine); + } + + std::string GeneratorWindTurbine::rotorType() const { + return getImpl()->rotorType(); + } + + std::string GeneratorWindTurbine::powerControl() const { + return getImpl()->powerControl(); + } + + double GeneratorWindTurbine::ratedRotorSpeed() const { + return getImpl()->ratedRotorSpeed(); + } + + double GeneratorWindTurbine::rotorDiameter() const { + return getImpl()->rotorDiameter(); + } + + double GeneratorWindTurbine::overallHeight() const { + return getImpl()->overallHeight(); + } + + int GeneratorWindTurbine::numberofBlades() const { + return getImpl()->numberofBlades(); + } + + double GeneratorWindTurbine::ratedPower() const { + return getImpl()->ratedPower(); + } + + double GeneratorWindTurbine::ratedWindSpeed() const { + return getImpl()->ratedWindSpeed(); + } + + double GeneratorWindTurbine::cutInWindSpeed() const { + return getImpl()->cutInWindSpeed(); + } + + double GeneratorWindTurbine::cutOutWindSpeed() const { + return getImpl()->cutOutWindSpeed(); + } + + double GeneratorWindTurbine::fractionSystemEfficiency() const { + return getImpl()->fractionSystemEfficiency(); + } + + double GeneratorWindTurbine::maximumTipSpeedRatio() const { + return getImpl()->maximumTipSpeedRatio(); + } + + double GeneratorWindTurbine::maximumPowerCoefficient() const { + return getImpl()->maximumPowerCoefficient(); + } + + boost::optional GeneratorWindTurbine::annualLocalAverageWindSpeed() const { + return getImpl()->annualLocalAverageWindSpeed(); + } + + double GeneratorWindTurbine::heightforLocalAverageWindSpeed() const { + return getImpl()->heightforLocalAverageWindSpeed(); + } + + double GeneratorWindTurbine::bladeChordArea() const { + return getImpl()->bladeChordArea(); + } + + double GeneratorWindTurbine::bladeDragCoefficient() const { + return getImpl()->bladeDragCoefficient(); + } + + double GeneratorWindTurbine::bladeLiftCoefficient() const { + return getImpl()->bladeLiftCoefficient(); + } + + double GeneratorWindTurbine::powerCoefficientC1() const { + return getImpl()->powerCoefficientC1(); + } + + double GeneratorWindTurbine::powerCoefficientC2() const { + return getImpl()->powerCoefficientC2(); + } + + double GeneratorWindTurbine::powerCoefficientC3() const { + return getImpl()->powerCoefficientC3(); + } + + double GeneratorWindTurbine::powerCoefficientC4() const { + return getImpl()->powerCoefficientC4(); + } + + double GeneratorWindTurbine::powerCoefficientC5() const { + return getImpl()->powerCoefficientC5(); + } + + double GeneratorWindTurbine::powerCoefficientC6() const { + return getImpl()->powerCoefficientC6(); + } + + bool GeneratorWindTurbine::setAvailabilitySchedule(Schedule& schedule) { + return getImpl()->setAvailabilitySchedule(schedule); + } + + bool GeneratorWindTurbine::setRotorType(std::string rotorType) { + return getImpl()->setRotorType(rotorType); + } + + bool GeneratorWindTurbine::setPowerControl(std::string powerControl) { + return getImpl()->setPowerControl(powerControl); + } + + bool GeneratorWindTurbine::setRatedRotorSpeed(double ratedRotorSpeed) { + return getImpl()->setRatedRotorSpeed(ratedRotorSpeed); + } + + bool GeneratorWindTurbine::setRotorDiameter(double rotorDiameter) { + return getImpl()->setRotorDiameter(rotorDiameter); + } + + bool GeneratorWindTurbine::setOverallHeight(double overallHeight) { + return getImpl()->setOverallHeight(overallHeight); + } + + bool GeneratorWindTurbine::setNumberofBlades(int numberofBlades) { + return getImpl()->setNumberofBlades(numberofBlades); + } + + bool GeneratorWindTurbine::setRatedPower(double ratedPower) { + return getImpl()->setRatedPower(ratedPower); + } + + bool GeneratorWindTurbine::setRatedWindSpeed(double ratedWindSpeed) { + return getImpl()->setRatedWindSpeed(ratedWindSpeed); + } + + bool GeneratorWindTurbine::setCutInWindSpeed(double cutInWindSpeed) { + return getImpl()->setCutInWindSpeed(cutInWindSpeed); + } + + bool GeneratorWindTurbine::setCutOutWindSpeed(double cutOutWindSpeed) { + return getImpl()->setCutOutWindSpeed(cutOutWindSpeed); + } + + bool GeneratorWindTurbine::setFractionSystemEfficiency(double fractionSystemEfficiency) { + return getImpl()->setFractionSystemEfficiency(fractionSystemEfficiency); + } + + bool GeneratorWindTurbine::setMaximumTipSpeedRatio(double maximumTipSpeedRatio) { + return getImpl()->setMaximumTipSpeedRatio(maximumTipSpeedRatio); + } + + bool GeneratorWindTurbine::setMaximumPowerCoefficient(double maximumPowerCoefficient) { + return getImpl()->setMaximumPowerCoefficient(maximumPowerCoefficient); + } + + bool GeneratorWindTurbine::setAnnualLocalAverageWindSpeed(double annualLocalAverageWindSpeed) { + return getImpl()->setAnnualLocalAverageWindSpeed(annualLocalAverageWindSpeed); + } + + void GeneratorWindTurbine::resetAnnualLocalAverageWindSpeed() { + getImpl()->resetAnnualLocalAverageWindSpeed(); + } + + bool GeneratorWindTurbine::setHeightforLocalAverageWindSpeed(double heightforLocalAverageWindSpeed) { + return getImpl()->setHeightforLocalAverageWindSpeed(heightforLocalAverageWindSpeed); + } + + bool GeneratorWindTurbine::setBladeChordArea(double bladeChordArea) { + return getImpl()->setBladeChordArea(bladeChordArea); + } + + bool GeneratorWindTurbine::setBladeDragCoefficient(double bladeDragCoefficient) { + return getImpl()->setBladeDragCoefficient(bladeDragCoefficient); + } + + bool GeneratorWindTurbine::setBladeLiftCoefficient(double bladeLiftCoefficient) { + return getImpl()->setBladeLiftCoefficient(bladeLiftCoefficient); + } + + bool GeneratorWindTurbine::setPowerCoefficientC1(double powerCoefficientC1) { + return getImpl()->setPowerCoefficientC1(powerCoefficientC1); + } + + bool GeneratorWindTurbine::setPowerCoefficientC2(double powerCoefficientC2) { + return getImpl()->setPowerCoefficientC2(powerCoefficientC2); + } + + bool GeneratorWindTurbine::setPowerCoefficientC3(double powerCoefficientC3) { + return getImpl()->setPowerCoefficientC3(powerCoefficientC3); + } + + bool GeneratorWindTurbine::setPowerCoefficientC4(double powerCoefficientC4) { + return getImpl()->setPowerCoefficientC4(powerCoefficientC4); + } + + bool GeneratorWindTurbine::setPowerCoefficientC5(double powerCoefficientC5) { + return getImpl()->setPowerCoefficientC5(powerCoefficientC5); + } + + bool GeneratorWindTurbine::setPowerCoefficientC6(double powerCoefficientC6) { + return getImpl()->setPowerCoefficientC6(powerCoefficientC6); + } + + /// @cond + GeneratorWindTurbine::GeneratorWindTurbine(std::shared_ptr impl) : Generator(std::move(impl)) {} + /// @endcond + +} // namespace model +} // namespace openstudio diff --git a/src/model/GeneratorWindTurbine.hpp b/src/model/GeneratorWindTurbine.hpp new file mode 100644 index 00000000000..6e21777fa7d --- /dev/null +++ b/src/model/GeneratorWindTurbine.hpp @@ -0,0 +1,197 @@ +/*********************************************************************************************************************** +* 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. +***********************************************************************************************************************/ + +#ifndef MODEL_GENERATORWINDTURBINE_HPP +#define MODEL_GENERATORWINDTURBINE_HPP + +#include "ModelAPI.hpp" +#include "Generator.hpp" + +namespace openstudio { + +namespace model { + + namespace detail { + + class GeneratorWindTurbine_Impl; + + } // namespace detail + + /** GeneratorWindTurbine is a Generator that wraps the OpenStudio IDD object 'OS:Generator:WindTurbine'. */ + class MODEL_API GeneratorWindTurbine : public Generator + { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit GeneratorWindTurbine(const Model& model); + + virtual ~GeneratorWindTurbine() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + std::string rotorType() const; + + std::string powerControl() const; + + double ratedRotorSpeed() const; + + double rotorDiameter() const; + + double overallHeight() const; + + int numberofBlades() const; + + double ratedPower() const; + + double ratedWindSpeed() const; + + double cutInWindSpeed() const; + + double cutOutWindSpeed() const; + + double fractionSystemEfficiency() const; + + double maximumTipSpeedRatio() const; + + double maximumPowerCoefficient() const; + + boost::optional annualLocalAverageWindSpeed() const; + + double heightforLocalAverageWindSpeed() const; + + double bladeChordArea() const; + + double bladeDragCoefficient() const; + + double bladeLiftCoefficient() const; + + double powerCoefficientC1() const; + + double powerCoefficientC2() const; + + double powerCoefficientC3() const; + + double powerCoefficientC4() const; + + double powerCoefficientC5() const; + + double powerCoefficientC6() const; + + //@} + /** @name Setters */ + //@{ + + bool setAvailabilitySchedule(Schedule& schedule); + + bool setRotorType(std::string rotorType); + + bool setPowerControl(std::string powerControl); + + bool setRatedRotorSpeed(double ratedRotorSpeed); + + bool setRotorDiameter(double rotorDiameter); + + bool setOverallHeight(double overallHeight); + + bool setNumberofBlades(int numberofBlades); + + bool setRatedPower(double ratedPower); + + bool setRatedWindSpeed(double ratedWindSpeed); + + bool setCutInWindSpeed(double cutInWindSpeed); + + bool setCutOutWindSpeed(double cutOutWindSpeed); + + bool setFractionSystemEfficiency(double fractionSystemEfficiency); + + bool setMaximumTipSpeedRatio(double maximumTipSpeedRatio); + + bool setMaximumPowerCoefficient(double maximumPowerCoefficient); + + bool setAnnualLocalAverageWindSpeed(double annualLocalAverageWindSpeed); + + void resetAnnualLocalAverageWindSpeed(); + + bool setHeightforLocalAverageWindSpeed(double heightforLocalAverageWindSpeed); + + bool setBladeChordArea(double bladeChordArea); + + bool setBladeDragCoefficient(double bladeDragCoefficient); + + bool setBladeLiftCoefficient(double bladeLiftCoefficient); + + bool setPowerCoefficientC1(double powerCoefficientC1); + + bool setPowerCoefficientC2(double powerCoefficientC2); + + bool setPowerCoefficientC3(double powerCoefficientC3); + + bool setPowerCoefficientC4(double powerCoefficientC4); + + bool setPowerCoefficientC5(double powerCoefficientC5); + + bool setPowerCoefficientC6(double powerCoefficientC6); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::GeneratorWindTurbine_Impl ImplType; + + explicit GeneratorWindTurbine(std::shared_ptr impl); + + friend class detail::GeneratorWindTurbine_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.GeneratorWindTurbine"); + }; + + /** \relates GeneratorWindTurbine*/ + typedef boost::optional OptionalGeneratorWindTurbine; + + /** \relates GeneratorWindTurbine*/ + typedef std::vector GeneratorWindTurbineVector; + +} // namespace model +} // namespace openstudio + +#endif // MODEL_GENERATORWINDTURBINE_HPP diff --git a/src/model/GeneratorWindTurbine_Impl.hpp b/src/model/GeneratorWindTurbine_Impl.hpp new file mode 100644 index 00000000000..9111dba5323 --- /dev/null +++ b/src/model/GeneratorWindTurbine_Impl.hpp @@ -0,0 +1,198 @@ +/*********************************************************************************************************************** +* 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. +***********************************************************************************************************************/ + +#ifndef MODEL_GENERATORWINDTURBINE_IMPL_HPP +#define MODEL_GENERATORWINDTURBINE_IMPL_HPP + +#include "ModelAPI.hpp" +#include "Generator_Impl.hpp" + +namespace openstudio { +namespace model { + + namespace detail { + + /** GeneratorWindTurbine_Impl is a Generator_Impl that is the implementation class for GeneratorWindTurbine.*/ + class MODEL_API GeneratorWindTurbine_Impl : public Generator_Impl + { + + public: + /** @name Constructors and Destructors */ + //@{ + + GeneratorWindTurbine_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle); + + GeneratorWindTurbine_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle); + + GeneratorWindTurbine_Impl(const GeneratorWindTurbine_Impl& other, Model_Impl* model, bool keepHandle); + + virtual ~GeneratorWindTurbine_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const override; + + virtual IddObjectType iddObjectType() const override; + + virtual std::string generatorObjectType() const override; + + virtual std::vector getScheduleTypeKeys(const Schedule& schedule) const override; + + virtual boost::optional ratedElectricPowerOutput() const override; + + virtual boost::optional availabilitySchedule() const override; + + virtual boost::optional ratedThermaltoElectricalPowerRatio() const override; + + //@} + /** @name Getters */ + //@{ + + std::string rotorType() const; + + std::string powerControl() const; + + double ratedRotorSpeed() const; + + double rotorDiameter() const; + + double overallHeight() const; + + int numberofBlades() const; + + double ratedPower() const; + + double ratedWindSpeed() const; + + double cutInWindSpeed() const; + + double cutOutWindSpeed() const; + + double fractionSystemEfficiency() const; + + double maximumTipSpeedRatio() const; + + double maximumPowerCoefficient() const; + + boost::optional annualLocalAverageWindSpeed() const; + + double heightforLocalAverageWindSpeed() const; + + double bladeChordArea() const; + + double bladeDragCoefficient() const; + + double bladeLiftCoefficient() const; + + double powerCoefficientC1() const; + + double powerCoefficientC2() const; + + double powerCoefficientC3() const; + + double powerCoefficientC4() const; + + double powerCoefficientC5() const; + + double powerCoefficientC6() const; + + //@} + /** @name Setters */ + //@{ + + bool setAvailabilitySchedule(Schedule& schedule); + + bool setRotorType(std::string rotorType); + + bool setPowerControl(std::string powerControl); + + bool setRatedRotorSpeed(double ratedRotorSpeed); + + bool setRotorDiameter(double rotorDiameter); + + bool setOverallHeight(double overallHeight); + + bool setNumberofBlades(int numberofBlades); + + bool setRatedPower(double ratedPower); + + bool setRatedWindSpeed(double ratedWindSpeed); + + bool setCutInWindSpeed(double cutInWindSpeed); + + bool setCutOutWindSpeed(double cutOutWindSpeed); + + bool setFractionSystemEfficiency(double fractionSystemEfficiency); + + bool setMaximumTipSpeedRatio(double maximumTipSpeedRatio); + + bool setMaximumPowerCoefficient(double maximumPowerCoefficient); + + bool setAnnualLocalAverageWindSpeed(double annualLocalAverageWindSpeed); + + void resetAnnualLocalAverageWindSpeed(); + + bool setHeightforLocalAverageWindSpeed(double heightforLocalAverageWindSpeed); + + bool setBladeChordArea(double bladeChordArea); + + bool setBladeDragCoefficient(double bladeDragCoefficient); + + bool setBladeLiftCoefficient(double bladeLiftCoefficient); + + bool setPowerCoefficientC1(double powerCoefficientC1); + + bool setPowerCoefficientC2(double powerCoefficientC2); + + bool setPowerCoefficientC3(double powerCoefficientC3); + + bool setPowerCoefficientC4(double powerCoefficientC4); + + bool setPowerCoefficientC5(double powerCoefficientC5); + + bool setPowerCoefficientC6(double powerCoefficientC6); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.GeneratorWindTurbine"); + }; + + } // namespace detail + +} // namespace model +} // namespace openstudio + +#endif // MODEL_GENERATORWINDTURBINE_IMPL_HPP diff --git a/src/model/Model.cpp b/src/model/Model.cpp index 14e3e333f6e..7ff834e70e9 100644 --- a/src/model/Model.cpp +++ b/src/model/Model.cpp @@ -2815,6 +2815,7 @@ namespace model { REGISTER_CONSTRUCTOR(GeneratorMicroTurbineHeatRecovery); REGISTER_CONSTRUCTOR(GeneratorPhotovoltaic); REGISTER_CONSTRUCTOR(GeneratorPVWatts); + REGISTER_CONSTRUCTOR(GeneratorWindTurbine); REGISTER_CONSTRUCTOR(GlareSensor); REGISTER_CONSTRUCTOR(GroundHeatExchangerHorizontalTrench); REGISTER_CONSTRUCTOR(GroundHeatExchangerVertical); @@ -3320,6 +3321,7 @@ namespace model { REGISTER_COPYCONSTRUCTORS(GeneratorMicroTurbineHeatRecovery); REGISTER_COPYCONSTRUCTORS(GeneratorPhotovoltaic); REGISTER_COPYCONSTRUCTORS(GeneratorPVWatts); + REGISTER_COPYCONSTRUCTORS(GeneratorWindTurbine); REGISTER_COPYCONSTRUCTORS(GlareSensor); REGISTER_COPYCONSTRUCTORS(GroundHeatExchangerHorizontalTrench); REGISTER_COPYCONSTRUCTORS(GroundHeatExchangerVertical); diff --git a/src/model/ModelGenerators.i b/src/model/ModelGenerators.i index dedf9c6f3d2..32a0993baf6 100644 --- a/src/model/ModelGenerators.i +++ b/src/model/ModelGenerators.i @@ -104,6 +104,7 @@ MODELOBJECT_TEMPLATES(GeneratorPhotovoltaic); MODELOBJECT_TEMPLATES(GeneratorMicroTurbineHeatRecovery); MODELOBJECT_TEMPLATES(GeneratorMicroTurbine); MODELOBJECT_TEMPLATES(GeneratorPVWatts); +MODELOBJECT_TEMPLATES(GeneratorWindTurbine); MODELOBJECT_TEMPLATES(ElectricLoadCenterTransformer); MODELOBJECT_TEMPLATES(ElectricLoadCenterDistribution); MODELOBJECT_TEMPLATES(ElectricLoadCenterInverterLookUpTable); @@ -133,6 +134,7 @@ SWIG_MODELOBJECT(GeneratorPhotovoltaic, 1); SWIG_MODELOBJECT(GeneratorMicroTurbineHeatRecovery, 1); SWIG_MODELOBJECT(GeneratorMicroTurbine, 1); SWIG_MODELOBJECT(GeneratorPVWatts, 1); +SWIG_MODELOBJECT(GeneratorWindTurbine, 1); SWIG_MODELOBJECT(ElectricLoadCenterTransformer, 1); SWIG_MODELOBJECT(ElectricLoadCenterDistribution, 1); SWIG_MODELOBJECT(ElectricLoadCenterInverterLookUpTable, 1); diff --git a/src/model/ScheduleTypeRegistry.cpp b/src/model/ScheduleTypeRegistry.cpp index 05445697184..e5c5a6ee77f 100644 --- a/src/model/ScheduleTypeRegistry.cpp +++ b/src/model/ScheduleTypeRegistry.cpp @@ -284,6 +284,7 @@ namespace model { {"GeneratorFuelCellWaterSupply", "Water Temperature", "waterTemperatureScheduleName", true, "Temperature", 0.0, 100.0}, {"GeneratorMicroTurbine", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"GeneratorPhotovoltaic", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, + {"GeneratorWindTurbine", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"HeatExchangerAirToAirSensibleAndLatent", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"HeatExchangerFluidToFluid", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"HumidifierSteamElectric", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, diff --git a/src/model/test/GeneratorPVWatts_GTest.cpp b/src/model/test/GeneratorPVWatts_GTest.cpp index d0c20c6ff1b..a70d8b575cd 100644 --- a/src/model/test/GeneratorPVWatts_GTest.cpp +++ b/src/model/test/GeneratorPVWatts_GTest.cpp @@ -55,7 +55,7 @@ TEST_F(ModelFixture, GeneratorPVWatts_GeneratorPVWatts) { // create a model to use Model model; - // create a foundation kiva object to use + // create a pvwatts object to use GeneratorPVWatts generator(model, 1); exit(0); diff --git a/src/model/test/GeneratorWindTurbine_GTest.cpp b/src/model/test/GeneratorWindTurbine_GTest.cpp new file mode 100644 index 00000000000..f979a458de9 --- /dev/null +++ b/src/model/test/GeneratorWindTurbine_GTest.cpp @@ -0,0 +1,224 @@ +/*********************************************************************************************************************** +* 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 "ModelFixture.hpp" + +#include "../Model.hpp" + +#include "../GeneratorWindTurbine.hpp" +#include "../GeneratorWindTurbine_Impl.hpp" +#include "../ElectricLoadCenterDistribution.hpp" +#include "../ElectricLoadCenterDistribution_Impl.hpp" +#include "../ScheduleConstant.hpp" +#include "../ScheduleConstant_Impl.hpp" + +using namespace openstudio; +using namespace openstudio::model; + +TEST_F(ModelFixture, GeneratorWindTurbine) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + + ASSERT_EXIT( + { + Model model; + + GeneratorWindTurbine generator(model); + + exit(0); + }, + ::testing::ExitedWithCode(0), ""); + + Model model; + + GeneratorWindTurbine generator(model); + + EXPECT_TRUE(generator.availabilitySchedule()); + EXPECT_EQ("HorizontalAxisWindTurbine", generator.rotorType()); + EXPECT_EQ("VariableSpeedVariablePitch", generator.powerControl()); + EXPECT_EQ(41.0, generator.ratedRotorSpeed()); + EXPECT_EQ(19.2, generator.rotorDiameter()); + EXPECT_EQ(30.5, generator.overallHeight()); + EXPECT_EQ(3, generator.numberofBlades()); + EXPECT_EQ(55000.0, generator.ratedPower()); + EXPECT_EQ(11.0, generator.ratedWindSpeed()); + EXPECT_EQ(3.5, generator.cutInWindSpeed()); + EXPECT_EQ(25.0, generator.cutOutWindSpeed()); + EXPECT_EQ(0.835, generator.fractionSystemEfficiency()); + EXPECT_EQ(5.0, generator.maximumTipSpeedRatio()); + EXPECT_EQ(0.25, generator.maximumPowerCoefficient()); + EXPECT_FALSE(generator.annualLocalAverageWindSpeed()); + EXPECT_EQ(50.0, generator.heightforLocalAverageWindSpeed()); + EXPECT_EQ(2.08, generator.bladeChordArea()); + EXPECT_EQ(0.9, generator.bladeDragCoefficient()); + EXPECT_EQ(0.05, generator.bladeLiftCoefficient()); + EXPECT_EQ(0.5176, generator.powerCoefficientC1()); + EXPECT_EQ(116.0, generator.powerCoefficientC2()); + EXPECT_EQ(0.4, generator.powerCoefficientC3()); + EXPECT_EQ(0.0, generator.powerCoefficientC4()); + EXPECT_EQ(5.0, generator.powerCoefficientC5()); + EXPECT_EQ(21.0, generator.powerCoefficientC6()); +} + +TEST_F(ModelFixture, GeneratorWindTurbine_SetGetFields) { + Model model; + + GeneratorWindTurbine generator(model); + + ScheduleConstant schedule(model); + generator.setAvailabilitySchedule(schedule); + generator.setRotorType("VerticalAxisWindTurbine"); + generator.setPowerControl("FixedSpeedFixedPitch"); + generator.setRatedRotorSpeed(42.0); + generator.setRotorDiameter(20.0); + generator.setOverallHeight(31.0); + generator.setNumberofBlades(4); + generator.setRatedPower(0.1); + generator.setRatedWindSpeed(15.0); + generator.setCutInWindSpeed(4.0); + generator.setCutOutWindSpeed(30.0); + generator.setFractionSystemEfficiency(0.9); + generator.setMaximumTipSpeedRatio(6.0); + generator.setMaximumPowerCoefficient(0.3); + generator.setAnnualLocalAverageWindSpeed(10.0); + generator.setHeightforLocalAverageWindSpeed(55.0); + generator.setBladeChordArea(3.0); + generator.setBladeDragCoefficient(1.0); + generator.setBladeLiftCoefficient(0.2); + generator.setPowerCoefficientC1(0.6); + generator.setPowerCoefficientC2(120.0); + generator.setPowerCoefficientC3(0.1); + generator.setPowerCoefficientC4(0.3); + generator.setPowerCoefficientC5(8.0); + generator.setPowerCoefficientC6(25.0); + + EXPECT_TRUE(generator.availabilitySchedule()); + EXPECT_EQ("VerticalAxisWindTurbine", generator.rotorType()); + EXPECT_EQ("FixedSpeedFixedPitch", generator.powerControl()); + EXPECT_EQ(42.0, generator.ratedRotorSpeed()); + EXPECT_EQ(20.0, generator.rotorDiameter()); + EXPECT_EQ(31.0, generator.overallHeight()); + EXPECT_EQ(4, generator.numberofBlades()); + EXPECT_EQ(0.1, generator.ratedPower()); + EXPECT_EQ(15.0, generator.ratedWindSpeed()); + EXPECT_EQ(4.0, generator.cutInWindSpeed()); + EXPECT_EQ(30.0, generator.cutOutWindSpeed()); + EXPECT_EQ(0.9, generator.fractionSystemEfficiency()); + EXPECT_EQ(6.0, generator.maximumTipSpeedRatio()); + EXPECT_EQ(0.3, generator.maximumPowerCoefficient()); + ASSERT_TRUE(generator.annualLocalAverageWindSpeed()); + EXPECT_EQ(10.0, generator.annualLocalAverageWindSpeed().get()); + EXPECT_EQ(55.0, generator.heightforLocalAverageWindSpeed()); + EXPECT_EQ(3.0, generator.bladeChordArea()); + EXPECT_EQ(1.0, generator.bladeDragCoefficient()); + EXPECT_EQ(0.2, generator.bladeLiftCoefficient()); + EXPECT_EQ(0.6, generator.powerCoefficientC1()); + EXPECT_EQ(120.0, generator.powerCoefficientC2()); + EXPECT_EQ(0.1, generator.powerCoefficientC3()); + EXPECT_EQ(0.3, generator.powerCoefficientC4()); + EXPECT_EQ(8.0, generator.powerCoefficientC5()); + EXPECT_EQ(25.0, generator.powerCoefficientC6()); + + generator.resetAnnualLocalAverageWindSpeed(); + + EXPECT_FALSE(generator.annualLocalAverageWindSpeed()); +} + +TEST_F(ModelFixture, GeneratorWindTurbine_Clone) { + Model model; + GeneratorWindTurbine generator(model); + generator.setAnnualLocalAverageWindSpeed(12.0); + + // clone it into the same model + GeneratorWindTurbine generatorClone = generator.clone(model).cast(); + ASSERT_TRUE(generatorClone.annualLocalAverageWindSpeed()); + + // clone it into a different model + Model model2; + GeneratorWindTurbine generatorClone2 = generator.clone(model2).cast(); + ASSERT_TRUE(generatorClone2.annualLocalAverageWindSpeed()); +} + +TEST_F(ModelFixture, GeneratorWindTurbine_Remove) { + Model model; + //start with 0 + std::vector gens = model.getModelObjects(); + EXPECT_EQ(0u, gens.size()); + //add 1 + GeneratorWindTurbine generator(model); + gens = model.getModelObjects(); + EXPECT_EQ(1u, gens.size()); + //remove + EXPECT_FALSE(generator.remove().empty()); + gens = model.getModelObjects(); + EXPECT_EQ(0u, gens.size()); +} + +TEST_F(ModelFixture, GeneratorWindTurbine_ElectricLoadCenterDistribution) { + Model model; + ElectricLoadCenterDistribution elcd(model); + EXPECT_EQ(0, elcd.generators().size()); + GeneratorWindTurbine generator(model); + elcd.addGenerator(generator); + EXPECT_EQ(1u, elcd.generators().size()); + boost::optional optelcd = generator.electricLoadCenterDistribution(); + EXPECT_TRUE(optelcd); + ElectricLoadCenterDistribution elcd2 = optelcd.get(); + EXPECT_EQ(elcd, elcd2); + EXPECT_TRUE(elcd.removeGenerator(generator)); + EXPECT_FALSE(generator.electricLoadCenterDistribution()); + ASSERT_EQ(0, elcd.generators().size()); + ASSERT_EQ(0, elcd2.generators().size()); + elcd.addGenerator(generator); + elcd.remove(); + EXPECT_FALSE(generator.electricLoadCenterDistribution()); +} + +TEST_F(ModelFixture, GeneratorWindTurbine_ElectricLoadCenterDistribution2) { + Model model; + + GeneratorWindTurbine generator(model); + + //should be 0 default ELCD attached to wind turbine + std::vector elcd = model.getModelObjects(); + 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 wind turbine to it which should remove the existing one attached to wind turbine + EXPECT_TRUE(elcd2.addGenerator(generator)); + EXPECT_EQ(0, elcd1.generators().size()); + EXPECT_EQ(elcd2.handle(), generator.electricLoadCenterDistribution().get().handle()); +} diff --git a/src/utilities/filetypes/EpwFile.cpp b/src/utilities/filetypes/EpwFile.cpp index 103b877d7ac..5245a0b633a 100644 --- a/src/utilities/filetypes/EpwFile.cpp +++ b/src/utilities/filetypes/EpwFile.cpp @@ -1564,9 +1564,9 @@ static int stringToInteger(const std::string& string, bool* ok) { *ok = true; try { value = std::stoi(string); - } catch (const std::invalid_argument &) { + } catch (const std::invalid_argument&) { *ok = false; - } catch (const std::out_of_range &) { + } catch (const std::out_of_range&) { *ok = false; } return value; @@ -1577,9 +1577,9 @@ static double stringToDouble(const std::string& string, bool* ok) { *ok = true; try { value = std::stod(string); - } catch (const std::invalid_argument &) { + } catch (const std::invalid_argument&) { *ok = false; - } catch (const std::out_of_range &) { + } catch (const std::out_of_range&) { *ok = false; } return value;