Finished projects as of 07/20
This commit is contained in:
parent
94e0884ab6
commit
0c5f54cad5
9 changed files with 479 additions and 0 deletions
23
A10_awparle_P1.py
Normal file
23
A10_awparle_P1.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
## Problem 13
|
||||
#Adam Parler ENGR 1410-013 January 31, 2014
|
||||
#Problem Statement: Calculate the weight of a metal rod
|
||||
|
||||
from A10_awparle_P1F import A10_awparle_P1F
|
||||
|
||||
V=input('User Input: \n Volume = ')
|
||||
V = float(V)
|
||||
print('cubic meters');
|
||||
SG=input('Specific Gravity = ')
|
||||
SG = float(SG)
|
||||
|
||||
Weight = A10_awparle_P1F(V,SG)
|
||||
print('With these values, a rod on Callisto would weigh',end='')
|
||||
print(f' {Weight:.4f} pounds-force. \n')
|
||||
|
||||
## Sample Output
|
||||
|
||||
##
|
||||
#
|
||||
# <<A10_awparle1.PNG>>
|
||||
#
|
||||
|
||||
13
A10_awparle_P1F.py
Normal file
13
A10_awparle_P1F.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#Adam Parler ENGR 1410-013 January 31, 2014
|
||||
#Problem Statement: Calculate the weight of a metal rod
|
||||
|
||||
def A10_awparle_P1F(V,SG):
|
||||
|
||||
g=1.25; #m/s^2
|
||||
rho_w=1000; #[-]
|
||||
lb_f=0.225; #[pound-force]
|
||||
|
||||
Wi=V*SG*rho_w*g;
|
||||
Weight=Wi*lb_f;
|
||||
return Weight
|
||||
|
||||
56
A10_awparle_P2.py
Normal file
56
A10_awparle_P2.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import numpy as np
|
||||
from A10_awparle_P2F import A10_awparle_P2F
|
||||
|
||||
#Adam Parler ENGR 1410-013 January 31, 2014
|
||||
#Problem Statement: Convert all of the spring data to the same units and
|
||||
#create a program to allow user inputs.
|
||||
|
||||
#Assumptions
|
||||
#This takes place on earth
|
||||
#g=-9.8 m/s^2
|
||||
|
||||
# Spring 1 Data (Mass [g], Time [min])
|
||||
Mass1=np.array([40,60,90,110])
|
||||
Time1=np.array([0.187,0.255,0.293,0.323])
|
||||
|
||||
# Spring 2 Data (Mass [lbm], Time [s])
|
||||
Mass2=np.array([0.24,0.31,0.35,0.46])
|
||||
Time2=np.array([16.5,18.4,20.3,22.5])
|
||||
|
||||
# Spring 3 Data (Mass [kg], Time [s])
|
||||
Mass3=np.array([0.51,0.66,0.81,1.01])
|
||||
Time3=np.array([12.3,13.6,14.8,16.3])
|
||||
|
||||
# Number of oscillations
|
||||
N=25
|
||||
|
||||
#Conversion Factors
|
||||
kg=2.205 #2.205lb_mass-->1kg
|
||||
g=1000 #1kg-->1000g
|
||||
s=60 #1min-->60s
|
||||
|
||||
#Conversions
|
||||
M1=Mass1 #g-->g
|
||||
M2=g/kg*Mass2 #lb_mass-->g
|
||||
M3=Mass3*g #kg-->g
|
||||
T1=s*Time1 #min-->s
|
||||
T2=Time2 #s-->s
|
||||
T3=Time3 #s-->s
|
||||
|
||||
M = [M1,M2,M3]
|
||||
M = np.array(M).reshape(1,-1)
|
||||
|
||||
T = [T1,T2,T3]
|
||||
T = np.array(T).reshape(1,-1)
|
||||
|
||||
M=np.rot90(M)
|
||||
T=np.rot90(T)
|
||||
|
||||
[MAT1,MAT2] = A10_awparle_P2F(M,T,N)
|
||||
|
||||
print(MAT1)
|
||||
print(MAT2)
|
||||
|
||||
|
||||
20
A10_awparle_P2F.py
Executable file
20
A10_awparle_P2F.py
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#Adam Parler ENGR 1410-013 January 31, 2014
|
||||
#Problem Statement: Convert all of the spring data to the same units and
|
||||
#create a program to allow user inputs.
|
||||
|
||||
import numpy as np
|
||||
|
||||
def A10_awparle_P2F (M,T,N):
|
||||
|
||||
H=1000 #g-->kg
|
||||
g=9.81 #gravitational acceleration
|
||||
|
||||
MAT1 = [M/H, T/N]
|
||||
MAT2 = [M*g/H, N/T]
|
||||
|
||||
MAT1 = np.array(MAT1)[:,:,0]
|
||||
MAT2 = np.array(MAT2)[:,:,0]
|
||||
|
||||
return MAT1.T, MAT2.T
|
||||
|
||||
|
||||
68
A5_awparle.py
Normal file
68
A5_awparle.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
## Problem Review 15-1
|
||||
#Adam Parler ENGR 1410-013 January 17, 2014
|
||||
# Problem Statement: Determine the weight of a rod in pound-force.
|
||||
|
||||
#Variables:
|
||||
#V-Volume of rod [m^3]
|
||||
#SG-Specific Gravity of rod [-]
|
||||
#g-Gravitaty [9.8 m/s^2]
|
||||
#D_r-density of rod [kg/m^3]
|
||||
#D_w-density of water [kg/m^3]
|
||||
#W-Weight of rod [lb_force]
|
||||
#N-Newton [kg*m/s^2]
|
||||
#lb_f-pound-force
|
||||
|
||||
#Assumptions:
|
||||
# 1 N=1 [kg*m/s^2]
|
||||
#SG=4.7 [-]
|
||||
#g=1.25 [m/s^2]
|
||||
#W=D_r*V*g
|
||||
#1 N=.225 [lb_force]
|
||||
#D_w=1000 [kg/m^3]
|
||||
|
||||
#Set inputs and constants
|
||||
V=.3;
|
||||
SG=4.7;
|
||||
D_w=1000;
|
||||
g=1.25;
|
||||
|
||||
#Calculate weight
|
||||
W=SG*D_w*V*g;
|
||||
|
||||
#Convert to pound-force
|
||||
lb_f=W*.225
|
||||
|
||||
|
||||
## Problem Review 15-3
|
||||
#Adam Parler ENGR 1410-013 January 17, 2014
|
||||
#Problem Statement: Determine the density of tribromoethylene in kilograms
|
||||
#per cubic meter
|
||||
|
||||
#Variables:
|
||||
#H-height of cylinder [ft]
|
||||
#P_s-surface Pressure [atm]
|
||||
#P_t-total Pressure [atm]
|
||||
#g=gravity [9.8 m/s^2]
|
||||
#rho-Density [kg/m^3]
|
||||
|
||||
#Assumptions:
|
||||
#P_t=P_s+rho*g*h
|
||||
#g=9.8 [m/s^2]
|
||||
#1 atm=101325 Pa
|
||||
#1 Pa= 1 kg/m*s^2
|
||||
#1 m=3.28 ft
|
||||
|
||||
#set input variables
|
||||
H=25;
|
||||
P_t=5;
|
||||
P_s=3;
|
||||
g=9.8;
|
||||
|
||||
#convert to SI units
|
||||
H=H/3.28; #[ft]-->[m]
|
||||
|
||||
#calculate density of tribromoethylene
|
||||
rho=((P_t*101325)-(P_s*101325))/(g*H)
|
||||
|
||||
44
A6_awparle.py
Normal file
44
A6_awparle.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
#Adam Parler ENGR 1410-013 January 21, 2014
|
||||
#Problem Statement: Store matrices into MATLAB and perform calcuations
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
#Input Variables:
|
||||
A=[[4, 6], [-3, 8]];
|
||||
B=[[3, 5], [ 5, 5]];
|
||||
C=[0, 1];
|
||||
D=[[1], [1]];
|
||||
E=[[3, 6, 5], [ 7, 1, 5]];
|
||||
F=[[2, 8], [ 4, 3], [ 1, 5]];
|
||||
G=np.arange(1,301);
|
||||
h=[200,-300,-1];
|
||||
H=h[::-1]
|
||||
J=[[20,200,20], [ 10,100,10]];
|
||||
# k=[5:5:50; 50:-5:-50];
|
||||
# K=k'
|
||||
#This matrix will not work because there are more rows for one operation
|
||||
#than the other.
|
||||
|
||||
#Calculations
|
||||
A = np.array(A)
|
||||
B = np.array(B)
|
||||
L=A @ B
|
||||
m=A+B
|
||||
# n=A+C
|
||||
#To be added, the matrix demensions must be the same
|
||||
# p=C-E
|
||||
#To be subtracted, the maxrix demensions must be the same
|
||||
F = np.array(F)
|
||||
E = np.array(E)
|
||||
q=F @ E
|
||||
r=B^2
|
||||
s=A*30
|
||||
u=F.T+E
|
||||
J = np.array(J)
|
||||
v=J.T+30
|
||||
# w=E^2 +50
|
||||
#Maxrix E is not a scalar or a square matrix. The number of columns and
|
||||
#rows are not equal, so the matrix cannot be multiplied.
|
||||
66
A7_awparle.py
Normal file
66
A7_awparle.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
#Adam Parler ENGR 1410-013 January 22, 2014
|
||||
#Problem Statement:Write statements that will accomplish the stated purpose
|
||||
|
||||
import numpy as np
|
||||
|
||||
#Input Variables
|
||||
V1= [125, 367, 498, 24, 63, 0.25, 543, 89];
|
||||
V2= [75, 32, 0.67, 34];
|
||||
V3= [98, 56, 56, 1, 98, 56, 87, 98];
|
||||
V4= [5, 10, 100, 0.5, 67, 87];
|
||||
|
||||
# Calculations
|
||||
A=max(V1)
|
||||
B=np.argmax(V1)
|
||||
BigVal=[A, B]
|
||||
C=len(V1);
|
||||
D=len(V2);
|
||||
E=len(V3);
|
||||
F=len(V4);
|
||||
H=[C, D, E, F];
|
||||
MinL=min(H)
|
||||
|
||||
UV=np.unique(V3)
|
||||
|
||||
r100=np.random.randint(-5, 5, size=(1, 10))
|
||||
|
||||
V=75*np.ones(12);
|
||||
L=np.diag(V);
|
||||
p75=np.rot90(L)
|
||||
|
||||
Ma = []
|
||||
Ma.append(V1)
|
||||
Ma.append(V3)
|
||||
temp = [x + 5 for x in V1]
|
||||
Ma.append(temp)
|
||||
temp = [x*3 for x in V3]
|
||||
Ma.append(temp)
|
||||
print(Ma)
|
||||
|
||||
MaRows, MaCols=np.array(Ma).shape
|
||||
print(MaRows, MaCols)
|
||||
|
||||
X=min(min(Ma));
|
||||
Y=np.argmin(V1)
|
||||
MaxMa= [X, Y]
|
||||
|
||||
V1.sort(reverse=True)
|
||||
print(V1)
|
||||
|
||||
|
||||
## Adam Parler ENGR 1410-013 January 22, 2014
|
||||
#Problem Statement: Evaluates the mathmatical equation
|
||||
#clear
|
||||
#clc
|
||||
|
||||
#Input Variables
|
||||
x=0;
|
||||
u=0;
|
||||
rho= np.array([1, 2, 5]);
|
||||
|
||||
# Calculation
|
||||
L=(-(x-u)**2)/(2*rho**2);
|
||||
P=(1/(rho*np.sqrt(2*np.pi)))*np.exp(L)
|
||||
print(P)
|
||||
60
A8_awparle.py
Executable file
60
A8_awparle.py
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
##Problem 1
|
||||
#Adam Parler ENGR 1410-013 January 24, 2014
|
||||
#Problem Statement: Convert Kelvin to other common unit systems
|
||||
|
||||
#Variables
|
||||
#k=Kelvin
|
||||
#c=Degrees Celcius
|
||||
#f=Degrees Fahrenheit
|
||||
#r=Degrees Rankine
|
||||
|
||||
#Assumptions
|
||||
#273 k=0 c
|
||||
#0 c=32 f
|
||||
#400 r=60 f
|
||||
#(f-32)/180=c/100
|
||||
|
||||
#Calculations
|
||||
k=float(input('Enter Temperature [K]: ')) #[K]
|
||||
c=k-273 #[K-->C]
|
||||
f=(1.8*c)+32 #[C-->F]
|
||||
r=f+460 #[F-->R]
|
||||
print(f'The temperatrue of {k:.2f} K = {c:.2f} deg C = {f:.2f} deg F',end='')
|
||||
print(f' = {r:.2f} deg R\n\n\n')
|
||||
|
||||
## Problem 2
|
||||
#Adam Parler ENGR 1410-013 January 24, 2014
|
||||
#Problem Statement: Converts between calories per gram degree Celsius and
|
||||
#British Thermal Units per pound-mass degree Farenheit
|
||||
|
||||
#Variables
|
||||
#cal/(g*degC)=calories per gram degree Celsius
|
||||
#BTU/lb_m*deg F)=British Thermal Units per pound-mass degree Farenheit
|
||||
|
||||
#Assumptions
|
||||
#239 calories?0.948 British Thermal Unit
|
||||
#1000 grams=2.205 pound-mass
|
||||
#change in 1 deg Celsius=change in 1.8 deg Farenheit
|
||||
|
||||
#Defined Units
|
||||
cal=239
|
||||
BTU=0.948
|
||||
g=1000
|
||||
lb_m=2.205
|
||||
deg_C=1
|
||||
deg_F=1.8
|
||||
|
||||
#Variable Calculations
|
||||
i=float(input('Enter specific heat [cal/(g deg C)]: ')) #[cal/g deg C]
|
||||
a=i*(BTU/cal)*(g/lb_m)*(deg_C/deg_F)
|
||||
|
||||
#[cal/(g*degC)--> BTU/(lb_m*deg F)]
|
||||
print(f'The specific heat is {i:.1f} cal/(g deg C) =',end='')
|
||||
print(f' {a:.4f} BTU/(lb_m deg F)\n\n\n')
|
||||
|
||||
## Sample Output
|
||||
#
|
||||
# <<A8_awparle1.PNG>>
|
||||
#
|
||||
129
A9_awparle.py
Executable file
129
A9_awparle.py
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
## ICA 18-15
|
||||
#Adam Parler ENGR 1410 January 29, 2014
|
||||
#Problem Statement:Create a proper plot for the Joule effect data.
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
#Experimental Data
|
||||
Current=[0.50,1.25,1.50,2.25,3.00,3.20,3.50]; #Current (I) [A]
|
||||
Power=[1.20,7.50,11.25,25.00,45.00,50.00,65.00]; #Power (P) [W]
|
||||
|
||||
#plt.figure(color='w')
|
||||
plt.figure()
|
||||
plt.plot(Current, Power, '^b',fillstyle='none')
|
||||
T = 'Joule Effect Graph'
|
||||
plt.title(T,color='k',fontsize=12)
|
||||
plt.xlabel('Current (I) [A]')
|
||||
plt.ylabel('Power (P) [W]')
|
||||
plt.grid()
|
||||
plt.axis([0, 4, 0, 70])
|
||||
plt.xticks(np.arange(0,4.5,0.5))
|
||||
plt.yticks(np.arange(0,80,10))
|
||||
plt.draw()
|
||||
|
||||
#############################################################################
|
||||
|
||||
## ICA 18-20
|
||||
# Adam Parler ENGR 1410 January 29, 2014
|
||||
# Problem Statement: Create a proper plot of the theoretical voltage decay
|
||||
# of a resistor-capacitor circuit
|
||||
|
||||
#Variables
|
||||
# C=Capacitance Microfarads (C) [?F]
|
||||
# R=Resistance Ohms (R) [?]
|
||||
# V_0=Initial Voltage (V) [V]
|
||||
# V(t)=Volts after t seconds (V) [V]
|
||||
# t=time (t) [s]
|
||||
|
||||
#Assumptions
|
||||
C = 500 # Microfarads (C) [?F]
|
||||
R = 0.5 # Ohms (R) [?]
|
||||
V_0 = 10 # Volts (V) [V]
|
||||
|
||||
# Calculations
|
||||
t = np.arange(1,601)
|
||||
V = V_0 * np.exp(-t/(R*C))
|
||||
|
||||
# Graph
|
||||
plt.figure()
|
||||
plt.plot(t,V,'sb',fillstyle = 'none')
|
||||
T = 'Voltage Decay'
|
||||
plt.title(T,color='k',fontsize=12)
|
||||
plt.xlabel('Time (t) [s]')
|
||||
plt.ylabel('Volts (V) [V]')
|
||||
plt.grid()
|
||||
plt.axis([0, 650, 0, 11])
|
||||
plt.xticks(np.arange(0,700,50))
|
||||
plt.yticks(np.arange(0,12,1))
|
||||
plt.draw()
|
||||
|
||||
#############################################################################
|
||||
|
||||
## ICA 18-21
|
||||
#Adam Parler ENGR 1410 January 29, 2014
|
||||
#Problem Statement:
|
||||
|
||||
# Variables:
|
||||
# C=angle (deg) [o]
|
||||
# M=measure of angle (-) [-]
|
||||
|
||||
pi = np.pi
|
||||
|
||||
#Calculaions
|
||||
C = np.arange(0,390,30)
|
||||
M_1 = np.sin(C*pi/180);
|
||||
M_2 = 3*np.sin(C*pi/180);
|
||||
M_3 = np.sin(C*pi*3/180);
|
||||
M_4 = 3*np.sin(2*C*pi/180)-2;
|
||||
|
||||
#fig = plt.figure()
|
||||
fig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(nrows = 2, ncols=2)
|
||||
plt.tight_layout()
|
||||
|
||||
ax1.plot(C,M_1,'or', markerfacecolor='r')
|
||||
ax1.set_xlabel('Angle (deg) [o]')
|
||||
ax1.set_ylabel('Sine of X (sinx) [-]')
|
||||
ax1.grid()
|
||||
ax1.axis([0, 360, -1, 1])
|
||||
ax1.set_xticks(np.arange(0,390,30))
|
||||
ax1.set_yticks(np.arange(-1,1.25,0.25))
|
||||
T = 'Graph A'
|
||||
ax1.set_title(T,color='k',fontsize=12)
|
||||
|
||||
ax2.plot(C,M_2,'^g', markerfacecolor='g')
|
||||
ax2.set_xlabel('Angle (deg) [o]')
|
||||
ax2.set_ylabel('Sine of X (sinx) [-]')
|
||||
ax2.grid()
|
||||
ax2.axis([0, 360, -3, 3])
|
||||
ax2.set_xticks(np.arange(0,390,30))
|
||||
ax2.set_yticks(np.arange(-3,4,1))
|
||||
T = 'Graph B'
|
||||
ax2.set_title(T,color='k',fontsize=12)
|
||||
|
||||
ax3.plot(C,M_3,'sb', markerfacecolor='b')
|
||||
ax3.set_xlabel('Angle (deg) [o]')
|
||||
ax3.set_ylabel('Sine of X (sinx) [-]')
|
||||
ax3.grid()
|
||||
ax3.axis([0, 360, -1, 1])
|
||||
ax3.set_xticks(np.arange(0,390,30))
|
||||
ax3.set_yticks(np.arange(-1,1.25,0.25))
|
||||
T = 'Graph C'
|
||||
ax3.set_title(T,color='k',fontsize=12)
|
||||
|
||||
ax4.plot(C,M_4,'dk', markerfacecolor='k')
|
||||
ax4.set_xlabel('Angle (deg) [o]')
|
||||
ax4.set_ylabel('Sine of X (sinx) [-]')
|
||||
ax4.grid()
|
||||
ax4.axis([0, 360, -5, 1])
|
||||
ax4.set_xticks(np.arange(0,390,30))
|
||||
ax4.set_yticks(np.arange(-5,1.1,1))
|
||||
T = 'Graph F'
|
||||
ax4.set_title(T,color='k',fontsize=12)
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue