NRL-Plasma-Physics-Division / turbopy

A lightweight computational physics framework, based on the organization of turboWAVE. Implements a "Simulation, PhysicsModule, ComputeTool, Diagnostic" class hierarchy.
https://turbopy.readthedocs.io/
Creative Commons Zero v1.0 Universal
10 stars 18 forks source link

Add a method to the Simulation class to display model #9

Open arichar6 opened 4 years ago

arichar6 commented 4 years ago

It could be helpful to both developers and users to have a way to quickly visualize the various PhysicsModules and Diagnostics that have been added to a Simulation (an instance of the Simulation class).

This could be achieved by creating a method for the Simulation class that loops over the physics_module list and prints the name (or class name) of each item in the list. And then does something similar for the diagnostics.

Perhaps better would be to also add a method to the PhysicsModule and Diagnostic classes, which prints specifics about the module/diagnostic. For example, each module could also print the values of its settings, and a list of variables that it is sharing.

There are many possibilities for more advanced versions of such functionality. Perhaps a tool that takes a Simulation instance and creates a flowchart (use html/js, perhaps flowchart.js) that shows the Modules, Diagnostics, and the connections between the variables.

Thoughts?

padamson commented 4 years ago

I'd like to see this feature support causal model graphs that are useful in visualizing UQ and sensitivity studies. Something like this (but not powerpoint engineering but a real interactive diagram with all the details of the simulation):

image

Related to this, could we add metadata to the data objects? For example, a good first metadata object would be a descriptive string.

arichar6 commented 4 years ago

That's exactly the kind of thing I'm thinking about. It would be really useful, and it would be cool if it could tie into UQ.

Regarding adding metadata to the shared data objects, that is totally possible. I've been thinking about various ways to do that. Need to balance increased functionality with possible increased complexity.

Rethinking the data objects might actually help with other things though... e.g. it could help with #10, and also with a rewrite of the sharing algorithm that I've been mulling over.

arichar6 commented 4 years ago

So, don't judge... I've been reading python documentation, and searching for options for an annotated data type like you describe. I finally got around to reading about xarray. I had heard it described as N-dim pandas, or an easier/more powerful NumPy array. Reading the page linked above makes me think we should explore using it for turboPy. If nothing else, it looks like adding arbitrary metadata would be easy.

padamson commented 4 years ago

No judgement here! (But I'm not good litmus.)

They had me at "you’ll understand what you were thinking when you come back to look at it weeks or months later."

I had been looking at netCDF already for nepc. On its face, this seems perfect for our whole UQ/chemistry/turboPy toolchain.

GarethTMorgan commented 4 years ago

Going along with the no judgment theme, what is UQ? I've heard it referred to in the theory division MMM but haven't spoken up about it.

arichar6 commented 4 years ago

UQ is short for uncertainty quantification. At the most basic level it is a field of study which tries to answer the question "how do uncertainties in inputs to a model affect the model outputs (both value of the output, and uncertainty in the output)?"

At least that's my understanding of what it means.

arichar6 commented 4 years ago

On a separate note, xarray looks great. See the recent push to the example app. I'm going to open a separate issue to discuss using xarray more extensively.

padamson commented 4 years ago

I think I’ll start a similar issue to look at using xarray in nepc, too.