Skip to content

Instantly share code, notes, and snippets.

# dharmatech/pse-example-5.10.md

Last active January 4, 2017 13:20
Star You must be signed in to star a gist

# Acceleration of Two Objects Connected by a Cord

A ball of mass m1 and a block of mass m2 are attached by a lightweight cord that passes over a frictionless pulley of negligible mass, as shown in the figure below. The block lies on a frictionless incline of angle θ. Find the magnitude of the acceleration of the two objects and the tension in the cord.

Let's solve this problem using Symbolism, a computer algebra library for C#.

Free-body diagram for the ball:

There are two forces acting on the ball. Here are the symbols we'll need for the ball:

```var F1_m1 = new Symbol("F1_m1");        // force 1 on mass 1
var F2_m1 = new Symbol("F2_m1");        // force 2 on mass 1

var th1_m1 = new Symbol("th1_m1");      // direction of force 1 on mass 1
var th2_m1 = new Symbol("th2_m1");      // direction of force 2 on mass 1

var F1x_m1 = new Symbol("F1x_m1");      // x-component of force 1 on mass 1
var F2x_m1 = new Symbol("F2x_m1");      // x-component of force 2 on mass 1

var F1y_m1 = new Symbol("F1y_m1");      // y-component of force 1 on mass 1
var F2y_m1 = new Symbol("F2y_m1");      // y-component of force 2 on mass 1

var Fx_m1 = new Symbol("Fx_m1");        // x-component of total force on mass 1
var Fy_m1 = new Symbol("Fy_m1");        // y-component of total force on mass 1

var ax_m1 = new Symbol("ax_m1");        // x-component of acceleration of mass 1
var ay_m1 = new Symbol("ay_m1");        // y-component of acceleration of mass 1

var m1 = new Symbol("m1");```

Free-body diagram for the block:

There are three forces acting on the block. The symbols we'll be using for the block:

```var F1_m2 = new Symbol("F1_m2");        // force 1 on mass 2
var F2_m2 = new Symbol("F2_m2");        // force 2 on mass 2
var F3_m2 = new Symbol("F3_m2");        // force 3 on mass 2

var th1_m2 = new Symbol("th1_m2");      // direction of force 1 on mass 2
var th2_m2 = new Symbol("th2_m2");      // direction of force 2 on mass 2
var th3_m2 = new Symbol("th3_m2");      // direction of force 3 on mass 2

var F1x_m2 = new Symbol("F1x_m2");      // x-component of force 1 on mass 2
var F2x_m2 = new Symbol("F2x_m2");      // x-component of force 2 on mass 2
var F3x_m2 = new Symbol("F3x_m2");      // x-component of force 3 on mass 2

var F1y_m2 = new Symbol("F1y_m2");      // y-component of force 1 on mass 2
var F2y_m2 = new Symbol("F2y_m2");      // y-component of force 2 on mass 2
var F3y_m2 = new Symbol("F3y_m2");      // y-component of force 3 on mass 2

var Fx_m2 = new Symbol("Fx_m2");        // x-component of total force on mass 2
var Fy_m2 = new Symbol("Fy_m2");        // y-component of total force on mass 2

var ax_m2 = new Symbol("ax_m2");        // x-component of acceleration of mass 2
var ay_m2 = new Symbol("ay_m2");        // y-component of acceleration of mass 2

var m2 = new Symbol("m2");```

A few other miscellaneous symbols we'll use:

```var incline = new Symbol("incline");

var T = new Symbol("T");                // tension in cable

var g = new Symbol("g");                // gravity

var n = new Symbol("n");                // normal force on block

var a = new Symbol("a");

var Pi = new Symbol("Pi");```

Here are the equations for the ball:

```F1x_m1 == F1_m1 * cos(th1_m1),
F2x_m1 == F2_m1 * cos(th2_m1),

F1y_m1 == F1_m1 * sin(th1_m1),
F2y_m1 == F2_m1 * sin(th2_m1),

Fx_m1 == F1x_m1 + F2x_m1,
Fy_m1 == F1y_m1 + F2y_m1,

Fx_m1 == m1 * ax_m1,
Fy_m1 == m1 * ay_m1,```

Equations for the block:

```F1x_m2 == F1_m2 * cos(th1_m2),
F2x_m2 == F2_m2 * cos(th2_m2),
F3x_m2 == F3_m2 * cos(th3_m2),

F1y_m2 == F1_m2 * sin(th1_m2),
F2y_m2 == F2_m2 * sin(th2_m2),
F3y_m2 == F3_m2 * sin(th3_m2),

Fx_m2 == F1x_m2 + F2x_m2 + F3x_m2,
Fy_m2 == F1y_m2 + F2y_m2 + F3y_m2,

Fx_m2 == m2 * ax_m2,
Fy_m2 == m2 * ay_m2,```

We need to relate the acceleration of the ball to the acceleration of the block:

``````ax_m2 == ay_m1,     // the block moves right as the ball moves up
``````

Finally, we'll say `a` is the same as `ax_m2`

``````a == ax_m2
``````

All of the above go in an `And` expression. This is our system of equations:

```var eqs = new And(

ax_m2 == ay_m1,                     // the block moves right as the ball moves up

////////////////////////////////////////////////////////////////////////////////

F1x_m1 == F1_m1 * cos(th1_m1),
F2x_m1 == F2_m1 * cos(th2_m1),

F1y_m1 == F1_m1 * sin(th1_m1),
F2y_m1 == F2_m1 * sin(th2_m1),

Fx_m1 == F1x_m1 + F2x_m1,
Fy_m1 == F1y_m1 + F2y_m1,

Fx_m1 == m1 * ax_m1,
Fy_m1 == m1 * ay_m1,

////////////////////////////////////////////////////////////////////////////////

F1x_m2 == F1_m2 * cos(th1_m2),
F2x_m2 == F2_m2 * cos(th2_m2),
F3x_m2 == F3_m2 * cos(th3_m2),

F1y_m2 == F1_m2 * sin(th1_m2),
F2y_m2 == F2_m2 * sin(th2_m2),
F3y_m2 == F3_m2 * sin(th3_m2),

Fx_m2 == F1x_m2 + F2x_m2 + F3x_m2,
Fy_m2 == F1y_m2 + F2y_m2 + F3y_m2,

Fx_m2 == m2 * ax_m2,
Fy_m2 == m2 * ay_m2,

////////////////////////////////////////////////////////////////////////////////

a == ax_m2

);```

Now let's define the "values" that are known:

```var vals = new List<Equation>()
{
ax_m1 == 0,                         // ball  moves vertically
ay_m2 == 0,                         // block moves horizontally

F1_m1 == T,
F2_m1 == m1 * g,

th1_m1 == 90 * Pi / 180,            // force 1 is straight up
th2_m1 == 270 * Pi / 180,           // force 2 is straight down

F1_m2 == n,
F2_m2 == T,
F3_m2 == m2 * g,

th1_m2 == 90 * Pi / 180,            // force 1 is straight up
th2_m2 == 180 * Pi / 180,           // force 2 is straight down
th3_m2 == 270 * Pi / 180 + incline  // force 3 direction
};```

OK, to find the symbolic value of `a`, we substitute `vals` into our equations, eliminate all the unknowns, and display the result:

```eqs
.SubstituteEqLs(vals)

.EliminateVariables(
F1x_m1, F2x_m1,
F1y_m1, F2y_m1,

Fx_m1, Fy_m1,

F1x_m2, F2x_m2, F3x_m2,
F1y_m2, F2y_m2, F3y_m2,

Fx_m2, Fy_m2,

ax_m2, n, T, ay_m1
)

.DispLong()```

Here's what's printed to the console:

Let's find the acceleration of each object when m1 = 10.0 kg, m2 = 5.00 kg, and θ = 45.0°. We'll substitute these values into the symbolic result found earlier:

```eqs
.SubstituteEqLs(vals)

.EliminateVariables(
F1x_m1, F2x_m1,
F1y_m1, F2y_m1,

Fx_m1, Fy_m1,

F1x_m2, F2x_m2, F3x_m2,
F1y_m2, F2y_m2, F3y_m2,

Fx_m2, Fy_m2,

ax_m2, n, T, ay_m1
)

.SubstituteEq(m1 == 10.0)
.SubstituteEq(m2 == 5.0)
.SubstituteEq(incline == 45 * Math.PI / 180)
.SubstituteEq(g == 9.8)

.DispLong()```

The result displayed on the console:

So in this case, where the ball weighs more than the block, the ball moves downward and the block moves left.

Finding the tension in the cord is similar:

```eqs
.SubstituteEqLs(vals)

.EliminateVariables(
F1x_m1, F2x_m1,
F1y_m1, F2y_m1,

Fx_m1, Fy_m1,

F1x_m2, F2x_m2, F3x_m2,
F1y_m2, F2y_m2, F3y_m2,

Fx_m2, Fy_m2,

ax_m2, n, a, ay_m1
)

.IsolateVariable(T)
.RationalizeExpression()```

The output:

This problem is used as a unit test.

to join this conversation on GitHub. Already have an account? Sign in to comment