diff --git a/statics/physics/modern-phys-lab/blue.dat b/statics/physics/modern-phys-lab/blue.dat new file mode 100644 index 0000000..2ce2078 --- /dev/null +++ b/statics/physics/modern-phys-lab/blue.dat @@ -0,0 +1,52 @@ +V (Volts) I (mAmps) +0.0885278062 0.02217680919 +0.08791088769 0.04435361837 +0.1566973016 0.04435361837 +0.2347374931 0.05544202296 +0.3106184698 0.04435361837 +0.3908178761 0.05544202296 +0.4642311788 0.06653042756 +0.5435052074 0.06653042756 +0.6215453989 0.06653042756 +0.6995855904 0.06653042756 +0.7770088634 0.07761883215 +0.8547405957 0.07761883215 +0.9321638687 0.07761883215 +1.024701645 0.07761883215 +1.103975674 0.08870723674 +1.178622813 0.09979564134 +1.256663005 0.08870723674 +1.330693226 0.09979564134 +1.408424959 0.09979564134 +1.484305935 0.09979564134 +1.562963045 0.1108840459 +1.641003237 0.1108840459 +1.718118051 0.1219724505 +1.79307365 0.1219724505 +1.872039219 0.1219724505 +1.951313247 0.1219724505 +2.026577306 0.1330608551 +2.104925956 0.1219724505 +2.184199985 0.1219724505 +2.26069788 0.1330608551 +2.33935499 0.1552376643 +2.425723582 0.1995912827 +2.480937788 0.3215637332 +2.520420573 0.5544202296 +2.548181906 0.8205419399 +2.570699431 1.119928864 +2.586122394 1.419315788 +2.603396113 1.729791116 +2.620669831 2.062443254 +2.632699742 2.384006987 +2.644729653 2.72774753 +2.657376482 3.049311263 +2.669406393 3.381963401 +2.680819386 3.725703943 +2.691923919 4.08053289 +2.701177696 4.424273433 +2.712590689 4.768013975 +2.723695222 5.122842922 +2.736342051 5.566379106 +2.744053533 5.887942839 +2.75361577 6.25386019 diff --git a/statics/physics/modern-phys-lab/data.tar.xz b/statics/physics/modern-phys-lab/data.tar.xz new file mode 100644 index 0000000..fc9c7b2 Binary files /dev/null and b/statics/physics/modern-phys-lab/data.tar.xz differ diff --git a/statics/physics/modern-phys-lab/green.dat b/statics/physics/modern-phys-lab/green.dat new file mode 100644 index 0000000..ff63249 --- /dev/null +++ b/statics/physics/modern-phys-lab/green.dat @@ -0,0 +1,52 @@ +V (Volts) I (mAmps) +0.0885278062 0.05544202296 +0.08791088769 0.03326521378 +0.1563888423 0.04435361837 +0.2350459523 0.04435361837 +0.3112353883 0.04435361837 +0.3917432539 0.04435361837 +0.4654650159 0.06653042756 +0.5438136666 0.05544202296 +0.6233961544 0.06653042756 +0.6992771312 0.06653042756 +0.7782427005 0.07761883215 +0.8544321365 0.07761883215 +0.934940002 0.08870723674 +1.025627023 0.08870723674 +1.103975674 0.08870723674 +1.179239732 0.09979564134 +1.256663005 0.08870723674 +1.331001685 0.09979564134 +1.408116499 0.09979564134 +1.486156691 0.09979564134 +1.563579964 0.1108840459 +1.641620155 0.1108840459 +1.717809591 0.1108840459 +1.793999027 0.1330608551 +1.8714223 0.1330608551 +1.951313247 0.1330608551 +2.025651928 0.1441492597 +2.100915986 0.1774144735 +2.163224756 0.2772101148 +2.207334429 0.4435361837 +2.240956488 0.6763926802 +2.272727791 0.9979564134 +2.298329909 1.286254933 +2.318996679 1.574553452 +2.338429612 1.873940376 +2.357554086 2.184415705 +2.374210886 2.483802629 +2.392409982 2.794277957 +2.409066782 3.115841691 +2.422022071 3.437405424 +2.438061952 3.770057562 +2.453484915 4.08053289 +2.468599418 4.391008219 +2.481554707 4.723660357 +2.49666921 5.056312494 +2.512400632 5.400053037 +2.524430543 5.699439961 +2.537694291 6.032092099 +2.554351091 6.442363068 +2.569465594 6.786103611 +2.579336291 7.129844153 diff --git a/statics/physics/modern-phys-lab/orange.dat b/statics/physics/modern-phys-lab/orange.dat new file mode 100644 index 0000000..3606cd2 --- /dev/null +++ b/statics/physics/modern-phys-lab/orange.dat @@ -0,0 +1,52 @@ +V (Volts) I (mAmps) +0.08791088769 0.04435361837 +0.0885278062 0.03326521378 +0.1557719238 0.03326521378 +0.2338121153 0.04435361837 +0.3133946031 0.05544202296 +0.3902009576 0.04435361837 +0.4660819344 0.06653042756 +0.5438136666 0.06653042756 +0.6218538582 0.06653042756 +0.6989686719 0.06653042756 +0.7773173227 0.08870723674 +0.8547405957 0.07761883215 +0.933706165 0.08870723674 +1.02686086 0.06653042756 +1.104284133 0.08870723674 +1.180473569 0.09979564134 +1.256663005 0.1108840459 +1.331618604 0.09979564134 +1.407191121 0.09979564134 +1.485231313 0.1108840459 +1.562037668 0.1219724505 +1.641003237 0.1219724505 +1.710715028 0.1552376643 +1.769630746 0.2550333056 +1.811889664 0.4546245883 +1.836257945 0.7318347031 +1.85507396 1.053398436 +1.867720789 1.386050574 +1.876049189 1.718702712 +1.884686048 2.084620063 +1.890546774 2.450537415 +1.897949796 2.916250408 +1.903810522 3.271079355 +1.906895115 3.648085111 +1.911213544 4.025090867 +1.91707427 4.413185028 +1.919233485 4.790190784 +1.923243455 5.178284945 +1.926636507 5.566379106 +1.927253425 5.932296457 +1.930029559 6.320390618 +1.933422611 6.697396374 +1.935581825 7.085490535 +1.938357959 7.473584696 +1.940517173 7.883855666 +1.944218685 8.249773017 +1.94606944 8.648955582 +1.947920196 9.037049743 +1.951313247 9.513851141 +1.951930166 9.901945301 +1.953472462 10.30112787 diff --git a/statics/physics/modern-phys-lab/purple.dat b/statics/physics/modern-phys-lab/purple.dat new file mode 100644 index 0000000..b4a1ca3 --- /dev/null +++ b/statics/physics/modern-phys-lab/purple.dat @@ -0,0 +1,52 @@ +V (Volts) I (mAmps) +0.08791088769 0.03326521378 +0.08760242843 0.03326521378 +0.1551550053 0.04435361837 +0.2341205746 0.06653042756 +0.3115438476 0.05544202296 +0.3905094169 0.06653042756 +0.4651565566 0.05544202296 +0.5441221259 0.05544202296 +0.6227792359 0.06653042756 +0.6986602127 0.06653042756 +0.7782427005 0.07761883215 +0.8522729217 0.07761883215 +0.9343230835 0.07761883215 +1.027477779 0.07761883215 +1.106443348 0.07761883215 +1.178931273 0.08870723674 +1.256663005 0.08870723674 +1.330384767 0.08870723674 +1.408116499 0.09979564134 +1.485848232 0.09979564134 +1.562037668 0.1108840459 +1.641928615 0.1108840459 +1.717809591 0.1219724505 +1.79276519 0.1108840459 +1.871113841 0.1219724505 +1.95007941 0.1219724505 +2.026885765 0.1330608551 +2.104309038 0.1330608551 +2.183891526 0.1330608551 +2.260080962 0.1330608551 +2.338429612 0.1441492597 +2.433743522 0.1441492597 +2.515793684 0.1552376643 +2.592291579 0.1663260689 +2.67064023 0.1774144735 +2.747446585 0.1774144735 +2.824561398 0.2106796873 +2.887795546 0.2772101148 +2.932213678 0.4657129929 +2.961208848 0.7318347031 +2.981567159 1.020133223 +2.999457796 1.35278536 +3.013030003 1.674349094 +3.023209159 2.007001231 +3.037089825 2.339653369 +3.04757744 2.694482316 +3.058373514 3.038222858 +3.065468077 3.393051805 +3.075955691 3.836587989 +3.085517928 4.169240127 +3.09292095 4.546245883 diff --git a/statics/physics/modern-phys-lab/red.dat b/statics/physics/modern-phys-lab/red.dat new file mode 100644 index 0000000..835301f --- /dev/null +++ b/statics/physics/modern-phys-lab/red.dat @@ -0,0 +1,52 @@ +V (Volts) I (mAmps) +0.0885278062 0.03326521378 +0.0885278062 0.04435361837 +0.1557719238 0.05544202296 +0.2350459523 0.05544202296 +0.3124692254 0.05544202296 +0.3898924984 0.05544202296 +0.4651565566 0.06653042756 +0.5447390444 0.06653042756 +0.6215453989 0.07761883215 +0.6986602127 0.06653042756 +0.777625782 0.08870723674 +0.8531982994 0.07761883215 +0.9343230835 0.08870723674 +1.025627023 0.08870723674 +1.105826429 0.07761883215 +1.179548191 0.09979564134 +1.257588383 0.09979564134 +1.331001685 0.08870723674 +1.408424959 0.09979564134 +1.486156691 0.1108840459 +1.561729208 0.09979564134 +1.637301726 0.1330608551 +1.701152792 0.2217680919 +1.740944035 0.4213593745 +1.764695398 0.6985694894 +1.781969116 1.009044818 +1.795232864 1.341696956 +1.809113531 1.674349094 +1.81775039 2.02917804 +1.824536494 2.384006987 +1.831322597 2.749924339 +1.840576375 3.182372118 +1.847362478 3.559377874 +1.853531664 3.925295226 +1.860009308 4.280124173 +1.868029249 4.657129929 +1.872347678 5.034135685 +1.876049189 5.422229846 +1.881292996 5.765970388 +1.885302967 6.142976144 +1.889621396 6.519981901 +1.894248285 6.896987657 +1.898258256 7.262905008 +1.902576685 7.662087574 +1.907512033 8.028004925 +1.911522003 8.416099086 +1.917382729 8.793104842 +1.918925026 9.181199003 +1.923551914 9.6580004 +1.926944966 10.01282935 +1.931571855 10.40092351 diff --git a/statics/physics/modern-phys-lab/run.py b/statics/physics/modern-phys-lab/run.py new file mode 100644 index 0000000..e2cb1dc --- /dev/null +++ b/statics/physics/modern-phys-lab/run.py @@ -0,0 +1,70 @@ +import numpy as np +from numpy.polynomial import polynomial +import matplotlib.pyplot as plt +import scipy + +colors = ['blue', 'green', 'orange', 'purple', 'red'] +wavelengths = { + 'blue': 465, + 'green': 520, + 'orange': 589, + 'purple': 390, + 'red': 622 +} + +u_0 = np.empty((len(colors))) +wavelength_inv = np.empty((len(colors))) + +fig, axs = plt.subplots(len(colors), sharex='all', sharey='all') +fig.tight_layout() + +for color_index, color in enumerate(colors): + with open(f'{color}.dat', 'r') as file: + lines = file.readlines() + lines.pop(0) + + voltage = np.empty((len(lines))) + current = np.empty((len(lines))) + for index, line in enumerate(lines): + parts = line.split('\t') + voltage[index] = float(parts[0]) + current[index] = float(parts[1]) + + ## Line 1 + line_1_bound = len(lines) // 3 + line_2_bound = len(lines) - 12 + line_1 = polynomial.Polynomial.fit(voltage[1:line_1_bound], current[1:line_1_bound], 1) + line_2 = polynomial.Polynomial.fit(voltage[line_2_bound:], current[line_2_bound:], 1) + line_1 = line_1.convert(domain=(voltage[0], voltage[-1])) + line_2 = line_2.convert(domain=line_1.domain) + + intersect_x = scipy.optimize.fsolve(line_1 - line_2, 0) + intersect_y = line_1(intersect_x) + + ax = axs[color_index] + ax.scatter(voltage, current, label="Raw Data", color=color) + ax.set_ylim(ax.get_ylim()) + + space = np.linspace(voltage[0], voltage[-1]) + ax.plot(space, line_1(space), color='red', label='Trendline 1') + ax.plot(space, line_2(space), color='orange', label='Trendline 2') + ax.scatter(intersect_x, intersect_y, color='pink', label=f'Intersect: {intersect_x[0]:0.3f}V') + + ax.legend() + ax.set_title(f"Voltage v Current ({color})") + ax.set_xlabel("Voltage (V)") + ax.set_ylabel("Current (mA)") + + u_0[color_index] = intersect_y[0] + wavelength_inv[color_index] = 1 / wavelengths[color] + +plt.show() + +line = polynomial.Polynomial.fit(u_0, wavelength_inv, 1) +space = np.linspace(min(u_0), max(u_0)) +plt.plot(space, line(space), color='orange', label='Trendline 2') + +plt.scatter(u_0, wavelength_inv) +plt.xlabel("U_0") +plt.ylabel("1/Wavelength") +plt.show()