Merge pull request #417 from ThomasRigoni7/peplinski_soil_materials_name_fix

fixed material index mismatch between Grid.solid and materials list
这个提交包含在:
Craig Warren
2023-12-22 13:58:07 +00:00
提交者 GitHub
当前提交 c6bed1df9a
共有 2 个文件被更改,包括 16 次插入21 次删除

查看文件

@@ -867,7 +867,7 @@ def process_geometrycmds(geometry, G):
if nbins == 1: if nbins == 1:
raise CmdInputError("'" + ' '.join(tmp) + "'" + ' must be used with more than one material from the mixing model.') raise CmdInputError("'" + ' '.join(tmp) + "'" + ' must be used with more than one material from the mixing model.')
# Create materials from mixing model as number of bins now known from fractal_box command # Create materials from mixing model as number of bins now known from fractal_box command
mixingmodel.calculate_debye_properties(nbins, G) mixingmodel.calculate_debye_properties(nbins, G, tmp[13])
elif not material: elif not material:
raise CmdInputError("'" + ' '.join(tmp) + "'" + ' mixing model or material with ID {} does not exist'.format(tmp[12])) raise CmdInputError("'" + ' '.join(tmp) + "'" + ' mixing model or material with ID {} does not exist'.format(tmp[12]))

查看文件

@@ -266,7 +266,7 @@ class PeplinskiSoil(object):
self.mu = watervolfraction self.mu = watervolfraction
self.startmaterialnum = 0 self.startmaterialnum = 0
def calculate_debye_properties(self, nbins, G): def calculate_debye_properties(self, nbins, G, fractalboxname):
""" """
Calculates the real and imaginery part of a Debye model for the soil as Calculates the real and imaginery part of a Debye model for the soil as
well as a conductivity. It uses an approximation to a semi-empirical model (http://dx.doi.org/10.1109/36.387598). well as a conductivity. It uses an approximation to a semi-empirical model (http://dx.doi.org/10.1109/36.387598).
@@ -274,7 +274,9 @@ class PeplinskiSoil(object):
Args: Args:
nbins (int): Number of bins to use to create the different materials. nbins (int): Number of bins to use to create the different materials.
G (class): Grid class instance - holds essential parameters describing the model. G (class): Grid class instance - holds essential parameters describing the model.
fractalboxname (str): Name of the fractal box for which the materials are being created.
""" """
self.startmaterialnum = len(G.materials)
# Debye model properties of water # Debye model properties of water
f = 1.3e9 f = 1.3e9
@@ -311,15 +313,8 @@ class PeplinskiSoil(object):
sig = muiter[0]**(b2 / a) * ((sigf * (self.rs - self.rb)) / (self.rs * muiter[0])) sig = muiter[0]**(b2 / a) * ((sigf * (self.rs - self.rb)) / (self.rs * muiter[0]))
# Check to see if the material already exists before creating a new one # Check to see if the material already exists before creating a new one
requiredID = '|{:.4f}|'.format(float(muiter[0])) materialID = '|{:.4f}_{}|'.format(float(muiter[0]), fractalboxname)
material = next((x for x in G.materials if x.ID == requiredID), None) m = Material(len(G.materials), materialID)
if muiter.index == 0:
if material:
self.startmaterialnum = material.numID
else:
self.startmaterialnum = len(G.materials)
if not material:
m = Material(len(G.materials), requiredID)
m.type = 'debye' m.type = 'debye'
m.averagable = False m.averagable = False
m.poles = 1 m.poles = 1