From d4fc26c9b4c6d481de0db647c1b6e012394abaf3 Mon Sep 17 00:00:00 2001 From: tyneises Date: Mon, 14 Oct 2019 15:25:00 -0500 Subject: [PATCH] add new cmod to check udpc table parameters --- build_android/Makefile-ssc | 1 + build_ios/Makefile-ssc | 1 + build_linux/Makefile-ssc | 1 + build_osx/Makefile-ssc | 1 + build_vs2017/ssc_vs2017.vcxproj | 1 + ssc/cmod_ui_udpc_checks.cpp | 81 +++++++++++++++++++++++++++++++++ ssc/sscapi.cpp | 2 + 7 files changed, 88 insertions(+) create mode 100644 ssc/cmod_ui_udpc_checks.cpp diff --git a/build_android/Makefile-ssc b/build_android/Makefile-ssc index a814e0c6b..97fc8b170 100644 --- a/build_android/Makefile-ssc +++ b/build_android/Makefile-ssc @@ -37,6 +37,7 @@ TARGET=ssc_${ARCH}.a OBJECTS = \ cmod_singlediode.o \ cmod_ui_tes_calcs.o \ + cmod_ui_udpc_checks.o \ csp_common.o \ cmod_lcoefcr.o \ cmod_thirdpartyownership.o \ diff --git a/build_ios/Makefile-ssc b/build_ios/Makefile-ssc index da697a6c9..229315ad0 100644 --- a/build_ios/Makefile-ssc +++ b/build_ios/Makefile-ssc @@ -27,6 +27,7 @@ TARGET=ssc_${ARCH}.a OBJECTS = \ cmod_singlediode.o \ cmod_ui_tes_calcs.o \ + cmod_ui_udpc_checks.o \ csp_common.o \ cmod_lcoefcr.o \ cmod_thirdpartyownership.o \ diff --git a/build_linux/Makefile-ssc b/build_linux/Makefile-ssc index d3c889e7f..620c27615 100644 --- a/build_linux/Makefile-ssc +++ b/build_linux/Makefile-ssc @@ -14,6 +14,7 @@ TARGET = ssc.so OBJECTS = \ cmod_singlediode.o \ cmod_ui_tes_calcs.o \ + cmod_ui_udpc_checks.o \ csp_common.o \ cmod_lcoefcr.o \ cmod_thirdpartyownership.o \ diff --git a/build_osx/Makefile-ssc b/build_osx/Makefile-ssc index bf6bed593..7488f5fa6 100644 --- a/build_osx/Makefile-ssc +++ b/build_osx/Makefile-ssc @@ -13,6 +13,7 @@ TARGET = ssc.dylib OBJECTS = \ cmod_singlediode.o \ cmod_ui_tes_calcs.o \ + cmod_ui_udpc_checks.o \ csp_common.o \ cmod_lcoefcr.o \ cmod_thirdpartyownership.o \ diff --git a/build_vs2017/ssc_vs2017.vcxproj b/build_vs2017/ssc_vs2017.vcxproj index 3832b9b5e..7b002987a 100644 --- a/build_vs2017/ssc_vs2017.vcxproj +++ b/build_vs2017/ssc_vs2017.vcxproj @@ -83,6 +83,7 @@ + diff --git a/ssc/cmod_ui_udpc_checks.cpp b/ssc/cmod_ui_udpc_checks.cpp new file mode 100644 index 000000000..d4df7bdf6 --- /dev/null +++ b/ssc/cmod_ui_udpc_checks.cpp @@ -0,0 +1,81 @@ +/** +BSD-3-Clause +Copyright 2019 Alliance for Sustainable Energy, LLC +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 its contributors may be used to endorse +or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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, CONTRIBUTORS, UNITED STATES GOVERNMENT OR 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 "core.h" +#include "csp_solver_pc_Rankine_indirect_224.h" + +static var_info _cm_vtab_ui_udpc_checks[] = { + + /* VARTYPE DATATYPE NAME LABEL UNITS META GROUP REQUIRED_IF CONSTRAINTS UI_HINTS*/ + { SSC_INPUT, SSC_MATRIX, "ud_ind_od", "Off design user-defined power cycle performance as function of T_htf, m_dot_htf [ND], and T_amb", "", "", "User Defined Power Cycle", "?=[[0]]", "", ""}, + + { SSC_OUTPUT, SSC_NUMBER, "n_T_htf_pars", "Number of HTF parametrics", "-", "", "", "*", "", "" }, + { SSC_OUTPUT, SSC_NUMBER, "T_htf_low", "HTF design temperature", "C", "", "", "*", "", "" }, + { SSC_OUTPUT, SSC_NUMBER, "T_htf_des", "HTF design temperature", "C", "", "", "*", "", "" }, + { SSC_OUTPUT, SSC_NUMBER, "T_htf_high", "HTF design temperature", "C", "", "", "*", "", "" }, + + + var_info_invalid }; + +class cm_ui_udpc_checks : public compute_module +{ +public: + + cm_ui_udpc_checks() + { + add_var_info(_cm_vtab_ui_udpc_checks); + } + + void exec() override + { + int n_T_htf_pars, n_T_amb_pars, n_m_dot_pars; + n_T_htf_pars = n_T_amb_pars = n_m_dot_pars = -1; + double m_dot_low, m_dot_des, m_dot_high, T_htf_low, T_htf_des, T_htf_high, T_amb_low, T_amb_des, T_amb_high; + m_dot_low = m_dot_des = m_dot_high = T_htf_low = T_htf_des = T_htf_high = T_amb_low = T_amb_des = T_amb_high = std::numeric_limits::quiet_NaN(); + + util::matrix_t cmbd_ind = as_matrix("ud_ind_od"); + util::matrix_t T_htf_ind, m_dot_ind, T_amb_ind; + + try + { + split_ind_tbl(cmbd_ind, T_htf_ind, m_dot_ind, T_amb_ind, + n_T_htf_pars, n_T_amb_pars, n_m_dot_pars, + m_dot_low, m_dot_des, m_dot_high, + T_htf_low, T_htf_des, T_htf_high, + T_amb_low, T_amb_des, T_amb_high); + } + catch (C_csp_exception &csp_exception) + { + n_T_htf_pars = n_T_amb_pars = n_m_dot_pars = -1; + m_dot_low = m_dot_des = m_dot_high = T_htf_low = T_htf_des = T_htf_high = T_amb_low = T_amb_des = T_amb_high = std::numeric_limits::quiet_NaN(); + } + + assign("n_T_htf_pars", (ssc_number_t)n_T_htf_pars); + assign("T_htf_low", (ssc_number_t)T_htf_low); + assign("T_htf_des", (ssc_number_t)T_htf_des); + assign("T_htf_high", (ssc_number_t)T_htf_high); + + return; + } +}; + +DEFINE_MODULE_ENTRY(ui_udpc_checks, "Calculates the levels and number of paramteric runs for 3 udpc ind variables", 0) \ No newline at end of file diff --git a/ssc/sscapi.cpp b/ssc/sscapi.cpp index 1169b1111..a254b9848 100644 --- a/ssc/sscapi.cpp +++ b/ssc/sscapi.cpp @@ -146,6 +146,7 @@ extern module_entry_info cm_entry_sco2_air_cooler, cm_entry_user_htf_comparison, cm_entry_ui_tes_calcs, + cm_entry_ui_udpc_checks, cm_entry_cb_mspt_system_costs, cm_entry_cb_construction_financing, cm_entry_cb_empirical_hce_heat_loss, @@ -237,6 +238,7 @@ static module_entry_info *module_table[] = { &cm_entry_sco2_air_cooler, &cm_entry_user_htf_comparison, &cm_entry_ui_tes_calcs, + &cm_entry_ui_udpc_checks, &cm_entry_cb_mspt_system_costs, &cm_entry_cb_construction_financing, &cm_entry_cb_empirical_hce_heat_loss,