In order to investigate absorption, we need to create an instance of a X-ray spectrum first. This is done by instantiating an instance of PolychromaticXRaySpectrum:
PolychromaticXRaySpectrum spectrum = new PolychromaticXRaySpectrum(min, max, delta, peakVoltage, timeCurrentProduct);
Next, we create an instance of a monochromatic absorption model. Here, we chose the average energy of the spectrum as energy of the monochromatic process:
SelectableEnergyMonochromaticAbsorptionModel monochromaticAbsorptionModel = new SelectableEnergyMonochromaticAbsorptionModel();
monochromaticAbsorptionModel.configure(spectrum.getAveragePhotonEnergy());
Furthermore, we require an instance of a polychromatic absorption model:
PolychromaticAbsorptionModel polychromaticAbsorptionModel = new PolychromaticAbsorptionModel();
polychromaticAbsorptionModel.setInputSpectrum(spectrum);
polychromaticAbsorptionModel.configure();
Now, we want to evaluate the absorption models several times. The model is evaluated given a list of intersection lengths with different materials. This is modeled as a list of PhysicalObjects. As we only want to investigate water, we only require a list with a single object:
PhysicalObject segment = new PhysicalObject();
segment.setMaterial(MaterialsDB.getMaterial("water"));
segment.setNameString("Water Path");
ArrayList<PhysicalObject> segments = new ArrayList<PhysicalObject>();
segments.add(segment);
This segment can now be used to sample different path lengths using our absorption models:
for (int i = 0; i < vals; i++){
double length = i*20;
Edge edge = new Edge(new PointND(0), new PointND(length));
segment.setShape(edge);
monochromaticAbsorptionModel.evaluateLineIntegral(segments);
polychromaticAbsorptionModel.evaluateLineIntegrl(segments);
The final code for the data generation of the image on the right can be reviewed in package edu.stanford.rsl.tutorial.physics in class SpectralAbsorption.