PyPSA / pypsa-usa

PyPSA-USA: An Open-Source Energy System Optimization Model for the United States
https://pypsa-usa.readthedocs.io
MIT License
35 stars 15 forks source link

EqC Constraint Error #204

Open ktehranchi opened 4 months ago

ktehranchi commented 4 months ago

Checklist

The Issue

Error thrown when using the Eq0.2c constraint that requires 0.2 % of generation to be produced within a given country/region.

Steps To Reproduce

No response

Expected Behavior

No response

Error Message

scripts/tmp_5aijmfg.solve_network.py", line 598, in extra_functionality
    add_EQ_constraints(n, o)
  File "/home/groups/iazevedo/kamran/pypsa-usa/workflow/.snakemake/shadow/tmpp_za9rkr/.snakemake/scripts/tmp_5aijmfg.solve_network.py", line 322, in add_EQ_constraints
    n.model.add_constraints(lhs >= rhs, name="equity_min")
                            ^^^^^^^^^^
  File "/home/groups/iazevedo/miniforge3/envs/pypsa-usa/lib/python3.11/site-packages/linopy/expressions.py", line 483, in __ge__
    return self.to_constraint(GREATER_EQUAL, rhs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groups/iazevedo/miniforge3/envs/pypsa-usa/lib/python3.11/site-packages/linopy/expressions.py", line 846, in to_constraint
    all_to_lhs = (self - rhs).data
                  ~~~~~^~~~~
  File "/home/groups/iazevedo/miniforge3/envs/pypsa-usa/lib/python3.11/site-packages/linopy/expressions.py", line 414, in __sub__
    other = as_expression(
            ^^^^^^^^^^^^^^
  File "/home/groups/iazevedo/miniforge3/envs/pypsa-usa/lib/python3.11/site-packages/linopy/expressions.py", line 1367, in as_expression
    raise ValueError("Cannot convert to LinearExpression") from e
ValueError: Cannot convert to LinearExpression

Anything else?

No response