# Exercise 1a Two nodes

### **Create a new model** <a href="#create-a-new-model" id="create-a-new-model"></a>

Ceate a new network called Exercise 1a using the following template:

**Pywr child template v1 (March 2021) - flow units in Mm3/day**

<figure><img src="https://2363830371-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODCd8VK2OOl9jOdp5KFf%2Fuploads%2FdqnWm1n6L9BkI0uCo4em%2Fimage.png?alt=media&#x26;token=cb2a7979-3c0d-4f16-8cf2-b4816c34b28e" alt=""><figcaption></figcaption></figure>

### **Set Up Time Horizon** <a href="#set-up-time-horizon" id="set-up-time-horizon"></a>

This step is mandatory for all networks as it defines the simulation's start, end, and timestep. For this example, we will configure a 1-year simulation horizon with a daily timestep.

<figure><img src="https://2363830371-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODCd8VK2OOl9jOdp5KFf%2Fuploads%2FDWfPS67553kSxt0S5jR7%2Fimage.png?alt=media&#x26;token=dbc0519c-f7ac-4476-8e93-b650494bd151" alt=""><figcaption></figcaption></figure>

### **Adding Nodes** <a href="#adding-nodes" id="adding-nodes"></a>

Navigate to the left panel and click on **Build** to open the Nodes list.

<figure><img src="https://2363830371-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODCd8VK2OOl9jOdp5KFf%2Fuploads%2FzNf9SWOFx3H6EmkXlIO3%2Fimage.png?alt=media&#x26;token=f72bf940-4415-4286-a46d-3020e0886d90" alt=""><figcaption></figcaption></figure>

Drag and drop to the workspace Map:

· 1 input node ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252Fp6IcyyIr7fCzV9v3HMQv%252Fimage.png%3Falt%3Dmedia%26token%3D36fa8c07-8f63-4ded-88fc-0dbabb032a83\&width=300\&dpr=4\&quality=100\&sign=71b57dd\&sv=2)

· 1 output node ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FfWwLPBlBvaq7ZsFNaOfN%252Fimage.png%3Falt%3Dmedia%26token%3D70d572d3-8707-4d27-9617-f0144ca95dfa\&width=300\&dpr=4\&quality=100\&sign=37509149\&sv=2)

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FsPr62T4a30QLGrT19B3K%252F4.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=cc64304f\&sv=2)

Note: To learn more about different node types, refer to the documentation [here](https://water-strategy.gitbook.io/water-strategy/modelling-fundamentals/node-types).

### **Adding Edges** <a href="#adding-edges" id="adding-edges"></a>

Click on **edge** ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FNuMmfpzaZSKHIOybT53d%252F5.png%3Falt%3Dmedia\&width=300\&dpr=4\&quality=100\&sign=2ddc37f2\&sv=2) to activate “link mode”.

To create a connection between nodes, first click on the input node and then click on the output node. Edges are directional, and the direction is set from the first to the second node.

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252Fv96Yvy0O9q90aPHJRPK5%252F6.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=d3f81232\&sv=2)

Click again on **edge** ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FX1VBTRuwkFsrvwHLGUK7%252F7.png%3Falt%3Dmedia\&width=300\&dpr=4\&quality=100\&sign=18a2869d\&sv=2) to deactivate “link mode”.

### **Add flow input node and Run the network** <a href="#add-flow-input-node-and-run-the-network" id="add-flow-input-node-and-run-the-network"></a>

Double-click on the input node. This will open the node panel on the right side of the screen.

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FOIc9Ngpvk6owrOTwFOEV%252F8.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=33e5742a\&sv=2)

Node Panel Sections:

* **Details:** Here, you can change the name and description of the node.
* **Inputs:** This section contains the basic attributes that need to be configured for each node. These attributes are user-defined.
* **Outputs:** This section displays the results after the simulation.

Select the **input** node and change **max\_flow** to 10.

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FQXQ5djh3FqWH3TZ1HnU6%252F9.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=431883d8\&sv=2)

On the left panel Click on **Run a Model** ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FN9XX7GOmGAGHveR3I33q%252F10.png%3Falt%3Dmedia\&width=300\&dpr=4\&quality=100\&sign=e53c96b\&sv=2).

A new window will pop-up, click on **Submit**

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FI94P07yMknyJG2F8uvTb%252F11.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=48eeaf8d\&sv=2)

Wait until the **Runs panel** shows a green indicator for successful execution.

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FaM3jKAyF6ZHhoRhvgGXv%252F13.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=43a07251\&sv=2)

To visualize the supplied flow from the input, click on the **input** node and then **click on the icon** ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252Fs7IK1rxjpCzzb0h9dp4y%252F14.png%3Falt%3Dmedia\&width=300\&dpr=4\&quality=100\&sign=a918e465\&sv=2) for the attribute **simulated\_flow**

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252F8Y2n57P3GVJnDggRmQ84%252Fimage.png%3Falt%3Dmedia%26token%3D77064db5-0377-4e3a-8b2e-52ed0efe4284\&width=768\&dpr=4\&quality=100\&sign=2f909a88\&sv=2)

To visualize the supplied flow to the output, click on the **output** node and then **click on the icon** ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FClGLWgzLIeYy4a9NiI6C%252F16.png%3Falt%3Dmedia\&width=300\&dpr=4\&quality=100\&sign=7e4f3882\&sv=2) for the attribute **simulated\_flow**

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FCUUMMfY3QrpyFirC8lGU%252Fimage.png%3Falt%3Dmedia%26token%3D55465607-868b-4781-b245-8ec898bc67f7\&width=768\&dpr=4\&quality=100\&sign=847191fb\&sv=2)

The following plots are the results generated by the network

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FhFSztDcgcKzzcWKCVMC9%252F18.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=f1c2a347\&sv=2)![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FyBgOnBwEPpi5bm9mKxyj%252F19.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=32488224\&sv=2)

### **Explanation** <a href="#explanation" id="explanation"></a>

The input node acts as a water supply source, providing a maximum of 10Mm³/day, according to the demand required, as the output node doesn’t have an allocation penalty associated, then no water supply is required.

### **Add priority to the output node and Run The network** <a href="#add-priority-to-the-output-node-and-run-the-network" id="add-priority-to-the-output-node-and-run-the-network"></a>

Select the **output** node and change **allocation penalty** to -10. A negative value sets up a higher priority for the node. For more information on allocation penalties, refer to the [Allocation Penalty](https://water-strategy.gitbook.io/water-strategy/modelling-fundamentals/allocation-penalty) documentation

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FChjakxDkReHt8ka69Emu%252F20.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=c68d6a2f\&sv=2)

On the left panel click on **Run a Model** ![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252F3D7oEvhFAzyDHZKnsMTv%252F21.png%3Falt%3Dmedia\&width=300\&dpr=4\&quality=100\&sign=fe1cd6b6\&sv=2).

Run the model and visualize the results as described on the previous step

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FekKvPk6pNvToC5iL3dh8%252F22.png%3Falt%3Dmedia\&width=768\&dpr=4\&quality=100\&sign=81ff8d87\&sv=2)

### **Explanation** <a href="#explanation-1" id="explanation-1"></a>

The input node acts as a water supply source, providing a maximum of 10Mm³/day.

The **allocation penalty** in the output node is set to a negative value (-10), prioritizing the allocation of water to this node, with no constraint on maximum flow, the output node can consume as much water as the network can supply to it.

### **Add required flow to the output node and Run The network** <a href="#add-required-flow-to-the-output-node-and-run-the-network" id="add-required-flow-to-the-output-node-and-run-the-network"></a>

Select the **output** node and change **max\_flow** to 6Mm³/day, it tells the network which is the required consumption for this output node.

On the left panel click on **Run a Model** . Run the model and visualize the results as described previously

![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FIX2rApG9Yg5Owpyf4PGL%252Fimage.png%3Falt%3Dmedia%26token%3Df3dc4379-94ad-4bf6-b7ba-e0ba21f58da1\&width=768\&dpr=4\&quality=100\&sign=2ce8e3a1\&sv=2)![](https://water-strategy.gitbook.io/~gitbook/image?url=https%3A%2F%2F530325344-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOe4DHiaeqejzGopyV9BO%252Fuploads%252FMPcxNcUPQaYpVbBEylSj%252Fimage.png%3Falt%3Dmedia%26token%3D1728f953-2152-4af7-bb6c-a3ec067e726b\&width=768\&dpr=4\&quality=100\&sign=6e85c0f6\&sv=2)

#### **Explanation** <a href="#explanation-2" id="explanation-2"></a>

The input node acts as a water supply source, providing a maximum of 10Mm³/day.

The **allocation penalty** prioritizes the allocation of water to the output node, a constrain to maximum 6Mm³/day withdrawal has been added, now the output only gets the constrained 6Mm³/day a maximum supply of the requested demand.
