openPMD / openPMD-standard

:notebook: Open Standard for Particle-Mesh Data
http://www.openPMD.org
Creative Commons Attribution 4.0 International
79 stars 29 forks source link

Species Type: Full Grammar of some Ideas #256

Open s9105947 opened 2 years ago

s9105947 commented 2 years ago

Dear Maintainers,

I am currently working on a PICMI implementation, which cites the OpenPMD "Convention for Specifying Particle Species". While reading the extension my internal "hm, maybe this might be {too permissive|not entirely clear}" went of too often for my personal comfort, and I want to share my thoughts.

I don't work with/on openPMD directly, and also tend to be a little over-pedantic: Please take my comments with a grain of salt. (Also, my background is in computer science, so I'm not too familiar with your typical physics simulation.)

This issue summarizes a group of issues regarding the species type definition into a (well-defined) grammar:

257 #258 #259 #260 #261

ABNF Grammar

rough sketch of a speciesType syntax definition using ABNF from the top of my head:
(... is an omitted finite list, ELEMENT a one- or two-letter chemical symbol)

A implementation of the species type extension expects an ascii string and must accept at least expressions based on the rule species-type with the following definition:

species-type = species-single / species-list
species-list = species-single *( ";" species-single )
species-single = elementary / hadron-or-jet / atom / ion / molecule / other

other = "other:" *( ALPHA / DIGIT / "+" / "-" / "_" / "." / "#" / "^" )

elementary = quark / leptop / boson
quark = quark-anti / quark-normal
qurak-anti = "anti-" quark-normal
quark-normal = "up" / "down" / "charm" / "strange" / "top" / "bottom"
lepton = lepton-anti / lepton-normal
lepton-anti = "positron" / "anti-electron-neutrino" / "anti-muon" / ...
lepton-normal = "electron" / "electron-neutrino" / "muon" / ...
boson = "photon" / "gluon" / "w-boson" / "z-boson" / "higgs"

hadron-or-jet = hadron-or-jet-normal / hadron-or-jet-anti
hadron-or-jet-anti = "anti-" hadron-or-jet-normal
hadron-or-jet-normal = "proton" / "neutron"

atom = ELEMENT / isotope
isotope = "#" 1*DIGIT ELEMENT

ion = atom charge-postfix
charge-postfix = "^" *DIGIT ("+" / "-")

molecule = 1*(atom *DIGIT) [charge-postfix]

Notes

I have no stake in this discussion (besides my general love for standards), the implementation I'm working on only accepts a subset of species anyways.

This entire discussion might be obsolete because the title of the extension clearly states that it is (purely) a convention. (I'd still argue that even if purely convention a clear definition should be used, so others -- like PICMI -- can use it as a standard; but that's debatable.)

Once the questions here/in the related issues are discussed I'd be willing to join the results into a PR for incorporation into the existing species extension document.

DavidSagan commented 2 years ago

@s9105947 I think your points are good ones. Could you form a PR with all this?

ax3l commented 2 years ago

ABNF Grammar A implementation of the species type extension expects an ascii string and must accept at least expressions based on the rule species-type with the following definition:

A few details: we always mean ASCII at the moment for text/string, defined by the base standard.

I like the formal definition, yet I think the standard is currently easy to read since we go by examples.

If you find a compact way to add the grammar to each existing section as a sub-bullet ABNF grammar:, the same way as we have a sub-bullet type, scope, allowed values and examples then this can be added as a PR :)