Question

In: Physics

Use Visual Python or equivalent, to write a program that allows the user to observe the...

Use Visual Python or equivalent, to write a program that allows the user to observe the following:

Damped and forced harmonic oscillators. The program should be user friendly and have default values for the initial velocities, positions, masses, and spring constants as well as damping constants. Values and frequencies for the forced oscillators should also be given. It should allow the user to input values for the velocities, positions, spring constants, and masses. The program should determine automatically the scale that best allows the observation of the motion of the oscillators. Negative masses or spring constants should not be allowed.

Solutions

Expert Solution

 import numpy as np from scipy.integrate import odeint import math import matplotlib.pyplot as plt %Defining the differential equation for damped and forced harmonic oscillator def system(theta,t,b(>0),g,l,m(>0): theta1 = theta[0] theta2 = theta[1] dtheta1_dt = theta2 dtheta2_dt = -(b/m)*theta2-g*math.sin(theta1) dtheta_dt = [dtheta1_dt,dtheta2_dt] return dtheta_dt %put inputs b = 0.05 g = 9.81 l = 1 m = 1 %put initial condition theta_0 = [0,5] %time plot t = np.linspace(0,10,100) %solving ordinary differential equation theta = odeint(system,theta_0,t,args = (b(>0),g,l,m(>0)) %For animation creating plot f =1 for i in range(0,100) filename = str(f)+'.png' f = f+1 plt.figure() plt.plot([5,l*math.sin(theta[i,0]) + 5)],[5,5-l*math.cos(theta[i,0])],marker = "s") plt.xlim([0,10]) plt.ylim([0,10]) plt.savefig(filename) plt.plot(t,theta[:,0],'r-') plt.plot(t,theta[:,1],'mo') plt.show() 

Related Solutions

In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from 0 to 100, computes the average of those scores and then writes out a letter grade using the typical grading scale. Your program will also: 1. Allow the user to enter any number of scores he or she wishes but assume there will be at least one score entered. 2. Use a sentinel-controlled loop variable to terminate the loop when the user has no...
Write a program using Python that allows the user to play a guessing game (please provide...
Write a program using Python that allows the user to play a guessing game (please provide a picture of code so it is easier to read). The game will choose a "secret number", a positive integer less than 10000. The user has 10 tries to guess the number. Requirements: Normally, we would have the program select a random number as the "secret number". However, for the purpose of testing your program (as well as grading it), simply use an assignment...
Please write in python Use modular design to write a program that asks the user to...
Please write in python Use modular design to write a program that asks the user to enter his or her weight and the name of a planet. The program then outputs how much the user would weigh on that planet. The following table gives the factor by which the weight must be multiplied for each planet. PLANET CONVERSION FACTOR Mercury 0.4155 Venus 0.8975 Earth 1.0000 Moon 0.1660 Mars 0.3507 Jupiter 2.5374 Saturn 1.0677 Uranus 0.8947 Neptune 1.1794 Pluto 0.0899 The...
9) This is in Python Code a program that allows the user to manage its expenses...
9) This is in Python Code a program that allows the user to manage its expenses accepting the following commands: - Add <player_name> -> This command adds a new player to the system. Assume there can’t be repeated names. If a name already exists then an error is shown to the user. - Score <player_name> <score> -> This command adds the score to the player with the name player-name. Each score needs to be added individually - Report -> This...
In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
Write an interactive program in c++ that allows the user toenter 2-15 vectors (use the...
Write an interactive program in c++ that allows the user to enter 2-15 vectors (use the if statement). Display the resultant on the screen.
Python Add a command to this chapter’s case study program that allows the user to view...
Python Add a command to this chapter’s case study program that allows the user to view the contents of a file in the current working directory. When the command is selected, the program should display a list of filenames and a prompt for the name of the file to be viewed. Be sure to include error recovery in the program. If the user enters a filename that does not exist they should be prompted to enter a filename that does...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT