94 def _read_attr(self, tag, attr, solver, type=None, pyattr=None):
95 if pyattr
is None: pyattr = attr
103 raise plask.XMLError(
"{}: {} attribute {} has illegal value '{}'".format(
104 tag, type.__name__.title(), attr, tag[attr]))
106 setattr(solver, pyattr, val)
132 if tag ==
'geometry':
133 self.
thermal.geometry = tag.getitem(manager.geo,
'thermal')
134 self.
electrical.geometry = tag.getitem(manager.geo,
'electrical')
136 self.
thermal.mesh = tag.getitem(manager.msh,
'thermal')
138 self.
electrical.mesh = tag.getitem(manager.msh,
'electrical')
139 elif tag ==
'junction':
141 for key, val
in tag.attrs.items():
142 if key.startswith(
'beta')
or key.startswith(
'js'):
146 raise plask.XMLError(
"{}: Float attribute '{}' has illegal value '{}'".format(tag, key, val))
148 elif tag ==
'contacts':
152 self.
tfreq = int(tag.get(
'tfreq', self.
tfreq))
156 elif tag ==
'tmatrix':
158 elif tag ==
'ematrix':
160 elif tag ==
'temperature':
161 self.
thermal.temperature_boundary.read_from_xpl(tag, manager)
162 elif tag ==
'heatflux':
163 self.
thermal.heatflux_boundary.read_from_xpl(tag, manager)
164 elif tag ==
'convection':
165 self.
thermal.convection_boundary.read_from_xpl(tag, manager)
166 elif tag ==
'radiation':
167 self.
thermal.radiation_boundary.read_from_xpl(tag, manager)
168 elif tag ==
'voltage':
169 self.
electrical.voltage_boundary.read_from_xpl(tag, manager)
171 raise plask.XMLError(
"{}: Unrecognized tag '{}'".format(tag, tag.name))
229 if isinstance(mesh, (plask.mesh.Mesh1D, plask.ndarray, list, tuple)):
231 Mesh = plask.mesh.Rectangular2D
232 elif isinstance(mesh, plask.mesh.Rectangular2D):
234 Mesh = plask.mesh.Rectangular2D
235 elif isinstance(mesh, plask.mesh.Rectangular3D):
236 hor = mesh.axis0, mesh.axis1
237 Mesh = plask.mesh.Rectangular3D
241 points = Mesh.SimpleGenerator()(geometry).elements.mesh
244 roles = geometry.get_roles(p)
247 for prefix
in (
'active',
'junction'):
248 if role.startswith(prefix):
249 suffix = role[len(prefix):]
251 if suffix
is not None and (
not required
or any(role
in required
for role
in roles)):
252 levels[suffix] = p[-1]
254 for name, v
in levels.items():
262 jmesh = vmesh.elements.mesh
263 temp = self.
thermal.outTemperature(tmesh)
265 curr = self.
electrical.outCurrentDensity(jmesh)
266 plask.save_field(temp, h5file, group +
'/Temperature')
267 plask.save_field(volt, h5file, group +
'/Potential')
268 plask.save_field(curr, h5file, group +
'/CurrentDensity')
270 curr2 = self.
electrical.outCurrentDensity(jmesh2)
271 plask.save_field(curr2, h5file, group +
'/Junction' + name +
'CurrentDensity')
273 def save(self, filename=None, group='ThermoElectric'):
275 Save the computation results to the HDF5 file.
278 filename (str): The file name to save to.
279 If omitted, the file name is generated automatically based on
280 the script name with suffix denoting either the batch job id or
281 the current time if no batch system is used.
283 group (str): HDF5 group to save the data under.
285 h5file, group, filename, close = h5open(filename, group)
289 plask.print_log(
'info',
"Fields saved to file '{}' in group '{}'".format(filename, group))
326 Get current densities at the active regions.
329 refine (int): Number of points in the plot between each two points
330 in the computational mesh.
332 interpolation (str): Interpolation used when retrieving current density.
335 dict: Dictionary of junction current density data.
336 Keys are the junction number.
338 axis = plask.concatenate([
339 plask.linspace(x, self.
electrical.mesh.axis0[i+1], refine+1)
340 for i,x
in enumerate(list(self.
electrical.mesh.axis0)[:-1])
349 except ValueError:
pass
350 result[lb] = self.
electrical.outCurrentDensity(msh, interpolation).array[:,0,1]
353 def plot_temperature(self, geometry_color='0.75', mesh_color=None, geometry_alpha=0.35, mesh_alpha=0.15,
354 geometry_lw=1.0, mesh_lw=1.0, **kwargs):
356 Plot computed temperature to the current axes.
359 geometry_color (str or ``None``): Matplotlib color specification for
360 the geometry. If ``None``, structure is not plotted.
362 mesh_color (str or ``None``): Matplotlib color specification for
363 the mesh. If ``None``, the mesh is not plotted.
365 geometry_alpha (float): Geometry opacity (1 — fully opaque, 0 – invisible).
367 mesh_alpha (float): Mesh opacity (1 — fully opaque, 0 – invisible).
369 geometry_lw (float): Line width for geometry.
371 mesh_lw (float): Line width for mesh.
373 **kwargs: Keyword arguments passed to the plot function.
376 :func:`plask.plot_field` : Plot any field obtained from receivers
379 plask.plot_field(field, **kwargs)
380 cbar = plask.colorbar(use_gridspec=
True)
381 cbar.set_label(
"Temperature (K)")
382 if geometry_color
is not None:
383 plask.plot_geometry(self.
thermal.geometry, color=geometry_color, alpha=geometry_alpha, lw=geometry_lw)
384 if mesh_color
is not None:
385 plask.plot_mesh(self.
thermal.mesh, color=mesh_color, alpha=mesh_alpha, lw=mesh_lw)
386 plask.window_title(
"Temperature")
388 def plot_voltage(self, geometry_color='0.75', mesh_color=None, geometry_alpha=0.35, mesh_alpha=0.15,
389 geometry_lw=1.0, mesh_lw=1.0, **kwargs):
391 Plot computed voltage to the current axes.
394 geometry_color (str or ``None``): Matplotlib color specification
395 for the geometry. If ``None``, structure is not plotted.
397 mesh_color (str or ``None``): Matplotlib color specification for
398 the mesh. If ``None``, the mesh is not plotted.
400 geometry_alpha (float): Geometry opacity (1 — fully opaque, 0 – invisible).
402 mesh_alpha (float): Mesh opacity (1 — fully opaque, 0 – invisible).
404 geometry_lw (float): Line width for geometry.
406 mesh_lw (float): Line width for mesh.
408 **kwargs: Keyword arguments passed to the :func:`plask.plot_field`.
411 :func:`plask.plot_field` : Plot any field obtained from receivers
414 plask.plot_field(field, **kwargs)
415 cbar = plask.colorbar(use_gridspec=
True)
416 cbar.set_label(
"Voltage (V)")
417 if geometry_color
is not None:
418 plask.plot_geometry(self.
electrical.geometry, color=geometry_color, alpha=geometry_alpha, lw=geometry_lw)
419 if mesh_color
is not None:
420 plask.plot_mesh(self.
electrical.mesh, color=mesh_color, alpha=mesh_alpha, lw=mesh_lw)
421 plask.window_title(
"Voltage")
448 Plot current density at the active region.
451 refine (int): Number of points in the plot between each two points
452 in the computational mesh.
454 bounds (bool): If *True* then the geometry objects boundaries are
457 interpolation (str): Interpolation used when retrieving current density.
459 label (str or sequence): Label for each junction. It can be a sequence of
460 consecutive labels for each junction, or a string
461 in which case the same label is used for each
462 junction. If omitted automatic label is generated.
464 **kwargs: Keyword arguments passed to the plot function.
466 axis = plask.concatenate([
467 plask.linspace(x, self.
electrical.mesh.axis0[i+1], refine+1)
468 for i,x
in enumerate(list(self.
electrical.mesh.axis0)[:-1])
473 curr = self.
electrical.outCurrentDensity(msh, interpolation).array[:,0,1]
476 lab =
"Junction {:s}".format(lb)
477 elif isinstance(label, tuple)
or isinstance(label, tuple):
481 plask.plot(msh.axis0, curr
if s > 0
else -curr,
484 plask.legend(loc=
'best')
485 plask.xlabel(
u"${}$ (µm)".format(plask.config.axes[-2]))
486 plask.ylabel(
u"Current Density (kA/cm\xb2)")
489 plask.window_title(
"Current Density")