terrapower / armi

An open-source nuclear reactor analysis automation framework that helps design teams increase efficiency and quality
https://terrapower.github.io/armi/
Apache License 2.0
214 stars 82 forks source link

Density of a custom material is zero despite knowing the density #1695

Open drewj-usnctech opened 2 months ago

drewj-usnctech commented 2 months ago

Related to #1682: Material.density returns zero, probably under the assumption a subclass will override the method. And most cases that's true.

But, if you make a custom material in the blueprint file and provide a mass density, the CustomMaterial object does not override the density and will return zero. This is despite the fact that is known by the class

https://github.com/terrapower/armi/blob/7b26f79ac8c58b0477b0d7fa384b363d10fa9406/armi/materials/custom.py#L40

and used in the pseudoDensity method

https://github.com/terrapower/armi/blob/7b26f79ac8c58b0477b0d7fa384b363d10fa9406/armi/materials/custom.py#L42-L50

But, if you have a routine that does something with a subclass of Material and relies on Material.density, you can see strange problems because CustomMaterial.density falls back to Material.density which relies on the refDens property

https://github.com/terrapower/armi/blob/7b26f79ac8c58b0477b0d7fa384b363d10fa9406/armi/materials/material.py#L492-L514

which defaults to zero

https://github.com/terrapower/armi/blob/7b26f79ac8c58b0477b0d7fa384b363d10fa9406/armi/materials/material.py#L101

john-science commented 2 months ago

@drewj-usnctech Just to be sure. This features is meant to support "custom isotopics" in our blueprints:

https://github.com/terrapower/armi/blob/7b26f79ac8c58b0477b0d7fa384b363d10fa9406/armi/reactor/blueprints/tests/test_componentBlueprint.py#L290-L293

Is that how you're using the Custom(Material) class?

drewj-usnctech commented 2 months ago

@drewj-usnctech Just to be sure. This features is meant to support "custom isotopics" in our blueprints:

https://github.com/terrapower/armi/blob/7b26f79ac8c58b0477b0d7fa384b363d10fa9406/armi/reactor/blueprints/tests/test_componentBlueprint.py#L290-L293

Is that how you're using the Custom(Material) class?

That is correct