Skip to content

Commit

Permalink
Merge branch 'patch' into or-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dguittet committed Apr 22, 2024
2 parents a7ed18c + 3e5aef0 commit 3c94ea2
Show file tree
Hide file tree
Showing 27 changed files with 27,171 additions and 146 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ deploy/runtime/defaults/*.txt text eol=lf
*.c text
*.cpp text
*.h text
*.csv text
*.lk text
*.json text


# Ensure those won't be messed up with
*.jpg binary
Expand Down
31 changes: 3 additions & 28 deletions api/api_autogen/builder_PySAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,26 +619,6 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
"{\n\tPyObject* ptr = PyLong_FromVoidPtr((void*)self->data_ptr);\n"
"\treturn ptr;\n}\n\n\n";

fx_file << "static PyObject *\n"
"" << tech_symbol << "_set_data_ptr(" << object_type << " *self, PyObject *args)\n"
"{\n"
"\tlong long int ptr = 0; // 64 bit arch\n"
"\tif (!PyArg_ParseTuple(args, \"L:data_ptr\", &ptr)){\n"
"\t\tPyErr_BadArgument();\n"
"\t\treturn NULL;\n"
"\t}\n\tself->data_ptr = (void*)ptr;\n";

// modify the data ptr for all the groups
for (auto& i : root->vardefs_order) {
auto mm = root->m_vardefs.find(i);
if (mm->second.empty()) continue;
std::string module_symbol = format_as_symbol(mm->first);
fx_file << "\tVarGroupObject* " << module_symbol << "_obj = (VarGroupObject*)PyDict_GetItemString(self->x_attr, \"" << module_symbol << "\");\n"
"\t" << module_symbol << "_obj->data_ptr = (void*)ptr;\n";
}

fx_file << "\treturn Py_None;\n}\n\n\n";

if (stateful) {
fx_file << "static PyObject *\n"
"" << tech_symbol << "_setup(" << object_type << " *self, PyObject *args)\n"
Expand Down Expand Up @@ -719,10 +699,6 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin

fx_file << "\t\t{\"execute\", (PyCFunction)" << tech_symbol << "_execute, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"execute(int verbosity) -> None\\n Execute simulation with verbosity level 0 (default) or 1\")},\n"
"\t\t{\"get_data_ptr\", (PyCFunction)" << tech_symbol << "_get_data_ptr, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"get_data_ptr() -> Pointer\\n Get ssc_data_t pointer\")},\n"
"\t\t{\"set_data_ptr\", (PyCFunction)" << tech_symbol << "_set_data_ptr, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"set_data_ptr(data_ptr)\\n Set ssc_data_t pointer\")},\n"
"\t\t{\"assign\", (PyCFunction)" << tech_symbol << "_assign, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"assign(dict) -> None\\n Assign attributes from nested dictionary, except for Outputs\\n\\n"
"``nested_dict = { '" << root->vardefs_order[0] << "': { var: val, ...}, ...}``\")},\n"
Expand All @@ -734,7 +710,9 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
"\t\t{\"value\", (PyCFunction)" << tech_symbol << "_value, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"value(name, optional value) -> Union[None, float, dict, sequence, str]\\n Get or set by name a value in any of the variable groups.\")},\n"
"\t\t{\"unassign\", (PyCFunction)" << tech_symbol << "_unassign, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"unassign(name) -> None\\n Unassign a value in any of the variable groups.\")},\n";
"\t\t\t\tPyDoc_STR(\"unassign(name) -> None\\n Unassign a value in any of the variable groups.\")},\n"
"\t\t{\"get_data_ptr\", (PyCFunction)" << tech_symbol << "_get_data_ptr, METH_VARARGS,\n"
"\t\t\t\tPyDoc_STR(\"get_data_ptr() -> Pointer\\n Get ssc_data_t pointer\")},\n";

// add ssc equations as methods under the cmod class
auto cmod_it = root->m_eqn_entries.find(cmod_symbol);
Expand Down Expand Up @@ -1169,9 +1147,6 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
"\tdef get_data_ptr(self):\n"
"\t\tpass\n"
"\n"
"\tdef set_data_ptr(self, data_ptr):\n"
"\t\tpass\n"
"\n"
"\tdef __getattribute__(self, *args, **kwargs):\n"
"\t\tpass\n"
"\n"
Expand Down
10 changes: 5 additions & 5 deletions api/api_autogen/data_structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ static std::unordered_map<std::string, std::string> config_to_cmod_name = {
{"DSLF", "TcslinearFresnel"},
{"EmpiricalTrough", "TcstroughEmpirical"},
{"ETES", "EtesElectricResistance"},
{"PTES", "EtesPtes"},
{"FlatPlatePV", "Pvsamv1"},
{"FuelCell", "Fuelcell"},
{"GenericCSPSystem", "TcsgenericSolar"},
Expand All @@ -195,9 +194,9 @@ static std::unordered_map<std::string, std::string> config_to_cmod_name = {
{"LCOHCalculator", "IphToLcoefcr"},
{"LeveragedPartnershipFlip", "Levpartflip"},
{"MerchantPlant", "MerchantPlant"},
{"MEtidal", "METidal"},
{"MEwave", "MEWave"},
{"MEwaveBattery", "MEWaveBattery"},
{"MEtidal", "MHKTidal"},
{"MEwave", "MHKWave"},
{"MEwaveBattery", "MHKWave,Battery"},
{"MSLF", "FresnelPhysical"},
{"MSLFIPH", "FresnelPhysicalIph"},
{"MSPT", "TcsmoltenSalt"},
Expand All @@ -206,11 +205,12 @@ static std::unordered_map<std::string, std::string> config_to_cmod_name = {
{"PhotovoltaicWindBatteryHybrid", "Pvsamv1,Windpower,Battery"},
{"PhysicalTrough", "TroughPhysical"},
{"PhysicalTroughIPH", "TroughPhysicalProcessHeat"},
{"PVBattery", "PVBattery"},
{"PVBattery", "Pvsamv1"},
{"PVWatts", "Pvwattsv8"},
{"PVWattsBattery", "BattWatts"},
{"PVWattsWindBatteryHybrid", "Pvwattsv8,Windpower,Battery"},
{"PVWattsWindFuelCellBatteryHybrid", "Pvwattsv8,Windpower,Fuelcell,Battery"},
{"PTES", "EtesPtes"},
{"Residential", "Residential"},
{"SaleLeaseback", "Saleleaseback"},
{"SCO2", "SCO2"},
Expand Down
4 changes: 2 additions & 2 deletions deploy/runtime/cashflow.lk
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function cf_production()
{
cfline( 'cf_energy_net', 0);
}
if ( is_batt_tech() )
if ( is_batt_tech() && (varinfo('gen_without_battery')!= null)) // SAM issue 1563
{
cfline( 'cf_energy_without_battery',0);
cfline( 'batt_annual_discharge_energy',0);
Expand Down Expand Up @@ -1736,7 +1736,7 @@ function set_annual_values( xl )
}
}
// tech-dependent
if ( is_batt_tech() )
if ( is_batt_tech() && (varinfo('gen_without_battery')!= null)) // SAM issue 1563
{
xl_set_output( xl, 'cf_energy_without_battery' );
xl_set_output( xl, 'batt_annual_discharge_energy');
Expand Down
Binary file modified deploy/runtime/reports/pvbattery.samreport
Binary file not shown.
Binary file modified deploy/runtime/spreadsheets/community_solar.xlsx
Binary file not shown.
Binary file modified deploy/runtime/spreadsheets/residential_commercial.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions deploy/runtime/startup.lk
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ configopt( 'Photovoltaic Wind Battery Hybrid', { 'tree_parent'='Hybrid', 'long_n
configopt( 'Generic PVWatts Wind FuelCell Battery Hybrid', { 'tree_parent'='Hybrid', 'long_name'='Generic PVWatts Wind FuelCell Battery Hybrid', 'short_name' = 'Generic-PVWatts-Wind-FuelCell-Battery', 'description' ='Hybrid power system with PVWatts and wind power generation and battery storage)'});
configopt( 'MSPT', { 'tree_parent'='Concentrating Solar Power', 'long_name'='Power Tower Molten Salt', 'short_name'='CSP Tower Molten Salt', 'description'='CSP molten salt power tower system using heat transfer and thermodynamic component models' } );
configopt( 'Physical Trough', { 'tree_parent'='Concentrating Solar Power', 'long_name'='Parabolic Trough Physical Model', 'short_name'='CSP Trough (Physical Model)', 'description'='CSP parabolic trough system using heat transfer and thermodynamic component models' } );
configopt( 'Empirical Trough', { 'tree_parent'='Concentrating Solar Power', 'long_name'='Parabolic Trough Empirical Model', 'short_name'='CSP Trough (Emprical Model)', 'description'='CSP parabolic trough system using model with empirically-derived coefficients and equations' } );
configopt( 'Empirical Trough', { 'tree_parent'='Concentrating Solar Power', 'long_name'='Parabolic Trough Empirical Model', 'short_name'='CSP Trough (Empirical Model)', 'description'='CSP parabolic trough system using model with empirically-derived coefficients and equations' } );
//configopt( 'Dish Stirling', { 'tree_parent'='Retired', 'long_name'='CSP Dish Stirling', 'short_name'='Dish Stirling', 'description'='Dish Stirling model with parameters for SES and WGA-ADDS systems' } );
configopt( 'Generic CSP System', { 'tree_parent'='Concentrating Solar Power', 'long_name'='Generic Solar Model', 'short_name'='CSP Generic Model', 'description'='CSP power system with solar field modeled using a table of optical efficiency values' } );
configopt( 'DSLF', { 'tree_parent'='Concentrating Solar Power', 'long_name'='Linear Fresnel Direct Steam', 'short_name'='CSP Linear Fresnel Direct Steam', 'description'='CSP power system that uses long small mirrors to line focus sunlight on fixed receiver tubes mounted above them.' } );
Expand Down Expand Up @@ -3165,4 +3165,4 @@ setup_grid_limits_page();
setup_grid_outage_page();// host developer
// host developer
setup_host_developer_pages(LOAD_SIMPLE);
addpage([['Hybrid Costs']], {'sidebar'='Hybrid System Costs', 'help'='hybrid_system_costs', 'top_page'=true});
addpage([['Hybrid Costs']], {'sidebar'='Hybrid System Costs', 'help'='hybrid_system_costs', 'top_page'=true});
21 changes: 18 additions & 3 deletions deploy/runtime/versions.lk
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ version_upgrade{'2023.12.17'} = define() {
//assigned periods are a matrix [[x,y,z]], unassigned periods are [1]. the latter must be reformatted to [0,0,0] to simulate correctly.
p = x.periods;
p1 = p[0];
if (typeof(p1) == 'number') {p = [[0,0,0]];}
if ( typeof(p1) == 'number' ) {
p = [[0,0,0]];
}
elseif ( #p1 != 3 ) {
p = [[0,0,0]];
}
value('adjust_periods', p);
value('adjust_en_timeindex', x.en_timeindex);
value('adjust_timeindex', x.timeindex);
Expand Down Expand Up @@ -203,7 +208,12 @@ version_upgrade{'2023.12.17'} = define() {
//assigned periods from previous versions are a matrix [[x,y,z]], unassigned periods are [1]. the latter must be reformatted to [[0,0,0]] to simulate correctly.
p = x.periods;
p1 = p[0];
if (typeof(p1) == 'number') {p = [[0,0,0]];}
if ( typeof(p1) == 'number' ) {
p = [[0,0,0]];
}
elseif ( #p1 != 3 ) {
p = [[0,0,0]];
}
value('dc_adjust_periods', p);
value('dc_adjust_en_timeindex', x.en_timeindex);
value('dc_adjust_timeindex', x.timeindex);
Expand All @@ -216,7 +226,12 @@ version_upgrade{'2023.12.17'} = define() {
//assigned periods are a matrix [[x,y,z]], unassigned periods are [1]. the latter must be reformatted to [0,0,0] to simulate correctly.
p = x.periods;
p1 = p[0];
if (typeof(p1) == 'number') {p = [[0,0,0]];}
if ( typeof(p1) == 'number' ) {
p = [[0,0,0]];
}
elseif ( #p1 != 3 ) {
p = [[0,0,0]];
}
value('adjust_periods', p);
value('adjust_en_timeindex', x.en_timeindex);
value('adjust_timeindex', x.timeindex);
Expand Down
3 changes: 3 additions & 0 deletions samples/Python Scripts/End Use Load Profiles/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ To use the data in SAM:

You will need 15-minute weather data to run a simulation in SAM, which you can download by using the **Advanced download** option on the Location and Resource page, and choosing a 15-minute file from the "psm3-5min" dataset. You can choose the year to match the load data if you want to use SAM simulation results to explore the correlation between weather and load.

## Additional Resources

TMY3 weather files used to generate ResStock and ComStock data are available here: https://data.nrel.gov/submissions/156

0 comments on commit 3c94ea2

Please sign in to comment.