hyperstudy function

MIN_21722
MIN_21722 Altair Community Member
edited July 2021 in Community Q&A

I want to get the X coordinate of maximum value with a graph,which function is available .thank you

 

Answers

  • Rahul Rajan_21763
    Rahul Rajan_21763 New Altair Community Member
    edited June 2019

    Use file assistant for extracting responses. Refer attached video.

    Unable to find an attachment - read this blog

  • MIN_21722
    MIN_21722 Altair Community Member
    edited June 2019

    thank you very much

     

  • Autumn
    Autumn Altair Community Member
    edited April 2021

    When defining output responses is it possible to determine the index of a specific value that isn't the minimum or maximum?

    For example, I'm interested in knowing when the displacement of an element reaches a specific value that isn't necessarily the minimum/maximum, so the functions 'indexofmin' and 'indexofmax' aren't useful in this situation.

  • Autumn
    Autumn Altair Community Member
    edited May 2021
    Autumn said:

    When defining output responses is it possible to determine the index of a specific value that isn't the minimum or maximum?

    For example, I'm interested in knowing when the displacement of an element reaches a specific value that isn't necessarily the minimum/maximum, so the functions 'indexofmin' and 'indexofmax' aren't useful in this situation.

    (SOLUTION)

    I was able to define two .py files and load them using a .mvw preferences file in HyperStudy to achieve this.

    The first .py function found the value in the list closest to a specific value:
    > def closest(list, val):
    >     return list[min(range(len(list)), key = lambda i: abs(list[i]-val))]

    The next .py function simply utilizes the index() function in Python:
    > def indexofval(list, val):
    >     return list.index(val)

    I then created a .mvw preferences file following the steps outlined in HS-1040 being sure to use *RegisterPythonFunction in the file twice to properly load both functions.

    Example: If I am then interested in finding the index of when the displacement of a node (list = disp) reaches 0.03 (=val) I can use the expression: "indexofval(disp, closest(disp, 0.03))". Since the displacement might not actually ever equal 0.03 exactly, I needed the "closest" function.

    I also used the pre-defined function "getval2" to find other values (e.g. internal energy) associated with this specific displacement point. More information on these pre-defined functions in HyperStudy can be found in the HyperWorks online help page (HyperWorks Desktop Ref Guide > Templex & Math Ref Guide > Math Ref > Functions & Operators    - AND -    HyperWorks Desktop Ref Guide > Templex & Math Ref Guide > Templex Ref > Templex Statements)

  • Diana_38240
    Diana_38240
    Altair Employee
    edited May 2021
    Autumn said:

    When defining output responses is it possible to determine the index of a specific value that isn't the minimum or maximum?

    For example, I'm interested in knowing when the displacement of an element reaches a specific value that isn't necessarily the minimum/maximum, so the functions 'indexofmin' and 'indexofmax' aren't useful in this situation.

    Hello,

    I see your request without response along this thread.

    The easiest way I see is to first identify the index of interest in the data source and then define a response to extract the value at this index. Fon instance in the example below the response is defined with Displacement value at index 6505.

    Can this work in your case?

    image

  • Autumn
    Autumn Altair Community Member
    edited May 2021

    Hello,

    I see your request without response along this thread.

    The easiest way I see is to first identify the index of interest in the data source and then define a response to extract the value at this index. Fon instance in the example below the response is defined with Displacement value at index 6505.

    Can this work in your case?

    image

    Hello,

    Thank you for this information. I ended up creating two functions using Python and uploading a preferences file to HyperStudy (details in my response above titled with "(SOLUTION)" for anyone interested). This approach you've outlined would work, it would just be quite tedious in my case as I'm looking for a specific value that may not be at the same index for each run and I have quite a number of runs.

    I really appreciate your feedback!

  • Diana_38240
    Diana_38240
    Altair Employee
    edited May 2021
    Autumn said:

    Hello,

    Thank you for this information. I ended up creating two functions using Python and uploading a preferences file to HyperStudy (details in my response above titled with "(SOLUTION)" for anyone interested). This approach you've outlined would work, it would just be quite tedious in my case as I'm looking for a specific value that may not be at the same index for each run and I have quite a number of runs.

    I really appreciate your feedback!

    Thanks for sharing your solution!

    For information, in HyperStudy 2021 there is a simpler way to register python function through the GUI.

    image

    image

  • Autumn
    Autumn Altair Community Member
    edited May 2021

    Thanks for sharing your solution!

    For information, in HyperStudy 2021 there is a simpler way to register python function through the GUI.

    image

    image

    Thank you for the tip!

  • Diana_38240
    Diana_38240
    Altair Employee
    edited May 2021
    Autumn said:

    Thank you for the tip!

    You are welcome.

  • Michael Herve
    Michael Herve
    Altair Employee
    edited July 2021

    Hello Automn,

     

    let's say you have a stress vs plastic strain function for which you want to extract some information

    You first need to create 2 data sources:

    plastic strain, data source ds_1: {0 .1 .2 .3 .4 .5}

    stress, data_source ds_2: {200 220 230 235 248}

     

    let's say that you want the stress for plastic strain = .25, which is not available

    You can then use lininterp command to get the value : lininterp(ds_1, ds_2, .25)

     

    Best Regards,

    Michael