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

Updated code #14

Conversation

ShravanKumar23
Copy link
Collaborator

Some updates to the code

  1. Updated storage equations
  2. Technology-specific discount rates
  3. Losses in thermal storage
  4. Correcting bugs

@@ -57,7 +57,6 @@

inputFile = "Test_case_Input.xlsx" # Update with actual filename
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't hard code file names into the code - use a command-line argument instead and provide access via an import statement and function call.

@@ -398,17 +397,20 @@ def saveResultsToExcel(dataframe, fileDir, fileName):
DaySplit = createParameter(df, 'DaySplit')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could iterate over a list of parameters and store the resulting initialised parameters in a dict rather than individual variables.

@@ -625,11 +642,15 @@ def saveResultsToExcel(dataframe, fileDir, fileName):
StorageLevelYearFinish = createVariable('StorageLevelYearFinish', variables)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, create a function which iterates over the list of variables.

@@ -777,7 +796,7 @@ def saveResultsToExcel(dataframe, fileDir, fileName):
model += Demand.get(ci(rfly)) == RateOfDemand.get(ci(rfly)) * YearSplit.get(ci(rfly[2:4])), ""

# EBa11_EnergyBalanceEachTS5
model += Production.get(ci(rfly)) >= Demand.get(ci(rfly)) + Use.get(ci(rfly)) + pulp.lpSum([Trade.get(ci([rfly[0], rr, *rfly[1:4]])) * TradeRoute.get(ci([rfly[0], rr, rfly[1], rfly[3]]), dflt.get('TradeRoute')) for rr in REGION2]), ""
model += Production.get(ci(rfly)) >= Demand.get(ci(rfly)) + Use.get(ci(rfly)) + (GIS_Losses.get(ci([*rfly[0:2]]), dflt.get('GIS_Losses')) * (8760 / int(max(TIMESLICE)))) + pulp.lpSum([Trade.get(ci([rfly[0], rr, *rfly[1:4]])) * TradeRoute.get(ci([rfly[0], rr, rfly[1], rfly[3]]), dflt.get('TradeRoute')) for rr in REGION2]), ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be max(int(TIMESLICE))

@@ -873,42 +888,45 @@ def saveResultsToExcel(dataframe, fileDir, fileName):
# SI4_UndiscountedCapitalInvestmentStorage
model += CapitalInvestmentStorage.get(ci(rsy)) == CapitalCostStorage.get(ci(rsy), dflt.get('CapitalCostStorage')) * NewStorageCapacity.get(ci(rsy)), ""
# SI5_DiscountingCapitalInvestmentStorage
model += DiscountedCapitalInvestmentStorage.get(ci(rsy)) == CapitalInvestmentStorage.get(ci(rsy)) * (1/ ((1+DiscountRate.get(rsy[0], dflt.get('DiscountRate')))**(int(rsy[2]) - int(min(YEAR))))), ""
model += DiscountedCapitalInvestmentStorage.get(ci(rsy)) == CapitalInvestmentStorage.get(ci(rsy)) * (1/ ((1+DiscountRateSto.get(ci(rsy[0:2]), dflt.get('DiscountRateSto')))**(int(rsy[2]) - int(min(YEAR))))), ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COuld make more readable with something like:

index = combined_index(rsy[0:2]) # extract region and storage from index
model += DiscountedCapitalInvestmentStorage.get(ci(rsy)) == \
CapitalInvestmentStorage.get(ci(rsy)) \
* (1/ ((1+DiscountRateSto.get(index), \
* dflt.get('DiscountRateSto')))**(int(rsy[2]) - int(min(YEAR))))), ""

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

Successfully merging this pull request may close these issues.

2 participants