How can I extract the magnitude of a single harmonic in a spectrum and assign it to an I/O parameter using a pyflux commend?

Cyril Favre_21925
Cyril Favre_21925
Altair Employee
edited April 15 in Altair HyperWorks

The magnitude in a spectrum 'Name' of harmonic number 'HarmonicNumber' is obtained by the pyflux command:

CurveVariation2D['Name'].spectrumResults[HarmonicNumber].amplitude

Both the magnitude extraction and the I/O parameter update can be done in the same pyflux command line. Here the I/O parameter 'ParameterName' is assigned the magnitude of harmonic 'HarmonicNumber' from the spectrum 'CurveName':

VariationParameter['ParameterName'].formula=str(CurveVariation2D['CurveName'].spectrumResults[HarmonicNumber].amplitude)

Note: 

the I/O parameter should be defined as a formula type. It must be created in Flux before running the pyflux command.

Example:

1. Extracting the magnitude of a harmonic:

Extracts magnitude of harmonic #2 in curve SPECTRUM. The value is given in the Output Window when executed in an interactive session.

2. Extracting the magnitude of a harmonic and assigning it to an I/O parameter:

The command extracts the amplitude of the second harmonic from the SPECTRUM curve and assigns the value to the parameter HARMONICMAGNITUDE.

Tagged: