XplWriter Class¶
-
class
plask.
XplWriter
¶ XPL writer that can save existing geometries and meshes to the XPL.
Objects of this class contain three dictionaries:
geometry
andmesh
that should contain the geometries or meshes, which should be saved andnames
with other geometry objects that should be explicitly named in the resulting XPL. All these dictionaries must have strings as their keys and corresponding objects as values.Parameters: - geo (dict) – Dictionary with geometries that should be saved to the file.
- mesh (dict) – Dictionary with meshes that should be saved to the file.
- names (dict) – Dictionary with names of the geometry objects that should be explicitly named in the file.
The final XPL can be simply retrieved as a string (
str(writer)
) or saved to a file with thesaveto()
method.Example
Create an XML file with a simple geometry:
>>> rect = plask.geometry.Rectangle(2, 1, 'GaAs') >>> geo = plask.geometry.Cartesian2D(rect) >>> xml = plask.XplWriter({'geo': geo}, {}, {'rect': rect}) >>> print(xml) <plask> <geometry> <cartesian2d name="geo" axes="zxy"> <extrusion length="inf"> <block2d name="rect" material="GaAs" dx="2" dy="1"/> </extrusion> </cartesian2d> </geometry> <grids/> </plask>
Attributes¶
geometry |
Dictionary with geometries that should be saved to the file. |
mesh |
Dictionary with meshes that should be saved to the file. |
names |
Dictionary with names of the geometry objects that should be explicitly named in the file. |