---
Hello PyPSA Community,
I am experiencing an issue with adding carbon emission constraints for each investment period in my PyPSA model. My code looks as follows:
```python
base_emission_limit = 2e+9 # The emission limit in the base year, in tons of CO2
end_emission_limit = 1e+9 # The emission limit in the end year, in tons of CO2
# Calculate the annual decrease in emission limit
annual_decrease = (base_emission_limit - end_emission_limit) / (end_year - base_year)
for year in range(base_year, end_year + 1):
# Calculate the emission limit for this year
emission_limit = base_emission_limit - annual_decrease * (year - base_year)
print(f"CO2-Emission-limit-{year} {emission_limit} ton")
# Add the global constraint
network_temp.add("GlobalConstraint", f"CO2-Emission-limit-{year}",
investment_period=year,
carrier_attribute="co2_emissions",
sense="<=",
constant=emission_limit)
```
After adding these constraints, I made sure that they were successfully implemented. For instance:
I could find the constraints in the exported csv files as follows:
name investment_period sense constant
CO2-Emission-limit-2023 2023 <= 2000000000
CO2-Emission-limit-2024 2024 <= 1666666667
CO2-Emission-limit-2025 2025 <= 1333333333
CO2-Emission-limit-2026 2026 <= 1000000000
To solve for optimization, I use the following command:
```python
network_temp .lopf(solver_name="gurobi", solver_options=solver_options)
```
However, after adding the constraints, there seems to be no change in the optimization results, and the annual carbon emissions are still exceeding the limits I have set. Moreover, if I set the emission limits to a very low number, Gurobi reports that there is no feasible solution.
Could anyone suggest how to address this issue?
Thank you in advance for your assistance!
---