Skip to main content

Package for modeling in CST Microwave studio using python

Project description

CST geometry manager

It’s a package that allows you to model geometries contain wires and then export it into CST Microwave Studio 2021 project using python.

Features

  • One file format for all wire geometries

  • Сreate a CST project directly from a script or notebook.

  • Convenient data structure for creating your own unique complex geometries from wires

Install

For simple installation use pip:

pip install cst-geometry

Usage

During using scripts or notebooks for creating projects all the CST Microwave studio windows must be closed

Wire

Wire objects serves to create Geometry objects. Wire object initialized using start point of wire point0, finish point of wire point1 and its radius radius. As needed after initializing you can use length property. point0 and point1 are vectors of cartesian coordinates.

from cst_geometry import Wire

x0 = 0; y0 = 0; z0 = 0
x1 = 1; y1 = 1; z1 = 1
radius = 0.5

wire = Wire(
   point0 = (x0, y0, z0),
   point1 = (x1, y1, z1),
   radius = radius
)
print(wire.length)  # Returns length of wire

Geometry

Geometry object allows to easily export geometry to CST Microwave Studio or just export .txt file with geometry parameters. For initializing Geometry object you should pass a list of Wire objects. create_cst_project is a method for creating a .cst project with geometry model. export_geometry is a method for exporting geometry as .txt file.

from cst_geometry import Wire, Geometry


def create_wires_by_rule():
    wires = []
    # ...
    # Your code for creating Wire objects
    # ...
    wires.append(wire)
    return wires

wires = create_wires_by_rule()
geometry = geometry(wires)

To create your own geometry use Wire and Geometry classes.

import numpy as np
from cst_geometry import Wire, Geometry


def get_circular_geometry(radius, lengths_of_wires, wire_radius=1e-3, delta_angle=0):
    number_of_wires = len(lengths_of_wires)
    angles = np.linspace(0, 2 * np.pi, number_of_wires, endpoint=False) + delta_angle

    wires = []
    for i, length in enumerate(lengths_of_wires):
        phi = angles[i]
        wire = Wire(
            point0=(radius * np.cos(phi), radius * np.sin(phi), -length / 2),
            point1=(radius * np.cos(phi), radius * np.sin(phi), length / 2),
            radius=wire_radius
        )
        wires.append(wire)

    return Geometry(wires)

Examples

from cst_geometry import simple_geometries

# Path to CST DESIGN ENVIRONMENT.exe
path_to_CST_DE = r"Absolute\Path\To\CST DESIGN ENVIRONMENT.exe"

# Route to folder with .txt geometries and CST projects
route_to_folder = r"Absolute\Path\To\FOLDER"


def circular_geometry_equal_wires(length, number_of_wires, radius):
    lengths = [length for i in range(number_of_wires)]

    circular_geometry = simple_geometries.get_circular_geometry(
                    radius=radius, lengths_of_wires=lengths, wire_radius=1e-3, delta_angle=0
    )
    return circular_geometry

# During using scripts or notebooks for creating projects
# all the CST Microwave studio windows must be closed !!!

# Creating an array of 18 vertical aligned wires with length 2
# on of imaginary cylinder with radius 4
circular_geometry = circular_geometry_equal_wires(2, 18, 4)
output = circular_geometry.create_cst_project(
    name="circular_geometry",
    path_to_CST_DE=path_to_CST_DE,
    path_to_geometry_folder=route_to_folder,
    path_to_CST_project=route_to_folder
)

This code creates simple geometry contain 18 wires equally distributed on imaginary cylinder. Then create_cst_project method creates project. To start using scripts firstly need to change path_to_CST_DE variable. CST project create in cst_project folder.

examples/CST_example.gif

Several examples with CST projects are located in examples/ folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cst_geometry-0.1.5.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cst_geometry-0.1.5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file cst_geometry-0.1.5.tar.gz.

File metadata

  • Download URL: cst_geometry-0.1.5.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.4 Darwin/20.3.0

File hashes

Hashes for cst_geometry-0.1.5.tar.gz
Algorithm Hash digest
SHA256 54a67d7d61d4b000bdd835d0ca3d8ccb84ea8918d7557d542f870c36aa64fe5a
MD5 757fbbbcf55d9971c6b1e8190bd92915
BLAKE2b-256 9333d9c8a264c274d012f49748392bb88569cfb1a12143ed5004408d4f7719b0

See more details on using hashes here.

File details

Details for the file cst_geometry-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: cst_geometry-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.4 Darwin/20.3.0

File hashes

Hashes for cst_geometry-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e5734fd975075320207eac642e3faf3da89bb385c47ad0a9f9c576dd765fc3e6
MD5 9687c422cab3808f04836e1b5e2232ad
BLAKE2b-256 50a4352bb96b0a67ecc24980a04540f76a9f5fd816a4972cf043b23f98fa0481

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page