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

Save/restore Circuits to HDF5 #51

Open
bendudson opened this issue Feb 8, 2021 · 1 comment
Open

Save/restore Circuits to HDF5 #51

bendudson opened this issue Feb 8, 2021 · 1 comment

Comments

@bendudson
Copy link
Collaborator

Circuits are saved to HDF5 files as an array of dtypes, which are created using Coil.dtype:
https://github.com/bendudson/freegs/blob/master/freegs/machine.py#L74
Unfortunately, circuits may include different types of coils, e.g. ShapedCoil and MultiCoil. This means that e.g. machine.MASTU can't be written to HDF5. Some possibilities:

  1. Use groups to represent circuits. In principle circuits could contain other circuits, so groups could be nested
  2. Define a coil dtype which is a superset of all the coil types which could be added. This would then not be future-proof, for adding new coil types, and I don't think would work with circuits which contain circuits.
@ZedThree
Copy link
Collaborator

Looking at how to convert to/from IMAS, there are two relevant data structures: pf_active and pf_passive. Note that the schemas on the website are not the most recent versions, so you might need to look through the actual schemas.

They're slightly different, pf_active has coils while pf_passive has loops, but they are both made up of elements:

Each PF coil is comprised of a number of cross-section elements described individually

And each element has area and geometry properties, with geometry being a structure itself, with a geometry_type property:

Type used to describe the element shape (1:'outline', 2:'rectangle', 3:'oblique', 4:'arcs of circle, 5: 'annulus', 6 : 'thick line')

Each of these corresponds to a separate structure with its own properties, e.g.:

 "pf_active.coil[:].element[:].geometry.outline": {
  "data_type": "STRUCTURE",
  "documentation": "Irregular outline of the element. Do NOT repeat the first point.",
 },
 "pf_active.coil[:].element[:].geometry.outline.r": {
  "coordinates": [
   "1...N"
  ],
  "data_type": "FLT_1D",
  "documentation": "Major radius",
  "type": "static",
  "units": "m"
 },
 "pf_active.coil[:].element[:].geometry.outline.z": {
  "coordinates": [
   "pf_active.coil[:].element[:].geometry.outline.r"
  ],
  "data_type": "FLT_1D",
  "documentation": "Height",
  "type": "static",
  "units": "m"
 },

There's definitely some correspondence between FreeGS coil types and IMAS geometry types, but maybe not one-to-one.

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

No branches or pull requests

2 participants