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

Negative timeseries values terminate simulation #101

Open
smartie2076 opened this issue Jul 15, 2020 · 1 comment
Open

Negative timeseries values terminate simulation #101

smartie2076 opened this issue Jul 15, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@smartie2076
Copy link
Collaborator

When a timeseries has negative values for an investment object, the simulation terminates. This is for example the case for PV plants: Some API might generate a negative value at early/late hours of the day...
grafik

...which then is not noticed when reading the input files but only in a termination of the simulation. The termination message is very generic:

11:42:00-INFO-Starting simulation of case pv-diesel-storage-mg, project site FID_256753, experiment no. 50/200...
11:42:00-INFO-Added constraint: Stability though actual generation of diesel generators and backup through batteries.
11:42:00-INFO-Simulating...
11:42:00-INFO-Optimization successful...
11:42:01-INFO-Restoring attributes will overwrite existing attributes.
11:42:01-WARNING-Stability criterion is strictly not fullfilled, but deviation is less then e6.
11:42:01-INFO-Simulation of case "pv-diesel-storage-mg" resulted in :
                  3.576 currency/kWh, at a renewable share of 83.61 percent with a reliability of 100.0 percent
11:42:01-INFO-    Initial simulation time (s): 0.24 / Actual evaluation time (s): 1.01
11:42:01-INFO-    Estimated simulation time left: 2.3 minutes.


11:42:01-INFO-Starting simulation of case pv-storage-mg, project site FID_91254, experiment no. 51/200...
11:42:01-INFO-Added constraint: Stability though actual generation of diesel generators and backup through batteries.
11:42:01-INFO-Simulating...
11:42:02-ERROR-Optimization failed with status ok and terminal condition infeasible
ERROR: evaluating expression: No value for uninitialized NumericValue object
    InvestmentFlow.invest[bus_electricity_dc,transformer_inverter_dc_ac]
        (expression: 0.2073418975127565*InvestmentFlow.invest[bus_electricity_
        dc,transformer_inverter_dc_ac] +
        0.2125492347806967*InvestmentFlow.invest[source_pv,bus_electricity_dc]
        + 0.21434363752638408*GenericInvestmentStorageBlock.invest[generic_sto
        rage])
11:42:02-ERROR-evaluating expression: No value for uninitialized NumericValue object InvestmentFlow.invest[bus_electricity_dc,transformer_inverter_dc_ac]
    (expression: 0.2073418975127565*InvestmentFlow.invest[bus_electricity_dc,transformer_inverter_dc_ac] + 0.2125492347806967*InvestmentFlow.invest[source_pv,bus_electricity_dc]
 + 0.21434363752638408*GenericInvestmentStorageBlock.invest[generic_storage])
Traceback (most recent call last):
  File "Offgridders.py", line 275, in <module>
    main()
  File "Offgridders.py", line 185, in main
    sensitivity_experiment_s[experiment], experiment_case_dict
  File "D:\PycharmProjects\offgridders\src\G0_oemof_simulate.py", line 74, in run
    experiment, micro_grid_system, model, file_name
  File "D:\PycharmProjects\offgridders\src\G1_oemof_create_model.py", line 483, in simulate
    micro_grid_system.results["meta"] = outputlib.processing.meta_results(model)
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\oemof\outputlib\processing.py", line 189, in meta_results
    meta_res = {'objective': om.objective()}
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\pyomo\core\base\expression.py", line 55, in __call__
    return self.expr(exception=exception)
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 208, in __call__
    exception=exception))
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 812, in _apply_operation
    return sum(c*next(values) for c in self._coef) + self._const
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 812, in <genexpr>
    return sum(c*next(values) for c in self._coef) + self._const
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\pyomo\core\kernel\expr_coopr3.py", line 217, in _evaluate_arglist
    yield value(arg, exception=exception)
  File "C:\ProgramData\Miniconda3\envs\offgridders_python3-6\lib\site-packages\pyomo\core\kernel\numvalue.py", line 170, in value
    % (obj.name,))
ValueError: No value for uninitialized NumericValue object InvestmentFlow.invest[bus_electricity_dc,transformer_inverter_dc_ac]

This could be fixed by printing a warnining for these cases and clipping everything below 0.

@smartie2076 smartie2076 self-assigned this Jul 15, 2020
@smartie2076 smartie2076 added the enhancement New feature or request label Jul 15, 2020
@smartie2076
Copy link
Collaborator Author

Way to fix input files:

import pandas as pd
import numpy
import os

folder = "2020_07_10_all_sites_value_between_0_1"
files = "data_"
range = numpy.arange(1,28,1)

for number in range:
    file_path = os.path.join(os.path.abspath("."),folder,files+str(number)+".csv")
    data = pd.read_csv(file_path, sep=",")
    data = data.clip(0,1)
    data.to_csv(file_path, index=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant