Automating Measurments in Feko

Sasha1296
Sasha1296 Altair Community Member
edited October 2020 in Community Q&A

I am trying to automate taking a lot of measurements with FEKO

Basically what I am trying to do is create a large dataset for a neural network

and do that by writing a Lua script that does the following:
1) generate a few random let's say for now perfect conductor objects(cubes, spheres,...etc) at random positions with random sizes constrained by some constraints

2) create a source let's say 7 feet from the objects and send a wave at the objects

3) run simulation and measure the Hy field component at 6 evenly spaced locations let's say 1 foot from the objects

4) repeat many times, changing the position of the source and the position of the 6 measurement points by an interval in a given direction

5) store measurements in a file 

6) repeat 1-5 many times, generating a new set of random objects that are randomly placed and have random sizes and take a lot of measurements as described earler

 

I've been trying to figure out how to do this for a while for a project, any help would be greatly appreciated

Many thanks! 

Tagged:

Answers

  • Mel
    Mel Altair Community Member
    edited July 2020

    You can use script recording and playback to record the setup of a basic model in CADFEKO.
    Then modify the script to use a random function e.g. print(math.random()) in positioning and size of the objects. 
    The choice of object can also be made with the random function and using an IF statement for example, provided you have written a separate script that you can call to create each pre-decided object with the random numbers.

     

    In POSTFEKO you can write an automation script to export the data. Look in the help folder of Feko for Altair_Feko_Scripting_API_Reference_Guide.pdf and there search for 'DatasSet' and 'ExportDataSet'.
    Also see the Example Guide I.1 'Introduction to Application Automation'. 
     

  • Sasha1296
    Sasha1296 Altair Community Member
    edited July 2020

    Thanks for replying! 

    I apologize I'm not very experienced with FEKO, I can't seem to find the file you mentioned in the help folder Altair_Feko_Scripting_API_Reference_Guide.pdf

     

    I guess the thing that I am struggling the most is to figure out how to go from one version of FEKO to another through script. If simulation is done in CADFEKO and POSTFEKO basically analyzes the results(that's what I understand is how it woks), how can I launch postfeko(assuming I have to do so) from a Lua Script that was made in CADFEKO? Such that I run the simulation and record measurments using just a script and then repeat? 

     

     

  • Mel
    Mel Altair Community Member
    edited July 2020

    The pdfs are in help\feko\pdf in your Feko installation folder.

     

    See 'Command Line Arguments for Launching CADFEKO' and similarly '... POSTFEKO' in the Altair_Feko_User_Guide.pdf.

    The --run-script option is probably what you are looking for.

     

    You could write a simple .bat script for the Feko terminal where you first launch your CADFEKO script and when that is finished the POSTFEKO script. And that can easily be placed in a loop.

     

  • Sasha1296
    Sasha1296 Altair Community Member
    edited July 2020

    So when I look in help\feko\pdf these are the files that I see: 

     

    'ExampleGuide.pdf'                        7,281 Kb

    'GetStarted.pdf'                               2,892 Kb

    'InstallationGuide.pdf'                   3,486 Kb

    'QuickTips_CADFEKO.pdf'             806   Kb

    'QuickTips_POSTFEKO.pdf'           1,037 Kb

    Readme

    'ReleaseNotes.pdf'                          1,548 Kb

    'UserManual.pdf'                           52,236 Kb

     

    Is the pdf 'Altair_Feko_Scripting_API_Reference_Guide.pdf' just named differently in my folder?

     

    Also I wrote a cadfeko script that I hope to use to create a bunch of .out files but for now it doesn't seem to be working:

    It doesn't generate .out files and I cant seem to get the project.Mesher.Settings.TriangleEdgeLength = 0.2 command to run because currently my cubes are not meshed fine enough by default. If I have the mentioned line uncommented I get an error 'Unable to use the property as it is disabled'

     

     

     


    app = cf.GetApplication()
    project = app:OpenFile('C:/Users/an/Desktop/spiral antenna stuff/New folder/automating_data3/measurment_attempt_cadfeko.cfx')

    ---------corner = cf.Point(-0.25, -0.25, 0) 
    ----------cube = project.Geometry:AddCuboid(corner, 0.5, 0.5, 10.25)

    x_pos_list = {-0.1, -0.5, -0.4}
    y_pos_list = {3.0, 5.0, 9.0}
    Length_list = {0.5, 1.0, 0.64}

    Xt = 3.05
    Yt = -1.0

    for i = 1, #x_pos_list do
        print('begining loop')
        project = app:OpenFile('C:/Users/an/Desktop/spiral antenna stuff/New folder/automating_data3/measurment_attempt_cadfeko.cfx')

        corner = cf.Point(x_pos_list, y_pos_list, 0.0)
        cube = project.Geometry:AddCuboid(corner, Length_list, Length_list, Length_list)
        
        StandardConfiguration1 = project.SolutionConfigurations['StandardConfiguration1']      
        --Freq = StandardConfiguration1.Frequency 

        MagneticSource = StandardConfiguration1.Sources['MagneticPointSource1']                   -- It is for magnetic source. It needs to match the name of the dipole in CADFEKO.
        properties = MagneticSource:GetProperties() 
        
        properties.Position.U = Xt                                                        -- get the x location of the dipole from CADFEKO
        properties.Position.V = Yt                                                        -- get the y location
        properties.Position.N = 0.6                                                        -- get the z location

        ---1 + y_incrament*iter
        
        MagneticSource:SetProperties(properties)
        --C:\Users\an\Desktop\spiral antenna stuff\New folder\automating_data3\results
        

        --project = app:OpenFile(savePath)
        
        --project.Mesher.Settings.MeshSize = 0.2
        
        project.Mesher.Settings.Wi
        project.Mesher.Settings.WireRadius = '0.001'
        --project.Mesher.Settings.TriangleEdgeLength = 0.2
        project.Mesher:Mesh()
        project.Launcher:RunFEKO()
        
        savePath = 'C:/Users/an/Desktop/spiral antenna stuff/New folder/automating_data3/results/' 
        
        savePath = savePath ..'Cadfeko_test_' .. i .. '.cfx'         -- save files for each cases
        app:SaveAs(savePath)
        print(i)
    end

     

  • Mel
    Mel Altair Community Member
    edited July 2020

    The manuals were restructured in later Feko versions. You should find the pdf in Feko 2020 or 2019.

    In 2018 the API docs were still part of the UserManual.pdf

     

    You need to apply the Custom mesh size property. From the manual:

    TriangleEdgeLength
    Mesh triangle edge length. Only applied if MeshSizeOption is Custom and there is at least one
    surface in the model.

     

  • Sasha1296
    Sasha1296 Altair Community Member
    edited July 2020

    Thank you! 

    One more question, is there a way to close a CADFEKO project from script? 

    I got the code to work to produce lots of .out files for different configurations of objects, however it seems that they are still open somehow

    If I try to delete everything in the 'results' folder where I save the different iterations I looped through it says it cannot do so because these files are still open even though the generated CADFEKO files don't show up,  only the original project seems to be actually open

     

    is there a way to do something like:

     

           --- loop the following many times

           --- create new setup/project

           --- save as new project in results folder

            project.Launcher:RunFEKO()

            
            project.Close()

            

     

    Except the last command doesn't work? 

  • Mel
    Mel Altair Community Member
    edited July 2020

    That would be 

    app:Close()

  • Sasha1296
    Sasha1296 Altair Community Member
    edited July 2020

    Thank you so much for your help 

    Everything worked!