updated a few lines of code to make them more cleaner.

这个提交包含在:
Sai Suraj
2023-04-18 12:43:33 +05:30
父节点 72c85b29d6
当前提交 3ba49bfd14
共有 4 个文件被更改,包括 28 次插入28 次删除

查看文件

@@ -76,7 +76,7 @@ def write_hdf5_outputfile(outputfile, G):
# Write meta data and data for any subgrids
if sg_rxs:
for sg in G.subgrids:
grp = f.create_group('/subgrids/' + sg.name)
grp = f.create_group(f'/subgrids/{sg.name}')
write_hd5_data(grp, sg, is_subgrid=True)
if G.rxs or sg_rxs:

查看文件

@@ -371,8 +371,7 @@ class GeometryObjects:
parts = config.sim_config.input_file_path.with_suffix('').parts
self.filename_hdf5 = Path(*parts[:-1], self.basefilename)
self.filename_hdf5 = self.filename_hdf5.with_suffix('.h5')
self.filename_materials = Path(
*parts[:-1], self.basefilename + '_materials')
self.filename_materials = Path(*parts[:-1], f'{self.basefilename}_materials')
self.filename_materials = self.filename_materials.with_suffix('.txt')
# Sizes of arrays to write necessary to update progress bar

查看文件

@@ -105,7 +105,7 @@ class Scene:
# Check essential commands and warn user if missing
for cmd_type in self.essential_cmds:
d = any([isinstance(cmd, cmd_type) for cmd in cmds_unique])
d = any(isinstance(cmd, cmd_type) for cmd in cmds_unique)
if not d:
logger.exception('Your input file is missing essential commands ' +
'required to run a model. Essential commands ' +

查看文件

@@ -96,7 +96,7 @@ class VoltageSource(Source):
i = self.xcoord
j = self.ycoord
k = self.zcoord
componentID = 'E' + self.polarisation
componentID = f'E{self.polarisation}'
if self.polarisation == 'x':
if self.resistance != 0:
@@ -130,30 +130,31 @@ class VoltageSource(Source):
G: FDTDGrid class describing a grid in a model.
"""
if self.resistance != 0:
i = self.xcoord
j = self.ycoord
k = self.zcoord
if self.resistance == 0:
return
i = self.xcoord
j = self.ycoord
k = self.zcoord
componentID = 'E' + self.polarisation
requirednumID = G.ID[G.IDlookup[componentID], i, j, k]
material = next(x for x in G.materials if x.numID == requirednumID)
newmaterial = deepcopy(material)
newmaterial.ID = material.ID + '+' + self.ID
newmaterial.numID = len(G.materials)
newmaterial.averagable = False
newmaterial.type += ',\nvoltage-source' if newmaterial.type else 'voltage-source'
componentID = f'E{self.polarisation}'
requirednumID = G.ID[G.IDlookup[componentID], i, j, k]
material = next(x for x in G.materials if x.numID == requirednumID)
newmaterial = deepcopy(material)
newmaterial.ID = f'{material.ID}+{self.ID}'
newmaterial.numID = len(G.materials)
newmaterial.averagable = False
newmaterial.type += ',\nvoltage-source' if newmaterial.type else 'voltage-source'
# Add conductivity of voltage source to underlying conductivity
if self.polarisation == 'x':
newmaterial.se += G.dx / (self.resistance * G.dy * G.dz)
elif self.polarisation == 'y':
newmaterial.se += G.dy / (self.resistance * G.dx * G.dz)
elif self.polarisation == 'z':
newmaterial.se += G.dz / (self.resistance * G.dx * G.dy)
# Add conductivity of voltage source to underlying conductivity
if self.polarisation == 'x':
newmaterial.se += G.dx / (self.resistance * G.dy * G.dz)
elif self.polarisation == 'y':
newmaterial.se += G.dy / (self.resistance * G.dx * G.dz)
elif self.polarisation == 'z':
newmaterial.se += G.dz / (self.resistance * G.dx * G.dy)
G.ID[G.IDlookup[componentID], i, j, k] = newmaterial.numID
G.materials.append(newmaterial)
G.ID[G.IDlookup[componentID], i, j, k] = newmaterial.numID
G.materials.append(newmaterial)
class HertzianDipole(Source):
@@ -180,7 +181,7 @@ class HertzianDipole(Source):
i = self.xcoord
j = self.ycoord
k = self.zcoord
componentID = 'E' + self.polarisation
componentID = f'E{self.polarisation}'
if self.polarisation == 'x':
Ex[i, j, k] -= (updatecoeffsE[ID[G.IDlookup[componentID], i, j, k], 4] *
self.waveformvalues_halfdt[iteration] * self.dl *
@@ -217,7 +218,7 @@ class MagneticDipole(Source):
i = self.xcoord
j = self.ycoord
k = self.zcoord
componentID = 'H' + self.polarisation
componentID = f'H{self.polarisation}'
if self.polarisation == 'x':
Hx[i, j, k] -= (updatecoeffsH[ID[G.IDlookup[componentID], i, j, k], 4] *