Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
667 lines (630 loc) · 49.1 KB
/
Copy pathindex.html
File metadata and controls
667 lines (630 loc) · 49.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Brutus-Powder Indexing</title>
<!-- Single-source application version -->
<script src="js/core/version.js"></script>
<!-- Vendor libraries (bundled locally; no CDN dependencies) -->
<script type="application/x-brutus" src="vendor/chart.umd.js"></script>
<script type="application/x-brutus" src="vendor/hammer.min.js"></script>
<script type="application/x-brutus" src="vendor/chartjs-plugin-zoom.min.js"></script>
<script type="application/x-brutus" src="vendor/jspdf.umd.min.js"></script>
<!-- Crystallography: the same files run in both workers, which load them
through js/crystallography/manifest.js. Keep the two lists in step
(check_load_order.mjs compares them). -->
<script type="application/x-brutus" src="js/crystallography/limits.js"></script>
<script type="application/x-brutus" src="js/crystallography/metric.js"></script>
<script type="application/x-brutus" src="js/crystallography/hkl.js"></script>
<script type="application/x-brutus" src="js/crystallography/cell.js"></script>
<script type="application/x-brutus" src="js/crystallography/fit.js"></script>
<script type="application/x-brutus" src="js/crystallography/refine.js"></script>
<script type="application/x-brutus" src="js/crystallography/transforms.js"></script>
<script type="application/x-brutus" src="js/crystallography/monte-carlo.js"></script>
<script type="application/x-brutus" src="js/crystallography/niggli.js"></script>
<script type="application/x-brutus" src="js/crystallography/absences.js"></script>
<script type="application/x-brutus" src="js/crystallography/centering.js"></script>
<script type="application/x-brutus" src="js/crystallography/sg-ranking.js"></script>
<script type="application/x-brutus" src="js/crystallography/swap-search.js"></script>
<script type="application/x-brutus" src="js/crystallography/sg-ops.js"></script>
<script type="application/x-brutus" src="js/crystallography/sg-context.js"></script>
<script type="application/x-brutus" src="js/crystallography/sg-score.js"></script>
<!-- GPU engine and setup -->
<script type="application/x-brutus" src="js/gpu/webgpu-engine.js"></script>
<!-- Core utilities, UI bindings, and application state -->
<script type="application/x-brutus" src="js/core/utils.js"></script>
<script type="application/x-brutus" src="js/core/ui.js"></script>
<script type="application/x-brutus" src="js/core/state.js"></script>
<script type="application/x-brutus" src="js/core/inputs.js"></script>
<script type="application/x-brutus" src="js/core/sg-database.js"></script>
<script type="application/x-brutus" src="js/gpu/gpu-setup.js"></script>
<script type="application/x-brutus" src="js/gpu/gpu-limits.js"></script>
<!-- Data, wavelength, and diffraction pattern parsers -->
<script type="application/x-brutus" src="js/data/wavelength.js"></script>
<script type="application/x-brutus" src="js/data/session.js"></script>
<script type="application/x-brutus" src="js/data/kalpha2-strip.js"></script>
<script type="application/x-brutus" src="js/data/export.js"></script>
<script type="application/x-brutus" src="js/parsers/fullprof.js"></script>
<script type="application/x-brutus" src="js/parsers/generic.js"></script>
<script type="application/x-brutus" src="js/parsers/xml-utils.js"></script>
<script type="application/x-brutus" src="js/parsers/bruker-xml.js"></script>
<script type="application/x-brutus" src="js/parsers/xrdml.js"></script>
<script type="application/x-brutus" src="js/parsers/rigaku-ras.js"></script>
<script type="application/x-brutus" src="js/parsers/gsas.js"></script>
<script type="application/x-brutus" src="js/parsers/uxd.js"></script>
<script type="application/x-brutus" src="js/parsers/philips-udf.js"></script>
<script type="application/x-brutus" src="js/parsers/pdcif.js"></script>
<script type="application/x-brutus" src="js/parsers/detect.js"></script>
<script type="application/x-brutus" src="js/data/file-load.js"></script>
<!-- Peak detection and controls -->
<script type="application/x-brutus" src="js/peaks/peak-controls.js"></script>
<script type="application/x-brutus" src="js/peaks/peak-finder.js"></script>
<script type="application/x-brutus" src="js/peaks/peak-table.js"></script>
<!-- Indexing pipeline and solution management -->
<script type="application/x-brutus" src="js/indexing/solutions.js"></script>
<script type="application/x-brutus" src="js/indexing/worker-pool.js"></script>
<script type="application/x-brutus" src="js/indexing/diagnostics.js"></script>
<script type="application/x-brutus" src="js/indexing/run.js"></script>
<!-- Charting and interactive overlays -->
<script type="application/x-brutus" src="js/chart/axes.js"></script>
<script type="application/x-brutus" src="js/chart/chart.js"></script>
<script type="application/x-brutus" src="js/chart/interaction.js"></script>
<script type="application/x-brutus" src="js/chart/manual-space-group.js"></script>
<!-- Subgroup conversion, dialogs, and reporting -->
<script type="application/x-brutus" src="js/convert/sg_subgroups.js"></script>
<script type="application/x-brutus" src="js/convert/sg_convert.js"></script>
<script type="application/x-brutus" src="js/dialogs/context-menu.js"></script>
<script type="application/x-brutus" src="js/dialogs/refine-mc.js"></script>
<script type="application/x-brutus" src="js/dialogs/space-group-mc.js"></script>
<script type="application/x-brutus" src="js/dialogs/convert.js"></script>
<script type="application/x-brutus" src="js/report/pdcif-export.js"></script>
<script type="application/x-brutus" src="js/report/pdf-report.js"></script>
<!-- Workspace persistence, shell, and startup -->
<script type="application/x-brutus" src="js/core/workspace.js"></script>
<script type="application/x-brutus" src="js/core/shell.js"></script>
<script type="application/x-brutus" src="js/main.js"></script>
<!-- Sequential versioned script loader: appends ?v=<APP_VERSION> from js/core/version.js
to every script above so the page, workers, shaders, and space-group file share
one cache-busting version string. -->
<script>
document.addEventListener('DOMContentLoaded', () => {
const query = typeof APP_VERSION_QS === 'string' ? APP_VERSION_QS : '';
// A script that fails to load, or throws while it loads, used to leave a
// page that looked normal and was half dead (the scripts after it abort
// one by one). Say so, in plain markup that depends on no app code.
const problems = [];
const bootProblem = (what) => {
if (!problems.includes(what)) problems.push(what);
let banner = document.getElementById('boot-error');
if (!banner) {
banner = document.createElement('div');
banner.id = 'boot-error';
banner.setAttribute('role', 'alert');
banner.style.cssText = 'position:fixed;top:0;left:0;right:0;z-index:99999;padding:8px 14px;' +
'background:#b91c1c;color:#fff;font:14px/1.4 system-ui,sans-serif';
document.body.appendChild(banner);
}
banner.textContent = 'Brutus did not load completely: ' + problems.join('; ') +
'. Reload with Ctrl+F5. If this stays, a file is missing or blocked.';
};
const onBootError = (e) => {
const where = e && e.filename ? ' (' + String(e.filename).split('/').pop().split('?')[0] + ')' : '';
bootProblem('error while starting' + where + ': ' + (e && e.message ? e.message : 'unknown'));
};
window.addEventListener('error', onBootError);
const tags = document.querySelectorAll('script[type="application/x-brutus"]');
tags.forEach((tag, i) => {
const src = tag.getAttribute('src');
const script = document.createElement('script');
script.src = src + query;
script.async = false;
script.onerror = () => bootProblem('could not load ' + src);
// Start-up is over once the last script has run (or failed).
if (i === tags.length - 1) {
const done = () => window.removeEventListener('error', onBootError);
script.addEventListener('load', done);
script.addEventListener('error', done);
}
document.body.appendChild(script);
});
}, { once: true });
</script>
<link href="css/inter-font.css" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/workspace.css">
<link rel="stylesheet" href="css/dialogs.css">
</head>
<body class="app-shell">
<header class="workspace-header">
<span class="workspace-brand">Brutus</span>
<button type="button" id="btn-about" class="hbtn" title="About Brutus" aria-pressed="false">About</button>
<button type="button" id="help-guide" class="hbtn" title="Open the technical guide in a new tab">Help</button>
<button type="button" id="swap-panels" class="hbtn" title="Swap the controls and results panels" aria-pressed="false">⇄ Panels</button>
<nav class="menubar" aria-label="Main menu">
<details id="file-menu" class="workspace-menu"><summary>File</summary><div id="file-menu-items" class="menu-items">
<button id="load-file-button" type="button">Load pattern…</button>
<button id="save-as-button" type="button" disabled>Export pattern…</button>
<hr>
<button id="open-project" type="button">Open project…</button>
<button id="save-project" type="button">Save project…</button>
<hr>
<button id="menu-unload" type="button">Unload pattern</button>
</div></details>
<details id="solution-menu" class="workspace-menu"><summary>Solution</summary><div class="menu-items">
<button type="button" data-sol-action="refine" disabled>Refine</button>
<button type="button" data-sol-action="test-sg" disabled>Test Space Group</button>
<button type="button" data-sol-action="convert" disabled>Convert…</button>
<button type="button" data-sol-action="explore" disabled>Explore Space Group…</button>
<button type="button" data-sol-action="pdcif" disabled>Export pdCIF</button>
<button type="button" data-sol-action="report" disabled>Report PDF</button>
<hr>
<button type="button" data-sol-action="erase" disabled>Erase</button>
</div></details>
</nav>
<button type="button" id="hb-report" class="hbtn" title="Generate the PDF report" disabled>Report</button>
<button type="button" id="hb-run" class="fit-btn" title="Start the indexing search" disabled>▶ Index</button>
<label class="theme-switch"><input id="theme-toggle" type="checkbox" role="switch"><span class="track" aria-hidden="true"><i></i></span><span>Dark</span></label>
</header>
<input id="project-input" type="file" accept=".brutus,.json" hidden>
<div id="progress-bar-container" class="hidden" role="progressbar" aria-label="Indexing progress" aria-valuemin="0" aria-valuemax="100"><div id="progress-bar"></div></div>
<div id="app-container">
<div id="controls-panel">
<!-- Save-as format menu -->
<div id="save-menu-overlay">
<div id="save-menu-modal" role="dialog" aria-modal="true" aria-labelledby="save-menu-title" aria-describedby="save-menu-description" tabindex="-1">
<h3 id="save-menu-title">Save data as</h3>
<p id="save-menu-description" class="save-sub">Choose a format, then pick the folder and file name in the save dialog.</p>
<label class="save-field">
Format
<select id="save-format-select">
<option value="xy">XY — 2θ intensity (.xy)</option>
<option value="csv">CSV — 2θ,intensity (.csv)</option>
<option value="dat">DAT — whitespace 2 columns (.dat)</option>
<option value="xrdml">Panalytical XRDML (.xrdml)</option>
<option value="brukerxml">Bruker RawData XML (.xml)</option>
<option value="uxd">Bruker UXD (.uxd)</option>
<option value="gsas">GSAS ESD (.esd)</option>
</select>
</label>
<div id="save-menu-msg" role="status" aria-live="polite"></div>
<div id="save-menu-buttons">
<button id="save-menu-cancel" class="btn btn-secondary">Cancel</button>
<button id="save-menu-confirm" class="btn btn-primary">Save</button>
</div>
</div>
</div>
<!-- General notice / confirmation (large report, large history) -->
<div id="notice-overlay">
<div id="notice-modal" role="alertdialog" aria-modal="true" aria-labelledby="notice-title" aria-describedby="notice-text">
<h3 id="notice-title"></h3>
<p id="notice-text" class="save-sub"></p>
<div id="notice-buttons">
<button id="notice-cancel" class="btn btn-secondary">Cancel</button>
<button id="notice-confirm" class="btn btn-primary">OK</button>
</div>
</div>
</div>
<div id="unload-overlay">
<div id="unload-modal" role="dialog" aria-modal="true" aria-labelledby="unload-title">
<h3 id="unload-title">Unload file</h3>
<p class="save-sub">This clears the session and returns Brutus to its opening state. It cannot be undone.</p>
<p id="unload-file"></p>
<ul id="unload-losses"></ul>
<div id="unload-buttons">
<button id="unload-cancel" class="btn btn-secondary">Cancel</button>
<button id="unload-confirm" class="btn btn-primary">Unload</button>
</div>
</div>
</div>
<div class="tab-buttons" role="tablist" aria-label="Workflow steps">
<button class="tab-btn active" role="tab" aria-selected="true" aria-controls="data-tab-content" data-tab="data" title="Pattern and radiation">Data</button>
<button class="tab-btn" role="tab" aria-selected="false" aria-controls="peaks-tab-content" data-tab="peaks" title="Background and peak positions">Peaks</button>
<button class="tab-btn" role="tab" aria-selected="false" aria-controls="parameters-tab-content" data-tab="parameters" title="Search limits and crystal systems">Indexing</button>
<button class="tab-btn" role="tab" aria-selected="false" aria-controls="solutions-tab-content" data-tab="solutions" title="Candidate cells and space groups">
Solutions
<span id="solutions-led" class="led-indicator gray" role="img" aria-label="No solutions yet"></span>
</button>
</div>
<div class="tab-content-panels">
<div id="data-tab-content" class="tab-content-panel active" role="tabpanel">
<div class="control-group full-width">
<h3 class="section-title">Pattern</h3>
<input type="file" id="file-input" class="hidden" accept=".xy,.csv,.txt,.dat,.asc,.prn,.xrdml,.xml,.brml,.ras,.esd,.std,.udf,.uxd,.xra,.gsa,.cif">
<details id="file-meta-acc" class="meta-acc is-empty"><summary id="file-meta-name" title="">No file loaded</summary><div class="sol-body"><dl id="file-meta" class="meta-dl"></dl></div></details>
</div>
<div class="control-group full-width">
<h3 class="section-title">2θ range</h3>
<div class="slider-group has-entry">
<label for="tth-min-slider" class="control-label">2θ Min</label>
<div class="slider-value-track">
<input type="range" id="tth-min-slider" class="custom-slider" disabled>
<span id="tth-min-value" class="slider-value-display">-</span>
</div>
<input type="text" inputmode="decimal" autocomplete="off" spellcheck="false" class="control-input tth-entry" data-tth-entry="min" step="0.01" aria-label="2θ minimum (°)" title="Type the lower 2θ limit of the range used" disabled>
</div>
<div class="slider-group has-entry">
<label for="tth-max-slider" class="control-label">2θ Max</label>
<div class="slider-value-track">
<input type="range" id="tth-max-slider" class="custom-slider" disabled>
<span id="tth-max-value" class="slider-value-display">-</span>
</div>
<input type="text" inputmode="decimal" autocomplete="off" spellcheck="false" class="control-input tth-entry" data-tth-entry="max" step="0.01" aria-label="2θ maximum (°)" title="Type the upper 2θ limit of the range used" disabled>
</div>
</div>
<div class="control-group full-width">
<h3 class="section-title">Radiation</h3>
<div class="parameter-grid">
<div>
<label for="wavelength-preset" class="control-label" title="Kα (average): an unresolved or partly resolved Kα1/Kα2 doublet, as a laboratory tube without a monochromator gives. Kα1: monochromated radiation, or a pattern already stripped of Kα2.">Radiation Preset</label>
<select id="wavelength-preset" class="control-select">
<option value="Cu_ka1">Cu Kα₁</option>
<option value="Cu_avg" selected>Cu Kα (average)</option>
<option value="Co_ka1">Co Kα₁</option>
<option value="Co_avg">Co Kα (average)</option>
<option value="Fe_ka1">Fe Kα₁</option>
<option value="Fe_avg">Fe Kα (average)</option>
<option value="Mo_ka1">Mo Kα₁</option>
<option value="Mo_avg">Mo Kα (average)</option>
<option value="Ag_ka1">Ag Kα₁</option>
<option value="Ag_avg">Ag Kα (average)</option>
<option value="Cr_ka1">Cr Kα₁</option>
<option value="Cr_avg">Cr Kα (average)</option>
<option value="custom">Custom (Monochromatic)</option>
</select>
</div>
<div>
<label for="wavelength" class="control-label">Wavelength (Å)</label>
<input type="text" inputmode="decimal" autocomplete="off" spellcheck="false" id="wavelength" class="control-input">
</div>
</div>
<label class="checkbox-label" style="margin-top: 1rem; margin-bottom: 0.5rem;">
<input type="checkbox" id="strip-ka2-checkbox">
<span>Strip Kα₂</span> </label>
</div>
</div>
<div id="peaks-tab-content" class="tab-content-panel" role="tabpanel">
<div class="control-group" style="width: 100%; flex-grow: 1; display: flex; flex-direction: column;">
<div id="peak-controls" class="hidden" style="display: flex; flex-direction: column; flex-grow: 1;">
<h3 class="section-title">Peak search</h3>
<div class="slider-group">
<label for="peak-threshold-slider" class="control-label" title="Smallest peak kept, as a percentage of the strongest peak above the background.">Min peak (%)</label>
<div class="slider-value-track">
<input type="range" id="peak-threshold-slider" class="custom-slider">
<span id="peak-threshold-value" class="slider-value-display">2.0</span>
</div>
</div>
<div class="slider-group">
<label for="peak-prominence-slider" class="control-label" title="Rejects a maximum unless the valley beside it drops by at least this fraction of its own height. A fully resolved peak scores near 100%, an unresolved shoulder about 50%, a noise spike on a flank about 25%. Unlike a minimum-separation rule this keeps genuinely resolved close reflections. 0 disables the test.">Prominence (%)</label>
<div class="slider-value-track">
<input type="range" id="peak-prominence-slider" class="custom-slider">
<span id="peak-prominence-value" class="slider-value-display">25</span>
</div>
</div>
<div class="slider-group">
<label for="ball-radius-slider" class="control-label" title="Rolling-ball background window, expressed in reciprocal space (Q = 4πsinθ/λ). Independent of the scan step, so the same value gives the same background on data measured at any resolution.">Bkg radius (Å⁻¹)</label>
<div class="slider-value-track">
<input type="range" id="ball-radius-slider" class="custom-slider">
<span id="ball-radius-value" class="slider-value-display">0.100</span>
</div>
</div>
<div class="slider-group">
<label for="smoothing-width-slider" class="control-label" title="Moving-average half-width applied before the rolling-ball erosion, in reciprocal space (Q = 4πsinθ/λ). Same units as Radius, so the two are directly comparable: keep this well below Radius or the smoothing erodes the peaks. 0 disables smoothing.">Smoothing (Å⁻¹)</label>
<div class="slider-value-track">
<input type="range" id="smoothing-width-slider" class="custom-slider">
<span id="smoothing-width-value" class="slider-value-display">0.010</span>
</div>
</div>
<div id="peak-table-container" class="hidden" style="flex-grow: 1; min-height: 0;">
<div id="ka2-warning-banner" class="ka2-warning-banner" style="display:none;"></div>
<table class="peak-table">
<thead><tr><th>#</th><th>2θ Obs (°)</th><th>d (Å)</th><th><span class="visually-hidden">Delete</span></th></tr></thead>
<tbody id="peak-list-body"></tbody>
</table>
</div>
</div>
</div>
</div>
<div id="parameters-tab-content" class="tab-content-panel" role="tabpanel">
<div class="control-group full-width">
<h3 class="section-title">Search limits</h3>
<div class="parameter-grid">
<div>
<label for="max-volume" class="control-label" title="Largest cell volume accepted. Keep it chemically sensible: a large enough cell indexes any list of peaks.">Max Volume (ų)</label>
<input type="number" id="max-volume" class="control-input">
</div>
<div>
<label for="impurity-peaks" class="control-label" title="How many peaks a cell may leave unindexed (0 to 3). Use 0 for a clean, single-phase peak list.">Impurity Peaks</label>
<input type="number" id="impurity-peaks" class="control-input">
</div>
</div>
<div class="parameter-grid" style="margin-top: 1rem; align-items: end;">
<div>
<label for="tth-error" class="control-label" title="Tolerance on a peak position, in degrees 2θ: a calculated line indexes a peak when it lies within this distance of it. About 0.02° for synchrotron data, 0.04–0.05° for a laboratory instrument.">2θ Error (°)</label>
<input type="text" inputmode="decimal" autocomplete="off" spellcheck="false" id="tth-error" class="control-input">
</div>
<label class="checkbox-label" style="padding-bottom: 0.5rem;" title="Fit the zero-point error of the 2θ scale together with the cell.">
<input type="checkbox" id="refine-zero-checkbox" checked>
<span>Refine Zero Error</span>
</label>
</div>
</div>
<div class="control-group" style="width: 100%;">
<h3 class="section-title">Crystal systems</h3>
<div id="indexing-controls" class="hidden">
<p class="control-label" style="margin-bottom: 0.5rem;" title="Every checked system is searched on the GPU, one after the other, highest symmetry first: cubic, hexagonal, tetragonal, orthorhombic, monoclinic, triclinic. Rhombohedral (R) lattices are found by the hexagonal search, in hexagonal axes. Without WebGPU, cubic, tetragonal and hexagonal fall back to the CPU.">Systems to search</p>
<!-- Left column: one or two unknowns; right column: three or more.
Triclinic is off by default (rare, and by far the slowest).
Rhombohedral lattices are found by the hexagonal search. -->
<div class="parameter-grid">
<label class="checkbox-label system-gpu"><input type="checkbox" class="system-checkbox" value="cubic" checked> <span>Cubic</span></label>
<label class="checkbox-label system-gpu"><input type="checkbox" class="system-checkbox" value="orthorhombic" checked> <span>Orthorhombic</span></label>
<label class="checkbox-label system-gpu"><input type="checkbox" class="system-checkbox" value="hexagonal" checked> <span>Hexagonal</span></label>
<label class="checkbox-label system-gpu"><input type="checkbox" class="system-checkbox" value="monoclinic" checked> <span>Monoclinic</span></label>
<label class="checkbox-label system-gpu"><input type="checkbox" class="system-checkbox" value="tetragonal" checked> <span>Tetragonal</span></label>
<label class="checkbox-label system-gpu"><input type="checkbox" class="system-checkbox" value="triclinic"> <span>Triclinic</span></label>
</div>
<p id="gpu-note" class="hint gpu-note" hidden>WebGPU is not available in this browser: orthorhombic, monoclinic and triclinic are disabled, and cubic, tetragonal and hexagonal run on the CPU. See Help for how to enable it.</p>
<div id="gpu-params-container" class="control-group hidden" style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--light-bg);">
<p class="control-label" style="margin-bottom: 1rem;">GPU Search Parameters (all systems):</p>
<div class="parameter-grid">
<div>
<!-- Percent of each system's maximum usable basis (hklBasisMax
in js/gpu/gpu-setup.js), PER UNKNOWN cell parameter:
at 5, cubic uses 5%, hexagonal 10%, orthorhombic 15%,
monoclinic 20%, triclinic 30%. -->
<label for="gpu-hkl-percent" class="control-label" title="HKL basis searched, in percent of each system's maximum, per unknown cell parameter. The search basis is (number of unknowns) x this value %: at 5, tetragonal/hexagonal 10%, orthorhombic 15%, monoclinic 20%, triclinic 30%. Cubic always searches its whole list (752 hkl), which costs next to nothing. Typical range 2 to 12.">HKL Basis (% / unknown)</label>
<input type="text" inputmode="decimal" autocomplete="off" spellcheck="false" id="gpu-hkl-percent" class="control-input">
</div>
<div>
<label for="gpu-depth" class="control-label" title="Peaks combined per system. Orthorhombic, monoclinic, triclinic: number of unknowns + Depth (Depth 3: 6, 7, 9). Cubic, hexagonal, tetragonal: 3 x (unknowns + Depth), cheap with 1-2 unknowns (Depth 3: 12 and 15). Capped by the number of peaks available.">Depth (extra peaks)</label>
<input type="number" id="gpu-depth" class="control-input">
</div>
</div>
<div class="parameter-grid" style="margin-top: 0.75rem;">
<div>
<label for="gpu-fom-threshold" class="control-label" title="How loosely the GPU pre-filter accepts a trial cell: the mean misfit of the scored peaks, in units of the 2θ error. Lower is stricter (fewer candidates to refine); raise it only if a correct cell is being rejected.">FoM Tolerance</label>
<input type="text" inputmode="decimal" autocomplete="off" spellcheck="false" id="gpu-fom-threshold" class="control-input">
</div>
<div>
<label for="gpu-buffer-size" class="control-label" title="Size of the candidate buffer of each system, in thousands of cells. When it fills, that system's search stops early and is reported as truncated.">Candidate buffer (×1000)</label>
<input type="number" id="gpu-buffer-size" class="control-input">
</div>
</div>
<!-- Per-system plan, filled by updateGpuStatusText() -->
<div id="gpu-plan"></div>
</div>
</div>
</div>
</div>
<div id="solutions-tab-content" class="tab-content-panel" role="tabpanel">
<div class="control-group full-width">
<div class="sol-toolbar">
<label for="solutions-sort" class="control-label">Sort by</label>
<select id="solutions-sort" class="control-select">
<option value="m20:desc" selected>M(20), highest first</option>
<option value="m20:asc">M(20), lowest first</option>
<option value="volume:asc">Volume, smallest first</option>
<option value="volume:desc">Volume, largest first</option>
<option value="system:asc">Crystal system, A to Z</option>
<option value="system:desc">Crystal system, Z to A</option>
</select>
</div>
<div id="solutions-list" class="sol-list"></div>
<div hidden>
<input id="manual-sg-search" type="search" disabled>
<select id="manual-sg-select" disabled><option value="">No manual comparison</option></select>
<p id="manual-sg-status"></p>
<button id="browse-sg" type="button"></button>
</div>
</div>
</div>
</div>
<!-- Legacy controls remain available to the header and status bar. -->
<div hidden>
<p id="status-text"></p>
<div hidden style="display: flex; gap: 0.5rem;">
<button id="start-indexing-button" class="btn btn-primary flex-1" disabled>Find Peaks to Start</button>
<button id="report-button" class="btn btn-secondary flex-1" disabled>Generate PDF Report</button>
</div>
</div>
</div>
<div id="drag-handle"></div>
<div id="results-area">
<nav id="workspace-views" class="panel-tabs" role="tablist" aria-label="Result views"><button type="button" role="tab" id="view-tab-plot" data-view="plot" aria-controls="results-container" aria-selected="true" tabindex="0">Plot</button><button type="button" role="tab" id="view-tab-log" data-view="log" aria-controls="log-view" aria-selected="false" tabindex="-1">Log</button><button type="button" role="tab" id="view-tab-history" data-view="history" aria-controls="history-view" aria-selected="false" tabindex="-1">History</button></nav>
<div id="placeholder" class="placeholder">
<svg xmlns="http://www.w3.org/2000/svg" class="placeholder-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" /></svg>
<h2>Awaiting data</h2>
<p>Load a pattern from File → Load pattern to begin.</p>
</div>
<section id="log-view" class="workspace-view" hidden role="tabpanel" aria-labelledby="view-tab-log" tabindex="0"><ol id="workspace-log"></ol></section>
<section id="history-view" class="workspace-view" hidden role="tabpanel" aria-labelledby="view-tab-history" tabindex="0"><p class="hint">Completed indexing runs. Restore a run to compare its solutions.</p><div id="workspace-history"></div></section>
<section id="about-view" class="workspace-view" hidden aria-label="About">
<article class="about">
<h1>About Brutus</h1>
<p>This program uses a system-specific, exhaustive GPU search to find potential unit cells based on the first 20 peaks. The checked crystal systems are searched one after the other, highest symmetry first; rhombohedral (R) lattices are found by the hexagonal search and reported in hexagonal axes. WebGPU must be available and active in the browser; without it only cubic, tetragonal and hexagonal can be searched (on the CPU).</p>
<p>All trial cells are refined, scored (M(20)), and analyzed for space groups. For a full breakdown, <a href="brutus_help.html" target="_blank" rel="noopener">read the technical guide</a>.</p>
<h2>Supported file formats</h2>
<p>Generic 2-column (2θ, intensity; a “Wavelength” header line is read), .xrdml, Bruker .brml and RawData .xml, .ras, .uxd, .udf, GSAS (.gsa, .esd, .std, .xra), FullProf .dat and pdCIF. Data, raw or Kα<sub>2</sub>-stripped, can be saved in several formats.</p>
<h2>Working with it</h2>
<ol>
<li><b>Data</b>: load a pattern, check the radiation and the 2θ range.</li>
<li><b>Peaks</b>: adjust the background and peak search until the peak list is clean; Ctrl+click on the plot adds a peak.</li>
<li><b>Indexing</b>: set the search limits (maximum volume, 2θ error), choose the crystal systems and the GPU search parameters, then press <b>Index</b> (Esc or the red button stops the search).</li>
<li><b>Solutions</b>: open a solution to see its cell, Niggli cell and space group; the <b>Solution</b> menu refines it, tests its space group, converts it to a sub- or supergroup, explores a space group by hand, or exports a pdCIF.</li>
</ol>
<p class="hint">Projects (File → Save project) are JSON files: pattern, peaks, solutions with their space groups, settings, run history and log.</p>
</article>
</section>
<div id="results-container" role="tabpanel" aria-labelledby="view-tab-plot" tabindex="0" class="plot-pane" style="display: none;">
<div id="chart-toolbar" class="ptools">
<div class="seg" role="group" aria-label="Intensity scale">
<button type="button" data-yscale="linear" aria-pressed="false" title="Linear intensity">Linear</button><button type="button" data-yscale="sqrt" aria-pressed="true" title="Square-root intensity: weak peaks next to strong ones stay visible">√I</button><button type="button" data-yscale="log" aria-pressed="false" title="Logarithmic intensity">log I</button>
</div>
<select id="y-axis-mode" hidden>
<option value="linear">I</option>
<option value="sqrt" selected>√I</option>
<option value="log">log I</option>
</select>
<span class="tool-sep" aria-hidden="true"></span>
<label class="chk" title="Rolling-ball background"><input id="show-background" type="checkbox"><i class="swatch swatch-line" style="--c: var(--plot-bkg)" aria-hidden="true"></i> Background</label>
<label class="chk" title="The experimental pattern"><input id="show-data" type="checkbox" checked><i class="swatch swatch-line" style="--c: var(--plot-data)" aria-hidden="true"></i> Data</label>
<label class="chk" title="Observed peaks: the peak table"><input id="show-exp" type="checkbox" checked><i class="swatch" style="--c: var(--plot-exp)" aria-hidden="true"></i> Peaks</label>
<label class="chk" title="Reflections calculated from the cell of the open solution"><input id="show-sol" type="checkbox" checked><i class="swatch" style="--c: var(--plot-sol)" aria-hidden="true"></i> Cell</label>
<label class="chk" title="Reflections allowed by the space group chosen for the open solution"><input id="show-sim" type="checkbox" checked><i class="swatch" style="--c: var(--plot-sim)" aria-hidden="true"></i> Space group</label>
<span class="tool-sep" aria-hidden="true"></span>
<label class="chk" title="Abscissa. The data itself is never re-measured; only the view changes.">X
<select id="x-axis-mode" class="axis-select">
<option value="tth" selected>2θ (°)</option>
<option value="theta">θ (°)</option>
<option value="d">d (Å)</option>
<option value="q">Q (Å⁻¹)</option>
</select>
</label>
<label class="chk" title="Where Ctrl+click puts a new peak. Hold Shift while clicking to bypass snapping.">Snap
<select id="snap-mode" class="axis-select">
<option value="off" selected>Off</option>
<option value="data">Obs</option>
<option value="hkl">Calc</option>
</select>
</label>
<span class="tool-sep" aria-hidden="true"></span>
<label class="chk" title="A plain click or tap on the plot adds a peak, as Ctrl + click does (for touch screens)"><input id="mode-add-peak" type="checkbox"> Add peak</label>
<label class="chk" title="A plain drag moves the view instead of drawing a zoom box, as Alt + drag does"><input id="mode-pan" type="checkbox"> Pan</label>
<button type="button" id="reset-view" title="Show the whole 2θ range again (also: right-click on the plot)">Reset view</button>
<button type="button" id="save-png">Save PNG</button>
<span class="info-tip">
<button type="button" class="info-btn" aria-label="Mouse controls of the plot" aria-describedby="plot-help">i</button>
<span class="info-pop" id="plot-help" role="tooltip">
<b>Wheel</b><span>zoom; or drag a box to zoom to it</span>
<b>Alt + drag</b><span>pan (or tick Pan)</span>
<b>Right-click</b><span>reset the view (or Reset view)</span>
<b>Ctrl + click</b><span>add a peak at the cursor, or tick Add peak (Shift bypasses snapping)</span>
</span>
</span>
</div>
<div class="plot-host">
<canvas id="xrd-chart"></canvas>
</div>
</div>
</div>
</div>
<div id="status-box" role="status" aria-live="polite" title="Click to dismiss"></div>
<div id="context-menu">
<div id="ctx-erase">Erase Solution</div>
<div id="ctx-mc">Refine</div>
<div id="ctx-sg">Test Space Group</div>
<div id="ctx-pdcif">Export pdCIF</div>
<div id="ctx-report">Generate Report</div>
</div>
<div id="mc-overlay">
<div id="mc-modal" role="dialog" aria-modal="true" aria-labelledby="mc-title" aria-describedby="mc-sub" tabindex="-1">
<h3 id="mc-title">Refine (Monte-Carlo)</h3>
<p id="mc-sub">Monte-Carlo search around the selected cell, constrained to its
crystal system. Zero is refined as an extra parameter when "Refine Zero" is on.
The result is added as a new solution only if it improves M20.</p>
<div id="mc-params">
<label for="mc-iterations">Iterations
<span class="mc-hint">annealing steps per run; the minimum gives the walk time to cool</span>
</label>
<input id="mc-iterations" type="number">
<label for="mc-restarts">Restarts
<span class="mc-hint">independent runs; more restarts = less seed dependence</span>
</label>
<input id="mc-restarts" type="number">
</div>
<div id="mc-msg"></div>
<div id="mc-buttons">
<button id="mc-cancel" class="btn btn-secondary">Cancel</button>
<button id="mc-apply" class="btn btn-primary">Apply</button>
</div>
</div>
</div>
<div id="sg-overlay">
<div id="sg-modal" role="dialog" aria-modal="true" aria-labelledby="sg-title" aria-describedby="sg-sub" tabindex="-1">
<h3 id="sg-title">Test Space Group</h3>
<details id="sg-sub">
<summary>How this table is built and ranked</summary>
<p>Every space group of this crystal system is tried as a hypothesis: its forbidden
reflections are removed from the calculated line list, the cell is re-refined against what is
left, and the evidence is recomputed. Rule sets that produce the <i>same</i> calculated pattern
for this cell, wavelength, range and tolerance cannot be separated by the data, so they share
one row and are labelled by extinction symbol rather than by a representative group.
Ranking is in two tiers. A row with a hard violation the impurity allowance does not cover is
<i>falsified</i> - a single genuine reflection on a forbidden line rules a group out - and can
never outrank a row with none, whatever its score. Falsified rows are shown below, ordered
least-bad first. <b>Score</b> is the log-odds in nats against the leading row <i>of its own
tier</i>: it rewards forbidden lines that are cleanly empty (<b>Clean</b>) and penalises
observed peaks that only a forbidden line explains (<b>Viol</b>, hard count with soft
Ka2/weak/ambiguous ones in brackets) and peaks the refined cell cannot explain at all
(<b>Unidx</b>). Rows within about 2.3 nats of each other are a tie.
<b>M20</b> describes the refined cell only - it rises whenever lines are deleted, so it is not
what ranks the hypotheses, so the table is sorted by Score by default. Click any header to sort
by that column instead, and click it again to reverse. The row leading on Score stays bold
wherever the sort puts it. Select a row to keep its refined cell.</p>
</details>
<div id="sg-params">
<label for="sg-iterations">Iterations
<span class="sg-hint">annealing steps per run</span>
<input id="sg-iterations" type="number">
</label>
<label for="sg-restarts">Restarts
<span class="sg-hint">independent runs per class</span>
<input id="sg-restarts" type="number">
</label>
<label for="sg-top">Refine top classes
<span class="sg-hint">centering, unrestricted and the cleanest class are included</span>
<input id="sg-top" type="number">
</label>
</div>
<div id="sg-table-wrap">
<table id="sg-table">
<thead><tr>
<th tabindex="0" role="columnheader" aria-sort="none" data-sort="label">Class</th><th tabindex="0" role="columnheader" aria-sort="none" data-sort="groups">Space groups</th>
<th tabindex="0" role="columnheader" aria-sort="none" data-sort="lines">Lines</th><th tabindex="0" role="columnheader" aria-sort="none" data-sort="m20">M20</th>
<th tabindex="0" role="columnheader" aria-sort="none" data-sort="score">Score</th><th tabindex="0" role="columnheader" aria-sort="none" data-sort="clean">Clean</th>
<th tabindex="0" role="columnheader" aria-sort="none" data-sort="viol">Viol</th><th tabindex="0" role="columnheader" aria-sort="none" data-sort="unidx">Unidx</th>
<th tabindex="0" role="columnheader" aria-sort="none" data-sort="zero">Zero</th>
</tr></thead>
<tbody id="sg-tbody"></tbody>
</table>
</div>
<div id="sg-msg"></div>
<div id="sg-buttons">
<button id="sg-cancel" class="btn btn-secondary">Close</button>
<button id="sg-add" class="btn btn-secondary" disabled>Add as solution</button>
<button id="sg-run" class="btn btn-primary">Run scan</button>
</div>
</div>
</div>
<footer id="workspace-status"><span id="workspace-state">Ready</span><span id="snap-readout" title="Position under the pointer on the plot: 2θ, d and Q (and hkl when snapping to a calculated line)"></span><span id="workspace-solution">No solution selected</span><span id="gpu-chip" hidden title="WebGPU could not be initialised in this browser. Orthorhombic, monoclinic and triclinic need it and are disabled; cubic, tetragonal and hexagonal run on the CPU. See Help, section WebGPU.">CPU only</span><span id="app-footer">Brutus</span></footer>
<dialog id="sg-browser" aria-labelledby="sg-browser-title">
<h2 id="sg-browser-title">Explore space group</h2>
<p>Choose a setting: its allowed reflections are drawn on the plot for the selected cell, and the setting is added to the solution (and to the report) when you press Add to solution. The displayed cell axes are used; no basis conversion is applied.</p>
<label>Crystal system <select id="sg-filter-system"><option value="">All systems</option><option>cubic</option><option value="hexagonal+trigonal">hexagonal axes (hexagonal and trigonal)</option><option>hexagonal</option><option>trigonal</option><option>tetragonal</option><option>orthorhombic</option><option>monoclinic</option><option>triclinic</option></select></label>
<label>Centering <select id="sg-filter-centering"><option value="">All</option><option>P</option><option>A</option><option>B</option><option>C</option><option>I</option><option>F</option><option>R</option></select></label>
<label>Search <input id="sg-browser-query" type="search" placeholder="Number, symbol, Hall symbol, setting"></label>
<p id="sg-browser-count" role="status"></p>
<div class="sg-browser-columns"><div id="sg-browser-list" role="group" aria-label="Space-group settings"></div><section id="sg-browser-detail" aria-live="polite">Select a setting to inspect its symmetry and reflection conditions.</section></div>
<div class="dialog-actions"><button id="sg-browser-reset" type="button">Reset filters</button><button id="sg-browser-clear" type="button" title="Remove the space group from the solution">Remove from solution</button><button id="sg-browser-cancel" type="button">Cancel</button><button id="sg-browser-apply" type="button" class="primary" disabled>Add to solution</button></div>
</dialog>
<dialog id="convert-dialog" aria-labelledby="convert-title">
<h2 id="convert-title">Convert to a subgroup or supergroup</h2>
<p id="convert-intro"></p>
<div class="convert-row">
<label>Current space group <select id="convert-from"></select></label>
<label>Filter <input id="convert-from-filter" type="search" placeholder="Number, symbol, Hall"></label>
</div>
<div class="seg" role="group" aria-label="Conversion">
<button type="button" data-convert-mode="sub" aria-pressed="true">Maximal subgroups</button><button type="button" data-convert-mode="other" aria-pressed="false">Another group</button>
</div>
<div id="convert-other" class="convert-row" hidden>
<label>Target space group <select id="convert-to"></select></label>
<label>Filter <input id="convert-to-filter" type="search" placeholder="Number, symbol, Hall"></label>
</div>
<p id="convert-status" role="status"></p>
<div id="convert-results" class="convert-results"></div>
<div class="dialog-actions"><button id="convert-cancel" type="button">Cancel</button><button id="convert-apply" type="button" class="primary" disabled>Add as solution</button></div>
</dialog>
</body>
</html>