simos421 / CST-MATLAB-API

CST-MATLAB-API
GNU General Public License v3.0
212 stars 60 forks source link

Export E-Field data #2

Closed Mahabaleshwar-Rudramuni closed 5 years ago

Mahabaleshwar-Rudramuni commented 5 years ago

Hello Symeon,

I was using your code and tried to amend it to export the 2D/3D results from the simulations. Needed your help to export the E-Field results for a fixed bounding box size. If you can, please mail me on "mahabaleshwar.rudramuni@gmail.com", we can discuss further.

Thank You.

simos421 commented 5 years ago

Hello, Thank you for your msg and for taking interest in my code. My code is open source, feel free to make any additions you like to this repository. I never tried to write an m-file to export the local E-field. I find this a bit ...unusual. You need a 3d representation of your actual geometry for the local E-fields to make sense. Still, if you need to do it for your own reasons, you just need to tweek a bit my CstExportSparametersTXT.m m-file.

Start by changing the line: SelectTreeItem = invoke(mws,'SelectTreeItem','1D Results\S-Parameters\S1,1'); according to the cst tree result you want to export. i.e. This "1D Results\S-Parameters\S1,1'" should point to the tree directory you want to export

Mahabaleshwar-Rudramuni commented 5 years ago

Hello Symeon,

Thank You for your reply. I ran your code on the antenna array I have designed by doing some basic modifications to the code. I had 3 questions basically.

  1. At first, I tried to export the far-field, initially, the code was working fine and exporting the far field as the source for all the values of theta ranging from 0 to 180 and phi ranging from 0-360 , but how can I export the normal far field for all the values of theta ranging from 0 to 180 and phi ranging from 0-360 (I have attached a sample file, i'm expecting to export the far-field results in the same format, the file name is 'farfield (f=33.5) [1[1.0,0]+2[1.0,315]+3[1.0,270]+4[1.0,225],[33.5]].txt') I tried to amend your code but I'm getting a weird error, I have attached the screenshot of the error as well ) The filename is 'error.png'
  2. If I want to excite the antenna array patches with different phases by selecting the source type as 'Selection' and changing them after selecting 'Excitation List' what commands Do I need to use, I tried but I'm getting an error as a command not recognized. (File name Excitation List and Selecting_phases)

3.If I want to rerun the simulation, how to delete the old results automatically and rerun?

Thank you for your code, it really gave me an insight into how to control CST from MATLAB. But I'm facing some problems please help me with the commands.

Thank You.

Best regards- Mahab.

error excitation list selecting_phases antenna structure farfield (f=33.5) [1[1.0,0]+2[1.0,315]+3[1.0,270]+4[1.0,225],[33.5]].txt

simos421 commented 5 years ago

Hello! Ok it took me a while to understand what you want in the first question. I think what you are asking is how to export the combined farfield for your array. At first you did it with one element and it worked but then you combined them and it didn't. Yes, one of the many reasons might be that the name of the farfield in your CST result tree changes when it's combined compared to the single element farfield, therefore you need to edit inside the CSTExportFarfieldSourceAngleStep.m the name of the farfield that you need to export. Besides that, there is also a general strategy to follow when you are trying to add new functionalities that works every time and applies to your second question too.

The best solution for all of these when you are trying to create a new functionality for the code is: 1) Run your matlab script and comment every line of code right before the point that you get the error. That way you will isolate the error (You obviously done that) and you will also have the corresponding CST design that is one step before that error. 2) Go to that CST design and design whatever you were trying to script in matlab and got the error, manually. That way, CST will generate a history archive containing the vba script of the thing you just designed. You can see that code by going to Modeling->History List->Edit. That Macro is the solution to your problem! You need to turn that Macro into matlab code and you are done.
3) Open one of my m-files (besides an example file). For instance open CSTExportFarfieldsourceAngleStep.m and get oriented with the matlab invoke command that I use. This is the command that turns the CST Macros into Matlab code. Don't worry it is very easy, it is just a copy-paste thing.

For your third question. You don't need to delete anything, the old results are automatically overwritten. If you feel like deleting, something like: delete results.txt might work in the script, or for matlab memory stuff something like: clear all.