Evaluate functions in template

CdricCd
CdricCd Altair Community Member
edited May 2023 in Community Q&A

Hello guys,

 

I'm new here and I have a little problem I'm sure you can handle 

 

I will present you my model so if you want you can suggest different solution than mine 

 

[MODEL]

 

I'm trying to model the stiffness of a spring acting on a shift moving along his X axis by putting a force. The 'difficulty' is that we have different responses whether the shift is moving along +X or -X. So I have two curves (force vs displacement), one for the stiffness while the shift is moving along +X and the other one for the stiffness while the shift is moving along -X.

 

[SOLUTION]

 

The idea was to create 2 forces (with one curve attached to each other) at the point where the spring acts, and for example deactivate one force while the shift is moving in one direction and when it moves in the other direction, deactivate this force and activate the the other one etc.

So I wanted to create a template in which I activate/deactivate the concerned forces as a function of the sense of the velocity of the shift by using two markers (see picture).

 

[PROBLEM]


So I use the VX({marker0},{marker1}) function in the template but it says ' Unknown function 'VX' in expression: velx = VX({m_1.idstring},{m_0.idstring}) '

I tried with ' ` ` ' but it had non effect.

 

So my question is : How to evaluate this function is the template ?

 

I join you a picture of the model and the little script I use for the Simulation Commands (Write text to solver command file).

I'm a beginner with the scripted simulation so it can be totally wrong 

 

Thank you !

 

 

Here the script :

 

 

<Simulate

   analysis_type  = 'Transient'

   end_time       = '1.0'

   print_interval = '0.001'

/>

 

{velx = VX({m_1.idstring},{m_0.idstring})}

 

{if (velx<0)}

     <Activate

   element_type = 'FORCE'

   element_id   = '30101'

/>

 

<Deactivate

   element_type = 'FORCE'

   element_id   = '30102'

/>

 

{elseif(velx>0)}

     <Activate

   element_type = 'FORCE'

   element_id   = '30102'

/>

 

<Deactivate

   element_type = 'FORCE'

   element_id   = '30101'

/>

 

{endif}

 

<Stop/>

<?xml version="1.0" encoding="UTF-8"?>model.PNG

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    Hi @CdricCd

     

    Use ` ` (the key below Esc on keyboard) and check if there are any syntax errors.

     

    If everything is fine and you still get the same error, please share the model file. (use the flie transfer link in my signature)

  • CdricCd
    CdricCd Altair Community Member
    edited November 2020

    Hi,

     

    I already tried this and had this error : { Syntax error in expression: velx = `VX({m_1.idstring},{m_0.idstring})` }

     

    The file is small i linked it with my message.

     

    Thanks

    Unable to find an attachment - read this blog

  • CdricCd
    CdricCd Altair Community Member
    edited May 2017

    Wrong message

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    Hi,

    VX({m_1.idstring},{m_0.idstring})`  is a MotionSolve runtime expression

    it is evaluated by MotionSolve..

    template cannot do it...

     

    But this can be done through expression, I will update to you soon. 

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    @CdricCd

     

    Try this model:

    Also try to increase number of points on curve. They need to be smooth when AKIMA interpolation is switched ON in the curves panel

     

    Unable to find an attachment - read this blog

  • CdricCd
    CdricCd Altair Community Member
    edited May 2017

    Thanks !

     

    The 'IF' function in expression was my second idea but I had no idea how to introduce curves. I will investigate your solution.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    [MODEL]

     

    I'm trying to model the stiffness of a spring acting on a shift moving along his X axis by putting a force. The 'difficulty' is that we have different responses whether the shift is moving along +X or -X. So I have two curves (force vs displacement), one for the stiffness while the shift is moving along +X and the other one for the stiffness while the shift is moving along -X.

     

     

    I also stuck in the same problem. Though couldnt find out the solution. Your idea is pretty cool

  • CdricCd
    CdricCd Altair Community Member
    edited May 2017

    So I come back for the news and the solution works perfectly. I just have to use the LINSPL function instead of the AKISPL one and add a lot of point on the curve in order to make a correct interpolation.