Message Boards Message Boards

Cost cutting in procedurally specified simulations

Posted 8 years ago

I wanted to simulate the bar chains on a suspension bridge, roughly a linkage of uniform bars. It's easy to specify equations for motion and tension of a few links, and then hope that Solve and NDSolve can hash things out. However computation time becomes unfeasible as the number of segments grows towards double digits. Whilst a lot of the simulations I'm interested in are essentially static, they should comprise thirty or forty bars.

overhead timing

A log plot of overhead time Mathematica spent simplifying my definition of systems with one to six bars.

The complexity of a numeric system is not intuitively tied to the complexity of its definition. It is easy to describe a simple system in slightly ill thought out equations, and be left with a lot of algebraic work to do. In my system the complex aspects are equalities in derivatives of angles, the initial conditions are a trivial addendum. Rather than generating concise equations for each bar and letting the symbolic algebra do the heavy lifting, I calculate the derivative of the nth bar manually, and simplify for angular second derivatives.

speed comparison plot

Before simplifying, this four link plot had a simplification overhead of twenty one seconds. Doing the work preemptively on the general link reduces this to one second!

With the difficult symbolic work extracted, one can easily simulate hundreds of links for calm systems. It's easy to insert your own forces and initial conditions on these systems. Pictured is a blade of grass: a uniform chain with forces correcting angular displacement, and providing drag. In theory it's returning to equilibrium as a deforming force is removed. Calculated by NDSolve in a quarter second.

grass correction grass angular displacement plot

The attached notebook walks through all this, and talks about some structural ideas that aid working on these kinds of simplification.

Attachments:
POSTED BY: David Gathercole
3 Replies

enter image description here - another post of yours has been selected for the Staff Picks group, congratulations !

We are happy to see you at the tops of the "Featured Contributor" board. Thank you for your wonderful contributions, and please keep them coming!

POSTED BY: Moderation Team

Nice post, David! Do you have a force diagram and general form of equations you are solving?

POSTED BY: Sam Carrettie

A force diagram (tension excluded) can be shown nicely for the grass example, as the dynamic forces are defined directly from equations of angular derivatives, and thus have already been calculated. This also helps stress how easy it is to play with said forces, as they are stuck in after all the hard work.

grass forces

Arrows representing forces. Gravity, drag, and angular restorative forces are respectively blue, green, and red. Length proportional to square root of force magnitude.

The general equations would be as follows. All angle specified forces were appended, rather than worked with throughout (though you've incurred some self doubt here, I'll try to explicitly verify some assumptions soon.)

D[ MassOneX[t] ,{t,2}] = Sin[ AngleOne[t] ] TensionOne[t] + Sin[ AngleOne[t] ] TensionTwo[t]
D[ MassOneY[t] ,{t,2}] = Cos[ AngleOne[t] ] TensionOne[t] + Cos[ AngleOne[t] ] TensionTwo[t] + m g
...
D[ MassN-1X[t] ,{t,2}] = Sin[ AngleN-1[t] ] TensionN-1[t] + Sin[ AngleN-1[t] ] TensionN[t]
D[ MassN-1Y[t] ,{t,2}] = Cos[ AngleN-1[t] ] TensionN-1[t] + Cos[ AngleN-1[t] ] TensionN[t] + m g
D[ MassNX[t] ,{t,2}] = Sin[ AngleN[t] ] TensionN[t]
D[ MassNY[t] ,{t,2}] = Cos[ AngleN[t] ] TensionN[t] + m g
POSTED BY: David Gathercole
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract