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

Addition of irrigation water pumping costs for India #401

Merged
merged 62 commits into from
Jul 7, 2022

Conversation

vartika271987
Copy link
Contributor

@vartika271987 vartika271987 commented Jun 14, 2022

🐦 Purpose of this PR 🐦

  • This PR includes the addition of irrigation water pumping costs for India, including input data as well as code changes. This also includes switches for policy shocks for India

🔧 Checklist for PR creator 🔧

  • Medium risk : New realization / Changes to existing realization / Other changes which don't modify default.cfg
  • Providing additional information based on PR label
  • Medium risk : Default run based on the current version of the fork from which PR is made
  • Cropland at Global level
    image

*Water Use at Global level - difference mainly due to India
image
image

*Crop Production
image

*Crop Production in India
image

  • 📉 Performance loss/gain from current default behavior 📈

    • Current develop branch default : 31.1 mins
    • This PR's default : 29.5 mins
  • Added changes to CHANGELOG.md

  • Compilation check (model starts without compilation errors - use gams main.gms action=c in model folder for testing).

  • No hard coded numbers and cluster/country/region names.

  • The new code doesn't contain declared but unused parameters or variables.

  • Where relevant, In-code comments added including documentation comments.

  • Made sure that documentation created with goxygen is okay (use goxygen::goxygen() for testing).

  • Changes to magpie4 R library for post processing of model output (ideally backward compatible).

  • Self-review of my own code.

  • For high risk runs: validation of major model indicators - Land-use, emissions, food prices, Tau. %Delete this line in case it is not a high risk run%

⚠️ Additional notes or warnings ⚠️

NA

🚨 Checklist for RSE reviewer 🚨

  • PR is labeled correctly.
  • CHANGELOG is updated correctly
  • No hard coded numbers and cluster/country/region names.
  • No unnecessary increase in module interfaces
  • All required updates in interfaces (if any) have been properly adressed in the module contracts
  • In-code comments and documentation comments are satisfactory.
  • model behavior/performance is satisfactory.
  • Requested changes (if any) were applied correctly

🚨 Checklist for MAgPIE reviewer 🚨

  • PR is labeled correctly.
  • CHANGELOG is updated correctly
  • No hard coded numbers and cluster/country/region names.
  • Changes to the model are scientifically sound
  • In-code comments and documentation comments are satisfactory.
  • model behavior/performance is satisfactory.
  • Requested changes (if any) were applied correctly

config/default.cfg Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
main.gms Show resolved Hide resolved
# | Contact: magpie@pik-potsdam.de

name,type,reason
vm_water_cost, variable, calculates cost of water pumping to be used in the costs module directly
Copy link
Member

Choose a reason for hiding this comment

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

the variable vm_water_cost is declared in the water demand module. As it is an interface variable it has to be declared and set in every realization of that module. Currently, the other realizations won't work anymore due to a domain violation error (the costs module tries to access a variable which does not exist).
So, if you have a water demand realization which should not introduce any water costs, you still have to do two things:

  • declare the variable
  • fix the variable to 0

modules/42_water_demand/all_sectors_aug13/declarations.gms Outdated Show resolved Hide resolved
modules/42_water_demand/all_sectors_aug13/declarations.gms Outdated Show resolved Hide resolved
*Pumping cost in the current time step
if(m_year(t) > s42_pumping_startyear,
ic42_pumping_cost(i) = f42_pumping_cost(t,i)*s42_multiplier;
);
Copy link
Member

Choose a reason for hiding this comment

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

what happens for years before the start year with ic42_pumping_costs? The parameter should be initialized for these years as well. And do you actually use this feature that the start year can be changed? If not, I would suggest to skip it and just set the pumping costs for all years

Copy link
Contributor Author

@vartika271987 vartika271987 Jun 21, 2022

Choose a reason for hiding this comment

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

Added the initialization in presolve and also changed scalar description to clarify the purpose

Copy link
Member

Choose a reason for hiding this comment

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

same here as in the other realization: s42_pumping = 0 does not deactivate pumping costs

modules/42_water_demand/input/files Show resolved Hide resolved
# cfg$gms$s42_shock_year <- 2020 #def = 1995
# cfg$gms$s42_shock_scalar<- 0.4 #def = 0.4

#start_run(cfg, codeCheck=F)
Copy link
Member

Choose a reason for hiding this comment

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

please don't add uncommented code. If you want to have this code only sometimes activated, use a switch instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. I also changed the start script completely now as it had irrelevant material for my test runs. I have renamed it to fable_india to also contain the input data files for project requirements.

vartika271987 and others added 7 commits June 21, 2022 15:04
remove mention of India input files and add them to separate start script

Co-authored-by: Jan Dietrich <dietrich@pik-potsdam.de>
Bugfix in unit

Co-authored-by: Jan Dietrich <dietrich@pik-potsdam.de>
@FelicitasBeier
Copy link
Member

FelicitasBeier commented Jun 21, 2022

Thanks Feli. Your concern is mostly around the use of the Cornish et.al. publication for irrigation water costs, but to clarify, we are not using that reference any longer. And therefore, in the input file, we do not have any pumping costs for any of the regions except India. For India, I have calculated the pumping costs by applying conversion factors to convert energy prices of Kilowatts per hour to prices per million cubic meter and for the year 2005, these costs turn out to be 0.05 cents. We now apply this value as pumping costs for India in the input file as a default value as they have been obtained from existing observed data. I believe this addresses points 1 and 2.
Point 3: Fair point. I introduced this only in all_sectors because that was the current default and at some point it was discussed that it was the more advanced and useful realization. If we still feel the need to update agr_sectors realization, I could add it there too.
Point 4: Since we underestimate irrigated yields for India, we have already applied a correction factor for yields in the pre-processing for India. These data with improved India yields are the input files we will be using for India and hence I have added their paths to the default.cfg file. We have tested that using the improved yields input data for India with the default pumping costs of 0.05 cents does not bring much change in the model outcomes.
Point 5: The default pumping costs are 0 for all the regions except India where they are 0.05 cents. See input file here. The description still refers Cornish et.al but I will change it now since we don't use it any longer.

Thanks for the clarifications.

My follow-up questions refer to

  • point 2: Since MAgPIE is a global model, introducing costs only for one country biases the overall outcomes because it affects in how far a country has a comparative advantage w.r.t. (in this case) irrigation. There are also irrigation costs in other countries (some countries even have water markets, e.g. Australia). If these are not considered, these other countries have a comparative advantage in irrigation in the global cost minimisation. If you only look at India, that might be ok (even though you would need
  • this brings me back to point 5: Q: "is there a way of having 0 pumping costs (and is this still the default in the end)?". A: "The default pumping costs are 0 for all the regions except India where they are 0.05 cents. See input file here". My remaining questions are (a) Is there still a setting where pumping costs are 0 for all regions (to obtain unbiased results)? (b) Do we want to have a default where there are only pumping costs for India, even though it is most likely not the only country that faces these costs? If so: why?

@tscheypidi
Copy link
Member

This is an important point Feli brought up and I somehow missed. I somehow was (apparently incorrectly) assuming that in a default setup we have globally 0 pumping costs and that only in your specific India setup you introduce costs for India. As it is crucial not to introduce systematic biases towards certain regions in a global analysis it is critically important that in the default configuration there are 0 pumping costs globally, including India.

@vartika271987
Copy link
Contributor Author

Hi Feli and Jan,

I understand the concerns around implementing these costs only for India but to clarify, these values are too small to bring about any significant differences in model outcomes overall, as I have shared in the results above. Adding more results below where you will see that the results of the model do not differ much in the default (with 0 pumping costs for all regions, including India) and default_pc where the costs are included only for India. I agree that several other regions have water costs as well as to our best we should include them, but until we don't have these values (as it would take some time to obtain, calculate and integrate them), we could have this setup that will also allow me to run scenarios for my paper and our India team to include in their multiple analyses as well. I am proposing to make default_pc as the new default.

Cropland
image

Water use (the effect at Global level is only because of India and other regions have no impact)
image

Crop Production (small impacts for India, negligible for other regions)
image

CH4 Emissions
image

Trade (change observed only in LAM and India)
image

@tscheypidi
Copy link
Member

Hi Vartika,

for our standard runs it is important to avoid systematic biases where possible, independent of whether they have a significant impact on the results or not. Hence, there must be a setting used as default in which all regions are treated equally (in this particular case a scenario in which all pumping costs are 0).
As discussed earlier it is ok to have a (non-default) scenario in which there are costs for india but not for other regions so that you can use it for your studies. What we are asking for is that 1) this scenario is not default 2) there is a default scenario with 0 pumping costs.
From my perspective this should be rather easy to implement and should not conflict with your paper plans.

@vartika271987
Copy link
Contributor Author

Thank you all for the discussion on this. I have now made the change so that default pumping costs are 0 for all the regions and added the switch option in fable_india start script where we allow the value of pumping costs for India to be used for India-specific analyses. You may please review again now and approve if all looks good @mishkos @tscheypidi @FelicitasBeier

Copy link
Contributor

@mishkos mishkos left a comment

Choose a reason for hiding this comment

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

Some minor changes requested.

cfg$gms$c41_initial_irrigation_area <- "LUH2v2" # def = LUH2v2

# * Sets the rate of depreciation of irrigation infrastructure in every timestep.
# * Only applicable when (endo_apr13) realization is selected
cfg$gms$s41_AEI_depreciation <- 0 # def = 0


# * switch for initialization area
# * (LUH2v2): area equipped for irrigation based on LUH2v2
# * (Siebert): area equipped for irrigation from Siebert et al.
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this moved to the end here and not before the line where this switch is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake. My mouse playing catch. Fixed it now.

@@ -15,15 +15,18 @@ parameters
* country-specific scenario switch
p42_country_dummy(iso) Dummy parameter indicating whether country is affected by EFP (1)
p42_EFP_region_shr(t_all,i) Weighted share of region with regards to EFP (1)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD per m^3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here also instead of USD write USD05MER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

;

positive variables
vm_watdem(wat_dem,j) Water demand from different sectors (mio. m^3 per yr)
v42_irrig_eff(j) Irrigation efficiency (1)
vm_water_cost(i) Cost of irrigation water (USD per m^3)
Copy link
Contributor

Choose a reason for hiding this comment

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

also here the unit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


*Costs of pumping are taken observed values in India and a conversion factor is applied to change them into USD values per cubic meter
parameter
f42_pumping_cost(t_all,i) Cost of pumping irrigation water (USD per m^3)
Copy link
Contributor

Choose a reason for hiding this comment

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

unit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -106,3 +108,13 @@ $ondelim
$include "./modules/42_water_demand/input/f42_env_flow_policy.cs3"
$offdelim
;

*Costs of pumping are taken observed values in India and a conversion factor is applied to change them into USD values per cubic meter
Copy link
Contributor

Choose a reason for hiding this comment

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

here is a need for more documentation. Perhaps refer to your study in preparation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edited reference of forthcoming paper, god willing!

@@ -15,18 +15,18 @@ parameters
* country-specific scenario switch
p42_country_dummy(iso) Dummy parameter indicating whether country is affected by EFP (1)
p42_EFP_region_shr(t_all,i) Weighted share of region with regards to EFP (1)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD per m^3 per yr)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD per m^3)
Copy link
Contributor

Choose a reason for hiding this comment

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

unit

;

positive variables
vm_watdem(wat_dem,j) Amount of water needed in different sectors (mio. m^3 per yr)
v42_irrig_eff(j) Irrigation efficiency (1)
vm_water_cost(i) Cost of irrigation water (USD per m^3 per yr)
vm_water_cost(i) Cost of irrigation water (USD per m^3)
Copy link
Contributor

Choose a reason for hiding this comment

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

unit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -118,9 +118,9 @@ $include "./modules/42_water_demand/input/f42_env_flow_policy.cs3"
$offdelim
;

*Costs of pumping are taken from Cornish et.al. 2014 which are average global costs in USD
*Costs of pumping are taken observed values in India and a conversion factor is applied to change them into USD values per cubic meter
Copy link
Contributor

Choose a reason for hiding this comment

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

refer to your study or add more detail on calculation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

parameter
f42_pumping_cost(t_all,i) Cost of pumping irrigation water (1)
f42_pumping_cost(t_all,i) Cost of pumping irrigation water (USD per m^3)
Copy link
Contributor

Choose a reason for hiding this comment

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

unit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@tscheypidi tscheypidi left a comment

Choose a reason for hiding this comment

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

I think we are getting close to have this PR ready for approval. Most important step before that is to have a clear interface to switch off/on pumping costs in the model.

cfg$gms$c41_initial_irrigation_area <- "LUH2v2" # def = LUH2v2

# * Sets the rate of depreciation of irrigation infrastructure in every timestep.
# * Only applicable when (endo_apr13) realization is selected
cfg$gms$s41_AEI_depreciation <- 0 # def = 0


# * switch for initialization area
# * (LUH2v2): area equipped for irrigation based on LUH2v2
# * (Siebert): area equipped for irrigation from Siebert et al.
Copy link
Member

Choose a reason for hiding this comment

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

why did you move the description down here? Doesn't it belong to c41_initial_irrigation_area?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error. Fixed it.

config/default.cfg Show resolved Hide resolved
@@ -6,4 +6,3 @@
# | Contact: magpie@pik-potsdam.de

name,type,reason
vm_water_cost, variable, calculates cost of water pumping to be used in the costs module directly
Copy link
Member

Choose a reason for hiding this comment

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

please delete this file as there are no remaining entries in the table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@mishkos mishkos left a comment

Choose a reason for hiding this comment

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

Looks good from my side.

Copy link
Member

@tscheypidi tscheypidi left a comment

Choose a reason for hiding this comment

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

s42_pumping = 0 does not work yet

if(m_year(t) > s42_multiplier_startyear,
ic42_pumping_cost(i) = f42_pumping_cost(t,i)*s42_multiplier;
);
);
Copy link
Member

Choose a reason for hiding this comment

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

if s42_pumping is set to 0, pumping costs will be active as you do set pumping costs and then use these pumping costs in the equations! You need to set ic42_pumping_cost(i) = 0; for the case of s42_pumping = 0!

CHANGELOG.md Show resolved Hide resolved
*Pumping cost in the current time step
if(m_year(t) > s42_pumping_startyear,
ic42_pumping_cost(i) = f42_pumping_cost(t,i)*s42_multiplier;
);
Copy link
Member

Choose a reason for hiding this comment

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

same here as in the other realization: s42_pumping = 0 does not deactivate pumping costs

@tscheypidi tscheypidi dismissed FelicitasBeier’s stale review July 7, 2022 09:11

Felis points have been adressed now

@vartika271987 vartika271987 merged commit 018de0f into magpiemodel:develop Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Medium risk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants