The assignment is in Python. I have never used Python in my life :(
Homework 3 In this homework assignment, we further learn how to implement the RK4 integrator. In Can- vas, give proper values for upper alphabets (from A to U), each of which is 1 pt. It is 21 pt in total. For Problems 1b and 2d, submit generated plots to Canvas (6 pt for each and 12 pt in total). Canvas Grades shows 33 pt as the total score. This score will be converted to 8% of the final grade. This time, Python is the mandatory program language. By this, the only submission of Matlab does not suffice. The submission policy given in the syllabus will apply. 2 bonus pt (to the final grade) if a Matlab script is submitted in addition to a Python script. Do not use any Matlab and python embedded integrators. 1. Consider the following spin-damper system in which a cart with m is connected with a fixed wall by a spring, k [N/m], and a damper, c [N/m/sec]. These components provide forces, −kx and −cẋ, where x and ẋ are the displacement and its rate. See Figure 1. The displacement from the original place where the cart experiences zero force is x1. Define X = [x1, ẋ1, t]T . The units in these elements are m, m/sec, and sec, respectively. By using this state, we may have the state space form as Ẋ = F(X) = AX. (1) k c x 1 Figure 1: One-cart system connected with a wall by a spring and a damper. (a) Calculate the state, X, numerically, given the following conditions. Note that the step size, h, should be chosen properly. Hint: Choose h small enough that the numerical results become stable and do not change due to h. i. Give X at t = 10 sec, given X(t0) = [1.0, 0.1, 0.]T , m = 10 kg, k = 0.1 N/m, and c = 0.1 N/m/sec. X = A× 100B × 10−2 C × 101 (2) ii. Give X at t = 20 sec, given X(t0) = [−2.0, 0.3, 0.]T , m = 15 kg, k = 0.3 N/m, and c = 0.1 N/m/sec. 1 X = D × 100E × 10−1 F × 101 (3) iii. Give X at t = 50 sec, given X(t0) = [−0.5, 0.3, 0.]T , m = 100 kg, k = 0.2 N/m, and c = 0.5 N/m/sec. X = G× 100H × 10−1 I × 101 (4) (b) Generate one plot to show x1 as a function of t for Problem 1aiii. Use the following format: Line width, 2; Line color, black; Text font size, 15; Box on; Grid on; X label, “Time [sec]”; Y label, “x1 [m]”; Print resolution, 300 dpi; Image format, png; Title, “Time evolution of x1 generated by (your programming language)”. 2. There are two wheeled carts connected with each other by a spring and a damper, one of which is also connected with a wall. The spring coefficient is k, and the damper coefficient is c. The masses of both carts are m. The displacement of the cart on the left side from its static condition is x1, and that on the right side from its static condition is x2. Use the following parameters: m = 15 kg, k = 7 N/m. c is a free parameter. Define the state as the state x = [x1, ẋ1, x2, ẋ2]T , where T means transpose. The units of the potion and the velocity are m and m/sec, respectively. k c c k x 1 x 2 Figure 2: Two-wheeled cart system in which two carts are connected by a spring and a damper, and one of them is also connected with a wall . (a) Compute the state when t = 10 sec and c = 1 N/m/sec. Use the initial condition, x0 = [1, 0, 0,−1]T . x = J × 10−1 K × 10−1 L× 100 M × 10−1 (5) 2 (b) Compute the state when t = 50 sec and c = 10 N/m/sec. Use the initial condition, x0 = [2, 1, 3,−1]T . x = N × 10−3 O × 10−3 P × 10−3 Q× 10−3 (6) (c) When t = 10 sec and c = 2.5 N/m/sec, the state was x = [1.5098958, 7.0845009× 10−1, 1.8676761, 1.6186728]T . Compute the initial condition at t = 0 sec. x0 = R× 10−1 S × 100 T × 100 U × 100 (7) (d) Generate one plot to show x1 and x2 as a function of t for Problem 2b. Use the following format: Line width, 2; Line color, red for x1 and blue for x2; Text font size, 15; Box on; Grid on; X label, “Time [sec]”; Y label, “Amplitude [m]”; Print resolution, 300 dip; Image format, png; Title, “Time evolution of x1 and x2”; Legend, “x1” and “x2”. 3