Package: cst-geometry
CST geometry managerIt’s a package that allows you to model geometries contain wires and
then export it into CST Microwave Studio 2021 project using python.FeaturesOne 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 wiresInstallFor simple installation use pip:pip install cst-geometryUsageDuring using scripts or notebooks for creating projects all the CST Microwave studio windows must be closedWireWireobjects serves to createGeometryobjects. Wire object initialized using start point of wirepoint0, finish point of wirepoint1and its radiusradius. As needed after initializing you can uselengthproperty.point0andpoint1are vectors of cartesian coordinates.fromcst_geometryimportWirex0=0;y0=0;z0=0x1=1;y1=1;z1=1radius=0.5wire=Wire(point0=(x0,y0,z0),point1=(x1,y1,z1),radius=radius)print(wire.length)# Returns length of wireGeometryGeometryobject allows to easily export geometry to CST Microwave Studio or just export .txt file with geometry parameters. For initializingGeometryobject you should pass a list ofWireobjects.create_cst_projectis a method for creating a .cst project with geometry model.export_geometryis a method for exporting geometry as .txt file.fromcst_geometryimportWire,Geometrydefcreate_wires_by_rule():wires=[]# ...# Your code for creating Wire objects# ...wires.append(wire)returnwireswires=create_wires_by_rule()geometry=geometry(wires)To create your own geometry useWireandGeometryclasses.importnumpyasnpfromcst_geometryimportWire,Geometrydefget_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_anglewires=[]fori,lengthinenumerate(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)returnGeometry(wires)Examplesfromcst_geometryimportsimple_geometries# Path to CST DESIGN ENVIRONMENT.exepath_to_CST_DE=r"Absolute\Path\To\CST DESIGN ENVIRONMENT.exe"# Route to folder with .txt geometries and CST projectsroute_to_folder=r"Absolute\Path\To\FOLDER"defcircular_geometry_equal_wires(length,number_of_wires,radius):lengths=[lengthforiinrange(number_of_wires)]circular_geometry=simple_geometries.get_circular_geometry(radius=radius,lengths_of_wires=lengths,wire_radius=1e-3,delta_angle=0)returncircular_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 4circular_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. Thencreate_cst_projectmethod creates project.
To start using scripts firstly need to changepath_to_CST_DEvariable. CST project create in cst_project folder.Several examples with CST projects are located inexamples/folder.