微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 电磁仿真讨论 > Re: CST MWS vba script parameter sweep ASCII export

Re: CST MWS vba script parameter sweep ASCII export

时间:03-31 整理:3721RD 点击:
Hi everybody

I have a little problem with the CST VB.

I design a model in CST MWS. Know

I want to performe a Parameter-Sweep.

I choose a userdefined output.

Cause I want to analyze some data in matlab,

I want, what CST save for expample the energy in a ascii file.

A new file for every run of the sweep.

But this is not working.

Do you have a idea?

The code:
Code:
Code:
Option Explicit

Sub ParameterSweepWatch(action As Integer)

   'Please define actions for the parameter sweep watch here.


   Select Case action
      Case 0
      'Please define actions before the parametersweep starts.

      Case 1
      'Please define actions after each calculation.
       Dim zaehler       As Integer
       Dim Dateiname    As String
        Dim filename        As String
         Dim Fileendung    As String
         Dim strwert         As String
       Dim wertdouble     As Double

        wertdouble= ParameterSweep.GetValueOfVaryingParameter()

      strwert    = CStr(wertdouble)
      filename     = "I:\simulation-Output\File-"
      Fileendung    = ".txt"
      Dateiname    =

      SelectTreeItem ("1D Results\Energy\Energy [5]")

      With ASCIIExport

       .Reset

       .FileName (Dateiname)

       .Mode ("FixedNumber")
         .Execute

      End With

      Case 2
      'Please define actions after the parametersweep has finished.

   End Select

End Sub

Sub Main()


  ParameterSweepWatch 0
  ParameterSweepWatch 1
  ParameterSweepWatch 2

End Sub
Thanking for your in anticipation.

Added after 9 minutes:

I found the answer.

It was to easy!

' userdefined watch for parameter sweep
Code:
Option Explicit

Sub ParameterSweepWatch(action As Integer)
'Please define actions for the parameter sweep watch here.

Select Case action	Case 0	'Please define actions before the parametersweep starts.
	Case 1	'Please define actions after each calculation.	 Dim zaehler 		As Integer	 Dim Dateiname 		As String
 		 Dim filename  		As String
  		 Dim Fileendung 	As String
  		 Dim strwert   		As String	 Dim wertdouble     As Double
     wertdouble		= ParameterSweep.GetValueOfVaryingParameter(0)     Parametername 	= ParameterSweep.GetNameOfVaryingParameter(0)
	strwert 	= CStr(wertdouble)	filename  	= "I:\simulation-Output\File-"	Fileendung 	= ".txt"	Dateiname 	=filename & Parametername & strwert & Fileendung
	SelectTreeItem ("1D Results\Energy\Energy [5]")
	With ASCIIExport

    	.Reset

    	.FileName (Dateiname)

    	.Mode ("FixedNumber")
	.Step(100)

   		.Execute
	End With
	Case 2	'Please define actions after the parametersweep has finished.
End Select

End Sub

Sub Main()


  ParameterSweepWatch 0
  ParameterSweepWatch 1
  ParameterSweepWatch 2

End Sub

what is your problem?
you can get your results directly from file-export-ascii format
may that i understand from your question,if not forgive me for misunderstand

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top