How do I create a specific acoustic results and a log. sum of these acoustic results

Erik Kostson
Erik Kostson Member, Employee Posts: 214
50 Answers 100 Comments 25 Likes Name Dropper
✭✭✭✭
edited June 2023 in Structures

So if we have 10 result sets, and want to automatically create 10 SPL dbA plots (identifier A1-A10) and then finally add a user defined result with their sum as shown below:

(10*log(10^(A1/10)+10^(A2/10)+10^(A3/10)+10^(A4/10)+10^(A5/10)+10^(A6/10)+10^(A7/10)+10^(A8/10)+10^(A9/10)+10^(A10/10)))

how is that done?

Best Answer

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 214
    50 Answers 100 Comments 25 Likes Name Dropper
    ✭✭✭✭
    edited May 2023 Answer ✓

    Below is a ACT python script that one can run inside mechanical (Scripting facility). It generates automatically all the results we want. So if we have 10 result sets it will create 10 SPL dbA plots and add a user defined result with their sum as shown below:

    (10*log(10^(A1/10)+10^(A2/10)+10^(A3/10)+10^(A4/10)+10^(A5/10)+10^(A6/10)+10^(A7/10)+10^(A8/10)+10^(A9/10)+10^(A10/10)))

    (A1-A10 are the identifiers)


    The script is:

    analysis = ExtAPI.DataModel.Project.Model.Analyses[0]
    reader = analysis.GetResultsData()
    freqs=reader.ListTimeFreq
    setmax=len(freqs)/2
    expr=''
    for i in range(1, setmax+1):
      res=ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddAcousticAWeightedSoundPressureLevel()
      idtext='A'+str(i)
      res.Identifier=idtext
      res.By=SetDriverStyle.ResultSet
      res.SetNumber=i
      if i>1:
        expr=expr+ '+10^('+idtext+'/'+ str(setmax) +')'
      else:
        expr='10^('+idtext+'/' + str(setmax) + ')'
    ExtAPI.DataModel.Tree.Refresh()
    fullexpr='10*log10('+expr+')'
    resur=ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddUserDefinedResult()
    resur.Expression=fullexpr
    resur.EvaluateAllResults()
    reader.Dispose()