Screen.Recording.2026-03-28.144741.mp4
Python script to automate the process of making antennas. Using CST Studio Suite 2025. Done with the help of claude qwen 3.5 local instance.
Important
- Needs CST Studio Suite 2025, I am working with this version not sure if it is compatible with other versions
- Python 3.11 required the cst studio suite python library packages require python <3.12,>=3.7
- Create python virtual environment by downloading python 3.11 and assigning it a name (cst_env)
py install 3.11py -3.11 -m venv cst_env- Set it may be required to enable the Activate.ps1 script by setting the execution policy for the user
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUsercst_env\Scripts\activate- Install CST library
pip install --no-index --find-links "C:/Program Files (x86)/CST Studio Suite 2025/Library/Python/repo/simple" cst-studio-suite-link- run the external script
py "*<Path\to\external\script>*"
This script uses CST's external Python scripting model to:
- Initialize a DesignEnvironment
- Create a new MWS (Microwave Studio) project
- Build geometries using the History List mechanism
- Configure simulation settings (FDTD solver, ports, frequency range)
- Save the project to disk
Reference Methodology: https://blog.technia.com/en/simulation/cst-studio-suite-python-scripting
- Refer to cst_patch_antenna.py to see fully automated workflow
- example_script.py asks the user for patch length in mm and substrate height in mm. This is done in accordance with our ML automated flow where given a frequency the algorithm will output the patch length and substrate height which then further will be inputted into the cst linker to automate the process of antenna generation. As of now the linker part is a separate module from the ML module.
- FirstExternalPythonScript.py can be used as a debugging script to check and verify if CST api is correctly installed and the module is properly working. If done correctly, running the script should open CST and automatically generate a solid block of PEC.
cst_patch_antenna.py
├── CSTPatchAntenna class
│ ├── __init__() : Initialize DesignEnvironment
│ ├── initialize() : Create and save MWS project
│ ├── create_substrate() : Create dielectric substrate
│ ├── create_ground_plane() : Create PEC ground
│ ├── create_patch() : Create dielectric patch
│ ├── add_top_ground() : Add top metal layer
│ ├── add_air_box() : Add simulation boundaries
│ ├── configure_solver() : Set FDTD/FEM solver
│ ├── set_frequency_range() : Define simulation band
│ ├── add_waveguide_port() : Add waveguide port
│ ├── add_discrete_port() : Add discrete port
│ ├── configure_simulation_time() : Set max time
│ ├── configure_adaptivity() : Set solver adaptivity
│ ├── create_full_antenna() : Create complete antenna
│ ├── run_simulation() : Run simulation
│ └── get_geometry_list() : Get geometry list
│
└── create_patch_antenna() : Convenience function
antenna.create_disk(
radius_mm=10.0,
height_mm=0.1,
material="PEC",
x_mm=0.0,
y_mm=0.0,
z_mm=10.0
)antenna.add_source(
source_name="monopulse",
source_type="Gaussian",
frequency_GHz=9.0,
power_W=1.0
)antenna.set_pml_boundaries()
antenna.set_periodic_boundaries()Install via:
pip install --no-index --find-links "C:/Program Files/CST/Studio Suite/2024/Python/repo/simple" cst-studio-suite-linkEnsure CST Studio is running. The DesignEnvironment requires an active CST license.
- Open the
.cstprjfile in CST - Check the 3D viewer for geometries
- Look in "Project Explorer" for component list
- Verify geometry is valid (no intersecting objects)
- Check port positioning
- Ensure frequency range covers expected resonances
| File | Description |
|---|---|
patch_antenna.cstprj |
CST project with geometry |
README.md |
This documentation |
This script is provided as-is for use with CST Studio Suite. Refer to CST's licensing terms for redistribution.
Uploading Screen Recording 2026-03-28 144741.mp4…