#run me!
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
from scipy import optimize
# Cell for calculations
Imax = 4/33.95
print(Imax)
### Edit this line ###
phi = 0
### End edit ###
frequency = 850 #Hz
time = np.linspace(0,5*1/frequency,1000)
angular_freq = 2*np.pi*frequency
audio_driver = 100*np.sin(angular_freq*time)
#the max current is not necessarily 0.1 A or 100 mA, we are just using this for a visualization
resistor_voltage = 4*np.sin((angular_freq*time)+phi)
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(time*1000,resistor_voltage,'g')
ax2.plot(time*1000,audio_driver,'r')
plt.title('Resistor Current and Voltage vs. Time')
ax1.set_xlabel('Time [ms]')
ax1.set_ylabel('Voltage across Resistor [V]', color='g')
ax2.set_ylabel('Current [mA]', color='r')
ax1.set_ylim([-6,6])
plt.show()
# Cell for calculations
print(0.3/1.2*360)
C = 1e-5 # F
### Edit this line ###
phi_C = -90
### End edit ###
cap_voltage = 2*np.sin((angular_freq*time)+phi_C)
plt.figure()
plt.plot(time*1000,resistor_voltage,'r', label='Voltage Across the Resistor')
plt.plot(time*1000,cap_voltage,'g', label='Voltage Across the Capacitor')
plt.title('Capacitor and Resistor Voltages vs. Time')
plt.xlabel('Time [ms]')
plt.ylabel('Voltage [V]')
plt.legend(bbox_to_anchor=(1.05, 1))
plt.show()
# Cell for calculations
print(2/0.118)
# Cell for calculations
w = 2*np.pi*850
print(1/(w*10*10**(-6)))
# pr
print(0.9/1.2*360)
L = 8.2e-3 # H
### Edit this line ###
phi_L = 90
### End edit ###
#the voltage across the capacitor is not 2 V necessarily, we are just using this for a visualization
ind_voltage = 5.*np.sin((angular_freq*time)+phi_L)
plt.figure()
plt.plot(time*1000,resistor_voltage,'r', label = 'Voltage Across the Resistor')
plt.plot(time*1000,ind_voltage,'g', label = 'Voltage Across the Inductor')
plt.title('Inductor and Resistor Voltages vs. Time')
plt.xlabel('Time [ms]')
plt.ylabel('Voltage [V]')
plt.legend(bbox_to_anchor=(1.05, 1))
plt.show()
# Cell for calculations
print(5/0.118)
# Cell for calculations
w = 2*np.pi*850
print(w*8.2*10**(-3))
# Cell for calculations
print(1.1/1.2*360)
# Cell for calculations
print(np.sqrt((33.95+6.7)**2+(42.37-16.95)**2))
print(47.94*0.118)
V_bulb = np.array([0.2,0.327,0.812,1.616,2.76,3.890,4.219,3.470,2.2,1.18])
freq_audio = np.array([100,135,182,247,333,450,608,822,1110,1500])
plt.figure()
plt.plot(freq_audio,V_bulb,'k-.')
plt.xlabel('Log(Frequency/[Hz])')
plt.ylabel('Light Bulb Voltage [V]')
plt.xscale('log')
plt.title('Bulb Voltage vs. Log Freqency in RLC circuit.')
# Cell for calculations
print(1/(2*np.pi*np.sqrt(8.2e-3*10e-6)))
# Cell for calculations
print((1/(10e-6))*(1/(2*np.pi*287.4)**2))