How to set a spring whose stiffness changes with body's displacement

53 views
Skip to first unread message

Yupeng Duan

unread,
Mar 20, 2024, 9:18:27 AM3/20/24
to ProjectChrono
Hi 
I am a beginer in using ProjectChrono, I want to calculate a body with a spring linked with the ground but the stiffness changes with the displacement of the body. I tryed give a if() i during the runtime ,but it seems nothing has changed, what should I do for this purpose.

微信截图_20240320211804.png

Radu Serban

unread,
Mar 20, 2024, 9:48:25 AM3/20/24
to ProjectChrono

Yupeng – you can do this by implementing your own custom force callback for a ChLinkTSDA.

See demo_MBS_spring.cpp which illustrates the use of such a callback mechanism.  While that example is very simple and for demonstration only, you can implement whatever function you want for the force produced by the spring. Within the Evaluate() function, you have access to the ChLinkTSDA element itself which means you can access the current positions of the connected bodies and use that in the force evaluation if you so desire.

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/0de81a94-f565-4993-bf28-9853a53571c1n%40googlegroups.com.

Yupeng Duan

unread,
Mar 20, 2024, 11:12:02 AM3/20/24
to ProjectChrono
Than you !  Radu 
Reply all
Reply to author
Forward
0 new messages