blocks.Experiment()

class feign.blocks.Experiment

A class used to represent an Experiment. An experiment is a complete passive gamma spectroscopy measurment setup with an assembly and detectors (absorbers and collimators are optional).

assembly

The Assembly containing the source

Type

Assembly()

pins

Dictionary containing the available pin types.

Type

dict

materials

Dictionary containing the available materials

Type

dict

detectors

Dictionary containing the detectors in the problem

Type

dict

absorbers

Dictionary containing the absorbers in the problem

Type

dict, optional

elines

Energy lines (in MeV) at which the geometric efficiency is computed (in case missing, only the distance travelled in various material is computed)

Type

list of float, optional

mu

The total attenuation coefficients for all the energies in elines, and for each material in the problem.

Type

dict

sourcePoints

List of pin-wise source point locations for each random sample. Each list element is a dictionary, where the keys are Detector._id identifiers and the values are 2D numpy arrays storing Point() objects

Type

list

dTmap

The average distance travelled by a gamma-ray from a lattice position to a detector given for each material in the problem. Outer keys are Detector._id identifiers, inner keys are Material._id identifiers. It is an average of all random samples (which are kept track in Experiment.dTmaps)

Type

dict of dictionaries of 2D numpy arrays

dTmapErr

The standard deviation of distance travelled by a gamma-ray from a lattice position to a detector given for each material in the problem. Outer keys are Detector._id identifiers, inner keys are Material._id identifiers. It is an standard deviation of all random samples (which are kept track in Experiment.dTmaps)

Type

dict of dictionaries of 2D numpy arrays

dTmaps

All random samples of distance travelled by a gamma-ray from a lattice position to a detector. Source point for each sample are stored in Experiment.sourcePoints

Type

list of dictionaries of 2D numpy arrays

contributionMap

Dictionary to store the rod-wise contributions averaged over random samples to each detector at each energy. Outer keys are detector Detector._id identifiers. Inner keys are energy lines (as given in Experiment.set_elines()) contributionMap[Detector._id][eline] is an NxM shaped numpy array, where N is Assembly.N and M is Assembly.M

Type

dict

contributionMapErr

Dictionary to store the standard deviation of rod-wise contributions averaged over random samples to each detector at each energy. Outer keys are detector Detector._id identifiers. Inner keys are energy lines (as given in Experiment.set_elines()) contributionMapErr[Detector._id][eline] is an NxM shaped numpy array, where N is Assembly.N and M is Assembly.M

Type

dict

contributionMaps

All random samples of contribution maps to each detector at each energy.

Type

list

contributionMapAve

Dictionary to store the rod-wise contribution averaged over all detectors at each energy averaged over all random samples. Keys are energy lines (as given in Experiment.set_elines()) contributionMapAve[eline] is an NxM shaped numpy array, where N is Assembly.N and M is Assembly.M

Type

dict

contributionMapAveErr

Dictionary to store the standard deviation of the pin-wise contribution averaged over all detectors at each energy averaged over all random samples. Keys are energy lines (as given in Experiment.set_elines()) contributionMapAveErr[eline] is an NxM shaped numpy array, where N is Assembly.N and M is Assembly.M

Type

dict

contributionMapAves

All random samples of the pin-wise contribution averaged over all detectors at each energy.

Type

list

geomEff

Dictionary to store the geometric efficiency at each detector location averaged over each random sample. Keys are detector Detector._id identifiers. geomEff[Detector._id] is E long numpy array, where E is the length of Experiment.elines

Type

dict

geomEffErr

Dictionary to store the standard deviation of the geometric efficiency at each detector location averaged over each random sample. Keys are detector Detector._id identifiers. geomEff[Detector._id] is E long numpy array, where E is the length of Experiment.elines

Type

dict

geomEffs

All random samples of the geometric efficiency at each detector location.

Type

list

geomEffAve

Geometric efficiency of the Experiment averaged over all detectors averaged over each random sample. The length is of Experiment.elines

Type

numpy.ndarray

geomEffAveErr

Standard deviation of the geometric efficiency of the Experiment averaged over all detectors averaged over each random sample. The length is of Experiment.elines

Type

numpy.ndarray

geomEffAves

All random samples of the geometric efficiency of the Experiment averaged over all detectors.

Type

list

output

filename (and path) where to print the geometric efficiency

Type

str, optional

Note

While computing the travelled distance, if the ray does not pass through the collimator, np.Inf is set in the given traveled distance map for the given position. This is useful, because the the probability of travelling infinite distance is zero, thus in the related contribution map, at the same location 0.0 will be found. If the geometry is so that rays emitted from any location from a pin will not pass through the collimator, than the mean traveled map (Experiment.dTmap) will have np.Inf at that location (which is correct since the mean of many infinities is infinity) and the the standard deviation will be 0.0 (which is again correct). However, in cases when rays emitted from some location in a pin pass through the collimator, whereas from some other locations in a pin they do not pass through, the mean traveled distance (Experiment.dTmap) and the standard deviation of the travelled distance (Experiment.dTmapErr) become meaningless at such pin positions. (This could be a situation when the collimator slit is narrower than the size of the pins). The reason is that the mean of something and infinity will become infinity as well. Also, for the standard deviation calculation the np.Inf values are set to 0.0, otherwise the map location would be filled with NaN. For these cases one might analyse the list of travelled distances (Experiment.dTmap) and the list of source locations (Experiment.sourcePoints). Nevertheless, the contribution maps and the geometric efficiency is correctly calculated even in these situations!

Examples

Examples of plotting attributes can be found at https://github.com/ezsolti/feign/blob/master/examples/ex1_2x2fuel.ipynb

Plot(out=None, dpi=600, xl=[-100, 100], yl=[-100, 100], detectorSize=0.4)

Function to plot the geometry of an Experiment() object. The function will randomly set colors to Material() objects for which colors were previously not defined.

Parameters
  • out (str (default=None)) – name of output file

  • dpi (int (default=600)) – dpi of the saved plot

  • xl (list of float (default=[-100,100])) – x-direction limits of region of the geometry to plot (in cm)

  • yl (list of float (default=[-100,100])) – y-direction limits of region of the geometry to plot (in cm)

  • detectorSize (float (default=400)) – radius of white circle to illustrate the detector points

Run()

The function to run an Experiment. It will update the dTmap, the contributionMap and the geomEff attributes.

add_absorber(*argv)

The function to add Absorber objects to an Experiment, which may have already included absorbers. If one wants to rewrite the existing absorbers, then the Experiment.set_absorbers() has to be called.

Parameters

*argv (Absorber() or more Absorber() objects) – Absorber() objects to be added in the Experiment

Examples

>>> leadsheet=Absorber('leadsheet')
>>> alusheet=Absorber('alusheet')
>>> experiment=Experiment()
>>> experiment.set_absorbers()
>>> experiment.absorbers
{}
>>> experiment.add_absorber(leadsheet)
>>> experiment.add_absorber(alusheet)
>>> experiment.absorbers
{'leadsheet': Absorber(absID=leadsheet), 'alusheet': Absorber(absID=alusheet)}
Raises
  • TypeError – if the parameter is not Absorber()

  • ValueError – if the Absorber is already included

add_detector(*argv)

The function to add Detector objects to an Experiment, which may have already included detectors. If one wants to rewrite the existing detectors, then the Experiment.set_detectors() has to be called.

Parameters

*argv (Detector() or more Detector() objects) – Detector() objects to be added in the Experiment

Examples

>>> F5=Detector('F5')
>>> F15=Detector('F15')
>>> experiment=Experiment()
>>> experiment.set_detectors()
>>> experiment.detectors
{}
>>> experiment.add_detector(F5)
>>> experiment.add_detector(F15)
>>> experiment.detectors
{'F5': Detector(detID=F5), 'F15': Detector(detID=F15)}
Raises
  • TypeError – if the parameter is not Detector()

  • ValueError – if the Detector is already included

add_material(*argv)

The function to add Material objects to an Experiment, which may have already included materials. If one wants to rewrite the existing materials, then the Experiment.set_materials() has to be called.

Parameters

*argv (Material() or more Material() objects) – Material() objects to be added in the Experiment

Examples

>>> uox=Material('1')
>>> zr=Material('2')
>>> experiment=Experiment()
>>> experiment.set_materials()
>>> experiment.materials
{}
>>> experiment.add_material(uox)
>>> experiment.add_material(zr)
>>> experiment.materials
{'1': Material(matID=1), '2': Material(matID=2)}
Raises
  • TypeError – if the parameter is not Material()

  • ValueError – if the Material is already included

attenuation(dTmap, mue, detector, sourcePoint)

The function to calculate the pin-wise contribution to the detector at a given energy. That is the probablity that a gamma-ray emitted from a pin will reach the detector point.

Parameters
  • dTmap (dict) – The travelled distance in various materials. Keys are material identifiers, values are pin-wise distance values. Shape as created by Experiment.distanceTravelled()

  • mue (dict) – Total attenuation coefficients at the given energy. Keys are materials, values are the total attenuation coefficient values.

  • detector (Detector()) –

  • sourcePoint (numpy array) – Pin-wise source locations, as created by Experiment.distanceTravelled().

Returns

contribmap – Pin-wise probabilities that a gamma-ray emitted from a given pin hits the detector.

Return type

numpy array

checkComplete()

Function to check whether everything is defined correctly in an Experiment() object.

  • checks whether assembly is complete

  • checks whether any pin contains any region with radius greater than the pitch

  • checks whether all the pins in the fuelmap are attributed to the assembly

  • in case a pool is defined, it is checked whether the pool is around the assembly.

Returns

True if everything is correct and complete, False otherwise

Return type

bool

distanceTravelled(detector)

The function to calculate the distanced travelled in any material by a gamma ray emitted from any pin positions of the Assembly to a detector

Parameters

detector (Detector()) –

Returns

  • dTmap (dict) – The travelled distance in various materials. Keys are material identifiers, values are pin-wise distance values.

  • sourcePoint (numpy array) – Pin-wise source location in the given calculation.

get_MuTable()

The function to create a nested dictionary to store the total attenuation coefficients.

Returns

Dictionary to store the attenuation coefficients. Outer keys are energies as defined in elines, inner keys are Material._id identifiers.

Return type

dict

remove_absorber(*argv)

The function to remove Absorber objects from an Experiment which already has previously included absorbers.

Parameters

*argv (Absorber() or more Absorber() objects) – Absorber() objects to be added in the Experiment

Examples

>>> leadsheet=Absorber('leadsheet')
>>> alusheet=Absorber('alusheet')
>>> experiment=Experiment()
>>> experiment.set_absorbers(leadsheet,alusheet)
>>> experiment.absorbers
{'leadsheet': Absorber(absID=leadsheet), 'alusheet': Absorber(absID=alusheet)}
>>> experiment.remove_absorber(alusheet)
>>> experiment.absorbers
{'leadsheet': Absorber(absID=leadsheet)}
>>> experiment.remove_absorber(alusheet)
ID alusheet is not in dict yet
Raises
  • TypeError – if the parameter is not Absorber()

  • TypeError – if absorbers is None.

remove_detector(*argv)

The function to remove Detector objects from an Experiment which already has previously included detectors.

Parameters

*argv (Detector() or more Detector() objects) – Detector() objects to be added in the Experiment

Examples

>>> F5=Detector('F5')
>>> F15=Detector('F15')
>>> experiment=Experiment()
>>> experiment.set_detectors(F5,F15)
>>> experiment.detectors
{'F5': Detector(detID=F5), 'F15': Detector(detID=F15)}
>>> experiment.remove_detector(F15)
>>> experiment.detectors
{'F5': Detector(detID=F5)}
>>> experiment.remove_detector(F15)
ID F15 is not in dict yet
Raises
  • TypeError – if the parameter is not Detector()

  • TypeError – if detectors is None.

remove_material(*argv)

The function to remove Material objects from an Experiment which already has previously included materials.

Parameters

*argv (Material() or more Material() objects) – Material() objects to be added in the Experiment

Examples

>>> uox=Material('1')
>>> zr=Material('2')
>>> experiment=Experiment()
>>> experiment.set_materials(uox,zr)
>>> experiment.materials
{'1': Material(matID=1), '2': Material(matID=2)}
>>> experiment.remove_material(zr)
>>> experiment.materials
{'1': Material(matID=1)}
>>> experiment.remove_material(zr)
ID 2 is not in dict yet
Raises
  • TypeError – if the parameter is not Material()

  • TypeError – if materials is None.

set_absorbers(*argv)

The function to include Absorber objects in an Experiment

Parameters

*argv (Absorber() or more Absorber() objects) – Absorber() objects to be included in the Experiment

Examples

>>> leadsheet=Absorber('leadsheet')
>>> alusheet=Absorber('alusheet')
>>> experiment=Experiment()
>>> experiment.absorbers
>>> experiment.set_absorbers(leadsheet,alusheet)
>>> experiment.absorbers
{'leadsheet': Absorber(absID=leadsheet), 'alusheet': Absorber(absID=alusheet)}
Raises
  • TypeError – if the parameter is not Absorber()

  • ValueError – if the Absorber is already included

set_assembly(assembly=None)

The function to include Assembly in an Experiment

Parameters

assembly (Assembly()) – Assembly to be included in Experiment

set_detectors(*argv)

The function to include Detector objects in an Experiment

Parameters

*argv (Detector() or more Detector() objects) – Detector() objects to be included in the Experiment

Examples

>>> F5=Detector('F5')
>>> F15=Detector('F15')
>>> experiment=Experiment()
>>> experiment.detectors
>>> experiment.set_detectors(F5,F15)
>>> experiment.detectors
{'F5': Detector(detID=F5), 'F15': Detector(detID=F15)}
Raises
  • TypeError – if the parameter is not Detector()

  • ValueError – if the Detector is already included

set_elines(elines=None)

The function to set energy lines at which the geometric efficiency is calculated

Parameters

elines (list of str) – Energy lines (in MeV) at which the geometric efficiency is calculated.

Note

values of elines are strings, because they will be keys of mu

set_materials(*argv)

The function to include Material objects in an Experiment

Parameters

*argv (Material() or more Material() objects) – Material() objects to be included in the Experiment

Examples

>>> uox=Material('1')
>>> zr=Material('2')
>>> experiment=Experiment()
>>> experiment.materials
>>> experiment.set_materials(uox,zr)
>>> experiment.materials
{'1': Material(matID=1), '2': Material(matID=2)}
Raises
  • TypeError – if the parameter is not Material()

  • ValueError – if the Material is already included

set_output(output='output.dat')

The function to set the output file for printing the geometric efficiency

Parameters

output (str) – filename and path where to print the geometric efficiency.

set_random(randomNum=1)

The function to set number of random source locations per pin.

Parameters

randomNum (int) – number of random source locations in each pin.