|
| 1 | +#include "SAM_eqns.h" |
| 2 | + |
| 3 | +char Reopt_size_standalone_battery_post_doc[] = |
| 4 | + "Given a PV system with Utilityrate5 parameters, get the optimal battery size.\n" |
| 5 | + "Maps SAM compute module inputs to those of the ReOpt API:\n" |
| 6 | + "Pvsamv1 model linked with Battery, Utilityrate5, with Cashloan optional.\n\n" |
| 7 | + "For more information on which PySAM variables are used, see: https://github.com/NREL/ssc/blob/develop/ssc/cmod_battery_eqns.h\n\n" |
| 8 | + "For an example, see the 'Examples' readthedocs page."; |
| 9 | + |
| 10 | +static PyObject* Reopt_size_standalone_battery_post(PyObject *self, PyObject *args, PyObject *keywds) |
| 11 | +{ |
| 12 | + |
| 13 | + CmodObject* self_obj = (CmodObject*)self; |
| 14 | + |
| 15 | + SAM_table data = self_obj->data_ptr; |
| 16 | + |
| 17 | + SAM_error error = new_error(); |
| 18 | + |
| 19 | + PyObject* reopt_post_obj = NULL; |
| 20 | + error = new_error(); |
| 21 | + SAM_Reopt_size_standalone_battery_post_eqn(data, &error); |
| 22 | + |
| 23 | + if (PySAM_has_error(error)){ |
| 24 | + return NULL; |
| 25 | + } |
| 26 | + |
| 27 | + error = new_error(); |
| 28 | + SAM_table reopt_post = SAM_table_get_table(data, "reopt_scenario", &error); |
| 29 | + if (PySAM_has_error(error)) |
| 30 | + goto cleanup; |
| 31 | + |
| 32 | + error = new_error(); |
| 33 | + const char* log_msg = SAM_table_get_string(data, "log", &error); |
| 34 | + if (PySAM_has_error(error)) |
| 35 | + goto cleanup; |
| 36 | + |
| 37 | + SAM_table results = SAM_table_construct(NULL); |
| 38 | + SAM_table_set_table(results, "reopt_post", reopt_post, NULL); |
| 39 | + SAM_table_set_string(results, "messages", log_msg, NULL); |
| 40 | + reopt_post_obj = PySAM_table_to_dict(results); |
| 41 | + SAM_table_destruct(results, NULL); |
| 42 | + |
| 43 | + cleanup: |
| 44 | + SAM_table_unassign_entry(data, "reopt_scenario", NULL); |
| 45 | + SAM_table_unassign_entry(data, "log", NULL); |
| 46 | + return reopt_post_obj; |
| 47 | +} |
0 commit comments