Commit Graph
239 Commits
Author SHA1 Message Date
salman e2b83297d0 Merge branch 'fix/scan-reliability' into master
1.6.0: web hardening (traversal fix, watchdog, pruner, archive lock,
caps), scan input validation and RNG freeze, parIRL=1 crash fix,
Electron plot fixes, and Plot menu no-focus crash fix.
2026-10-09 10:40:17 +02:00
salman bd5856a74f Release Workbench 1.6.0 2026-10-09 10:40:17 +02:00
salman 44b639c428 Fix Plot menu crash when the app window has no focus
The native-menu handlers resolved the send target with
BrowserWindow.getFocusedWindow(), which returns null once the OS file
dialog closes and focus does not return to the app window. webContents
was then read off null, throwing 'Cannot read properties of null
(reading webContents)' in the main process and dropping the selected
*.rge paths before they reached plotProfiles/plotFractions. Send to the
window the dialog belongs to (win) instead, fixing Plot Profiles,
Plot Fractions, Plot Mean, Open, Save Folder, Save, and Print.
2026-10-09 10:35:30 +02:00
salman a6f0b28cc5 Fix Electron plotting: expose Plotly as a global
Electron wraps every renderer <script> in its own CommonJS module scope,
so const Plotly = require('plotly.js-dist') stayed module-local and the
bare Plotly references in myplots.js (Plot_xy) and TrimSPlib.js
(Plotly.purge) threw ReferenceError, breaking both the Plot menu popups
and the in-app Plots tab. Export window.Plotly = Plotly, matching the
window.openElectronAuxiliaryWindow pattern already used in the file.
2026-10-08 16:18:11 +02:00
Zaher Salman 04c7c6b144 Record follow-ups from the parIRL / parERC fix
Adds a ToDo section for the three things deliberately left out of 93f0b1c, so
they are not lost:

- startSim() switches to the Results tab and purges the plots before
  runSimulationSequence() validates, so every refused run lands on an empty
  Results tab. Predates this work and affects all abort paths equally.
- scripts/deploy-web.sh only rewrites TRIMSP_BIN in the CGI and does not build,
  so the engine-side fix needs a rebuild and install before it reaches the live
  site. The GUI refusal works immediately, so a deployment can briefly pair the
  friendly GUI message with an engine that still segfaults on a hand-written
  deck.
- The untracked scratch in the tree (SrTiO3_E2000.inp, fortran/Makefile_org,
  fortran/profile*.txt, tests/{pcg32,ranlux,xoshiro}-test/) needs a decision on
  gitignore versus delete; .gitignore covers gmon.out and
  fortran/trimspNL-profile but not these.
2026-09-26 19:06:51 +02:00
Zaher Salman 93f0b1c4d5 Fix parIRL=1 crash: zero recoil cutoff makes the cascade diverge
parIRL=1 crashed the engine with SIGSEGV (CGI exitCode 139) at both GUI
defaults, so the sputtering path has never actually worked.

The first diagnosis blamed KO(600,MAXNL5,2) being shallower than the
2000-wide recoil lists. That is wrong: enlarging KO to 2000 does not help,
because the cascade overruns all of them. The real cause is parERC=0, which
is the GUI default and what tests/Si_1layer/Si_1layer_E19000.inp carries. The
primary knock-on test is IF(DEN(IV).LE.ERC) GO TO 6, so with no cutoff every
atom receiving any energy is respawned as a recoil on each cascade
generation; the branching ratio exceeds one and NREC1/NREC2 grow
geometrically (81, 153, 269, 455, 773, 1317, ...) instead of draining, so the
list-2/list-1 loop at label 83 never terminates. Forcing a real cutoff
converges, with a peak depth of only 103, so KO was left at 600.

fortran/trimspNL.F:
- Refuse parIRL>=1 with parERC<=0 after readGuiInput, before any transport
  work, with a message naming the field to change.
- The IF(NREC2.GT.2000) guard now stops non-zero instead of falling through
  into the out-of-bounds write loop, so any future non-convergent cascade
  fails cleanly instead of corrupting memory.

TrimSPlib.js / TrimSP.html, so this is caught before the engine is invoked:
- handleRecoilModeChange, wired to the parIRL widget, fills parERC with
  TRIMSP_MIN_RECOIL_CUTOFF = 0.02 when recoils are switched on with a cutoff
  of 0, and says so.
- A pre-run check refuses the run if the user then insists on parIRL=1 with
  parERC=0, reporting via the status bar and a transient warning and focusing
  parERC. Deliberately not wired to parERC, so retyping the cutoff is what
  insisting means and is not silently overridden; this also covers shared
  config links, which assign widget values directly.
- The parIRL tooltip documents the requirement.

Tests: tests/recoil-cutoff-test.js (12 cases) lifts the shipped cutoff code
out of TrimSPlib.js and runs it against a document stub. Verified against a
fresh build: parERC=0/parIRL=1 now exits 1 with the new message instead of
139, parERC=0.02 completes with parIRL=0 or 1, and parERC=0/parIRL=0 output
is unchanged (.rge byte-identical). tests/cgi-tests.sh 18/18.
2026-09-26 18:55:38 +02:00
salman 32a108734a Add validation limits 2026-09-26 17:06:09 +02:00
salman 2e01232afd Exclude the archive lock marker from the downloaded results archive 2026-09-26 16:38:35 +02:00
salman 5a8bd70957 Harden singleTrimSP.cgi: traversal fix, watchdog, pruner, archive lock, caps
- P0 path-traversal fix: run-name class is dot-free with \z anchors, so
  '.', '..', and %0A-trailing values can never escape TRIMSP_TMPROOT. The
  deployed path allowlist is derived from the configured root instead of the
  old hardcoded /tmp prefix.
- Replacing external  with an alarm() watchdog that kills the
  engine's whole process group (setpgrp + kill KILL -pid), matching
  muSRFlow; describe_result maps -2/-1/signal to 124/127/128+sig.
- prune_stale_jobs() ages out dirs (TrimSP.cfg marker only), orphaned .tgz,
  and leaked per-request logs; safe in shared /tmp (symlinks skipped,
  remove_tree safe mode, never touches non-trimsp dirs).
- Archive is serialized per run with flock (.trimsp-lock); per-point engine
  runs stay concurrent.
- Symlink/non-dir run dirs refused; mode 0700 so results are not
  world-readable. read/download also reject symlinked targets.
- Request caps: MAX_REQUEST_LINES 20000, MAX_REQUEST_BYTES 4 MiB -> 413.
- action=health deployment self-check; env overrides TRIMSP_BIN, TMPROOT,
  CMD_TIMEOUT, JOB_MAXAGE (sed anchor for the binary path kept intact).
- Wire contract preserved: ok/phase/message/exitCode/archiveUrl/log JSON,
  text read, gzip download, real HTTP statuses. No TrimSPweb.js change.
- New tests/cgi-tests.sh drives the real CGI offline (18 cases: traversal,
  %0A, escaping round-trip, success/fail/hang engine, 124 watchdog, archive+-
  download, pruner, symlink refusal, 413). deploy-web.sh now verifies the
  sed substitution embedded the selected engine path.
2026-09-26 16:32:38 +02:00
salman 9d88fa5d65 Harden the scan pipeline: input validation, RNG freeze, and re-entrancy guard
- Expand From/Step/To scans count-based so descending (negative-step)
  scans work, reject zero/unreachable ranges, and cap points at 5000
- Give parse_formula an unbalanced-bracket guard instead of an infinite
  loop and use direct recursion
- Return {ok:false,error} from CreateInpFile and validate projectile,
  layer composition, density, and thickness instead of the erroneous
  ErrMsg/$ErrMsg path
- Freeze the RNG backend after prep_cfg refreshes All and pass it through
  writeAsciiFileAsync so scans never mix generators mid-flight
- Wrap startSequence with a run-in-progress guard, disable the Run button,
  and snapshot runWorkPath for all output writes
- Unify web/Electron readAsciiFileAsync to throw instead of returning 0
- Make checkDir synchronous (mkdirSync) and honor its return value
- Fix setValues/template substitution parsing and write web input files
  byte-identical to Electron
- Track deferred seed-validation and input-cap work in ToDo.txt
2026-09-26 16:08:44 +02:00
salman 0ad68e1e57 Exclude build-id links from rpm to avoid electron conflicts
Two Electron applications built from the identical electron binary set
package the same ELF build-id links under /usr/lib/.build-id, so
installing trimsp next to musrflow failed the transaction test. Define
_build_id_links none in the rpm spec so the package no longer claims
those paths, regardless of the el9 build host.
2026-09-24 14:46:48 +02:00
salman 737666cea7 Make cgi non-blocking and borrow more ideas from muSRFlow 2026-09-18 23:06:01 +02:00
salman 0f7ca5d7a7 Merge branch 'feature/ui-modernization' into master 2026-09-06 21:37:50 +02:00
salman 46dc388a56 Add Workbench citation, gitea link, and Quick Start contact 2026-09-06 21:37:27 +02:00
salman 64736e7520 Correct web application URL casing 2026-08-28 16:14:15 +02:00
salman 6a33f04a67 Fix shared link URL and notification placement 2026-08-28 16:13:56 +02:00
salman 3b34ce3175 Hide web-only status actions in Electron 2026-08-28 16:05:58 +02:00
salman 4236f9450a Release Workbench 1.5.0 with sharing help 2026-08-28 15:04:02 +02:00
salman 8792ed3541 Upgrade Electron and Forge tooling 2026-08-28 14:41:32 +02:00
salman 74cf36eeac Modernize application icon 2026-08-27 22:00:45 +02:00
salman 8061f389fe Improve web results and diagnostics 2026-08-27 21:42:31 +02:00
salman 1f6ecc7982 Modernize scan workflow and web deployment 2026-08-27 19:24:27 +02:00
salman 65aeddd0ef Modernize application layout 2026-08-27 17:25:33 +02:00
salman 19b9eacf53 Fixed small final bug. v1.4.0 2026-08-27 15:22:15 +02:00
salman aa82948bbd Updated software links and version. 2026-08-27 15:09:24 +02:00
salman 8700fd3a85 Add README for tests 2026-08-27 15:07:36 +02:00
salman 5ccfe34f31 Added changelog 2026-08-27 15:06:01 +02:00
salman 66fc296eca Add citation file 2026-08-27 15:04:29 +02:00
salman cae1271788 Update names following the modernized version and associated paper. 2026-08-14 16:03:27 +02:00
salman dffbd1f6ea Adapt the web backend for the rng selection. 2026-06-25 23:53:10 +02:00
salman e54a8e4f6d Bump up version with rng features. Include citation instructions. 2026-06-25 09:50:42 +02:00
salman d4cdb1dd65 Expose RNG selcetion from GUI 2026-06-25 09:42:41 +02:00
salman a19dd6b96b Tests from pcg32, twice as fast and almost the same as the original ranlux. 2026-06-19 18:20:56 +02:00
Zaher Salman c721259556 Forgottent seeded pcg32 2026-06-19 17:14:53 +02:00
Zaher Salman a44db47586 Add pcg32 and xoshiro as optional number generators to get 2X speedup. 2026-06-19 17:03:40 +02:00
salman b713740f02 Merged master into fortran-cleanup 2026-06-18 13:13:20 +00:00
salman e292afff59 Add comments to subroutines. 2026-06-18 15:12:34 +02:00
salman 965cc556e2 Keep a copy of version 1.3.2 2026-06-18 15:10:46 +02:00
salman 1f3fd44f98 style-cleaned the extracted input reader. 2026-06-18 15:07:16 +02:00
salman d075ce5cee Modernise style 2026-06-18 14:58:25 +02:00
salman c201d83604 Extract the final transmission matrix / energy-angular correlation section 2026-06-18 14:08:16 +02:00
salman e90cab41d5 Extract the backscattering matrix / energy-angular correlation block. 2026-06-18 13:29:17 +02:00
salman 8eb8d07a46 Extract the forward/transmission sputtering matrix / energy-angle correlation block. 2026-06-18 13:04:23 +02:00
salman d76d40ea4c Extract the backward sputtering matrix / energy-angle correlation block. 2026-06-18 11:54:52 +02:00
salman 97dc213bbf Extract the matrix table axis setup block 2026-06-18 11:51:19 +02:00
salman 82e656e1cd Extract the transmission sputtering angular-distribution block 2026-06-18 11:39:52 +02:00
salman aa56bad442 Extract the transmission sputtering yields and energies block 2026-06-18 11:35:49 +02:00
salman 9369266988 Extract the backward sputtering angular-distribution block 2026-06-18 11:30:55 +02:00
salman 1ded610f99 Extract the backward sputtering yields and energies 2026-06-18 11:23:27 +02:00
salman 8a6ead44a4 Extract the transmission report block 2026-06-18 11:13:59 +02:00