Skip to content

Commit

Permalink
Update Runner::lastEPWFile before every Measure.
Browse files Browse the repository at this point in the history
ref #5009
  • Loading branch information
kbenne committed Oct 31, 2023
1 parent dcea6a4 commit c5219a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/workflow/ApplyMeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ void OSWorkflow::applyMeasures(MeasureType measureType, bool energyplus_output_r
if (!sqlPath.empty()) {
runner.setLastEnergyPlusSqlFilePath(sqlPath);
}
if (!epwPath.empty()) {
runner.setLastEpwFilePath(epwPath);
}

updateLastWeatherFileFromModel();

const auto measureDirName = step.measureDirName();
if (openstudio::filesystem::path(measureDirName).is_absolute()) {
Expand Down
11 changes: 7 additions & 4 deletions src/workflow/OSWorkflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,17 @@ void OSWorkflow::initializeWeatherFileFromOSW() {

if (auto epwFile_ = openstudio::EpwFile::load(epwPath)) {
model::WeatherFile::setWeatherFile(model, epwFile_.get());
runner.setLastEpwFilePath(epwPath);
} else {
LOG(Warn, "Could not load weather file from " << epwPath_.get());
}
} else {
LOG(Debug, "No weather file defined by osw");
LOG(Debug, "Weather file is not defined by the osw");
}
}

void OSWorkflow::applyWeatherFileFromModel() {
LOG(Debug, "Apply the final weather file");
void OSWorkflow::updateLastWeatherFileFromModel() {
LOG(Debug, "Find model's weather file and update LastEpwFilePath");
if (auto epwFile_ = model.weatherFile()) {
if (auto epwPath_ = epwFile_->path()) {
LOG(Debug, "Search for weather file " << epwPath_.get());
Expand All @@ -139,11 +140,13 @@ void OSWorkflow::applyWeatherFileFromModel() {
}

epwPath = epwFullPath_.get();
runner.setLastEpwFilePath(epwPath);

return;
}
}

LOG(Warn, "Weather file is not defined");
LOG(Debug, "Weather file is not defined by the model");
}

void OSWorkflow::applyArguments(measure::OSArgumentMap& argumentMap, const std::string& argumentName, const openstudio::Variant& argumentValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/OSWorkflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class OSWorkflow
//@}

void initializeWeatherFileFromOSW();
void applyWeatherFileFromModel();
void updateLastWeatherFileFromModel();
void applyMeasures(MeasureType measureType, bool energyplus_output_requests = false);
static void applyArguments(measure::OSArgumentMap& argumentMap, const std::string& argumentName, const openstudio::Variant& argumentValue);
void saveOSMToRootDirIfDebug();
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/RunTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void OSWorkflow::runTranslator() {
auto runDir = workflowJSON.absoluteRunDir();
OS_ASSERT(openstudio::filesystem::is_directory(runDir));

applyWeatherFileFromModel();
updateLastWeatherFileFromModel();

// Copy in the weather file
if (!epwPath.empty()) {
Expand Down

0 comments on commit c5219a5

Please sign in to comment.