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

Addresses #4647, wrap the E+ Table:Lookup, Table:IndependentVariableList, and Table:IndependentVariable objects #4652

Merged
merged 66 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
944dbdb
Updates to idd.
joseph-robertson Aug 19, 2022
079d88e
Deprecate table multivariable lookup.
joseph-robertson Aug 19, 2022
400d3b0
Stub table lookup model files.
joseph-robertson Aug 19, 2022
301a7f0
Stub table lookup ft files.
joseph-robertson Aug 19, 2022
441766e
Formatting.
joseph-robertson Aug 19, 2022
c92dfc8
Minor updates.
joseph-robertson Aug 19, 2022
ae6b64b
Use modelobjectlists for variablelist.
joseph-robertson Aug 19, 2022
cb07c92
Stub table independent variable model files.
joseph-robertson Aug 19, 2022
b3f5cfc
Stub table independent variable ft files.
joseph-robertson Aug 19, 2022
e70f2e8
Formatting.
joseph-robertson Aug 19, 2022
6d26fcc
Merge branch 'develop' into table-lookup
joseph-robertson Aug 22, 2022
9fa13cd
Progress on model files.
joseph-robertson Aug 22, 2022
632782d
Formatting.
joseph-robertson Aug 22, 2022
1bd7c00
Few updates.
joseph-robertson Aug 22, 2022
9233e3a
Change ind var to resource object.
joseph-robertson Aug 23, 2022
2b501a6
Stub more ft.
joseph-robertson Aug 23, 2022
722eb4f
Stub lookup ctor.
joseph-robertson Aug 23, 2022
e146312
Start filling in getters and setters.
joseph-robertson Aug 23, 2022
0fcdbe9
Progress on ft.
joseph-robertson Aug 23, 2022
51d234c
Start filling out model tests for basic function.
joseph-robertson Aug 23, 2022
7a3fc5c
Start filling out ft tests for basic function.
joseph-robertson Aug 23, 2022
4d23c12
Fix in ft test.
joseph-robertson Aug 23, 2022
9afa622
Update model tests.
joseph-robertson Aug 24, 2022
384a988
Fix tests.
joseph-robertson Aug 24, 2022
a306bb5
Fix ft test.
joseph-robertson Aug 24, 2022
1450bb3
Updates to ft.
joseph-robertson Aug 25, 2022
fef1128
Add methods for extensible groups.
joseph-robertson Aug 25, 2022
228b3f1
Clean up ft.
joseph-robertson Aug 25, 2022
2dd4b56
Hook sources back up in ft.
joseph-robertson Aug 25, 2022
c6ab3bf
Merge branch 'develop' into table-lookup
joseph-robertson Aug 26, 2022
aab51b4
Add remaining lookup methods.
joseph-robertson Aug 29, 2022
a878e52
Update idd and ft replacement.
joseph-robertson Aug 29, 2022
bc6822a
Formatting.
joseph-robertson Aug 29, 2022
87b4699
Wrong return types.
joseph-robertson Aug 29, 2022
631ddf3
Actually return in remove methods.
joseph-robertson Aug 29, 2022
432555b
Minor idd updates.
joseph-robertson Aug 29, 2022
6d6cc55
Finish table methods.
joseph-robertson Aug 29, 2022
829b114
Finish ft and replacement.
joseph-robertson Aug 29, 2022
c0b94ce
Update model and ft tests.
joseph-robertson Aug 29, 2022
513e531
Fix model and ft tests.
joseph-robertson Aug 30, 2022
8ecd225
Modify TableIndependentVariable
jmarrec Aug 31, 2022
8304c9d
Modify TableLookup
jmarrec Aug 31, 2022
dced8f0
add TableLookup::setOutputValues(vector<double>) + adjust gtest
jmarrec Aug 31, 2022
eb66a23
add TableIndependentVariable::setValues(vector<double>) + adjust gtest
jmarrec Aug 31, 2022
a9d87a7
Add a (failing) Gtest for TableLookup clone & remove (see failing log…
jmarrec Aug 31, 2022
09380da
Small fixup for numVariables / outputVariableNames + break FT tests i…
jmarrec Aug 31, 2022
b4255ac
Override TableLookup::clone & remove
jmarrec Aug 31, 2022
f5d52a7
Redo the ft, and add a translateTableIndependentVariable to avoid dup…
jmarrec Aug 31, 2022
75a179f
This is actually the grid size (product of UNIQUE count of independen…
jmarrec Aug 31, 2022
78103b1
Extend FT tests
jmarrec Aug 31, 2022
f49be26
Add a VT test
jmarrec Aug 31, 2022
f796e1c
Add VT for TableMultiVariableLookup to TableLookup
jmarrec Aug 31, 2022
db490c5
Port Coil Cooling/Heating Four Pipe Beam to using TableLookup
jmarrec Aug 31, 2022
bd9961f
Change tests to use TableLookup too
jmarrec Aug 31, 2022
6d14235
Deprecate the entire TableMultivariableLookup and pragma ignore depre…
jmarrec Aug 31, 2022
f3b8016
Port sdd MapHVAC to use TableLookup
jmarrec Aug 31, 2022
9d60fca
Update src/energyplus/ForwardTranslator.cpp
jmarrec Aug 31, 2022
461407e
Forgot to connect TableLookup to TableIndependentVariable
jmarrec Sep 1, 2022
521ee35
For VT, need to match Ctor and initialize Normalization Divisor/Method
jmarrec Sep 1, 2022
b79b389
Merge remote-tracking branch 'origin/develop' into table-lookup
jmarrec Sep 1, 2022
1c7521a
Put back old FT for TableMultiVariableLookup (easier to remove than t…
jmarrec Sep 1, 2022
019c0b5
Partially revert 1c7521a7910: swig chokes on the macro
jmarrec Sep 1, 2022
669969a
Write a ReverseTranslator + RT Test for TableLookup
jmarrec Sep 1, 2022
8ce7017
Slightly Adjust FT for TableMultiVariableLookup
jmarrec Sep 1, 2022
45452ea
Tweak getString to use uninitialized empty
jmarrec Sep 1, 2022
a8f312b
Merge branch 'develop' into table-lookup
joseph-robertson Sep 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
113 changes: 113 additions & 0 deletions resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -21052,6 +21052,119 @@ OS:Table:MultiVariableLookup,
\type real
\begin-extensible

OS:Table:IndependentVariable,
\memo An independent variable representing a single dimension of a Table:Lookup
\memo object.
\extensible:1
A1, \field Handle
\type handle
\required-field
A2, \field Name
\required-field
\reference IndependentVariableName
\type alpha
A3, \field Interpolation Method
\type choice
\key Linear
\key Cubic
\required-field
A4, \field Extrapolation Method
\type choice
\key Constant
\key Linear
\required-field
N1, \field Minimum Value
\type real
\unitsBasedOnField A5
N2, \field Maximum Value
\type real
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, I agree with the rest of the IDD objects. The required-field is used where appropriate 👍

\unitsBasedOnField A5
N3, \field Normalization Reference Value
\type real
\unitsBasedOnField A5
A5, \field Unit Type
\type choice
\key Dimensionless
\key Temperature
\key VolumetricFlow
\key MassFlow
\key Power
\key Distance
\key Angle
\required-field
A6, \field External File Name
\type object-list
\object-list ExternalFileNames
N4, \field External File Column Number
\type integer
\minimum 1
N5, \field External File Starting Row Number
\type integer
\minimum 1
N6; \field Value
\type real
\begin-extensible

OS:Table:Lookup,
\memo Lookup tables are used in place of curves and can represent any number
\memo of independent variables (defined as Table:IndependentVariable objects
\memo in a Table:IndependentVariableList). Output values are interpolated
\memo within the bounds defined by each independent variable and extrapolated
\memo beyond the bounds according to the interpolation/extrapolation methods
\memo defined by each independent variable.
\extensible:1
A1, \field Handle
\type handle
\required-field
A2, \field Name
\required-field
\reference UnivariateFunctions
\reference BivariateFunctions
\reference TrivariateFunctions
\reference QuadvariateFunctions
\reference QuintvariateFunctions
\reference MultivariateFunctions
\reference AllCurves
\type alpha
A3, \field Independent Variable List Name
\required-field
\type object-list
\object-list ModelObjectLists
A4, \field Normalization Method
\type choice
\key None
\key DivisorOnly
\key AutomaticWithDivisor
\required-field
N1, \field Normalization Divisor
\type real
\required-field
N2, \field Minimum Output
\type real
\unitsBasedOnField A5
N3, \field Maximum Output
\type real
\unitsBasedOnField A5
A5, \field Output Unit Type
\type choice
\key Dimensionless
\key Capacity
\key Power
\required-field
A6, \field External File Name
\type object-list
\object-list ExternalFileNames
N4, \field External File Column Number
\type integer
\minimum 1
N5, \field External File Starting Row Number
\type integer
\minimum 1
N6; \field Output Value
\type real
\unitsBasedOnField A5
\begin-extensible

OS:DesignSpecification:OutdoorAir,
\memo This object is used to describe general outdoor air requirements which
\memo are referenced by other objects.
Expand Down
5 changes: 5 additions & 0 deletions src/energyplus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ set(${target_name}_src
ForwardTranslator/ForwardTranslateSurfacePropertySurroundingSurfaces.cpp
ForwardTranslator/ForwardTranslateSwimmingPoolIndoor.cpp
ForwardTranslator/ForwardTranslateTableMultiVariableLookup.cpp
ForwardTranslator/ForwardTranslateTableLookup.cpp
ForwardTranslator/ForwardTranslateTableIndependentVariable.cpp
ForwardTranslator/ForwardTranslateTemperingValve.cpp
ForwardTranslator/ForwardTranslateThermalStorageIceDetailed.cpp
ForwardTranslator/ForwardTranslateThermalStorageChilledWaterStratified.cpp
Expand Down Expand Up @@ -587,6 +589,8 @@ set(${target_name}_src
ReverseTranslator/ReverseTranslateSurfacePropertyLocalEnvironment.cpp
ReverseTranslator/ReverseTranslateSurfacePropertySurroundingSurfaces.cpp
ReverseTranslator/ReverseTranslateSwimmingPoolIndoor.cpp
ReverseTranslator/ReverseTranslateTableLookup.cpp
ReverseTranslator/ReverseTranslateTableIndependentVariable.cpp
ReverseTranslator/ReverseTranslateThermostatSetpointDualSetpoint.cpp
ReverseTranslator/ReverseTranslateTimestep.cpp
ReverseTranslator/ReverseTranslateVersion.cpp
Expand Down Expand Up @@ -759,6 +763,7 @@ set(${target_name}_test_src
Test/SurfacePropertySurroundingSurfaces_GTest.cpp
Test/SwimmingPoolIndoor_GTest.cpp
Test/TableMultiVariableLookup_GTest.cpp
Test/TableLookup_GTest.cpp
Test/ThermalStorageChilledWaterStratified_GTest.cpp
Test/ThermalZone_GTest.cpp
Test/ThermostatSetpointDualSetpoint_GTest.cpp
Expand Down
27 changes: 27 additions & 0 deletions src/energyplus/ForwardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@

#include "../utilities/idd/IddEnums.hpp"

#include "../utilities/core/Deprecated.hpp"

#include <algorithm>
#include <sstream>
#include <thread>
Expand Down Expand Up @@ -2880,11 +2882,35 @@ namespace energyplus {
retVal = translateSwimmingPoolIndoor(obj);
break;
}

#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4996)
#elif (defined(__GNUC__))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
case openstudio::IddObjectType::OS_Table_MultiVariableLookup: {
model::TableMultiVariableLookup table = modelObject.cast<TableMultiVariableLookup>();
retVal = translateTableMultiVariableLookup(table);
break;
}
#if defined(_MSC_VER)
# pragma warning(pop)
#elif (defined(__GNUC__))
# pragma GCC diagnostic pop
#endif

case openstudio::IddObjectType::OS_Table_Lookup: {
auto table = modelObject.cast<TableLookup>();
retVal = translateTableLookup(table);
break;
}
case openstudio::IddObjectType::OS_Table_IndependentVariable: {
auto tableIndependentVariable = modelObject.cast<TableIndependentVariable>();
retVal = translateTableIndependentVariable(tableIndependentVariable);
break;
}
case openstudio::IddObjectType::OS_TemperingValve: {
auto mo = modelObject.cast<TemperingValve>();
retVal = translateTemperingValve(mo);
Expand Down Expand Up @@ -3414,6 +3440,7 @@ namespace energyplus {
result.push_back(IddObjectType::OS_Curve_Sigmoid);
result.push_back(IddObjectType::OS_Curve_Triquadratic);
result.push_back(IddObjectType::OS_Table_MultiVariableLookup);
result.push_back(IddObjectType::OS_Table_Lookup);
result.push_back(IddObjectType::OS_DistrictCooling);
result.push_back(IddObjectType::OS_DistrictHeating);
result.push_back(IddObjectType::OS_EvaporativeCooler_Direct_ResearchSpecial);
Expand Down
10 changes: 9 additions & 1 deletion src/energyplus/ForwardTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "../utilities/core/StringStreamLogSink.hpp"
#include "../utilities/time/Time.hpp"

#include "../utilities/core/Deprecated.hpp"

#include <iostream>

namespace openstudio {
Expand Down Expand Up @@ -448,6 +450,8 @@ namespace model {
class SurfacePropertySurroundingSurfaces;
class SwimmingPoolIndoor;
class TableMultiVariableLookup;
class TableLookup;
class TableIndependentVariable;
class TemperingValve;
class ThermalZone;
class ThermalStorageIceDetailed;
Expand Down Expand Up @@ -1427,7 +1431,11 @@ namespace energyplus {

boost::optional<IdfObject> translateSwimmingPoolIndoor(model::SwimmingPoolIndoor& modelObject);

boost::optional<IdfObject> translateTableMultiVariableLookup(model::TableMultiVariableLookup& modelObject);
OS_DEPRECATED boost::optional<IdfObject> translateTableMultiVariableLookup(model::TableMultiVariableLookup& modelObject);

boost::optional<IdfObject> translateTableLookup(model::TableLookup& modelObject);

boost::optional<IdfObject> translateTableIndependentVariable(model::TableIndependentVariable& modelObject);

boost::optional<IdfObject> translateTemperingValve(model::TemperingValve& modelObject);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2022, 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/TableIndependentVariable.hpp"

#include "../../utilities/idf/IdfExtensibleGroup.hpp"

#include <utilities/idd/Table_IndependentVariable_FieldEnums.hxx>
// #include "../../utilities/idd/IddEnums.hpp"
#include <utilities/idd/IddEnums.hxx>

using namespace openstudio::model;

namespace openstudio {

namespace energyplus {

boost::optional<IdfObject> ForwardTranslator::translateTableIndependentVariable(model::TableIndependentVariable& modelObject) {
boost::optional<IdfObject> result;

// Instantiate an IdfObject of the class to store the values
IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Table_IndependentVariable, modelObject);

// Interpolation Method: String
idfObject.setString(Table_IndependentVariableFields::InterpolationMethod, modelObject.interpolationMethod());

// Extrapolation Method: String
idfObject.setString(Table_IndependentVariableFields::ExtrapolationMethod, modelObject.extrapolationMethod());

// Minimum Value: boost::optional<double>
if (boost::optional<double> minimumValue_ = modelObject.minimumValue()) {
idfObject.setDouble(Table_IndependentVariableFields::MinimumValue, minimumValue_.get());
}

// Maximum Value: boost::optional<double>
if (boost::optional<double> maximumValue_ = modelObject.maximumValue()) {
idfObject.setDouble(Table_IndependentVariableFields::MaximumValue, maximumValue_.get());
}

// Normalization Reference Value: boost::optional<double>
if (boost::optional<double> normalizationReferenceValue_ = modelObject.normalizationReferenceValue()) {
idfObject.setDouble(Table_IndependentVariableFields::NormalizationReferenceValue, normalizationReferenceValue_.get());
}

// Unit Type: String
idfObject.setString(Table_IndependentVariableFields::UnitType, modelObject.unitType());

// Value
for (const double& value : modelObject.values()) {
IdfExtensibleGroup eg = idfObject.pushExtensibleGroup();
eg.setDouble(Table_IndependentVariableExtensibleFields::Value, value);
}
Comment on lines +77 to +81
Copy link
Collaborator

@jmarrec jmarrec Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think we should enforce ascending order here (?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarrec Is this still a TODO?


// External File Name: boost::optional<std::string>

// External File Column Number: boost::optional<int>

// External File Starting Row Number: boost::optional<int>

return idfObject;
} // End of translate function

} // end namespace energyplus
} // end namespace openstudio