Experiments
An experiment is a crystal, a beam and one or more wedges. Every model rejects unknown keys and validates its values when it is built.
Experiment
Bases: RD3DModel
Everything needed to compute a dose distribution.
Attributes:
-
crystal(Crystal) –The sample, its composition and its physics options.
-
beam(Beam) –The incident beam.
-
wedges(list[Wedge]) –One or more angular sweeps, applied in order.
-
seed(int | None) –Seed for the Monte Carlo escape calculations. Required for a reproducible run whenever escape modelling is enabled; ignored otherwise.
from_raddose_txt
classmethod
from_raddose_txt(path: str | PathLike[str]) -> Self
Load a RADDOSE-3D .txt input file.
Parameters:
-
path(str | PathLike[str]) –Path to the input file.
Returns:
-
Self–The validated experiment -- the same object the equivalent YAML would have produced.
Raises:
-
RaddoseTxtError–If the file does not parse, asks for something this port does not support, or leaves out something RADDOSE-3D requires. The message names the line.
from_file
classmethod
from_file(path: str | PathLike[str]) -> Self
Load either input format, chosen by the file's extension.
.yaml and .yml are read as YAML; anything else as a
RADDOSE-3D .txt input, since those have never had a fixed
extension.
Parameters:
-
path(str | PathLike[str]) –Path to the input file.
Returns:
-
Self–The validated experiment.
to_raddose_txt
to_raddose_txt() -> str
Render this experiment as a legacy RADDOSE-3D input file.
Used to drive the Java reference implementation for conformance testing, and as a migration path for existing users.
Returns:
-
str–The contents of an equivalent
.txtinput file.
Crystals
CuboidCrystal
Bases: _CrystalBase
A rectangular block.
Attributes:
-
dimensions(tuple[float, float, float]) –Extent in x, y and z, in micrometres.
SphericalCrystal
Bases: _CrystalBase
A sphere, meshed as an icosphere.
Attributes:
-
diameter(float) –Sphere diameter, in micrometres.
CylinderCrystal
Bases: _CrystalBase
A cylinder, meshed as a 32-segment prism.
Note the axis lies along y, not z. The reference implementation
ignores the third Dimensions value, with a warning, which is why this
model exposes diameter and height rather than a dimension
triple.
Attributes:
-
diameter(float) –Diameter of the circular cross-section, in micrometres.
-
height(float) –Axial length, in micrometres.
EscapeOptions
Bases: RD3DModel
Photoelectron and fluorescence escape, and the medium around the crystal.
Escape chooses each photoelectron's direction at random, so it has no
gradient. The port draws its random numbers exactly as RADDOSE-3D does
-- the same generator, in the same order -- so with the same seed
(Experiment.seed, RADDOSE-3D's --seed) it reproduces RADDOSE-3D's
result, not just its statistics.
Attributes:
-
photoelectron(bool) –CalculatePEEscape: photoelectrons carry dose away from the voxel that absorbed the photon, and out of the crystal. -
fluorescence(bool) –CalculateFLEscape: fluorescence photons do too. -
surrounding(bool) –CalcSurrounding: photoelectrons from the medium around the crystal carry dose into it. Only with photoelectron escape, as in RADDOSE-3D. -
pe_resolution, fl_resolution(int | None) –PEResolutionandFLResolution: distance bins along each track. RADDOSE-3D chooses when they are left out or below 2. -
goniometer_axis(float) –GoniometerAxis: 90 for a vertical goniometer, anything else horizontal. It sets which way the beam's polarisation sends photoelectrons. -
surrounding_heavy_conc(dict[str, float]) –SurroundingHeavyConc: heavy atoms in the surrounding, mmol/l. -
density_based(bool) –DensityBased: the surrounding is not water butsurrounding_elementsatsurrounding_density-- an oil, say. -
surrounding_elements(dict[str, float]) –SurroundingElements: atoms per formula unit of that material. -
surrounding_density(float | None) –SurroundingDensity: its density in g/ml.
any_enabled
property
any_enabled: bool
Whether any escape modelling is switched on.
SimulationOptions
Bases: RD3DModel
Settings of RADDOSE-3D's Monte Carlo and XFEL subprograms.
Only those subprograms read them: subprogram montecarlo, gos
or xfel.
Attributes:
-
photons(int) –SimPhotons(orSimElectrons): photons simulated per run. RADDOSE-3D's default is a million. -
runs(int) –Runs: independent repeats, each adding a row to the output files. -
polarisation_direction(float) –PolarisationDirection: 90 for vertical polarisation, anything else horizontal. Withescape.goniometer_axisit sets which way K-shell photoelectrons are sent. -
surrounding_thickness(tuple[float, float, float] | None) –SurroundingThickness: how far the surrounding extends from the crystal in x, y and z, um, for the Monte Carlo subprogram. Unset, or beyond a photoelectron's range, it is that range. The surrounding itself isescape.surrounding, as for the MX calculation.
MixtureContainer
Bases: _ContainerBase
A container of a compound or mixture NIST tabulates by name.
ContainerMaterialType Mixture. The mass attenuation coefficient is
interpolated from NIST's table for the material, as
ContainerMixture does.
Attributes:
-
material(str) –A NIST compound name: water, mylar, pmma, polyethylene, pyrex and 44 others. Kapton is not among them; use an elemental container.
ElementalContainer
Bases: _ContainerBase
A container given by its elemental formula.
ContainerMaterialType Elemental. Each element's coefficient comes
from its own NIST table, combined by mass fraction, as
ContainerElemental does.
Attributes:
-
elements(dict[str, float]) –Element symbol to number of atoms, e.g.
{"C": 22, "H": 10, "N": 2, "O": 5}for Kapton.
Compositions
composition
Sample composition: how absorption coefficients are determined.
Maps onto RADDOSE-3D's AbsCoefCalc directive. Each variant needs a
different set of parameters, so these are a discriminated union rather than
one model with many optional fields -- an incomplete composition then fails at
load time rather than part way through a run.
A field has a default only where RADDOSE-3D has one, and it is RADDOSE-3D's.
The Java's residue counts are uninitialised int fields, so an omitted
count is zero; the unit cell and the monomer count have no usable default and
are required, except that a SAXS sample's "cell" is a box of solution and
defaults to 1000 A on a side. These used to default to insulin's values, so a
configuration that left out num_residues was silently insulin.
AverageComposition
Bases: RD3DModel
Generic "average protein" coefficients (AbsCoefCalc Average).
Takes no composition parameters at all; useful as a control case.
UnitCellComposition
Bases: _CellMixin
Composition from unit cell contents (AbsCoefCalc RD3D).
This is the standard MX route.
Attributes:
-
num_monomers(int) –Monomers in the unit cell.
-
num_residues(int) –Amino acid residues per monomer.
-
num_rna, num_dna(int) –Nucleotides per monomer.
-
num_carb(int) –Carbohydrate residues per monomer.
-
protein_heavy_atoms(dict[str, float]) –Heavy atoms added to the protein part of each monomer, by symbol.
-
solvent_heavy_conc(dict[str, float]) –Heavy element concentrations in the solvent, in mmol/l. Oxygen and lighter elements should not be given.
-
solvent_fraction(float | None) –Fraction of the unit cell occupied by solvent. If
None, RADDOSE-3D computes it from the cell contents.
SmallMoleculeComposition
Bases: _CellMixin
Composition of a small-molecule crystal (AbsCoefCalc SmallMole).
Attributes:
-
atoms(dict[str, float]) –Atoms per unit cell asymmetric unit, by element symbol.
-
num_monomers(int) –Monomers in the unit cell.
SaxsComposition
Bases: _CellMixin
Composition of a SAXS sample (AbsCoefCalc SAXS).
Attributes:
-
unit_cell(tuple[float, float, float]) –The box of solution the monomers are counted in, in Angstroms.
-
protein_concentration(float) –Protein concentration in grams per litre.
-
num_residues(int) –Residues per monomer. At least one of the residue counts must be non-zero, or the monomer has no mass.
-
num_carb(int) –Carbohydrate residues per monomer.
SequenceComposition
Bases: _CellMixin
Composition read from a sequence file (AbsCoefCalc Sequence).
Attributes:
-
sequence_file(str) –Path to a FASTA file, resolved relative to the working directory of the run.
-
num_carb(int) –Carbohydrate residues per monomer, which a sequence cannot express.
SaxsSequenceComposition
Bases: _CellMixin
A SAXS sample, its monomer read from a sequence file (AbsCoefCalc SAXSSEQ).
The monomer count follows from the concentration, as for
:class:SaxsComposition, but the monomer's mass and atoms come from its
residues, as for :class:SequenceComposition.
Attributes:
-
unit_cell(tuple[float, float, float]) –The box of solution the monomers are counted in, in Angstroms.
-
protein_concentration(float) –Protein concentration in grams per litre.
-
sequence_file(str) –Path to a FASTA file, resolved relative to the working directory of the run.
-
num_carb(int) –Carbohydrate residues per monomer, which a sequence cannot express. They add to the monomer's mass, so to how few monomers a given concentration is.
PdbComposition
Bases: RD3DModel
Composition read from a PDB entry (AbsCoefCalc EXP or PDB).
EXP is the original keyword: the grammar's token named PDB matches
the literal "EXP", exactly as the token named CIF matches "EXPSM".
RADDOSE-3D has accepted PDB as well since 2026.
The unit cell, symmetry and solvent fraction all come from the file, so none of the usual cell parameters apply here.
Attributes:
-
pdb(str) –A path to a PDB or mmCIF file, or a four-character PDB code, such as
3I40, which is downloaded from RCSB, as RADDOSE-3D downloads it. A local path is reproducible; an entry can be revised.
CifComposition
Bases: RD3DModel
Composition read from a small-molecule CIF (AbsCoefCalc EXPSM or CIF).
EXPSM is the original keyword: the grammar's token named CIF matches
the literal "EXPSM". RADDOSE-3D has accepted CIF as well since 2026.
This is the small-molecule route. It needs _chemical_formula_sum and
_cell_volume, so a protein mmCIF (with dotted tags such as
_cell.length_a) will not work.
Attributes:
-
cif(str) –Path to the CIF file.
Beams
beam
Beam profile and collimation.
A field has a default only where RADDOSE-3D has one, and it is RADDOSE-3D's,
so that leaving a setting out of a YAML file means the same as leaving it out
of a .txt input. Flux, energy, a Gaussian's widths and an experimental
beam's image and pixel size are required by the Java and are required here.
XrayBeam
module-attribute
XrayBeam = Annotated[
GaussianBeam | TophatBeam | ExperimentalBeam,
Field(discriminator="type"),
]
A beam for the MX calculation.
Beam
module-attribute
Beam = Annotated[
GaussianBeam
| TophatBeam
| ExperimentalBeam
| ElectronBeam,
Field(discriminator="type"),
]
Any beam: an X-ray beam, or an electron beam for MicroED.
Collimation
Bases: RD3DModel
Aperture placed in front of the beam.
Attributes:
-
shape({'rectangular', 'circular'}) –Aperture shape. A circular aperture is an ellipse inscribed in the same bounding box, so it always transmits less than the rectangular one for the same dimensions.
-
x, y(float) –Full width of the aperture in each direction, in micrometres.
GaussianBeam
Bases: _BeamBase
A bivariate Gaussian profile.
Attributes:
-
fwhm(tuple[float, float]) –Full width at half maximum in x and y, in micrometres. For a horizontal goniometer x is vertical and y is horizontal.
TophatBeam
Bases: _BeamBase
A uniform beam filling its collimation aperture.
The aperture is the beam, so a tophat must have one; RADDOSE-3D's
BeamTophat refuses to construct without it.
ExperimentalBeam
Bases: _BeamBase
A measured beam profile, read from an image (Type ExperimentalPGM).
The image is a plain (P2) PGM file whose pixel values are relative
intensities; the flux sets their total. RADDOSE-3D lays the image's
horizontal axis along y, the rotation axis, and its vertical axis along
x, both reversed: a peak right of the image's centre is at negative y.
Attributes:
-
file(str) –Path to the PGM file, resolved relative to the working directory of the run.
-
pixel_size(tuple[float, float]) –Pixel size in x and y, in micrometres: the first down the image, the second across it.
-
collimation(Collimation | None) –An aperture, which clips the measured profile with its own sizes. The flux, the flux after collimation, is spread over the pixels it lets through. RADDOSE-3D used to ignore the sizes.
ElectronBeam
Bases: RD3DModel
An electron beam, for RADDOSE-3D's MicroED engine.
In a .txt input, a Type TopHat beam with Exposure in an
experiment whose crystal has Subprogram EMED. RADDOSE-3D's MicroED
refuses any other beam type: only a top-hat beam carries an exposure.
Attributes:
-
energy(float) –Electron energy in keV.
-
exposure(float) –Fluence, in electrons per square Angstrom.
-
collimation(Collimation) –The beam's size and shape. Where it is larger than the crystal, the crystal limits the exposed area, axis by axis.
Wedges
Wedge
Bases: RD3DModel
A single angular sweep of the crystal through the beam.
A field has a default only where RADDOSE-3D has one, and it is
RADDOSE-3D's, so that leaving a setting out of a YAML file means the same
as leaving it out of a .txt input. Start, end and exposure time are
required by the Java and are required here.
Attributes:
-
start(float) –Start of the rotation, in degrees.
-
end(float) –End of the rotation, in degrees.
-
exposure_time(float) –Total exposure over the whole angular range, in seconds.
-
angular_resolution(float | None) –Angular step of the simulation, in degrees.
Nonemeans 2. RADDOSE-3D also replaces a given step with 2 unless the wedge spans more than ten of them -- seesolve.wedge_resolution. -
start_offset(tuple[float, float, float] | None) –Crystal position at the start of the wedge, in micrometres.
-
translate_per_degree(tuple[float, float, float] | None) –Crystal translation per degree of rotation, in micrometres.
-
rot_axis_beam_offset(float | None) –Offset of the rotation axis from the beam axis, in micrometres.
-
max_resolution(float) –Highest resolution of the data, in angstroms. Sets the resolution of the last relative diffraction efficiency column RADDOSE-3D reports; it has no effect on the dose. Defaults to 2, as in
Wedge.java.