How to obtain the mean torque on a I/O parameter

Jaime Maraví
Jaime Maraví New Altair Community Member
edited August 2022 in Community Q&A

Hi, I am trying to obtain the mean value of "TorqueElecMag(ROTOR)" as an I/O parameter. However, I am unable to do so as there isn´t such a function on the available ones. See below. 

Regards, 

Jaime

image

Tagged:

Answers

  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited July 2022

    Hi Jaime Maraví,

     

    You need to create a 2D curve(I/O parameter) for the TorqueElecMag(ROTOR) as an expression.

    Then you load the macro, Analyse2DCurve.PFM, in the Extensions>Macros from the Data Tree, and run it for the Torque 2D curve to compute the integral, max, mean, min, rectified mean and RMS values, that are saved as I/O parameters.

     

    In an optimization study(HyperStudy) you need to write the pyFlux code to create the torque 2D curve and then the one to run the macro in the post-processing python file.

     

    Best regards,

    Alexandru

  • Jaime Maraví
    Jaime Maraví New Altair Community Member
    edited July 2022

    Hi Jaime Maraví,

     

    You need to create a 2D curve(I/O parameter) for the TorqueElecMag(ROTOR) as an expression.

    Then you load the macro, Analyse2DCurve.PFM, in the Extensions>Macros from the Data Tree, and run it for the Torque 2D curve to compute the integral, max, mean, min, rectified mean and RMS values, that are saved as I/O parameters.

     

    In an optimization study(HyperStudy) you need to write the pyFlux code to create the torque 2D curve and then the one to run the macro in the post-processing python file.

     

    Best regards,

    Alexandru

    Thanks very much for your response Alexandru. 

    I want to get the average torque and set it as a goal for my optimization on Hyperstudy. Could you please expand what you said regarding the pyFlux code or maybe provide some examples on how to do it?

    Thanks very much. 

    Regards, 

    Jaime

  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited July 2022

    Thanks very much for your response Alexandru. 

    I want to get the average torque and set it as a goal for my optimization on Hyperstudy. Could you please expand what you said regarding the pyFlux code or maybe provide some examples on how to do it?

    Thanks very much. 

    Regards, 

    Jaime

    Hi Jaime,

     

    You are welcome!

     

    You need to load the macro Analyse2DCurve.PFM in the Flux project from where you generate your component for HyperStudy.

     

    Then you create a python file for postprocessing, which will include the PyFlux code that will delete the Torque curve if exists, create a torque 2D curve(I/O parameter) and then run the macro for the torque curve.

    For example, if the curve has the name „TORQUE”, at the end of running the macro there will be a TORQUE_MEAN I/O parameter with the mean value of torque.

     

    When you generate the component for HyperStudy you need to select the python file as the postprocessing python file and set the TORQUE_MEAN as a Component output.

     

    HyperStudy will solve the Flux project and then run the postprocessing python file. In the end, TORQUE_MEAN will have the mean value of the torque corresponding to a set of input variables.

     

    I attached a postprocessing python file as an example (you need to set your limits for the torque curve and the I/O parameters on the abscissa).

     

    Best regards,

    Alexandru

  • Jaime Maraví
    Jaime Maraví New Altair Community Member
    edited July 2022

    Hi Jaime,

     

    You are welcome!

     

    You need to load the macro Analyse2DCurve.PFM in the Flux project from where you generate your component for HyperStudy.

     

    Then you create a python file for postprocessing, which will include the PyFlux code that will delete the Torque curve if exists, create a torque 2D curve(I/O parameter) and then run the macro for the torque curve.

    For example, if the curve has the name „TORQUE”, at the end of running the macro there will be a TORQUE_MEAN I/O parameter with the mean value of torque.

     

    When you generate the component for HyperStudy you need to select the python file as the postprocessing python file and set the TORQUE_MEAN as a Component output.

     

    HyperStudy will solve the Flux project and then run the postprocessing python file. In the end, TORQUE_MEAN will have the mean value of the torque corresponding to a set of input variables.

     

    I attached a postprocessing python file as an example (you need to set your limits for the torque curve and the I/O parameters on the abscissa).

     

    Best regards,

    Alexandru

    Thanks very much Alexandru, it works with the python code provided. 

    Really thankful for this. 

    Regards, 

    Jaime

  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited July 2022

    Thanks very much Alexandru, it works with the python code provided. 

    Really thankful for this. 

    Regards, 

    Jaime

    You are welcome!

  • walid_22046
    walid_22046 Altair Community Member
    edited May 28

    hello Alexandru-Ionel Constantin,

     

    I have a question about the ripples torque formula when we use optimization on hyper study ??

     
    Contributor
    Correct Answer - 5

     

  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited August 2022

    hello Alexandru-Ionel Constantin,

     

    I have a question about the ripples torque formula when we use optimization on hyper study ??

     
    Contributor
    Correct Answer - 5

     

    Hi Walid,

     

    You create a 2D curve(I/O parameter) for the TorqueElecMag(ROTOR) as an expression, for example with the name TORQUE.

    Then you load the macro, Analyse2DCurve.PFM, in the Extensions>Macros from the Data Tree, and run it for the Torque 2D curve to compute the integral, max, mean, min, rectified mean and RMS values, that are saved as I/O parameters, for example: TORQUE_MAX, TORQUE_MEAN and TORQUE_MIN.

    Then you create a new Parameter I/O, for example TORQUE_RIPPLE  in percents, define by the formula: (TORQUE_MAX-TORQUE_MIN)/TORQUE_MEAN*100.

    You can compute the value by accessing: Computation>On a physical entity>Compute, where you select the f(), editor of formula and parameters and from the Physical you select the TORQUE_RIPPLE I/O parameter.

     

    Then you create a python file for postprocessing, which will include the PyFlux code that will delete the Torque curve if exists, create a torque 2D curve(I/O parameter) and then run the macro for the torque curve.

     

    When you generate the component for HyperStudy you need to select the python file as the postprocessing python file and set the TORQUE_RIPPLE as a Component output.

     

    HyperStudy will solve the Flux project and then run the postprocessing python file. In the end, TORQUE_RIPPLE will have the value of the torque ripple in percents corresponding to a set of input variables.

     

    I attached a postprocessing python file as an example (you need to set your limits for the torque curve and the I/O parameters on the abscissa).

     

    Best regards,

    Alexandru

  • walid_22046
    walid_22046 Altair Community Member
    edited August 2022

    Hi Walid,

     

    You create a 2D curve(I/O parameter) for the TorqueElecMag(ROTOR) as an expression, for example with the name TORQUE.

    Then you load the macro, Analyse2DCurve.PFM, in the Extensions>Macros from the Data Tree, and run it for the Torque 2D curve to compute the integral, max, mean, min, rectified mean and RMS values, that are saved as I/O parameters, for example: TORQUE_MAX, TORQUE_MEAN and TORQUE_MIN.

    Then you create a new Parameter I/O, for example TORQUE_RIPPLE  in percents, define by the formula: (TORQUE_MAX-TORQUE_MIN)/TORQUE_MEAN*100.

    You can compute the value by accessing: Computation>On a physical entity>Compute, where you select the f(), editor of formula and parameters and from the Physical you select the TORQUE_RIPPLE I/O parameter.

     

    Then you create a python file for postprocessing, which will include the PyFlux code that will delete the Torque curve if exists, create a torque 2D curve(I/O parameter) and then run the macro for the torque curve.

     

    When you generate the component for HyperStudy you need to select the python file as the postprocessing python file and set the TORQUE_RIPPLE as a Component output.

     

    HyperStudy will solve the Flux project and then run the postprocessing python file. In the end, TORQUE_RIPPLE will have the value of the torque ripple in percents corresponding to a set of input variables.

     

    I attached a postprocessing python file as an example (you need to set your limits for the torque curve and the I/O parameters on the abscissa).

     

    Best regards,

    Alexandru

    thank's Alexandru-Ionel Constantin,
     
    I created the parameter ripple torque I inserted the formula tells me there is an error on the formula the parameter TORQUE_MAX is unknown.
     
    The message is :
     
    '' The following command cannot be interpreted:
    try:
    CurveVariation2D['TORQUE'].delete()
    except:
    print("Torque curve does not exist!")

    EvolutiveCurve2D(name='Torque',
    evolutivePath=EvolutivePath(parameterSet=[SetParameterXVariable(paramEvol=VariationParameter['TIME'],
    limitMin=2.0E-4,
    limitMax=0.0028)]),
    formula=['TORQUE'])

    lastInstance = VariationParameterFormula(name='TORQUE_RIPPLE',
    formula='(TORQUE_MAX-TORQUE_MIN)/TORQUE_MEAN*100')
     
    TORQUE_MAX is not a valid parameter name ''
  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited August 2022

    thank's Alexandru-Ionel Constantin,
     
    I created the parameter ripple torque I inserted the formula tells me there is an error on the formula the parameter TORQUE_MAX is unknown.
     
    The message is :
     
    '' The following command cannot be interpreted:
    try:
    CurveVariation2D['TORQUE'].delete()
    except:
    print("Torque curve does not exist!")

    EvolutiveCurve2D(name='Torque',
    evolutivePath=EvolutivePath(parameterSet=[SetParameterXVariable(paramEvol=VariationParameter['TIME'],
    limitMin=2.0E-4,
    limitMax=0.0028)]),
    formula=['TORQUE'])

    lastInstance = VariationParameterFormula(name='TORQUE_RIPPLE',
    formula='(TORQUE_MAX-TORQUE_MIN)/TORQUE_MEAN*100')
     
    TORQUE_MAX is not a valid parameter name ''

    Hi Walid,

     

    You wrote the wrong formula( expression), for the torque curve. The formula(expression) is TorqueElecMag(ROTOR), where ROTOR is the mechanical set for the rotor parts.

     

    Best regards,

    Alexandru

     

  • walid_22046
    walid_22046 Altair Community Member
    edited August 2022

    Hi Walid,

     

    You wrote the wrong formula( expression), for the torque curve. The formula(expression) is TorqueElecMag(ROTOR), where ROTOR is the mechanical set for the rotor parts.

     

    Best regards,

    Alexandru

     

    I am trying to calculate ripple torque and mean torque for a hyperstudy so the ripple torque formula
    I used this program :

    try:
    CurveVariation2D['TORQUE'].delete()
    except:
    print("Torque curve does not exist!")

    EvolutiveCurve2D(name='Torque',
    evolutivePath=EvolutivePath(parameterSet=[SetParameterXVariable(paramEvol=VariationParameter['TIME'],
    limitMin=2.0E-4,
    limitMax=0.0028)]),
    formula=['TORQUE'])

    lastInstance = VariationParameterFormula(name='TORQUE_RIPPLE',
    formula='(TORQUE_MAX-TORQUE_MIN)/TORQUE_MEAN*100')

  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited August 2022

    I am trying to calculate ripple torque and mean torque for a hyperstudy so the ripple torque formula
    I used this program :

    try:
    CurveVariation2D['TORQUE'].delete()
    except:
    print("Torque curve does not exist!")

    EvolutiveCurve2D(name='Torque',
    evolutivePath=EvolutivePath(parameterSet=[SetParameterXVariable(paramEvol=VariationParameter['TIME'],
    limitMin=2.0E-4,
    limitMax=0.0028)]),
    formula=['TORQUE'])

    lastInstance = VariationParameterFormula(name='TORQUE_RIPPLE',
    formula='(TORQUE_MAX-TORQUE_MIN)/TORQUE_MEAN*100')

    Hi Walid,

     

    formula=['TORQUE']) is wrong.

    The correct version is like this:

    formula=['TorqueElecMag(ROTOR)']), if your mechanical set assigned to the rotor parts  is named ROTOR.

     

    Add those lines before you define the TORQUE_RIPPLE I/O parameter, loading the macro for analyses of the torque curve and them run the macro to analyse the torque curve:

    loadMacro(fileName='C:/Program Files/Altair/2022/flux/Extensions/Macros/Analyse2DCurve.PFM')

    Analyse2DCurve(curve2D=Curve2d['TORQUE'])

     

    Best regards,

    Alexandru

  • walid_22046
    walid_22046 Altair Community Member
    edited August 2022

    Hi Walid,

     

    formula=['TORQUE']) is wrong.

    The correct version is like this:

    formula=['TorqueElecMag(ROTOR)']), if your mechanical set assigned to the rotor parts  is named ROTOR.

     

    Add those lines before you define the TORQUE_RIPPLE I/O parameter, loading the macro for analyses of the torque curve and them run the macro to analyse the torque curve:

    loadMacro(fileName='C:/Program Files/Altair/2022/flux/Extensions/Macros/Analyse2DCurve.PFM')

    Analyse2DCurve(curve2D=Curve2d['TORQUE'])

     

    Best regards,

    Alexandru

    thank you very much dear Alexandru-Ionel Constantin,

    I tested this program and it works very well. thank you 

     

     

     

     

  • Alexandru-Ionel Constantin
    Alexandru-Ionel Constantin Altair Community Member
    edited August 2022

    thank you very much dear Alexandru-Ionel Constantin,

    I tested this program and it works very well. thank you 

     

     

     

     

    Hi Walid,

    You're welcome!

    Best regards,

    Alexandru