Documentation

Docs / Scripting API

Project#

from te10_studio import api as em

Creating and opening#

em.Project(name="Project", units="mm")#

A new, empty project. units is the length unit for plain numbers: "m", "cm", "mm", "um", "nm", "in" or "mil".

em.Project.open(path) -> Project#

Opens a .te10 file (older .openem / .emfem / .te10json files open too). Its results folder (<name>.te10results/) is found beside it.

em.Project.from_palace(config_path, name=None) -> Project#

Builds a project from a Palace configuration file (.json) and its mesh: the mesh becomes geometry, with materials, boundaries, lumped ports (multi-element too), wave ports and the solver setup. prj.import_notes lists what wasn't carried over (post-processing blocks, periodic and Floquet boundaries...). Faces Palace leaves unassigned get a PMC boundary, Palace's default. TE10 meshes the model again, so results match Palace's to mesh accuracy.

em.Project.attach(core, on_change=None) -> Project#

Wraps a project that is open in the app. The Python Console's prj is made this way; you rarely need it.

Saving and checking#

prj.save(path) -> str#

Saves the project as a .te10 file (JSON) and returns the path. Later solves keep their results in <name>.te10results/ beside it.

prj.validate() -> list[str]#

The validation errors that would stop a solve, each as "Category: message" (for example "Boundaries: No port excitations defined in project."). An empty list means the model is ready.

problems = prj.validate()
if problems:
    raise SystemExit("\n".join(problems))

Attributes#

Attribute Type
prj.name str The project name
prj.units str The length unit for plain numbers
prj.variables Variables Design variables
prj.materials Materials Materials
prj.modeler Modeler Geometry
prj.boundaries Boundaries Boundaries
prj.excitations Excitations Ports and sources
prj.mesh MeshOperations Mesh rules
prj.setups Setups Solver setups
prj.picks Picks Picks
prj.wcs WCS Working coordinate system
prj.compute Compute Cluster profiles by name: prj.compute.names(), prj.compute["big"]
prj.overlap_rule str, settable "earlier" (default) or "later": see Overlaps
prj.core internal The internal project object. Not part of the stable API

Variables#

prj.variables holds design variables. Values are expressions with units; reading one gives its SI value.

Call Does
prj.variables["w"] = "3mm" Creates or changes a variable. Objects that use it are rebuilt
prj.variables["$h"] = "1.6mm" A project variable (name starts with $)
prj.variables["w"] The SI value: 0.003
prj.variables.expression("w") The expression as typed: "3mm"
"w" in prj.variables Whether it exists
del prj.variables["w"] Removes it
prj.variables.items() (name, expression) pairs
prj.variables.dataset("er", [(1e9, 4.4), (10e9, 4.2)]) A dataset of (x, y) points in SI, used in expressions as pwl(er, x) (piecewise linear)
prj.variables["f0"] = "2.4GHz"
prj.variables["er"] = "4.4"
prj.variables["lambda_g"] = "3e8 / (f0 * sqrt(er))"     # metres

Materials#

prj.materials holds the project's materials. Names are not case-sensitive. Built-in materials include vacuum, air, PEC, copper, aluminum, FR4, FR4_DjordjevicSarkar, Rogers_RO4350B, Teflon_PTFE, Alumina_99, Silicon, Sapphire, Quartz, LithiumNiobate, Niobium, Aluminum_Cryo and YBCO. The material library has about 2,400 more.

prj.materials.add(name, permittivity=1.0, permeability=1.0, conductivity=0.0, loss_tangent=0.0, is_pec=False, djordjevic_sarkar_at=None, ds_f_low=1e3, ds_f_high=1e12, ds_sigma_dc=0.0)#

A new material. conductivity is in S/m. With djordjevic_sarkar_at (a frequency, e.g. "1GHz"), the material is frequency-dependent (Djordjevic–Sarkar wideband Debye model): permittivity and loss_tangent are its values at that frequency, ds_f_low / ds_f_high the model's corner frequencies in Hz and ds_sigma_dc its DC conductivity. Driven solves of such projects run in sub-bands.

prj.materials.add("Substrate", permittivity=3.66, loss_tangent=0.0037)
prj.materials.add("FR4ds", permittivity=4.4, loss_tangent=0.02, djordjevic_sarkar_at="1GHz")

prj.materials.set_roughness(name, model, radius=None, surface_ratio=None, area_ratio=1.0, rms=None)#

Gives a metal surface roughness; every conductor surface made from it gets it. model is "huray" (nodule radius, surface_ratio, optional area_ratio), "hammerstad" or "groisse" (rms), or None for smooth. See Surface roughness.

prj.materials.set_roughness("copper", "huray", radius="0.5um", surface_ratio=2.26)

Other members#

Call Returns
prj.materials["copper"] The material (an internal Material with permittivity, conductivity, loss_tangent, ...)
prj.materials.names() list[str]
prj.materials.import_amat(path) Names added from an Ansys .amat library
prj.materials.export_amat(path, names=None) Names written
prj.materials.import_mtd(*paths) Names added from CST .mtd files
prj.materials.export_mtd(folder, names=None) Names written

Parametric sweeps#

prj.sweep(values, setup=None, backend="local", cores=None, **resources) -> Job#

Solves every combination of the given variable values as one job (an array job on a cluster), one result per variation. values maps variable names to lists of values (strings with units, or plain numbers, which get the project's length unit); setup is a setup name or Setup (default: the active setup). backend and resources are as for Setup.submit.

job = prj.sweep({"w": ["2mm", "3mm", "4mm"], "h": ["0.8mm", "1.6mm"]}, "S1", cores=4)
job.wait()
for res in job.results():                 # 6 results
    print(res.variables, res.s_parameters().get_db(1, 1).min())

Jobs#

prj.jobs() -> list[Job]#

Every job saved with the project, including ones started from the app. See Jobs.