Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVWatts Speed Up #8960

Merged
merged 13 commits into from
Aug 21, 2021
Merged
2 changes: 0 additions & 2 deletions src/EnergyPlus/Data/EnergyPlusData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ EnergyPlusData::EnergyPlusData()
this->dataOutputReports = std::make_unique<OutputReportsData>();
this->dataOutsideEnergySrcs = std::make_unique<OutsideEnergySourcesData>();
this->dataPTHP = std::make_unique<PackagedTerminalHeatPumpData>();
this->dataPVWatts = std::make_unique<PVWattsData>();
this->dataPackagedThermalStorageCoil = std::make_unique<PackagedThermalStorageCoilData>();
this->dataPhotovoltaic = std::make_unique<PhotovoltaicsData>();
this->dataPhotovoltaicState = std::make_unique<PhotovoltaicStateData>();
Expand Down Expand Up @@ -456,7 +455,6 @@ void EnergyPlusData::clear_state()
this->dataOutputReports->clear_state();
this->dataOutsideEnergySrcs->clear_state();
this->dataPTHP->clear_state();
this->dataPVWatts->clear_state();
this->dataPackagedThermalStorageCoil->clear_state();
this->dataPhotovoltaic->clear_state();
this->dataPhotovoltaicState->clear_state();
Expand Down
2 changes: 0 additions & 2 deletions src/EnergyPlus/Data/EnergyPlusData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ struct OutputReportTabularData;
struct OutputReportsData;
struct OutputsData;
struct OutsideEnergySourcesData;
struct PVWattsData;
struct PackagedTerminalHeatPumpData;
struct PackagedThermalStorageCoilData;
struct PhotovoltaicStateData;
Expand Down Expand Up @@ -472,7 +471,6 @@ struct EnergyPlusData : BaseGlobalStruct
std::unique_ptr<OutputReportsData> dataOutputReports;
std::unique_ptr<OutputsData> dataOutput;
std::unique_ptr<OutsideEnergySourcesData> dataOutsideEnergySrcs;
std::unique_ptr<PVWattsData> dataPVWatts;
std::unique_ptr<PackagedTerminalHeatPumpData> dataPTHP;
std::unique_ptr<PackagedThermalStorageCoilData> dataPackagedThermalStorageCoil;
std::unique_ptr<PhotovoltaicStateData> dataPhotovoltaicState;
Expand Down
24 changes: 16 additions & 8 deletions src/EnergyPlus/ElectricPowerServiceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1045,12 +1045,11 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje
ShowContinueError(state, "ElectricLoadCenter:Inverter:PVWatts can only be used with Generator:PVWatts");
ShowContinueError(state, "\"" + generatorController->name + "\" is of type " + generatorController->typeOfName);
} else {
PVWatts::PVWattsGenerator &pvwGen = PVWatts::GetOrCreatePVWattsGenerator(state, generatorController->name);
totalDCCapacity += pvwGen.getDCSystemCapacity();
totalDCCapacity += generatorController->pvwattsGenerator->getDCSystemCapacity();

// Pass the inverter properties to the PVWatts generator class
pvwGen.setDCtoACRatio(inverterObj->pvWattsDCtoACSizeRatio());
pvwGen.setInverterEfficiency(inverterObj->pvWattsInverterEfficiency());
generatorController->pvwattsGenerator->setDCtoACRatio(inverterObj->pvWattsDCtoACSizeRatio());
generatorController->pvwattsGenerator->setInverterEfficiency(inverterObj->pvWattsInverterEfficiency());
}
}
if (!errorsFound) {
Expand Down Expand Up @@ -2146,7 +2145,7 @@ GeneratorController::GeneratorController(EnergyPlusData &state,
: compGenTypeOf_Num(GeneratorType::Unassigned), compPlantTypeOf_Num(0), generatorType(GeneratorType::Unassigned), generatorIndex(0),
maxPowerOut(0.0), availSchedPtr(0), powerRequestThisTimestep(0.0), onThisTimestep(false), eMSPowerRequest(0.0), eMSRequestOn(false),
plantInfoFound(false), cogenLocation(PlantLocation(0, 0, 0, 0)), nominalThermElectRatio(0.0), dCElectricityProd(0.0), dCElectProdRate(0.0),
electricityProd(0.0), electProdRate(0.0), thermalProd(0.0), thermProdRate(0.0), errCountNegElectProd_(0)
electricityProd(0.0), electProdRate(0.0), thermalProd(0.0), thermProdRate(0.0), pvwattsGenerator(nullptr), errCountNegElectProd_(0)
{

static constexpr std::string_view routineName = "GeneratorController constructor ";
Expand Down Expand Up @@ -2177,6 +2176,16 @@ GeneratorController::GeneratorController(EnergyPlusData &state,
generatorType = GeneratorType::PVWatts;
compGenTypeOf_Num = GeneratorType::PVWatts;
compPlantTypeOf_Num = DataPlant::TypeOf_Other;

int ObjNum =
state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Generator:PVWatts", UtilityRoutines::MakeUPPERCase(objectName));
assert(ObjNum >= 0);
if (ObjNum == 0) {
ShowFatalError(state, "Cannot find Generator:PVWatts " + objectName);
}
pvwattsGenerator = PVWatts::PVWattsGenerator::createFromIdfObj(state, ObjNum);
pvwattsGenerator->setupOutputVariables(state);

} else if (UtilityRoutines::SameString(objectType, "Generator:FuelCell")) {
generatorType = GeneratorType::FuelCell;
compGenTypeOf_Num = GeneratorType::FuelCell;
Expand Down Expand Up @@ -2324,9 +2333,8 @@ void GeneratorController::simGeneratorGetPowerOutput(EnergyPlusData &state,
break;
}
case GeneratorType::PVWatts: {
PVWatts::PVWattsGenerator &pvwattsGenerator(PVWatts::GetOrCreatePVWattsGenerator(state, name));
pvwattsGenerator.calc(state);
pvwattsGenerator.getResults(dCElectProdRate, dCElectricityProd, thermProdRate, thermalProd);
pvwattsGenerator->calc(state);
pvwattsGenerator->getResults(dCElectProdRate, dCElectricityProd, thermProdRate, thermalProd);
electricPowerOutput = dCElectProdRate;
thermalPowerOutput = thermProdRate;
break;
Expand Down
3 changes: 3 additions & 0 deletions src/EnergyPlus/ElectricPowerServiceManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <EnergyPlus/EMSManager.hh>
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/OutputProcessor.hh>
#include <EnergyPlus/PVWatts.hh>
#include <EnergyPlus/Plant/PlantLocation.hh>

// SSC Headers
Expand Down Expand Up @@ -571,6 +572,8 @@ public: // data // might make this class a friend o
Real64 thermalProd; // Current Thermal energy Produced from Equipment (J)
Real64 thermProdRate; // Current Thermal energy Production Rate from Equipment (W)

std::unique_ptr<PVWatts::PVWattsGenerator> pvwattsGenerator; // PVWattsGenerator object pointer

private:
int errCountNegElectProd_; // error count for reccuring error when generators produce negative electric power

Expand Down
Loading