Water demands can be met by numerous sources of water. AWASH performs the allocation of water by solving an optimization problem resulting in the least costly solution to meet water demands under the environmental constraints. In this notebook, we conduct a sensitivity analysis to the choice of cost model for water.

Surface water use estimates are generally known at facility-, municipality- or county-level (e.g. USGS). To relate these numbers to the surface water network, an optimization problem is solved to determine the withdrawals at each canals linking nodes of the network (gauges) to the counties. As water in the network may be insufficient to meet demands, the model quantifies this failure by considering a super source.

Two models are considered here: 1. cost is uniform, 2. cost is proportional to the relative elevation of the point of source and point of use (meaning if the gauge is at a lower altitude than the county, pumping costs are proportional to the elevation difference, if it is higher, cost is null).

```
In [1]:
```cd("../../src/");
include("nui.jl");
include("lib/readconfig.jl");
config = readconfig("../configs/standard-1year.yml")
# setting extraction cost to 0 (option 1: cost is uniform)
config["watercost-extraction"] = false;
include("optimize-surface.jl");
include("simulate.jl");
# getting volumes and costs at the county level from the simulation
sw1 = getdata(:Allocation, :swsupply);
swc1 = getdata(:WaterCost, :swcost);
supw1 = getdata(:Allocation, :supersourcesupply);

```
```

```
In [2]:
```# setting extraction cost proportional to relative elevation (option 2)
config["watercost-extraction"] = true;
include("optimize-surface.jl");
include("simulate.jl");
# getting volumes and costs at the county level from the simulation
sw2 = getdata(:Allocation, :swsupply);
swc2 = getdata(:WaterCost, :swcost);
supw2 = getdata(:Allocation, :supersourcesupply);

```
```

```
In [3]:
```# comparison with usgs estimates - loading the data
recorded = readtable(datapath("extraction/USGS-2010.csv"));
swusgs = recorded[:, :TO_SW] * 1383. / 12 *config["timestep"] * numsteps;

```
In [4]:
```# verifying that demands are met
include("mapping.jl")
println("Total differences between USGS and model case 1: ", sum(abs(swusgs.data -sum(sw1+supw1,2))), " 1000m3")
println("Total differences between USGS and model case 2: ", sum(abs(swusgs.data -sum(sw2+supw2,2))), " 1000m3")
#mapdatacty(swusgs.data -sum(sw2+supw2,2), true)

```
```

```
In [5]:
```# Reliance supersource option 1
mapdatacty(sum(supw1,2))

```
Out[5]:
```

```
In [6]:
```# Reliance supersource option 2
mapdatacty(sum(supw2,2))

```
Out[6]:
```

```
In [7]:
```# Comparison of reliance on supersource between option 1 and 2
mapdatacty(sum(supw1-supw2,2),true)

```
Out[7]:
```

Counties in red face more failure when extraction costs are taken in consideration.

From this last map, it seems that the cost model only impacts redistribution of failure among adjacent counties, it does not seem to have effect at a larger scale. However, if we look at the same data but in percentage to total demand:

```
In [8]:
```# Percentage of failure option 1
mapdatacty(sum(supw1,2)./sum(sw1+supw1,2)*100)

```
Out[8]:
```

```
In [9]:
```# Percentage of failure option 2
mapdatacty(sum(supw2,2)./sum(sw2+supw2,2)*100)

```
Out[9]:
```

```
In [10]:
```# Percentage of failure option 2
mapdatacty((sum(supw1,2)-sum(supw2,2))./sum(sw2+supw2,2)*100, true)

```
Out[10]:
```

```
In [11]:
```R"par(mfrow=c(2,1))"
R"par(mar=c(4,4,2,0))"
f1prct = sum(supw1,2)./sum(sw1+supw1,2)*100
f2prct = sum(supw2,2)./sum(sw2+supw2,2)*100
R"hist($f1prct, xlab='failure in %', main='without extraction cost',breaks=20,ylim=c(0,1500))";
R"hist($f2prct, xlab='failure in %', main='with extraction cost',breaks=20,ylim=c(0,1500))";

```
```

Hereafter, we investigate how this depends on the quantity of demanded water.

```
In [12]:
```R"par(mfrow=c(2,1))"
R"par(mar=c(4,4,1,0))"
x = swusgs;
R"plot($x,$f1prct-$f2prct, xlab = 'demand', ylab = 'difference in % of failure')";
x = log10(swusgs);
R"plot($x,$f1prct-$f2prct, xlab = 'log10(demand)', ylab = 'difference in % of failure')";

```
```

The very large users (> 1e9 m3/year) seem to face very limited failure. I do not believe it is possible to conclude anything else.

The last aspect is the cost of water. We plot hereafter the cost per 1000m3 of water to understand where it was not possible to withdraw water without pumping water uphill

```
In [13]:
```# Surface water extraction cost per 1000m3
mapdatacty(sum(swc2,2)./sum(sw2,2))

```
Out[13]:
```