{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Water Age Analysis Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display, HTML\n", "display(HTML('\"Open'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example demonstrates how to perform a water age analysis." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pip install epyt-flow --quiet" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from epyt_flow.data.networks import load_ctown\n", "from epyt_flow.simulation import ScenarioSimulator\n", "from epyt_flow.utils import to_seconds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a new [simulation](https://epyt-flow.readthedocs.io/en/stable/epyt_flow.simulation.html#epyt_flow.simulation.scenario_simulator.ScenarioSimulator) based on the [C-Town network](https://epyt-flow.readthedocs.io/en/stable/epyt_flow.data.html#epyt_flow.data.networks.load_ctown):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "network_config = load_ctown(verbose=False)\n", "sim = ScenarioSimulator(scenario_config=network_config)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set simulation duration to two days:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.set_general_parameters(simulation_duration=to_seconds(days=2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Enable water age analysis by calling [enable_waterage_analysis()](https://epyt-flow.readthedocs.io/en/stable/epyt_flow.simulation.html#epyt_flow.simulation.scenario_simulator.ScenarioSimulator.enable_waterage_analysis):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.enable_waterage_analysis()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Place quality sensors at all nodes by calling [set_node_quality_sensors()](https://epyt-flow.readthedocs.io/en/stable/epyt_flow.simulation.html#epyt_flow.simulation.scenario_simulator.ScenarioSimulator.set_node_quality_sensors) -- i.e. measuring the water age at each node:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.set_node_quality_sensors(sensor_locations=sim.sensor_config.nodes)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Run the entire simulation:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "scada_data = sim.run_simulation()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Retrieve and show simulated water age at the first two nodes:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "scada_data.plot_nodes_quality(sensor_locations=sim.sensor_config.nodes[:2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Do not forget to close the simulation!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.close()" ] } ], "metadata": { "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.20" } }, "nbformat": 4, "nbformat_minor": 2 }