🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

.lua script for exporting Transmission and Reflection Coefficients in HyperStudy

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

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.

 

 

Find more posts tagged with

Sort by:
1 - 9 of 91
    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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.

     

     

     

     

     

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi @Peter Futter

    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

     

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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.

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi @Peter Futter

     

    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.

     

    <?xml version="1.0" encoding="UTF-8"?>Error1.png

    <?xml version="1.0" encoding="UTF-8"?>Error_in_detail.png

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Could you please attach your Lua file?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi @Peter Futter

     

    Please find attached the lua file.

     

    I think some modifications would be required to get a table of TR coefficients and frequency.

     

     

     

     

    Unable to find an attachment - read this blog

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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. 

     

     

     

    Unable to find an attachment - read this blog

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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.

     

    <?xml version="1.0" encoding="UTF-8"?>Capture1.png

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    sorry about that... this time should be correct :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />

     

    Unable to find an attachment - read this blog