simos421 / CST-MATLAB-API

CST-MATLAB-API
GNU General Public License v3.0
204 stars 58 forks source link

How to create lumped element #8

Closed colinnnq closed 2 years ago

colinnnq commented 3 years ago

Hi,

Is it possible to add a function for lumped elements in CST using matlab? When I try to use the following code to create a new lumped element, there is an error in the line "invoke(LumpedElement, 'Create')".

function CstLumpedElement(mws,SetName,FolderName,C_value,SetP1,SetP2) LumpedElement = invoke(mws,'LumpedElement'); invoke(LumpedElement,'Reset'); invoke(LumpedElement,'SetName',int2str(SetName));
invoke(LumpedElement,'Folder',FolderName); invoke(LumpedElement,'SetType','RLCSerial'); invoke(LumpedElement,'SetR','0'); invoke(LumpedElement,'SetL','0'); invoke(LumpedElement,'SetC',int2str(C_value)); invoke(LumpedElement,'SetGs','0'); invoke(LumpedElement,'SetI0','1e-14'); invoke(LumpedElement,'SetT','300'); invoke(LumpedElement,'SetP1','False',int2str(SetP1(1)),int2str(SetP1(2)),int2str(SetP1(3))); invoke(LumpedElement,'SetP2','False',int2str(SetP2(1)),int2str(SetP2(2)),int2str(SetP2(3))); invoke(LumpedElement,'SetInvert','False'); invoke(LumpedElement,'SetMonitor','True'); invoke(LumpedElement,'SetRadius','0.0'); invoke(LumpedElement,'Wire',''); invoke(LumpedElement,'Position','end1'); invoke(LumpedElement,'CircuitFileName',''); invoke(LumpedElement,'CircuitId','1'); invoke(LumpedElement,'UseCopyOnly','True'); invoke(LumpedElement,'UseRelativePath','False'); invoke(LumpedElement,'Create');
end

simos421 commented 2 years ago

Hello,

There is no such function in my code at the moment, but you can make your own lumped element function, it is easier than it seems. The steps to do that are:

1) first design what you want in CST, without using matlab 2) then, if you open the history log of CST you will see that it records everything you did in visual basic script 3) Now you need to interface this script with matlab. So open one of my functions (e.g. anything in the home folder of the api) and see how I translate tha visual basic script into a matlab function. I use the invoke function in matlab to do the visual basic to matlab translation. It might look intimidating but it is very easy. Mostly just copy-paste

To solve the error that you get in "invoke(LumpedElement, 'Create')" just copy paste the way I did it in other m functions, most probably it's some sort of syntax error

Br Simos

On Wed, 8 Sept 2021 at 17:58, colinnnq @.***> wrote:

Hi,

Is it possible to add a function for lumped elements in CST using matlab? When I try to use the following code to create a new lumped element, there is an error in the line "invoke(LumpedElement, 'Create')".

function CstLumpedElement(mws,SetName,FolderName,C_value,SetP1,SetP2) LumpedElement = invoke(mws,'LumpedElement'); invoke(LumpedElement,'Reset'); invoke(LumpedElement,'SetName',int2str(SetName)); invoke(LumpedElement,'Folder',FolderName); invoke(LumpedElement,'SetType','RLCSerial'); invoke(LumpedElement,'SetR','0'); invoke(LumpedElement,'SetL','0'); invoke(LumpedElement,'SetC',int2str(C_value)); invoke(LumpedElement,'SetGs','0'); invoke(LumpedElement,'SetI0','1e-14'); invoke(LumpedElement,'SetT','300');

invoke(LumpedElement,'SetP1','False',int2str(SetP1(1)),int2str(SetP1(2)),int2str(SetP1(3)));

invoke(LumpedElement,'SetP2','False',int2str(SetP2(1)),int2str(SetP2(2)),int2str(SetP2(3))); invoke(LumpedElement,'SetInvert','False'); invoke(LumpedElement,'SetMonitor','True'); invoke(LumpedElement,'SetRadius','0.0'); invoke(LumpedElement,'Wire',''); invoke(LumpedElement,'Position','end1'); invoke(LumpedElement,'CircuitFileName',''); invoke(LumpedElement,'CircuitId','1'); invoke(LumpedElement,'UseCopyOnly','True'); invoke(LumpedElement,'UseRelativePath','False'); invoke(LumpedElement,'Create'); end

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/simos421/CST-MATLAB-API/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAISOKHYKM6LBOROIJAPE3UA52Y7ANCNFSM5DVBNEUQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.