GithubHelp home page GithubHelp logo

hcui91 / e7-lrc Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 235 KB

This repository contained codes for the 2nd year experiment "Study of an Oscillating Electrical System Driven into Resonance". It would import data from csv file and output plotting with phase difference and angle. Please be aware of possible plagiarism check if using the code without any modification.

License: MIT License

Python 100.00%

e7-lrc's Introduction

E7-LRC

This repository contained codes for the 2nd year experiment Study of an Oscillating Electrical System Driven into Resonance. It would import data from csv file and output plotting with phase difference and angle.

Please be aware of possible plagiarism check if using the code without any modification.

From experiment to this code

From your RLC circuit

You will need to change the variables from line 13

##### Theoritical value #####

L=18e-3         #Inductance of the inductor in Henry (H)

C=1800e-12      #Capacitance of the capacitor in Faraday (F)

R=820           #Resistance of the resistor in Ohm

Note: 18e-3 means 18*10^{-3}

From your experiment data

I would recommand the arrangement of dataset below in a comma delimiated file.

#frequency(Hz) peak-to-peak voltage(volt) unc voltage (volt) y0 y1
10000 2.30 0.05 2.30 0.50

But feel free to change the order of columns, and update it in the code line 28&29. Change the order of variables.

freq, volt, delta_volt, y0, y1, delta_y = np.loadtxt("low_damp.csv",delimiter=",",unpack=True)   # Change file name and delimiter if required
freq_1, volt_1, delta_volt_1, y0_1, y1_1 = np.loadtxt("high_damp.csv",delimiter=",",unpack=True)

Tricks in coding

Better way to display axis

In the plot of phase angle, it is more convenient to display y-axis in unit of pi. On line 93, I used plt.yticks to modify the display of axis.

plt.yticks(np.arange(0,np.pi+0.1,step=0.25*np.pi), ('0',r'$\frac{1}{4} \pi$',r'$\frac{1}{2} \pi$',r'$\frac{3}{4} \pi$',r'$\pi$'))

It will devide pi into 4 ticks with step 0.25*pi, and display them on the axis. Text type of display is used to render \pi in Tex (matplotlib supports inline math with r'' in text contents).

e7-lrc's People

Contributors

hcui91 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.