ornlneutronimaging / ImagingReso

Resonance Imaging
http://imagingreso.readthedocs.io
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

With density input for 'Co', atoms_per_cm3 not updated #2

Closed zhangy6x closed 7 years ago

zhangy6x commented 7 years ago

By defining a new density for Co, atoms_per_cm3 of Co should be updated.

Initialization:

>>> _layer_1 = 'Co'
>>> _thickness_1 = 0.025 # mm
>>> o_reso = Resonance(energy_min=_energy_min, energy_max=_energy_max, energy_step=_energy_step)
>>> o_reso.add_layer(formula=_layer_1, thickness=_thickness_1)

Check:

>>> pprint.pprint(o_reso.get_stochiometric_ratio(compound='Co', element='Co'))
{'58-Co': 0.0, '59-Co': 1.0}
>>> pprint.pprint(o_reso.get_density(compound='Co', element='Co'))
8.9
>>> pprint.pprint(o_reso.stack['Co']['atoms_per_cm3'])
{'Co': 9.0945432502053166e+22}
>>> pprint.pprint(o_reso.stack['Co']['Co']['molar_mass'])`
{'units': 'g/mol', 'value': 58.9332}

Define a new density:

>>> o_reso.set_density(compound='Co', element='Co', density=8)
>>> pprint.pprint(o_reso.get_stochiometric_ratio(compound='Co', element='Co'))
{'58-Co': 0.0, '59-Co': 1.0}
>>> pprint.pprint(o_reso.get_density(compound='Co', element='Co'))
8
>>> pprint.pprint(o_reso.stack['Co']['atoms_per_cm3'])
{'Co': 9.0945432502053166e+22}
>>> pprint.pprint(o_reso.stack['Co']['Co']['molar_mass'])`
{'units': 'g/mol', 'value': 58.9332}
JeanBilheux commented 7 years ago

Good point. The algorithm is supposed to do that but looks like the logic somewhere is wrong. I'm working on a fix.

zhangy6x commented 7 years ago

I am going through the code, looks like the density used for get_atoms_per_cm3_of_layer is the density of the layer, which is not updated with isotopic input.