Write the whole-pattern X-ray diffraction phase analysis program of a cement works laboratory (crystalline phases and amorphous content with a corundum internal standard); it is run on further batches of weighed mixtures.
harbor run -t reactive-labs/xrd-phase-quantharbor download reactive-labs/xrd-phase-quantYou are Marit Solheim, staff scientist for mineralogy in the Central Laboratory of Tarnholm Cement's Skerrow Works. Since last week you are responsible for the X-ray diffractometer XRD-02 and for the quantitative phase analysis of clinker and cement under SOP-XRD-014. Today is Monday 2 November 2026. Graham Oduya, the laboratory manager, wrote this morning:
Rev D of SOP-XRD-014 has been in force for two weeks and we still have no software that does what section 8 says. I need one program that takes a batch folder as it comes off XRD-02 and writes the results file, no manual steps, so that the shift can run it and we can re-issue this year's results with it. And I need the results for the eight blind check batches Priscilla has released to us. She will run your program herself on the batches she has kept back.
In /app/inputs:
batches/XB-2026-Wnn: the eight released batches of the QA blind check programme (weeks 4, 8, 13, 19, 24, 30,
37 and 42 of 2026). Each folder holds batch_manifest.json, the weighing log spike_log.csv and one scan
file per specimen in scans/, as exported by the instrument software (.xy or .rtx).reference_library/: the laboratory's reference patterns with their README.docs/: SOP-XRD-014 rev D, the operational qualification report of XRD-02, the 2026 instrument logbook
(LIMS export), the certificates of the corundum internal standard, the QA memo on the blind check programme
and the e-mail thread with Graham and Priscilla Thwaite (QA).legacy/: the script the shift has used so far and its author's handover notes./app/output/xrd_qpa.py, run as
python3 /app/output/xrd_qpa.py <batch_dir> <out.json>
It reads one batch folder in the format of the eight in hand and writes one JSON object:
| Key | Content |
|---|---|
batch |
batch name from the manifest (not scored) |
samples |
object keyed by sample_id, one entry for every specimen of the manifest |
samples[id].wt_pct |
object with the thirteen keys alite, belite, aluminate, ferrite, periclase, free_lime, gypsum, bassanite, anhydrite, calcite, quartz, mullite, amorphous: mass fractions in wt% of the specimen as received (without the internal standard), numbers; a phase that is not reported is 0 |
samples[id].present |
list of the crystalline phases (keys as above, amorphous excluded) that the specimen contains according to SOP-XRD-014 section 8.4 |
The program runs with Python 3.12, numpy, scipy and pandas (python-docx is also installed), on one CPU core
with 3 GB of memory and no network. It must finish a batch within 60 seconds, and all further batches together
within 14 minutes; batches not reached by then score zero. It is run as another user from a copy of
/app/output: it may load helper files that you put in /app/output (found relative to __file__).
/app/output/results/XB-2026-Wnn.json for each of the eight batches in hand: the program's output for that
batch.
QA runs your program on further batches from the same instrument: other weeks of the 2026 blind check programme, prepared, weighed and measured by the same laboratory in the same way, each folder exactly as it was exported. Every specimen is a mixture that QA weighed from the reference materials, so its composition is known. The eight batches in hand are compared with their weighed compositions in the same way, from your result files.
Each specimen scores up to 100 points:
| Item | Points | Full credit within |
|---|---|---|
alite |
25 | 1.0 wt% |
belite |
15 | 1.0 wt% |
amorphous |
30 | 1.5 wt% |
| the other crystalline phases that the mixture contains | 15 | 0.6 wt% each |
present identical to the phases in the mixture |
15 | exact |
Errors are absolute differences in wt%. A value earns full credit within the stated error, falling linearly to
nothing at three times that error (four times for alite and belite); the 15 points for the other phases are
multiplied by the mean credit over those of the ten phases from aluminate to mullite that are in the mixture.
The last three items (60 points) count only as far as the silicates are right: their sum is multiplied by the
square root of the credit for alite times the credit for belite. A crystalline component of a mixture is never below 1 wt%. A missing or non-numeric value earns
nothing, and a specimen missing from the output scores zero. A batch scores the mean of its specimens; a batch
on which the program fails, runs out of time or writes no readable JSON scores zero. The final score is 80% the
mean over the further batches and 20% the mean over the eight result files.