FLUKA for VS Code
Language support for FLUKA Monte Carlo particle-transport
input (.inp) files: syntax highlighting, fixed-column diagnostics, hover
documentation, completion and quick fixes.
FLUKA input is a fixed-column format — every command card lays its fields out
in exact 80-column positions, and a stray tab or a value in the wrong column
silently changes the run. This extension helps you keep that layout correct and
understand each card without leaving the editor.
Unofficial, community-maintained tooling. Not affiliated with or endorsed by
the FLUKA collaboration or CERN. Card documentation is summarised from the
public FLUKA manual.
Features
Syntax highlighting — command cards, comments (* lines and in-line !),
numeric WHAT fields, the SDUM string, predefined materials, the
GEOBEGIN…GEOEND geometry block (body types and region operators) and input
preprocessor directives.
Diagnostics — flags what FLUKA cannot read or silently ignores:
- tab characters and lines whose content runs past column 80;
- a non-blank columns 9-10 separator;
- card-name typos (suggested via nearest match);
- per-card value rules (type, sign, range, enumerated SDUM/codes, required
fields) for 50+ cards, including mode-dependent rules that change with a
card's SDUM or a selector WHAT;
- cards FLUKA documents but does not implement (
NOT IMPLEMENTED YET).
Validation is deliberately conservative: a rule is encoded only when the
manual is unambiguous, so valid input is not flagged. Free-format regions
(a FREE card, or GLOBAL requesting free format) are skipped.
Hover — the manual's description, a usage skeleton and a per-parameter
breakdown when the cursor is on a card name, including what each field accepts
(its option set, valid codes, the name catalogues it draws from, whether it is
required).
Completion — two kinds:
- card names, with fixed-column snippet templates for common commands,
offered only in the card-name field (not inside geometry bodies or after
TITLE);
- field values, offered while the cursor sits in a WHAT or SDUM field that
takes a name: beam particles (
PROTON, MUON+, …), scored quantities
(ENERGY, DOSE-EQ, SI1MEVNE, …), pre-defined materials (BERYLLIU,
WATER, …), enumerated SDUM options and valid numeric codes — each shown
with its FLUKA code and the manual's description. The region names and
materials your own input defines are collected from the file and offered
first. The list is mode-aware (a track-length USRBIN never offers a
point-wise-only quantity) and insertion is width-preserving (a longer name
absorbs the field's padding instead of pushing SDUM out of column 71).
Catalogue values are harvested from the manual's own tables (Sections 5.1, 5.2).
Quick fixes — column-safe edits: correct a typo, pick a valid SDUM/code,
fix sign/integer/range, clear an unused field, add a missing paired card, fix
the columns 9-10 separator, replace tabs, truncate over-long lines. Value
edits rewrite the whole 10-column field so downstream fields stay aligned.
Getting started
- Install the extension (from a packaged
.vsix: code --install-extension fluka-vscode-<version>.vsix).
- Open any
.inp file, or set the language mode to FLUKA.
The fixed-column ruler is your friend — column 1-8 card name, 9-10 blank, six
10-column WHAT fields (11-70), then the SDUM string (71-80).
Development
npm install
npm run compile # type-check / build to out/
npm run test:unit # run all unit + e2e tests in plain Node
npm run gen:constraints # regenerate resources/fluka-constraints.json from TS source
npm run gen:docs # regenerate resources/fluka-cards.json from FLUKA_Manual.txt
npm run gen:values # regenerate resources/fluka-values.json from FLUKA_Manual.txt
The analysis layers are pure (no vscode import) so they can be unit-tested in
plain Node; thin adapters wire them to the VS Code API. Card rules are authored
as typed data in src/data/flukaConstraintData.ts and card docs are parsed from
FLUKA_Manual.txt; both are serialised to JSON in resources/ at build time.
Run npm run gen:* after changing either — a parity test fails if the shipped
JSON is stale.
License
MIT.
| |