Skip to document

CEP Report - 2021360

CEP Report Including Python Codes Pictures
Course

Engineering dynamics (me-212)

20 Documents
Students shared 20 documents in this course
Academic year: 2022/2023

Comments

Please sign in or register to post comments.

Preview text

COMPLEX ENGINEERING PROBLEM

DYNAMICS – ME202 – SECTION A

MUHAMMAD AWAIS – 2021360

SUBMITTED TO: SIR RIZWANULLAH

QUESTION 12 - 154:

ANSWER:

OUTPUT:

CODE EXPLANATION:

The code performs calculations related to the motion of a crate on a curve. It is explained step by step as:

  1. Importing Libraries: The code imports the math, sympy, and sympy modules. These modules provide mathematical functions and symbolic computation. By using the import statement;(from sympy import *) we can use sympy functions and directly by their names, such as symbols, solve, Eq, pi, sin, etc., without prefixing them with sp. Here I used the sp for understanding the concept.

  2. User Inputs: The code various inputs from the user such as the velocity of the crate at point A (v), acceleration at point A (v_dot), and the horizontal distance of point A (dist).

  3. Symbol Definitions: The code defines symbolic variables x and y using the symbols function from sympy. These symbols will be used for symbolic computations.

  4. Curve Path: The code asks the user to input the curve path equation using the variable x and converts the user input string to a symbolic expression using sympify.

  5. Derivatives: The code calculates the first derivative (derivative1_y) and second derivative (derivative2_y) of the curve path equation with respect to x using the diff function from sympy. It then substitutes the value of dist into the derivatives using the subs method.

  6. Round: I used the round to round off the value of derivatives to the desired decimal places.

  7. Radius of Curvature: The code calculates the radius of curvature (p) using the first and second derivatives. The formula (1 + (der1)2 )(3/2))/(der2) is used, and the result is rounded to two decimal places.

  8. Acceleration: The code calculates the tangential acceleration (a_t) by rounding the input v_dot. It calculates the normal acceleration (a_n) by using the given formula (v**2)/p, and rounding the result. Finally, it calculates the magnitude of acceleration (a) using the formula sqrt((a_t)**2 + (a_n)**2).

  9. Output: The code prints the calculated values for the first derivative, second derivative, radius of curvature, tangential acceleration, normal acceleration, and magnitude of acceleration.

Overall, the code takes user inputs for velocity, acceleration, distance, and curve path, performs calculations for derivatives, radius of curvature, and acceleration, and displays the results.


QUESTION 13 - 74:

ANSWER:

CODE EXPLANATION:

The provided code performs calculations related to the motion of a car on a curved path. The code is explained step by step below:

  1. Importing Libraries: The code imports the sympy module and assigns it the alias sy. This module provides symbolic computation capabilities.

  2. Symbol Definition: The code defines a symbolic variable x using the Symbol function from sympy. This symbol will be used for symbolic computations.

  3. User Inputs: The code asks the user for inputs such as the mass of the car (m) and the equation representing the curved path (y). The input for the curved path equation is converted to a symbolic expression using the sympify function.

  4. Derivatives: The code calculates the first derivative (dy) and the second derivative (d2y) of the curved path equation with respect to x using the diff function from sympy.

  5. Radius of Curvature: The code calculates the radius of curvature (p) at the maximum point where x = 0 and dy/dx = 0. The formula (1 + (dy)2 )(3/2) ) / abs(d2y) is used, and the result is rounded to two decimal places. We need an absolute value in the denominator, for that purpose, I used the Abs function from sympy.

  6. Velocity Calculation: The code calculates the velocity (v) of the car using the given equation m * g = m * ((v**2) / p), where m is the mass of the car and g is the acceleration due to gravity. For the square-root function, I recalled it from sympy as sy. The result is rounded to two decimal places. The argument of Eq to the left of the comma is simply the left-hand side of the equation and the argument to the right of the comma is the right-hand side of the equation. It uses the solve function from sympy to find the solution.

  7. Output: The code prints the calculated values for the first derivative, second derivative, radius of curvature, and velocity.

Overall, the code takes user inputs for the mass of the car and the equation representing the curved path performs calculations for derivatives, the radius of curvature, and velocity, and displays the results.


QUESTION 14 - 79:

ANSWER:

CODE EXPLANATION:

The provided code performs calculations based on a given problem related to a block's equilibrium and energy conservation. Let's go through it step by step:

  1. Importing Libraries: The code imports the math, sympy, and sympy modules. These modules provide mathematical functions and symbolic computation. By using the import statement;(from sympy import *) we can use sympy functions and directly by their names, such as symbols, solve, Eq, pi, sin, etc., without prefixing them with sp. Here I used the sp for understanding of the concept.

  2. Symbol Definitions: The code defines symbolic variables l and v using the symbols function from sympy. These symbols will be used for symbolic computations.

  3. User Inputs: The code asks the user for various inputs such as the weight of the block (W), angle at point B (angle), cord stiffness (k), and radius of the semicircle (r). I used the float function here as well so the user may also be able to input various values in decimals for more accurate solutions.

  4. Calculation of Speed: The code solves the equation Wcos(th) = (Wv**2) / (g * r) to determine the speed of the block (speed). The argument of Eq to the left of the comma is simply the left-hand side of the equation and the argument to the right of the comma is the right-hand side of the equation. It uses the solve function from sympy to find the solution.

  5. Sympy always gives us answers in a list form. For example, here it gave us {-speed, +speed}. We could not perform calculations with a list so I used the speed[1] indexing against the speed. It will give me the value of speed at 1 place in the list.

  6. Conservation of Energy Equation: The code sets up the conservation of energy equation between point A and point B. It solves the equation (1/2)k(r*(sp)-l)2 = (1/2)(W/g)(speed2) + W*(rsin(th)) + (1/2)(k)(r(3/4)*(sp)-l)**2 to determine the length of the cord (result). Again, the solve function is used to find the solution.

  7. Again, it gave me solution in a list form, though it is only one value. I cannot use it in calculations as it is in list form. So I used the result[0] to take the one value from the list.

  8. This calculation may result in a value up-to many decimal places, so I used the round function to round it off to the desired 2nd decimal place.

  9. Output: The code prints the calculated values for the speed (speed) and the length of the cord (result).

Overall, the code takes user inputs for weight, angle, cord stiffness, and radius, performs calculations for speed and length of the cord based on equilibrium and conservation of energy principles, and displays the results.

Was this document helpful?

CEP Report - 2021360

Course: Engineering dynamics (me-212)

20 Documents
Students shared 20 documents in this course
Was this document helpful?
1 | P a g e
COMPLEX ENGINEERING PROBLEM
DYNAMICS ME202 SECTION A
MUHAMMAD AWAIS 2021360
SUBMITTED TO: SIR RIZWANULLAH