.lua script for exporting Transmission and Reflection Coefficients in HyperStudy
Hi, I am interested in .lua script which can help me read Transmission and Reflection Coefficients into HyperStudy. I normally use .out file for reading the TR coefficients but the use-case is bit different.
Use-case : instead of picking a single min. value of reflection from .out file & optimizing thickness for further minimizing that value. I want to select a range of values for reflection and optimize thickness for minimizing all of them.
It would be great if If anyone from the forum can provide a .lua script for extracting the TR coefficients. I was told to access the reflection/transmission coefficient via LUA and define a “table t ” that contains the entries of the reflection coefficient versus e.g. frequency.
Any help on the same would be highly appreciated.
Thanks.
Answers
-
Hi @gsre9597
I haven't worked directly the the TR coefficients for optimisation yet, but I have set up similar problems. It is probably easiest to average the transmission (or reflections) over the angles that you calculate and define a single goal from the average and either maximise or minimise this in HyperStudy.You can find an example of working with TR coefficients with Lua in the user manual under the TRCoefficientCollection.
Here is an example where I calculate average gain (over frequency and angles) used in a HypeStudy optimization:function GetAveFF()
-- extract Farfield data and average over frequency, theta and phi values
local FarField = config.FarFields[ffLabel]:GetDataSet()
DeriveResults.FarField.Quantity.ValuesScaledToDB = indBs
local gain = DeriveResults.FarField.Gain( FarField ):ToMatrix( {'Gain'} ):Mean()
local realgain = DeriveResults.FarField.RealisedGain( FarField ):ToMatrix( {'RealisedGain'} ):Mean()
local t = {}
t.Gain = gain
t.RealisedGain = realgain
return t
end
local ff_average = GetAveFF( )local file = hstutl.NewOutputFile( )
hstutl.StoreScalarValue( file, 'Gain_ave', ff_average.Gain )
hstutl.StoreScalarValue( file, 'RealGain_ave', ff_average.RealisedGain )
hstutl.WriteFile( file )
I hope this helps.0 -
Thank you for your response. I will try the suggested method.
Also, can you please let me know where can I find this 'You can find an example of working with TR coefficients with Lua in the user manual under the TRCoefficientCollection.'.
Is it in the FEKO install directory or somewhere else ?
Regards
0 -
Hi @gsre9597
You can browse to the help menu at any time in CADFEKO/POSTFEKO, which will open the html help documentation. However, if you browse to the help while you are editing a script in the script editor it will automatically take you to the API documentation. Alternatively, just search for the word TRCoefficientCollection in the html help and it will take you to the correct location.
0 -
I didn't find TRCoefficientCollection in the FEKO help section but I found the user manual where I got some info on TRCoefficients.
I have written a script and I am now getting the following error. It would be great if you can please have a look at the attached snapshot and suggest the changes.
Many thanks.
0 -
Could you please attach your Lua file?
0 -
Please find attached the lua file.
I think some modifications would be required to get a table of TR coefficients and frequency.
0 -
Hi @gsre9597
I am attaching a script that will calculate the average transmission and average reflection coefficients - it averages over frequency, incident theta angle and incident phi angle. It will write these 2 coefficients into the HSt out file which you can then set up as independent goals to either maximise or minimise in your optimisation.
Remember that you will need to rename the Lua file to be yourmodelname.cfx_extract.lua so that HyperStudy will automatically execute the script after each run.
0 -
Hi @Peter Futter,
I think you have attached the wrong file (its the same as the one I sent you). Can you please check?
Many thanks.
0 -
sorry about that... this time should be correct /emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />
0