PYTHON   23
filtrages
Guest on 14th March 2023 01:15:12 PM

1. import random
2. import numpy as np
3. import matplotlib.pyplot as plt
4. import csv
5.
6. deg = 57.2958
7. j = 1j
8. nbfreq = 10001
9. tmin = 0 #s
10. tmax = 0.0006 #s
11. ech = 1000
12. t = np.linspace(tmin, tmax*2, ech)
13. f = np.linspace(1, nbfreq, nbfreq) #gamme de frĆ©quence entre 1 et nbfreq hz
14. z
16. uit
17. R = 2#Ohm
18. Ohm
19. C = 30.1 * 10 ** float(-9)
20. ue0 = 6.#Tension maximale d'entrĆ©e
22. w = 2*np.pi*f[#FrĆ©quence du GBF
23.  du GBF
24. w0 = 1/R/C
25. f0 = w0/2/np.p#Visualisation des signaux
26. signaux
27. x = np.linspace(0, np.log(nbfreq), ech)
28. ue = ue0*np.exp(j*w*t)
29. Hw_RC = 1/(1 + j*w/w0)
30. us = ue * Hw_RC
31. plt.plot(t, np.real(us), t, np.real(ue))
32. plt.xlim(0, tmax*2)
33. plt.ylim(-ue0, ue0)
34. plt.show()
35. "#Diagramme de Bode thĆ©orique en amplitude
36. amplitude
37. x = np.linspace(0, np.log(nbfreq), ech)
38. Gu = -10 * np.log10(1 + np.power(10, 2*x)/f0/f0)
39. plt.xlim(2, 5)
40. plt.ylim(-40, 1)
41. plt.plot(x, Gu)
42. plt.axhline(y=0, color='black')
43. bande3db = np.log10((10**0.3-1)*f0*f0)/2
44. plt.axvline(x=bande3db, color='black')
45. plt.grid()
46. plt.show()#Diagramme de Bode thĆ©orique en phase
47. ue en phase
48. X = np.linspace(0, 7, nbfreq)
49. phi = - np.arctan(10 ** X / f0) * deg
50. plt.xlim(0, 7)
51. plt.ylim(-90, 0)
52. plt.plot(X, phi)
53. plt.axhline(y=0, color='black')
54. plt.axvline(x=np.log10(np.tan(np.pi/4)*f0), color='black')
55. plt.grid()
56. pl

Raw Paste

or to edit or fork this paste. It's free.