diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index 5c5c4d26715c92cce609c9a74577184066d2c7eb..6683cccb792b214f0c30f89c971c4b4a57a178a8 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -100,7 +100,8 @@ public class ModelConfig { public static final String OUTPUT_DIR = getProperty("OUTPUT_DIR", BASE_DIR + File.separator + "output"); public static final String TEMP_DIR = getProperty("TEMP_DIR", OUTPUT_DIR + File.separator + "GamsTmp"); public static final String DATA_DIR = getProperty("DATA_DIR", BASE_DIR + File.separator + "data"); - public static final String GAMS_MODEL = getProperty("GAMS_MODEL", BASE_DIR + File.separator + "GAMS/IntExtOpt.gms"); + public static final String GAMS_DIR = getProperty("GAMS_DIR", BASE_DIR + File.separator + "GAMS"); + public static final String GAMS_MODEL = getProperty("GAMS_MODEL", GAMS_DIR + File.separator + "IntExtOpt.gms"); public static final boolean CLEANUP_GAMS_DIR = getBooleanProperty("CLEANUP_GAMS_DIR", false); // Country (non-gridded) data @@ -216,10 +217,8 @@ public class ModelConfig { public static final boolean ENABLE_GEN2_BIOENERGY = getBooleanProperty("ENABLE_GEN2_BIOENERGY", false); public static final String BIOENERGY_DEMAND_SCENARIO = getProperty("BIOENERGY_DEMAND_SCENARIO", "BAU"); public static final double BIOENERGY_DEMAND_SHIFT = IS_CALIBRATION_RUN ? 1.0 : getDoubleProperty("BIOENERGY_DEMAND_SHIFT", 1.0); - // public static final double BIOENERGY_HEATING_VALUE_GJ_PER_T = getDoubleProperty("BIOENERGY_HEATING_VALUE_GJ_PER_T", 17.5); // GJ per t DM - public static final double MARKET_LAMBA = getDoubleProperty("MARKET_LAMBA", 0.4); // controls international market price adjustment rate public static final double POPULATION_AGGREG_LIMIT = getDoubleProperty("POPULATION_AGGREG_LIMIT", 30.0); // in millions, smaller countries are aggregated on a regional basis @@ -247,6 +246,8 @@ public class ModelConfig { public static final boolean DEBUG_JUST_DEMAND_OUTPUT = getBooleanProperty("DEBUG_JUST_DEMAND_OUTPUT", false); public static final boolean DEBUG_LIMIT_COUNTRIES = getBooleanProperty("DEBUG_LIMIT_COUNTRIES", false); public static final String DEBUG_COUNTRY_NAME = getProperty("DEBUG_COUNTRY_NAME", "United States of America"); + public static final String GAMS_COUNTRY_TO_SAVE = getProperty("GAMS_COUNTRY_TO_SAVE", "China");; + public static final double PASTURE_MAX_IRRIGATION_RATE = getDoubleProperty("DEFAULT_MAX_IRRIGATION_RATE", 50.0); // shouldn't need this but some areas crops don't have a value, but was causing them to be selected public static final int LPJG_TIMESTEP_SIZE = 5; diff --git a/src/ac/ed/lurg/ModelMain.java b/src/ac/ed/lurg/ModelMain.java index 13c1d44e91dd5a9e06b91db74d57a070b72086ee..26e992d44ec7b81efb92eb855c8654089f41293f 100644 --- a/src/ac/ed/lurg/ModelMain.java +++ b/src/ac/ed/lurg/ModelMain.java @@ -8,6 +8,9 @@ import java.io.FileWriter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -158,17 +161,17 @@ public class ModelMain { continue; } - // some hacky code for debug purposes that keeps each gams gdx file - /* if (ca.getCountry().getName().equals("Spain")) { + // some hacky code for debug purposes that keeps each gams gdx file for one country + if (ModelConfig.GAMS_COUNTRY_TO_SAVE != null & ca.getCountry().getName().equals(ModelConfig.GAMS_COUNTRY_TO_SAVE)) { try { Files.copy( - FileSystems.getDefault().getPath("/Users/peteralexander/Documents/R_Workspace/UNPLUM/temp/GamsTmp/_gams_java_gdb1.gdx"), - FileSystems.getDefault().getPath("/Users/peteralexander/Documents/R_Workspace/UNPLUM/temp/GamsTmp/" + timestep.getTimestep() + ".gdx") + FileSystems.getDefault().getPath(ModelConfig.TEMP_DIR + File.separator + "_gams_java_gdb1.gdx"), + FileSystems.getDefault().getPath(ModelConfig.TEMP_DIR + File.separator + ModelConfig.GAMS_COUNTRY_TO_SAVE + timestep.getYear() + ".gdx") , StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { - LogWriter.printException(e); + LogWriter.print(e); } - } */ + } // update global rasters globalLandUseRaster.putAll(result.getLandUses()); diff --git a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java index 9a2ab9b607b2fd6060dfbc9994ca255d5c46d139..ea1a48aeff1e2e045b384963c8b63a553aef471f 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationOptimiser.java @@ -119,18 +119,17 @@ public class GamsLocationOptimiser { double prevFertI, prevIrrigI, prevOtherI; Intensity intensity = landUseItem.getIntensity(cropType); - double defaultI = CropType.PASTURE == cropType ? 0.01 : 0.5; if (intensity==null) { // could be first time through or this crop not previously grown in this location, so give it some default values - prevFertI = defaultI; - prevIrrigI = defaultI; - prevOtherI = defaultI; + prevFertI = CropType.PASTURE.equals(cropType) ? 0.0 : 0.5; + prevIrrigI = CropType.PASTURE.equals(cropType) ? 0.0 : 0.5; + prevOtherI = CropType.PASTURE.equals(cropType) ? 0.1 : 0.5; } else { prevOtherI = intensity.getOtherIntensity(); - if (prevOtherI == 0) { // this is needed or optimizer gets a bit confused if some areas are kept as cropland but are not productive, due to zero other intensity (i.e. set aside) - prevFertI = defaultI; - prevIrrigI = defaultI; + if (prevOtherI == 0 & !CropType.PASTURE.equals(cropType)) { // this is needed or optimizer gets a bit confused if some areas are kept as cropland but are not productive, due to zero other intensity (i.e. set aside) + prevFertI = 0.5; + prevIrrigI = 0.5; } else { prevFertI = intensity.getFertiliserIntensity();