Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulations pane #20

Merged
merged 25 commits into from
Sep 21, 2023
Merged

Simulations pane #20

merged 25 commits into from
Sep 21, 2023

Conversation

annehaley
Copy link
Collaborator

@annehaley annehaley commented Sep 14, 2023

Summary

The Simulations pane introduced in this PR allows the user to create SimulationResult objects in the database and view existing results. After picking a Simulation type, the user must specify all required inputs, then they may run the simulation.

Details

For this PR, only one Simulation type is implemented, called "Flood Scenario 1". Simulation types (not to be conflated with SimulationResults) are not database objects. Rather, they exist as a hard-coded mapping of celery tasks. The simulation types populate the side-panel under "Available Simulations."
image

(Side note: this PR also switches the order of the "Available Layers" and "Active Layers" panels for consistency with the other panels' organization)

When the user selects a simulation type, the simulations pane appears for the selected type. The pane has two tabs: a tab to create a new SimulationResult object, and a tab to view existing ones. The tab to create a new one allows the user to specify all the inputs required for the selected simulation type. Once all required inputs are specified, the user may run the simulation.
image

The request to run a simulation creates a SimulationResult object, which it returns to the client and sends into a Celery task to fill in the output_data field. While the celery task is running, the client shows the SimulationResult object's input_args and modified_date, as well as a spinner while the output_data is undefined. While the spinner is shown, the client polls the server every two seconds for an update.
image

Once the celery task is complete, the client will receive the updated output_data on the target SimulationResult object and display it. In the case of "Flood Scenario 1", the output type is "node_failure_animation", so a specialized component called NodeFailureAnimation is displayed in the results section once output_data is defined. The node failure animation can be played forward or backward (with 1 second ticks) or the user can go directly to a step using the slider.
image

As the slider moves, the list of deactivatedNodes changes. The new value is equal to the node failure list, sliced to end on the index of the current tick. (On the second tick, deactivatedNodes contains 2 node ids.) As the list of deactivated nodes changes, the client sends a computeGCC request and updates the map with the response. This happens in the same manner as when the user manually updates the deactivated nodes.

The video attached below shows this behavior.

Results

uvdat_simulations_compressed.mp4

Copy link
Member

@jjnesbitt jjnesbitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, tested locally. Just have a few questions/concerns

@annehaley
Copy link
Collaborator Author

Note: I realized that SimulationResults should also reference the City as their context (so similar simulations in different cities don't get confused). This change was made in 1cd52b8

@annehaley annehaley merged commit d7ecc06 into master Sep 21, 2023
@annehaley annehaley deleted the simulations-pane branch September 21, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants