NREL / EnergyPlus

EnergyPlus™ is a whole building energy simulation program that engineers, architects, and researchers use to model both energy consumption and water use in buildings.
https://energyplus.net
Other
1.1k stars 384 forks source link

Move to Case-Sensitive Comparisons within EnergyPlus #8907

Closed amirroth closed 1 year ago

amirroth commented 3 years ago

Issue overview

EnergyPlus IDF is case insensitive. In hindsight, this was a mistake, but it will be a painful one to correct at this point. However, it would be good to move to cheaper case sensitive comparisons and searches within EnergyPlus itself. The way to do this is to double up on enumerated value and object names, with Name in mixed case and NameUC in upper-case.

For an enumeration EnumeratedType there would be two lists of names:

constexpr std::array<std::string_view, EnumeratedType::Num> EnumeratedTypeNames;
constexpr std::array<std::string_view, EnumeratedType::Num> EnumeratedTypeNamesUC;

Converting EnumeratedType value name evName to EnumeratedType value would use:

getEnumerationValue(upperCase(evName), EnumeratedTypeNamesUC);

All named objects would store an upper-cased name addition to the mixed-case name:

std::string Name;
std::string NameUC;

Searching for an object of type ObjectType and name oName in the list of objects ObjectList would use:

FindItemInList(upperCase(oName), Objects, &ObjectType::NameUC);

We can enforce this by adding Name and NameUC to the EnergyPlus base class.

Checklist

jasondegraw commented 3 years ago

I suggest we go with name instead so we can eventually get to having all the member variables starting with lower case letters and it'd be a clean break from the past. If we're going to consider an object-oriented approach here, can we at least consider an object-oriented approach to the state object?

jmarrec commented 1 year ago

Duplicate of the more complete https://github.com/NREL/EnergyPlus/issues/9183. Closing this one and adding a link to it in