Ensure the same four component materials form the same ID.

这个提交包含在:
nmannall
2024-10-10 17:26:01 +01:00
父节点 8e40fcaad3
当前提交 405af94272

查看文件

@@ -53,17 +53,22 @@ cpdef void create_electric_average(
G: FDTDGrid class describing a grid in a model.
"""
# Make an ID composed of the names of the four materials that will be averaged
requiredID = (G.materials[numID1].ID + '+' + G.materials[numID2].ID + '+' +
G.materials[numID3].ID + '+' + G.materials[numID4].ID)
# Make an ID composed of the names of the four materials that will
# be averaged. Sort the names to ensure the same four component
# materials always form the same ID.
requiredID = "+".join(
sorted(
[
G.materials[numID1].ID,
G.materials[numID2].ID,
G.materials[numID3].ID,
G.materials[numID4].ID,
]
)
)
# Check if this material already exists
tmp = requiredID.split('+')
material = [x for x in G.materials if
x.ID.count(tmp[0]) == requiredID.count(tmp[0]) and
x.ID.count(tmp[1]) == requiredID.count(tmp[1]) and
x.ID.count(tmp[2]) == requiredID.count(tmp[2]) and
x.ID.count(tmp[3]) == requiredID.count(tmp[3])]
material = [x for x in G.materials if x.ID == requiredID]
if material:
G.ID[componentID, i, j, k] = material[0].numID