Storing simulation setup #10949
Replies: 2 comments 5 replies
|
Attributes should be fine (I'd create a single key like
|
|
In xarray-simlab, model parameters are usually represented as data variables. This has several advantages like:
Currently parameter sections are handled using a namespace prefix for the variable name, e.g., "control__nx", "control__ny", etc. but maybe using a DataTree would be a convenient alternative approach, also for having simulation inputs and outputs in separate groups/branches (xarray-simlab was developed before DataTree existed in Xarray). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I maintain a package called sdf-xarray which parses
.sdffiles intoxarray. These files are generated via a simulation and I would like the ability to add the simulation input parameters (which can be loaded from aninput.deckfile as a dict) from epydeck into thexarray.Datasetandxarray.DataArrayobjects. I'm considering adding them via attributes but was wondering if there was a better way.I was also wondering about the ability to display the dict within a jupyter notebook as a series of dropdowns/accordions below the attributes. Alternatively is there another way to render them so that it's integrated inside of the xarray objects a bit like the way the
pint_xarrayaccessor works (see how it renders the data here with the "magnitude" and "units")Any help or advice on how best to approach this would be extremely greatly appreciated :)
The simulation input files are called "decks" are technically Fortran files that contain multiple sections and are read in as Python dictionaries. Below is an example of one of these:
{ "control": { "nx": 256, "ny": 256, "t_end": 1e-08, "x_min": 0, "x_end": 1, "y_min": 0, "y_max": 1, "stdout_frequency": 10, }, "boundaries": { "bc_x_min": "simple_outflow", "bc_x_max": "simple_outflow", "bc_y_min": "periodic", "bc_y_max": "periodic", }, "window": { "move_window": True, "window_start_time": 0, "bc_x_min_after_move": "simple_outflow", "bc_x_max_after_move": "simple_outflow", "window_v_x": 200000000.0, }, "constant": { "x0": 1.31, "y0": 0.5, "r0": "0.4^2", "r2": "(x - x0)^2 + (y - y0)^2" }, "species": { "electron": { "name": "electron", "charge": -1.0, "mass": 1.0, "nparticles_per_cell": 5, "number_density": [ "if(abs(x-x0) lt 0.3, 2, 1)", "if(abs(y-y0) lt 0.2, number_density(electron), 1)", ], "temperature_ev": 0, } }, "output": { "normal": { "name": "normal", "dt_snapshot": 1e-10, "particles": "always", "px": "always", "py": "always", "pz": "always", "vx": "always", "vy": "always", "vz": "always", "particle_weight": "always", "grid": "always", "number_density": "always + species", "temperature": "always + species", } }, }All reactions