Note
Go to the end to download the full example code.
Checking a model for critical errors#
When creating and editing supply models in Polaris, it is useful to check for potential errors that would surface when running simulations, as that can help prevent crashes multiple hours into a simulation run.
This example shows how to check a supply model for critical errors and basic connectivity testing
Imports#
# Figure out where our polaris directory is (so we can get some test data)
from pathlib import Path
from polaris import Polaris
Open the project and get the Network object for checking sphinx_gallery_thumbnail_path = ‘../../examples/model_building/checking_cartoon.svg’
project = Polaris.from_dir(Path("/tmp/Bloomington"))
supply = project.network
The most important check, one that Polaris-Studio performs at the beginning of every convergence run, is the critical tests
chkr = supply.checker
chkr.critical()
print(chkr.errors)
[]
But connectivity tests are also critical to prevent mid-simulation crashes For more detail please refer to https://polaris.taps.anl.gov/polaris-studio/supply/network_checker.html
chkr.connectivity_auto()
print(chkr.errors)
# If you used low-memory mode
# print(chkr.auto_network_islands)
[]
The network still doesn’t have zones, locations or other things, so we won;t bother about running consistency checks
supply.close(clear_issues=False)
Total running time of the script: (0 minutes 0.302 seconds)