Optimising the Bandpass Filter with HyperStudy Using Scripting
Configure the HyperStudy setup and perform the optimisation. Minimize the reflection coefficient.
-
Copy the files from
%FEKO_HOME%/help/feko/example/ExampleGuide_models/Example-I04-HyperStudy_bandpass_filter_optimisation/opt_scripting
to a work directory.
Note: Ensure that you have write permissions in the work directory and that the directory is not “read only”.
The provided extraction script bandpassfilter.cfx_extract.lua is preconfigured to calculate s11avg for the filter and write the result to a HyperStudy .hstp file.
-- Run into POSTFEKO to fetch results and push the scalar values to a HyperStudy .hstp file HstUtl = require "hst.hstutl" local app = pf.GetApplication() local config = app.Models[1].Configurations[1] -- Get first s-parameter result local sparam = pf.SParameter.GetDataSet( pf.SParameter.GetNames()[1] ) local s11 = sparam[1][1].SParameter -- Calculate the average reflection coefficient across the frequency band local s11avg = 0 local num_frequencies = sparam.Axes[pf.Enums.DataSetAxisEnum.Frequency].Count for findex = 1,num_frequencies do s11avg = s11avg + sparam[findex][1].SParameter:Abs() end s11avg = s11avg/num_frequencies -- Create the output file file = HstUtl.NewOutputFile( ) HstUtl.StoreScalarValue( file, "s11avg", s11avg ) HstUtl.WriteFile( file ) -- End of file
- Open Altair HyperStudy.
-
Under the Study group, click
New.
The Add Study dialog is displayed.
- [Optional] In the Label field, specify a name for the study.
- Under Location enter the path to the work directory where the bandpassfilter.cfx is located.
-
Click Setup > Definition > Define models in the Explorer tab.
-
Click Add Model.
The Add dialog is displayed.
- Under Select Type, select FEKO and click OK.
-
Under Resource, browse to
bandpassfilter.cfx in the work directory.
Tip: Step 8 and Step 9 can be combined in a simple drag and drop of the bandpassfilter.cfx from the Windows File Explorer into HyperStudy.Note:
- The solver script is registered automatically. The script is accessible under Edit > Register Solver Script, which offers the possibility to register another solver or version.
- The Solver Input Arguments show ${filebasename} by default. The argument –np can be typed here to specify the number of cores to use.
- The provided file bandpassfilter.cfx_extract.lua is expected to be saved in the same location as the model file.
-
Click Import Variables to import CADFEKO model variables.
- Click Next.
-
Select which variables to include in the study. Only S1 – S3 should be
activated and the default ranges used.
An example of the selected variables is displayed.
- Click Next.
-
Click Run Definition.
During the Write phase, the bandpassfilter.cfx_extract.lua file was copied to the run directory and executed after the Feko solver was run in the Extract phase. This generated an output file that HyperStudy can process easily.Note: The script bandpassfilter.cfx_extract.lua is different if a .pfs file was present before importing the variables and will automatically extract the visible traces on a Cartesian graph and polar graph.See Figure 7 for the completed definition run for the Write, Execute and Extract phases for the initial test run done by HyperStudy.
- Click Next.
-
Click File Assistant.
The File Assistant dialog is displayed.
- Browse to ./m_1/hst_output.hstp in the default run directory.
- Confirm that Altair HyperWorks (HstReaderPdd) is selected and click Next.
-
Confirm that Single Item in a Time Series is selected
and click Next.
-
Confirm that s11avg is selected and click
Next.
-
In the Label field, enter s11avg
to change the name of the response label.
- Click Finish to close the dialog.
-
Under Goals click to add an optimisation goal.
The following dialog is displayed.
- Set the goal Type to Minimize and click OK.
-
Click Evaluate to extract the value from the output
file.
HyperStudy is now configured to understand which model to use, which variables are available for modification and how to process the output.
-
Right-click on the defined study in the Explorer tab and
click Add.
-
Under Select Type, select
Optimization and click
OK.
The optimisation approach is created in the Explorer tab
-
Click Optimization 1 > Specifications, and select the Adaptive Response Surface
Method as the optimiser.
-
Click Apply and click Next.
-
Click Evaluate Tasks.
Each of the input variables is altered randomly, and its effect on the response analysed.
-
Click Iteration History tab and look for the row
highlighted in green.
The optimum values are as follows:
- S1 = 0.4500000
- S2 = 1.9254786
- S3 = 2.2000000