Help in logic for amplitude vs frequency

In summary, the conversation discussed solving a problem found at page 115-116 of a pdf document, which involves using a code to plot the amplitude vs omega for a damped driven harmonic oscillator. The code uses the function Fexternal to calculate the external force, and the function springmass to calculate the differential equations for position and velocity. The issue mentioned is how to make the omega a variable in order to plot the desired graph.
  • #1
ChrisVer
Gold Member
3,378
464
I am trying to solve the problem 4.8 found http://phys.csuchico.edu/ayars/312/Handouts/comp-phys-python.pdf at pdf's page 115-6 [book's page 107-8].

My code so far is:
Python:
from mytools import rungekuta4
from pylab import *

#set globals
G=9.81
MASS=1.0
K=42.0
MU=0.15
A=1.
OMEGA=0.01

#set diff solver variables
N=1000
tau=5.
dt= tau/float(N-1)
t=linspace(0,tau,N)

def Fexternal(A,w,t):
    return A*cos(w*t)

def springmass(xv_vector,time):
    # x' =v
    # v' = -k/m x +/- mu g + F[t]
    diff0= xv_vector[1]
    if diff0>0:
        diff1= -(K/MASS)*xv_vector[0] - MU*G +  F(A,OMEGA,time) / MASS
    else:
        diff1= -(K/MASS)*xv_vector[0] + MU*G + F(A,OMEGA,time) / MASS

    return array([diff0,diff1])

xo=1.0
vo=0.0

y=zeros([N,2])
y[0,0]=xo
y[0,1]=vo

for i in range(N-1):
     y[i+1]= rungekuta4(y[i],t[i],dt,springmass)

plot(t,y[:,0],'r-')
show()

My problem is that I cannot see how I can make the w a variable... So that I could plot the amplitude vs the omega...
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Yes, it's a bit weird they ask this in a chapter where most of the material is about integrating differential equations. I think here you really need the expressions for the damped driven harmonic oscillator
 

Related to Help in logic for amplitude vs frequency

1. What is the relationship between amplitude and frequency?

The amplitude of a wave refers to the maximum displacement of the wave from its equilibrium position, while frequency refers to the number of complete cycles the wave makes in one second. The relationship between amplitude and frequency is inverse, meaning that as the amplitude increases, the frequency decreases and vice versa.

2. How do changes in amplitude affect the frequency of a wave?

Changes in amplitude do not directly affect the frequency of a wave. However, as the amplitude increases, the energy of the wave also increases, which can lead to changes in the frequency of the wave due to factors such as damping or resonance.

3. Can the amplitude and frequency of a wave be changed independently?

Yes, the amplitude and frequency of a wave can be changed independently. The amplitude can be changed by altering the energy of the wave, while the frequency can be changed by altering the source of the wave or the medium through which it travels.

4. What is the significance of amplitude and frequency in signal processing?

In signal processing, amplitude and frequency are important parameters that help to characterize a signal. Amplitude is related to the strength and intensity of the signal, while frequency is related to the rate at which the signal is changing. These parameters are used to filter, amplify, and analyze signals in various applications.

5. How does the human ear perceive changes in amplitude and frequency?

The human ear perceives changes in amplitude as changes in loudness or volume of a sound. Changes in frequency are perceived as changes in pitch. The greater the amplitude, the louder the sound, and the higher the frequency, the higher the pitch. This is why a person may perceive a loud sound as having a higher pitch than a softer sound.

Similar threads

Replies
1
Views
1K
Replies
5
Views
403
  • Programming and Computer Science
Replies
6
Views
1K
  • Advanced Physics Homework Help
Replies
0
Views
417
  • Differential Equations
Replies
1
Views
828
  • Introductory Physics Homework Help
Replies
6
Views
291
Replies
5
Views
970
  • Programming and Computer Science
Replies
1
Views
1K
Replies
2
Views
922
Replies
9
Views
921
Back
Top