<commit_before>from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from math import tan, cos, sin, pi
from scipy.integrate import odeint

##############
## y0 = yk 
## y1 = theta
## y2 = px
## y3 = py
##############

def model(y, t):
    yk, theta, vx, vy = y
    
    # constants
    m = 0.68 # Mass of pendulum
    k = 300 # Stiffness of Spring
    Y = 0
    R = 0.1 # Torsional Resistance
    L = 0.61  # Length of Pendulum
    g = 9.81 # Gravitional acceleration

    # in between terms
    disp = (yk - Y)

    d_yk = (tan(theta) * vx) + vy 
    d_theta = vx / L * cos(theta)
    d_vx = ((-tan(theta)) * k / m * disp) - ((R*vx) / (m * (L * cos(theta))**2)) 
    d_vy = (-k / m * disp) + g

    return [d_yk, d_theta, d_vx, d_vy]

time = np.linspace(0.0, 20.0, 100)
yinit = [0, pi/4, 0, 0]
y = odeint(model, yinit, time)

plt.plot(time, y[:,0], label="yk")
plt.xlabel('t')
plt.ylabel('Motion of Spring')
plt.legend()
plt.show()

plt.plot(time, y[:,1], label="theta")
plt.xlabel('t')
plt.ylabel('Angle of rotation')
plt.legend()
plt.show()

plt.plot(time, y[:,2], label="px")
plt.xlabel('t')
plt.ylabel('Displacement of Pendulum in Y')
plt.legend()
plt.show()

plt.plot(time, y[:,3], label="py")
plt.xlabel('t')
plt.ylabel('Displacement of Pendulum in Y')
plt.legend()
plt.show()<commit_msg>adding prettier plets<commit_after>from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from math import tan, cos, sin, pi
from scipy.integrate import odeint

##############
## y0 = yk 
## y1 = theta
## y2 = px
## y3 = py
##############

def model(y, t):
    yk, theta, vx, vy = y
    
    # constants
    m = 0.68 # Mass of pendulum
    k = 300 # Stiffness of Spring
    Y = 0
    R = 0.1 # Torsional Resistance
    L = 0.61  # Length of Pendulum
    g = 9.81 # Gravitional acceleration

    # in between terms
    disp = (yk - Y)

    d_yk = (tan(theta) * vx) + vy 
    d_theta = vx / L * cos(theta)
    d_vx = ((-tan(theta)) * k / m * disp) - ((R*vx) / (m * (L * cos(theta))**2)) 
    d_vy = (-k / m * disp) + g

    return [d_yk, d_theta, d_vx, d_vy]

time = np.linspace(0.0, 20.0, 100)
yinit = [0, pi/4, 0, 0]
y = odeint(model, yinit, time)

plt.figure(1)

plt.subplot(211)
plt.plot(time, y[:,0], 'b', label="yk")
plt.xlabel('t')
plt.ylabel('Motion of Spring')
plt.legend()

plt.subplot(212)
plt.plot(time, y[:,1], 'r', label="theta")
plt.xlabel('t')
plt.ylabel('Angle of rotation')
plt.legend()
plt.show()

plt.figure(2)

plt.subplot(211)
plt.plot(time, y[:,2], 'g', label="px")
plt.xlabel('t')
plt.ylabel('Displacement of Pendulum in X')
plt.legend()

plt.subplot(212)
plt.plot(time, y[:,3], 'y', label="py")
plt.xlabel('t')
plt.ylabel('Displacement of Pendulum in Y')
plt.legend()
plt.show()
{'fraction_non_alphanumeric': 0.19825708061002179, 'fraction_numerical': 0.03122730573710966, 'mean_word_length': 3.2713178294573644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '25811', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1129, 'n_words': 311}