Creating responses in HyperStudy (study setup)

Rahul_P1
Rahul_P1
Altair Employee
edited October 2020 in Community Q&A

Hi everyone,

Wondering if this is able to do when creating a response in HyperStudy.

I'd like to express a response via using a vector of result values. For example:
v_1={0, -1, -2, -7.7, 1, 0.5}

However, I'd like to discard the result values greater than (> 0) in the vector. So that, the vector v_1 becomes v_1={0, -1, -2, -7.7}.

Please help.

Any suggestions or ideas are welcome. icon_wink.gif

Thanks in advance!

Cheers,
cncwl

Answers

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi,
    Please let us know the type of response you would want to create by discarding the result values >0.

    i.e do you want max/min value of the vector in the results file.

    Regards
    Dilip Ram

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi Dilip,

    The response I'd like to create represents the stresses and is one of the constraint responses in optimization. The stress values <= 0 are considered simply because the problem being sought is to dismiss the wrinkles of a membrane structure (constraint lower bound (>=) value is 0). Wrinkles exist locally when compressive stresses about to appear. This means that the stress values of some elements are greater than 0 (tension) and therefore will be discarded.

    The minimum (min) value of the vector in the results file is a simple expression yet is treated as a local constraint rather than a 'global' constraint (using aggregation formulations) which potentially smoothen the function.

    Regards,

    cncwl

     
  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi,
    Please let me know the type of result file used to extract a response and a value in that vector you want to use it as constraint.
    If this file can be loaded in HG please get the index value by using the following command and use it as a constraint.

    getvalueatindex ('v_2',1)

    i,e the index value would be 1.This would return the corresponding value at index 1.

    Hope this helps

    Regards
    Dilip Ram

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi,

    It's Abaqus results (.fil) file.
    Element stresses can be easily extracted by defining a vector. However, as I explained, by doing so is to extract all the result values of the stresses, i.e. positive and negative. For example, the result values of a stress component for 5 elements using the vector can be {0, -1, 5, -2, 1}. I'd like to discard the result values in the vector > 0. So that, the result values extracted are {0, -1, -2}.
    Using the getvalueatindex templex statement will return a scalar value of the indexed vector, as in your example.

    Regards,
    cncwl

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi,
    I will check if there is any option get a vector with result values >0.
    Meanwhile try range operator in templex where x[n:m] will pull out the subvector of entries from n to m. so we are looking at having something like:

    Max(v_6(“min”:”max”))

    But we need to determine the min and max entries based on your element range. Here we can use the subrange command which will find in the index values within the supplied range. For example,

    Subrange(v_5,10,100) will pull the indices of entries with values between 10 and 100, the first is the starting point, and the last entry is the maximum index. Putting this all together, you can have:

    max(v_6[subrange(v_5,1,300)[0]:subrange(v_5,1,300)[maxindex(subrange(v_5,1,300))]])

    This will evaluate the max stress in elements 1 to 300.

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi
    You can also use the simple Hmath function below:
    function removeLesser(input,bound)
    retVec=[]
    for i = 1,Length(input) do
    if input(i) > bound then
    retVec(Length(retVec)+1)=input(i)
    end
    end
    return retVec
    end

    You have to register this function in the preference file for HyperStudy. To do so, save a preference file with .mvw extension. Contents of this file should be:
    *Id('HyperStudy v11.0')

    *BeginDefaults()
    *BeginTemplexFunctions()
    {templex_off}
    *BeginTemplexFunction()
    *BeginText()
    INSERT FUNCTION HERE
    *EndText()
    *EndTemplexFunction()
    {templex_on}
    *EndTemplexFunctions()
    *EndDefaults()

    Then in HyperStudy11.0, point to this preference file. You should see the function removeLesser in the response expression builder.
    I hope this helps, let me know if it does not.

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Hi guys,

    Thank you to all who have contributed ideas. Very much appreciated!

    Defining functions using the HyperMath function keyword is a convenient way as suggested by fatma. The function within the HyperMath HML (.hml) file has to be registered first in a preference (.mvw) file for HyperStudy prior to accessing from the HyperStudy-Response Expression Builder (Functions... panel below the window). The syntax for the registration keyword is:

    *RegisterHMATHFunction('removeLesser', 'the path name of the .hml file', 2)

    To do so in HyperStudy:
    1. Click on Tools pull-down menu.
    2. Click on Readers, Writers, and Functions... panel.
    Readers, Writers, and Functions window appears.
    3. Click Save As and provide a file name to this preference (.mvw) file, for example, userprefs.
    4. Click Save to save this file in your working directory.
    5. Open userprefs.mvw using a text editor.
    6. Insert the registration keyword above between the last *RegisterExternalFunction() statement and *EndPlotDefaults() statement.
    7. Save and exit userprefs.mvw.
    8. From the File pull-down menu, click on Set Preference File... panel.
    9. Select and open userprefs.mvw.

    Then, one can see removeLesser within the Functions... panel below the HyperStudy-Response Expression Builder window.

    I think this is how it works.

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    That is how it works in HyperStudy 11.0.
    Use of preference files is simplified in HyperStudy 12.0 which is about to be released with HyperWorks 12.0. Some of those simplifications are:
    You can right click on your function in HyperMath and register with HyperGraph (HG).
    This creates a preference (.mvw) file in your home directory
    Edit the file to change HyperGraph to HyperStudy
    In HyperStudy all you have to do is to go to File-Set Preference File and point to the .mvw file.
    Actually, lot of things are simplified and improved in HyperStudy12.0;)
    b2ns8-HMath_Register.png
    w1qj3-HSt_Preference.png

  • Rahul_P1
    Rahul_P1
    Altair Employee
    edited February 2015

    Good job! This is even quicker with a few clicks.