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 and mesh that should contain the geometries or meshes, which should be saved and names 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 the saveto() 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>

Methods

saveto(target)

Save the resulting XPL to the file.

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.

Descriptions

Method Details

XplWriter.saveto(target)

Save the resulting XPL to the file.

Parameters:

target (string or file) – A file name or an open file object to save to.

Attribute Details

XplWriter.geometry = <property object>

Dictionary with geometries that should be saved to the file.

XplWriter.mesh = <property object>

Dictionary with meshes that should be saved to the file.

XplWriter.names = <property object>

Dictionary with names of the geometry objects that should be explicitly named in the file.