Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
drewj-usnctech opened this issue Apr 25, 2024 · 2 comments
Open

Comments

@drewj-usnctech
Copy link
Contributor

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

self.customDensity = 1.0

and used in the pseudoDensity method

def pseudoDensity(self, Tk=None, Tc=None):
"""
The density value is set in the loading input.
In some cases it needs to be set after full core assemblies are populated (e.g. for
CustomLocation materials), so the missing density warning will appear no matter
what.
"""
return self.customDensity

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

def density(self, Tk: float = None, Tc: float = None) -> float:
"""
Return density that preserves mass when thermally expanded in 3D (in g/cm^3).
Notes
-----
Since refDens is specified at the material-dep reference case, we don't need to specify the
reference temperature. It is already consistent with linearExpansion Percent.
- p*(dp/p(T) + 1) =p*( p + dp(T) )/p = p + dp(T) = p(T)
- dp/p = (1-(1 + dL/L)**3)/(1 + dL/L)**3
"""
Tk = getTk(Tc, Tk)
dLL = self.linearExpansionPercent(Tk=Tk)
refD = self.refDens
if refD is None:
runLog.warning(
"{0} has no reference density".format(self),
single=True,
label="No refD " + self.getName(),
)
return None
f = (1.0 + dLL / 100.0) ** 3
return refD / f

which defaults to zero

self.refDens = 0.0

@drewj-usnctech drewj-usnctech changed the title Density of a custom material raises zero despite knowing the density Density of a custom material is zero despite knowing the density Apr 25, 2024
@john-science john-science added bug Something is wrong: Highest Priority and removed bug Something is wrong: Highest Priority labels Apr 25, 2024
@john-science
Copy link
Member

john-science commented Apr 25, 2024

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

custom isotopics:
Thorium:
input format: number densities
TH232: 1.0

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

@drewj-usnctech
Copy link
Contributor Author

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

custom isotopics:
Thorium:
input format: number densities
TH232: 1.0

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

That is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants