Homework 2

pdf

School

University of Illinois, Urbana Champaign *

*We aren’t endorsed by this school

Course

340

Subject

Mechanical Engineering

Date

Feb 20, 2024

Type

pdf

Pages

4

Uploaded by ChancellorWrenMaster915

Report
ME 340 HW 02 Due 11:59PM Feb 14, 2024 0. Reading Assignment: Read review notes on partial fractions given in the Lectures folder on the Canvas course website. [The reading assignment is not graded.] 1. Show that ? cos(𝜔? + 𝜃) + ? sin(𝜔? + 𝜃) = ? cos(𝜔? + 𝜃 + 𝜙), where ? = √? 2 + ? 2 and 𝜙 = ∠(? − ??) = −tan −1 ( ? ? ) . [20 points] [Hint: Use Euler’s formula to expand ?? 𝑗𝜙 ? 𝑗(𝜔?+𝜃) = ?? 𝑗(𝜔?+𝜃+𝜙) and compare the real parts of the two sides of the equation] 2. State the order of the following ordinary differential equations and state if they are (i) time- invariant or time-varying, and (ii) linear or nonlinear (a) ?̈ + (sin(?) ? ? )?̇ + ? = 0 [4 points] (b) ?̈ + (sin 10 (?))?̇ + ? = 0 [4 points] (c) ?̈ + (sin(?))?̇ + ? = 0 [4 points] (d) ?̈ + ?̇ + ? = 0 [4 points] 3. Note that derivative and integral can be considered as systems that relate the signals ? = ℱ(?). Show that these systems described below represent Linear systems by proving that they satisfy the principle of superposition; that is ℱ(?? 1 + ?? 2 ) = ?ℱ(? 1 ) + ?ℱ(? 2 ) for all real numbers ? and ?; and all signals ? 1 (?) and ? 2 (?). (a) ? = ℱ 1 (?) ≔ ?? ?? (?) [5 points] (b) ? = ℱ 2 (?) ≔ ∫ ?(𝜏)?𝜏 ? 0 [5 points] 4. Quarter-car suspension model: The quarter-car suspension model shown in the Figure is represented by 𝑚 ? ? + ?(?̇ ? − ?̇ ? ) + ?(? ? − ? ? ) = ? 1 𝑚 ? ? + ?(?̇ ? − ?̇ ? ) + ?(? ? − ? ? ) + ? ? (? ? − ? 2 ) = −? 1 , where 𝑚 ? and 𝑚 ? represent the chassis and wheel masses, ? and ? represent a passive shock absorber, ? ? represents tire stiffness, and ? 1 = ? (force) and ? 2 = 𝑟 (displacement) represent the active suspension and the road disturbance, respectively. Write down a state-space representation of this system. [15 points]
ME 340 HW 02 Due 11:59PM Feb 14, 2024 5. A phase portrait of a dynamical system ?̇ = ?(?) where ? = [ ? 1 ? 2 ] is shown in the figure. (a) Estimate the equilibrium points for this system using the displayed axis scales [4 points] (b) Estimate lim ?→∞ ?(?) when ?(0) = [ 0.5 −1.5 ] . [3 points] 6. Simulation Problem: The Lotka-Volterra model for predator-prey dynamics is: ?̇ = (? − ??)? ?̇ = (?? − ?)? where ? is the population of prey (fish), ? is the population of predator (sharks). In this model constants ? = 40, ? = 2, ? = 2, and ? = 400. (a) Simulate the evolution of the system starting from an initial condition of 100 fish , 5 sharks. Plot the population of fish and sharks as a function of time. Plot for the time range 0 ≤ ? ≤ 0.5. What is the minimum and maximum number of sharks that are ever present? Do these numbers suggest any problems with this model? [12 points] [Hint: Below we provide a python code that solves pendulum motion [ 𝜃 ̇ 𝜔̇ ] = [ 𝜔 −sin (𝜃) ] , [ 𝜃(0) 𝜔(0) ] = [ 𝜋/4 0 ] . Adapt the code to solve for the given Lotka-Volterra differential equation.] # Import necessary libraries import numpy as np from scipy.integrate import solve_ivp import matplotlib.pyplot as plt # Define the function describing the pendulum's motion def pendulum(t, state): theta, omega = state dtheta_dt = omega domega_dt = -np.sin(theta) return [dtheta_dt, domega_dt] # Set initial conditions initial_state = [np.pi/4, 0] # Solve the ODE t_eval = np.linspace(0, 20, 1000) sol = solve_ivp(pendulum, (t_eval[0], t_eval[-1]), initial_state, t_eval=t_eval)
ME 340 HW 02 Due 11:59PM Feb 14, 2024 # Plot the sample trajectory plt.plot(sol.t, sol.y[0, :], label="Theta") plt.plot(sol.t, sol.y[1, :], label="Omega") plt.xlabel("Time") plt.ylabel("Angle/Angular Velocity") plt.title("Sample Trajectory") plt.legend() plt.grid() # Plot the phase portrait plt.figure() plt.plot(sol.y[0, :], sol.y[1, :]) plt.xlabel("Theta") plt.ylabel("Omega") plt.title("Phase Portrait") plt.grid() (b) Simulate with different initial conditions and plot the resulting trajectories in state space (the x-y plane) such that one or both of the species i) Die out ii) Grow infinitely large. [8 points] [Hint: Think about what will happen if initially there are large number of sharks in comparison to fish. Or the case when there are no sharks.] (c) Construct a vector (velocity) field plot for this differential equation. Draw this phase portrait at a grid on the state-space given defined by points [0,300] for the ? -axis and [0,50] on the ? -axis. Also plot the trajectory starting at (150,20) on the phase portrait. [12 points] [Hint: Python has a quiver function in the matplotlib library that allows you to create quiver plots, which are used to visualize vector fields. Here's (below) a simple example code for the pendulum dynamics. The quiver function is then used to plot arrows at each grid point with magnitudes and directions determined by the values in 𝜃 ̇ and 𝜔̇ . Adapt this code to construct a vector field plot for the given Lotka-Volterra differential equation.] # Define the grid of points in phase space theta_array = np.linspace(-np.pi, np.pi, 20) omega_array = np.linspace(-5, 5, 20) theta_grid, omega_grid = np.meshgrid(theta_array, omega_array) # Calculate the vector field at each point dtheta_dt, domega_dt = pendulum(0, [theta_grid, omega_grid]) # Plot the vector field plt.quiver(theta_array, omega_array, dtheta_dt, domega_dt) # Plot some sample trajectories sol = solve_ivp(pendulum, (t_eval[0], t_eval[-1]), [-np.pi/4,0], t_eval=t_eval) plt.plot(sol.y[0, :], sol.y[1, :]) sol = solve_ivp(pendulum, (t_eval[0], t_eval[-1]), [-np.pi, 3], t_eval=t_eval)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ME 340 HW 02 Due 11:59PM Feb 14, 2024 plt.plot(sol.y[0, :], sol.y[1, :]) sol = solve_ivp(pendulum, (t_eval[0], t_eval[-1]), [np.pi, -3], t_eval=t_eval) plt.plot(sol.y[0, :], sol.y[1, :]) sol = solve_ivp(pendulum, (t_eval[0], t_eval[-1]), [-3.141, 0], t_eval=t_eval) plt.plot(sol.y[0, :], sol.y[1, :]) sol = solve_ivp(pendulum, (t_eval[0], t_eval[-1]), [3.141, 0], t_eval=t_eval) plt.plot(sol.y[0, :], sol.y[1, :]) # Add labels and title plt.xlabel("Theta") plt.ylabel("Omega") plt.title("Vector Field for the Pendulum") plt.grid() plt.xlim(-np.pi, np.pi) plt.ylim(-5, 5)