Wolfram Computation Meets Knowledge

Physics

Expand the curriculum with exciting experiments in dynamics and gain insight into how modeling and simulation can enhance and strengthen understanding of physics and math concepts.

Golf and Soccer

This example will show how you can create very different scenarios using some concepts in SystemModeler and Modelica. In this case, both a soccer kick and a golf strike are included in the same model, using something called replaceable components.

To run this example, you'll need

The latest versions of System Modeler and Mathematica.

Please make a selection:

Get a
free trial
Continue
with download

From Soccer to Golf

Inside the sport model component are the two different models for golf and soccer. By redeclaring the top-layer sport model, you can choose which of these models to use.

By redeclaring the model you want to use, all parameters will change appropriately, with only one click.

Having preconfigured options that the user can choose between when changing parameters reduces the risk of making errors by trying to modify a scenario manually. Let the big changes be done by redeclaring models and the small changes, such as how fast the golf swing should be, be decided manually by the user.

Redeclare Models

If you redeclare the top-layer sport model to use the soccer model, it is basically the same model as was analyzed in the Bend It Like Beckham example. If you want to see what can be done with the soccer model, check out that example! Here you can focus on what the golf model contains.

Diagram view of the golf model within the sport model component. Magnus and drag forces, as well as a visualization, are connected to a body to transform the body into a golf ball. A golf bag with different clubs is used to calculate the velocity of the ball after a strike.

User-Friendly Models

Redeclare can give drop-down choices so the user can decide what model configurations to simulate.

Modeling Golf Club Hitting Golf Ball

The equations modeling the club hitting the ball are relatively simple and taken from the book Physics for Game Programmers. The velocity of the ball after striking is dependent on the velocity of the club at impact, the loft angle of the club, and the mass of the club and ball. To model different clubs, each club has a different club mass, loft angle, and impact velocity. To make it easy for the user to change clubs, the replaceable component Golf Bag has been implemented, with preconfigured different clubs inside.

Golf Bag component where different redeclaration choices have been made. The user can easily decide what club should be modeled.

How does a 3 iron compare to a 9 iron? First simulate the golf model with a 3 iron and then simulate the same model with a 9 iron. This is done by just redeclaring the club in the Golf Bag component and simulating again. The loft angles for the two clubs are 21° for the 3 iron and 43° for the 9 iron. Both strikes will be identical except for the different club properties.

Ball trajectory visualized in the animation from a 3 iron.
Ball trajectory visualized in the animation from a 9 iron.

Comparing the 3 iron and the 9 iron, they have different properties when it comes to club mass, loft angle, and striking velocity. Since the 3 iron has a lower loft angle, it will launch the ball at a lower inclination angle compared to the 9 iron. In the figures above, the strikes in the two cases are identical, apart from the difference in club properties. It is easy to see that the 3 iron will make the ball go further, but not as high as the 9 iron.

Effects of Drag Force and Magnus Force

You can analyze how the drag force and Magnus force affect the trajectory of a ball. The simplest way to see the effect of the forces is to compare the cases of a model without drag force and one with drag force, and the same for the Magnus force.

This plot shows how the trajectory changes for a 3 iron with/without drag and with/without Magnus force.

How to Cheat at Golf

If you could disable the drag force and use the Magnus effect, you would be a golf pro in no time!

It is really easy to understand how the ball is affected by these forces, but it might be a bit difficult to grasp from just using mathematics. You could have a real advantage if you managed to shoot the ball utilizing the Magnus effect but discarding the drag. Sadly, this is impossible. However, the plot shows quite well the effect of both the decelerating drag force and the lifting Magnus force.

Flexible Modeling

Use the strength of SystemModeler and Modelica to create flexible models