Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

lid-name, no-tember, C0381, C0411, W0511, 10613 Semester 2, Assignment 3 Assignment Tasks: 3 Restrictions: Do not change anything outside TODO blocks. Do not add pylint

image text in transcribed
image text in transcribed
image text in transcribed
lid-name, no-tember, C0381, C0411, W0511, 10613 "Semester 2, Assignment 3 Assignment Tasks: 3 Restrictions: Do not change anything outside TODO blocks. Do not add pylint directives. Do not import additional modules. Guidance: Angles should be defined in radians. Author of template: Wolfgang Theis School of Physics and Astronomy University of Birmingham import numpy as np from scipy import interpolate from Scipy import integrate import matelotlib.Ryplot as plt class pendulum: " defines a simple pendulum". def __init__(self, pendulun_length, mass): * TODO: Assignment Task 1: write method body pass # End of Task 1; proceed to task 2. I def set_g(self, g): *** small to be used in calculations" self.9=g def dydt (self, y, t): Calculate the derivatives for a pendulum Parameters y: array-Like vector of unknowns for the ode equation at tinet t: float tinet Returns rets numpy array of float the derivatives of y TODO: Assignment Task 21 write method body End of Task 2: proceed to task 3. det period(self, maximum amplitude) * Calculate the period of the periodic motion. For amplitudes the small amplitude analytical solution is returned. Otherwise the period is calculated by Integrating the one using scipy, integrate.ade int() and determining the time between release at maximun amplitude and the first angleze crossing. The exact zero vector of unknowns for the ode equation at time t t: float time t Returns BEN ret: numpy array of float the derivatives of y # TODO: Assignment Task 2: write method body pass # End of Task 2; proceed to task 3. det period(self, maximum_amplitude): ""Calculate the period of the periodic motion. For amplitude the small amplitude analytical solution is returned. Otherwise the period is calculated by integrating the ODE using scipy, integrate odeint() and determining the title between release at maximum amplitude and the first angle crossing. The exact zero crossing is determined using scipy, interpolate, interpidi). In the calculation it is assumed that the period has a value between 904 and 150% of the small amplitude period. Parameters maximum amplitude: float maximun amplitude of the periodic motion Returns D. 11 p: float the period * TODO: Assignment Task 3: write method body pass # End of Task 3; no further tasks. _name__ == '__main__': #some test code pen - pendulum(1, 1) pen.set_g(9.81) #generate data for figure angles = np. linspacero, np.p1/2, 31) period_ode (pen.period(s) for a in angles) generate a plot fig - plt.figure() ax - fig.add_subplot(1, 1, 1) ax.plot(angles, period_ode, 'b', label='generated using ode') ax.set_title('Period of a la Pendulum as a function of Amplitude) ax.set_xlabel('amplitude/rad) ax..sety label('period/s') ax. Legend Loca' upper left') elt.show() Assignments > 5.5 - Coding assignment 3 5.5 - Coding assignment 3 Submit Assignment Due Saturday by 23:59 Points 100 Available until 8 May at 23:59 Submitting a file upload File types py This assignment asks you to explore the dependence of the period of a pendulum's motion as a function of its initial amplitude Please download y1Semester 2Assignment3.py, complete all TODO tasks and submit it. We mark your final pre- deadline submission. Feedback will be provided within one day of the submission deadline. Previous Next

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago