Additonal files translated on 07/21/2020

This commit is contained in:
bigperm17 2020-07-22 01:34:44 -07:00
parent 0d2cc01599
commit 9a39d06b55
8 changed files with 994 additions and 0 deletions

131
A13_awparle.py Executable file
View file

@ -0,0 +1,131 @@
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
eps = np.finfo(np.float32).eps
## Linear Polyfit
# Adam Parler ENGR 1410-013 February 6, 2014
# Problem Statement: Create different types of graphs and add trendlines
# to them.
#Variables
#T=Temperature Change (T) [K]
#Q=Heat applied (Q) [J]
#M=Mass (M) [g]
#C_P=Specific Heat
#Data
T=np.array([1.5, 2.0, 3.25, 5, 6.25, 7])
Q=np.array([12, 17, 25, 40, 50, 58])
#Graph
plt.figure()
plt.plot(Q,T,'ok',fillstyle='none')
plt.xlabel('Heat Applied (Q) [J]')
plt.ylabel('Temp Change ${\Delta}T$ [K]')
plt.title('Heat Applied vs Temp')
plt.grid()
plt.axis([10,60,1,8])
plt.draw()
#Polyfit Parameters
C = np.polyfit(Q,T,1)
m = C[0]
b = C[1]
# Create theoretical data series
Qpf = range(12,61)
Tpf = m*Qpf+b
plt.plot(Qpf,Tpf,':b')
# Place Trendline Equation on Graph
TE = '${\Delta}T$ = ' + f'{m:.3f} Q + {b:.3f}'
plt.text(40,4,TE, backgroundcolor = 'white')
plt.show()
###################################################
## Power Polyfit
#Variables
#r=Radius (r) [cm]
#h=Height (H) [cm]
#Data
r = np.array([0.01, 0.05, 0.10, 0.20, 0.40, 0.50])
h = np.array([14.0, 3.0, 1.5, 0.8, 0.4, 0.2])
#Create Plot
plt.figure()
plt.loglog(r,h,'^r',fillstyle='none')
plt.axis([0.01, 1, 0.1, 100])
plt.xlabel('Radius (r) [cm]')
plt.ylabel('Height (H) [cm]')
plt.title('Capillary Action Graph')
plt.grid()
plt.draw()
# Polyfit Parameters
C = np.polyfit(np.log10(r),np.log10(h),1)
m = C[0]
b = 10**C[1]
#Crete Trendline
Rpf = np.arange(0.01,0.5+eps, 0.01)
Hpf = b*Rpf**m
plt.plot(Rpf,Hpf,'--r')
#Put Trendline on graph
TE = f'H={b:.2f}*R^{m:.3f}'
plt.text(0.02,1,TE,backgroundcolor = 'white')
plt.show()
####################################################
## Exponential Polyfit
#Variables
#y=Years from 1967
#Q=Minumum gear size [mm]
#Data
y = np.array([0, 5, 7, 16, 25, 31, 37])
Q = np.array([0.8, 0.4, 0.2, 0.09, 0.007, 0.0002, 0.000008])
#Create Plot
plt.figure()
plt.semilogy(y,Q,'db',fillstyle='none')
plt.axis([0,40,0.000001,1])
plt.xlabel('Years from 1967')
plt.ylabel('Minimum Gear Size')
plt.title('Size of Working Gear')
plt.grid()
plt.draw()
#Polyfit Parameters
C = np.polyfit(y,np.log(Q),1)
m = C[0]
b = np.exp(C[1])
#Crete Trendline
ypf = np.arange(0.01,40+eps, 1)
Qpf = b*np.exp(ypf*m)
plt.plot(ypf,Qpf,'-.b',fillstyle='none')
#Put Trendline Equation on Graph
TE = f'Min={b:.4f}*e^(y*{m:.4f})'
plt.text(10,0.0001,TE, backgroundcolor = 'white')
plt.show()

137
A16_awparle.py Executable file
View file

@ -0,0 +1,137 @@
#!/usr/bin/env python3
import numpy as np
import tkinter as tk
from time import sleep as pause
from A16_awparle_F import A16_awparle_F
def quit_loop(master,num):
#print("Selection:",num)
global selection
selection = num
#master.quit()
master.destroy()
def menu_main(master,quest, *args):
listvar = []
for i in range(len(args)):
listvar.append([args[i],i+1])
master.title(quest)
master.attributes('-topmost', True)
r = 1
for b in listvar:
tk.Button(master, text=b[0], bg="light goldenrod",
command=lambda text=b: quit_loop(master,text[1])).grid(row=r, sticky='W')
r += 1
master.mainloop()
def menu(quest, *args):
master = tk.Tk()
temp = []
for i in range(len(args)):
temp.append(args[i])
menu_main(master,quest,*args)
global selection
pause(1)
try:
select = selection
except NameError:
#del selection
return None
else:
del selection
return select
# # Header and Test Cases
# Adam Parler ENGR 1410-013 February 27, 2014
# Problem Statement: This program will suggest solutions to medical
# problems.
# Variables
# Name=User's Name
# W=weight [lb_f]
# S=Ailment [Menu Selection]
# M=cell array of Medicine information {Symptoms; Medicine; Volume(mL); mass(g)}
# Med=Medicine
# N=number of pills
# SG=Specific Gravity [-]
# Test Case # 1
# Name='John Doe';
# W=170; # [pound-force]
# S=1; # Menu choice:Cold
# Expected outcome: SG of Achoo=2.500;Number of tablets=5
# Test Case # 2
# Name='John Doe'
# W=170; # [pound-force]
# S=2; # Menu choice: Flu
# Expected outcome: SG of Chill=3.200; Number of tablets=3
# Test Case # 3
# Name='John Doe'
# W=170; # [pound-force]
# S=3; # Menu Choice:Migraine
# Expected outcome: SG of HAche=2.750; Number of tablets=4
# Test Case # 4
# Name='John Doe'
# W=170; # [pound-force]
# S=0; # Menu was closed
# Expected outcome: You incorrectly selected a symptom
# Test Case # 5
# Name='John Doe'
# W=68; # [pound-force]
# S=2; # Menu Choice: Flu
# Expected outcome: Weight is too low, Asssumes weight is 75
# SG of Chill=3.200; Number of tablets=2
## Program
def main():
# Cell array of medicine choices and specifications
M = [['Cold','Flu','Migraine'],['Achoo', 'Chill', 'HAche'],[3.6, 5, 4], [9, 16, 11]]
x = 0
# Input data
Name = input('Enter your name: ')
W = input('Enter your weight in pound-force: ')
# Determines if weight is correct
if float(W) < 75.0:
print('The entered weight is too low to correctly use this program')
print('Program assumes that weight=75')
print(M[0])
while x == 0:
S = menu('Select your symptoms',M[0][0],M[0][1],M[0][2])
if S == 0 or S == None:
x = 0
print('You have incorrectly selected a symptom. Try again.')
else:
x = 1
# Determines which medicine to use
temp = []
for x in M:
temp.append(x[S-1])
Med = temp[1]
S = temp[0]
[SG, N] = A16_awparle_F(temp,int(W))
# Output Statements
print(f'\n\nThe specific gravity of {Med} is {SG:.3f}')
print(f'{Name} your recommended dosage of {Med} to treat a {S}: {N:.0f} tablets.\n')
if __name__ == "__main__":
main()

26
A16_awparle_F.py Executable file
View file

@ -0,0 +1,26 @@
import numpy as np
#Adam Parler ENGR 1410-013 February 27,2014
#This is the function to go along with program A16
#Variables
# SG=Specific Gravity [-]
# W=Weight [lb_f]
# N=Number of Pills
# M=Medicine information
# g=gravitational acceleration on earth
def A16_awparle_F(M,W):
g = 9.8
SG = M[3]/M[2] #mass(g)/volume(mL)
# Converts patient weight in pound-force to kilograms
W = W * 1/0.225/g # converts lb_f --> kg by lb_f*Newtons/lb_f/gravity
#Determines the dosage size
N = W*1.25/(2.5*SG) #mass(kg)*1.25(ml/kg)/(2.5*SG)*1 (Tablet)/Volume(mL)
# Rounds the dosage to the next highest tablet
N = np.ceil(N)
return SG,N

232
A17_awparle.py Executable file
View file

@ -0,0 +1,232 @@
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
# Adam Parler ENGR 1410-013 February 28, 2014
# Problem Statement: Calculates the phase the compound will be according to
# the percent A and B and the temperature.
# Variables
# MP=mass percent of beta
# T=Temerature in Celcius
# A_p1=X values for pure alpha
# A_p2=increasing y values for pure alpha
# A_n2=decreasing y values for pure alpha
# ELineX=Eutectic line x values
# ELineY=Eutectic line y values
# EPointAX=x values for higher percentage of alpha
# EPointAY=y values for higher percentage of alpha
# EpointBX=x values for higher percentage of beta
# EpointBY=y values for higher percentage of beta
# B_n1=x values for pure beta
# B_n2=decreasing y values for pure beta
# B_p2=increasing y values for pure beta
# AN=Slope of negative alpha
# AP=Slope of positive alpha
# ABP=slope of positive alpha and beta combination
# ABN=slope of negitive alpha and beta combination
# BP=slope of positive beta
# BN=slope of negative beta
# A=percent mass of Alpha
# Input data
# MP=input('Enter mass percent of B for the compound (# ): ');
# T=input('Enter temperature of compound in deg C: ');
# I cannot use the first two outcomes because they will produce an error.
# Therefore, I used my third condition, which will cause a warning, but
# still run.
## Test Case #1
# MP=120;
# T=500;
## Expected outcome: Data is not physically possible.
## Test Case #2
# MP=87;
# T=-300;
## Expected outcome: Data is not physically possible.
# Test Case #3
MP=43;
T=760;
# Expected outcome: Tempereture entered is greater than the maximum value.
# Temperature was set to 710. Phase = Liquid.
## Test Case #4
# MP=67;
# T=874;
## Expected outcome: Tempereture entered is greater than the maximum value.
## Temperature was set to 810. Phase = Liquid.
## Test Case #5
# MP=37;
# T=272;
## Expected outcome: Phase= Alpha + Beta
## Test Case #6
# MP=12;
# T=100;
## Expected outcome: Phase= Alpha + Beta.
## Test Case #7
# MP=2;
# T=500;
## Expected outcome: Phase = Alpha.
## Test Case #8
# MP=12;
# T=550;
## Expected outcome: Phase = Alpha + Liquid.
## Test Case #9
# MP=37;
# T=350;
## Expected outcome: Phase = Alpha + Liquid.
## Test Case #10
# MP=80;
# T=375;
## Expected outcome: Phase = Beta + Liquid.
## Test Case #11
# MP=87;
# T=50;
## Expected outcome: Phase = Alpha + Beta.
## Test Case #12
# MP=90;
# T=46;
## Expected outcome: Phase = Beta.
## Test Case #13
# MP=88;
# T=350;
## Expected outcome: Phase= Beta + Liquid.
## Test Case #14
# MP=50;
# T=300;
## Expected outcome: Material is at the eutectic point.
## Test Case #15
# MP=47;
# T=300;
## Expected outcome: Material is on the eutectic line.
## Test Case #16
# MP=50;
# T=450;
## Expected outcome: Phase= Liquid.
#Melting Point of Alpha
A_p1=[0, 15];
A_p2=[0, 300];
A_n2=[700, 300];
#Eutectic Line
ELineX=[15, 85];
ELineY=[300, 300];
#Eutectic Divider
EPointAX=[0, 50];
EPointAY=[700, 300];
EPointBX=[50, 100];
EPointBY=[300, 800];
#Melting Point of Beta
B_n1=[85, 100];
B_n2=[300, 0];
B_p2=[300, 800];
#Error messages
if MP> 100 or MP<0:
raise ValueError
elif T < -273:
raise ValueError
if MP <= 50 and T > 700:
print('Temperature entered is greater than the maximum value.')
print('Temperature was set to 710')
T = 710
elif MP >= 50 and T > 800:
print('Temperature entered is greater than the maximum value.')
print('Temperature was set to 810')
T = 810
#Graph
plt.figure()
plt.plot(A_p1, A_p2, '-b', A_p1, A_n2, '-b', EPointAX, EPointAY, '-b', EPointBX, EPointBY, '-b',fillstyle='none')
plt.plot(ELineX, ELineY, '-k', B_n1, B_n2, '-b', B_n1, B_p2, '-b',MP, T, 'sr', markersize=4,fillstyle='none')
plt.draw()
plt.axis([0, 100, 0, 850])
plt.xlabel('Composition of Beta (B) [%]')
plt.ylabel('Temperature (T) [deg C]')
plt.text(6.5, 300,r'$\alpha$')
plt.text(45, 150,r'$\alpha$+$\beta}$')
plt.text(45, 650,'Liquid')
plt.text(16, 400,r'$\alpha$+Liquid')
plt.text(65, 400,r'$\beta$+Liquid')
plt.text(90, 300,r'$\beta$')
plt.text(2, 702, u'700\N{DEGREE SIGN}C')
plt.text(16, 270,'15%')
plt.text(49, 270,'50%, 300\N{DEGREE SIGN}C')
plt.text(79, 270,'85%')
plt.text(95, 802,'800\N{DEGREE SIGN}C')
plt.show()
# Phase Calculations
AN = np.polyfit(A_p1,A_n2,1)
AP = np.polyfit(A_p1,A_p2,1)
ABN = np.polyfit(EPointAX,EPointAY,1)
ABP = np.polyfit(EPointBX,EPointBY,1)
BP = np.polyfit(B_n1, B_p2,1)
BN = np.polyfit(B_n1, B_n2,1)
# Determines what phase compound is in
if T < 300 and MP > 15 and MP < 85:
Phase = r'$\alpha+\beta$'
elif MP<15 and T<AP[0]*MP+AP[1]:
Phase=r'$\alpha+\beta$';
elif MP<15 and T<AN[0]*MP+AN[1]:
Phase=r'$\alpha$';
elif MP<15 and T>ABN[0]*MP+ABN[1]:
Phase=r'$\alpha$+Liquid';
elif MP>15 and MP<50 and T<ABN[0]*MP+ABN[1]:
Phase=r'$\alpha$+Liquid';
elif MP>50 and MP<85 and T<ABP[0]*MP+ABP[1]:
Phase=r'$\beta$+Liquid';
elif MP>85 and T<BN[0]*MP+BN[1]:
Phase=r'$\alpha+\beta$';
elif MP>85 and T<BP[0]*MP+BP[1]:
Phase=r'$\beta$';
elif MP>85 and T<ABP[0]*MP+ABP[1]:
Phase=r'$\beta$+Liquid';
elif MP==50 and T==300:
Phase='Material is at the eutectic point'
elif T==300 and MP<85 and MP>15:
Phase='Material is on the eutectic line'
else:
Phase='Liquid';
# Output Statement
A = 100-MP
print(f'\nFor the composition of {A:.1f}% A, {MP:.1f}% B and a temperature of')
print(f'{T:.0f} degrees Celcius, the phase is {Phase}.\n')

87
A20_awparle.py Executable file
View file

@ -0,0 +1,87 @@
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
#Adam Parler ENGR 1410-013 March 6, 2014
#Problem Statement: Determine the efficiency of the engines.
def load(name):
if not name.lower().endswith(('.npy', '.npz')):
name = name+'.npz'
try:
temp = np.load(name)
except FileNotFoundError:
print('File location does not exist, please try again.')
tmp = os.getcwd()
print('Filepath: '+tmp+'/'+name)
raise FileNotFoundError
# sys.exit()
return temp
# j=repeat counter
# r=number of rows
# c=number of columns
# TE=Total energy row vector
# KE=Total Kinetic energy row vector
# i=counter
#Loads code and creates a figure
temp = load('Spacecraft.npz')
D = temp['D']
r,c = D.shape
j = 1
plt.figure()
plt.axis([0, 12, 0, 10])
plt.grid()
plt.title('Energy Analysis of Spacecraft Energies')
plt.xlabel('Energy Input (E$_I$) [MJ]')
plt.ylabel('Kinetic Energy (E$_o$) [MJ]')
plt.xticks(range(0,13,2))
plt.yticks(range(0,11,2))
# Loop to test input and output energies to calculate efficiency
for i in range(1,r,2):
TE = D[i-1,:]
KE = D[i,:]
E = np.polyfit(TE,KE,1)
m = E[0]
b = E[1]
R = max(TE)
S = max(KE)
# Tests to see if efficiency is 80% or above
if m >= 0.8:
Texp = np.arange(1,R+1)
Kexp = m*Texp+b
plt.plot(Texp,Kexp,'-r',TE,KE,'dr')
TEX = f'E{j:.0f}$_O$={m:.3f}E{j:.0f}$_I$+{b:.2f}'
plt.text(R+0.2,S-0.6,TEX,backgroundcolor='white')
# Test to see if efficiency is 50% or above
elif m >= 0.5:
Texp = np.arange(1,R+1)
Kexp = m*Texp+b
plt.plot(Texp,Kexp,'-.b',TE,KE,'ob')
TEX = f'E{j:.0f}$_O$={m:.3f}E{j:.0f}$_I$+{b:.2f}'
plt.text(R+0.2,S-0.6,TEX,backgroundcolor='white')
# All other efficiencies
else:
plt.plot(TE,KE,'xk')
plt.draw()
j += 1
plt.show()

191
A21_awparle.py Executable file
View file

@ -0,0 +1,191 @@
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
from A16_awparle import menu
# Adam Parler ENGR 1410-013 March 7, 2014
# Problem Statement: This program proves that a proposed matrix is a magic
# square.
# Variables
# MS=proposed magic square
# r=number of rows
# c=number of columns
# D=value of a specific number in matrix MS
# N=value of first row to be compared
# P=value of second row to be compared
# Q=value of first column to be compared
# R=value of second column to be compared
# W=program ending variable
# K=menu selection
# x=variable to repeat program
# V=Answer to is it a Semi-Magic Square?
# Y=Answer to is it a Normal Magic Square?
# Z=Answer to is it a Perfect Magic Square?
# S=Rotated MS matrix
# Test Case 1: Random magic square
# MS=[80 15 10 65; 25 50 55 40; 45 30 35 60; 20 75 70 5];
# Expected Outcome:
# The Magic Constant for your magic square is 34.
# The classification of your magic square:
# Semi-Magic Normal Perfect
# yes yes no
# Test Case 2: Albrecht Durer magic square
# MS=[16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1];
# Expected Outcome:
# The Magic Constant for your magic square is 34.
# The classification of your magic square:
# Semi-Magic Normal Perfect
# yes yes yes
# Test Case 3: Harry's magic square
# MS=[7 12 5 6; 11 1 17 2; 9 4 14 3; 8 6 12 4];
# Expected Outcome:
# The Magic Constant for your magic square is 34.
# The classification of your magic square:
# Semi-Magic Normal Perfect
# yes no no
# Test Case 4: Exciting magic square
# MS=[80 15 10 65; 25 -50 55 40; 45 30 35 60; 20 75 70 5];
# Expected Outcome:
# The values you entered are not more than zero, try again.
# Enter proposed 4x4 Magic square
# Test Case 5: Kelsey's magic square
# MS=[1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20; 21 22 23 24
# 25];
# Expected Outcome:
# The matrix you entered is not a 4x4 matrix, please enter a 4x4
# matrix.
# Enter proposed 4x4 Magic square:
# Test Case 6: Ralph's magic square
# MS=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
# Expected Outcome:
# This is not a magic square. Would you like to try another square?
x=1
t=1
while x==1:
W=1
while W != 0:
print('Enter proposed 4x4 Magic Square: ')
MS = list(map(int, input().split()))
MS = np.array(MS).reshape(4, 4)
r,c = MS.shape
for i in range(r):
for j in range(c):
D = MS[i,j]
if D < 0:
print('Values entered are not more than zero, try again.')
MS = input('Enter proposed 4x4 Magic Square: ')
while t == 1:
if r != 4 or c != 4:
print('The matrix you entered is not a 4x4. Please enter a 4x4 matrix.')
MS = input('Enter proposed 4x4 Magic Square: ')
r,c = MS.shape
t = 1
else:
t = 0
for i in range(3):
N = MS[i,:]
P = MS[i+1,:]
if sum(N) == sum(P):
for j in range(3):
Q = MS[:,j]
R = MS[:,j+1]
if sum(Q) == sum(R):
Q = Q.T
if sum(Q) == sum(N):
V = 'yes'
U = MS.copy()
for k in range(4):
if sum(np.diag(U)) == sum(Q):
Y = 'yes'
U = U.T
if np.amax(MS) == 16:
Z = 'yes'
else:
Z = 'no'
else:
Y = 'no'
else:
V = 'no'
else:
V = 'no'
W = 0
if W == 0:
K = menu('This is a Magic Square. Would you like to try another square?','Yes','No')
if K == 1:
W = 1
else:
W = 0
else:
print(f'The magic constant for your magic square is {np.amax(R):.0f}.')
print('The classification for your magic square:\n\t',end='')
print(f'Semi-Magic\t\t Normal\t\t Perfect\n\t {V}\t\t\t {Y}\t\t {Z}')
K = menu('This is a Magic Square. Would you like to try another square?','Yes','No')
if K == 1:
W = 1
else:
W = 0
if K == 1:
x = 1
else:
x = 0

147
A23_awparle.py Executable file
View file

@ -0,0 +1,147 @@
# !/usr/bin/env python3
import numpy as np
import tkinter as tk
from time import sleep as pause
from A23_awparle_F import A23_awparle_F
def quit_loop(master,num):
#print("Selection:",num)
global selection
selection = num
#master.quit()
master.destroy()
def menu_main(master,quest, *args):
listvar = []
for i in range(len(args)):
listvar.append([args[i],i+1])
master.title(quest)
master.attributes('-topmost', True)
r = 1
for b in listvar:
tk.Button(master, text=b[0], bg="light goldenrod",
command=lambda text=b: quit_loop(master,text[1])).grid(row=r, sticky='W')
r += 1
master.mainloop()
def menu(quest, *args):
master = tk.Tk()
temp = []
for i in range(len(args)):
temp.append(args[i])
menu_main(master,quest,*args)
global selection
pause(1)
try:
select = selection
except NameError:
#del selection
return None
else:
del selection
return select
def main():
## Header and Test Cases
# Adam Parler ENGR 1410-013 March 25, 2014
# Problem Statement: This program will suggest solutions to medical
# problems.
# Test Case # 1
Name='John Doe';
W=170; # [pound-force]
S=1; # Menu choice:Cold
# Expected outcome: Density of Achoo=2500 kg/m^3;Number of tablets=5
# Test Case # 2
# Name='John Doe'
# W=170; # [pound-force]
# S=2; # Menu choice: Flu
# Expected outcome: Density of Chill=3200 kg/m^3; Number of tablets=3
# Test Case # 3
# Name='John Doe'
# W=170; # [pound-force]
# S=3; # Menu Choice:Migraine
# Expected outcome: Density of HAche=2750 kg/m^3; Number of tablets=4
# Test Case # 4
# Name='John Doe'
# W=170; # [pound-force]
# S=0; # Menu was closed
# Expected outcome: You incorrectly selected a symptom
# Test Case # 5
# Name='John Doe'
# W=68; # [pound-force]
# S=2; # Menu Choice: Flu
# Expected outcome: Weight is too low, Asssumes weight is 75
# Density of Chill=3200 kg/m^3; Number of tablets=2
# Variables
# x=looping variable
# Name=User's Name
# W=weight [lb_f]
# S=Ailment [Menu Selection]
# M=cell array of Medicine information {Symptoms; Medicine; Volume(mL); mass(g)}
# Info=Medicine information for symptom
# N=number of pills
# D=Density [kg/m^3]
## Program
# Cell array of medicine choices and specifications
M = [['Cold','Flu','Migraine'],['Achoo', 'Chill', 'HAche'],[3.6, 5, 4], [9, 16, 11]]
x = 0
#Input data
# Name = input('Enter your name: ')
# W = input('Enter your weight in pound-force: ')
# Determines if weight is correct
if float(W) < 75.0:
print('The entered weight is too low to correctly use this program')
print('Program assumes that weight=75')
'''
while x == 0:
S = menu('Select your symptoms',M[0][0],M[0][1],M[0][2])
if S == 0 or S == None:
x = 0
print('You have incorrectly selected a symptom. Try again.')
else:
x = 1
'''
# Determines which medicine to use
temp = []
for x in M:
temp.append(x[S-1])
Med = temp[1]
S = temp[0]
print(temp[2:])
[SG, N] = A23_awparle_F(temp[2:],int(W))
# Output Statements
print(f'\n\nThe density of {Med} is {SG:.3f} kg/m^3')
print(f'{Name} your recommended dosage of {Med} to treat a {S}: {N:.0f} tablets.\n')
if __name__ == "__main__":
main()

43
A23_awparle_F.py Normal file
View file

@ -0,0 +1,43 @@
import numpy as np
#Adam Parler ENGR 1410-013 March 25,2014
#This is the function to go along with program A23
#Assumptions
# calculations done on earth
# Density of water is 1 g/mL
# SG*1000 kg/m^3= Density [kg/m^3]
# Specific gravity of water is 1.
#Variables
# SG=Specific Gravity [-]
# W=Weight [lb_f]
# N=Number of Pills
# D=Medicine Density
# g=gravitational acceleration on earth
# DW=Density of water (kg/m^3)
# SG=specific gravity [-]
# SGW=specific gravity of water
def A23_awparle_F (M,W):
g = 9.8
DW = 1000
SGW = 1
SG = M[1]/M[0]/SGW #(g/mL)/(g/mL)
D = SG*DW #mass(g)/volume(mL)*Density of water in
#Converts patient weight in pound force to kilograms
W = W*1/0.225/g #converts lb_f-->kg by lb_f*Newtons/lb_f/gravity
#Determines the dosage size
N = W*1.25/(2.5*SG)/M[0]; #mass(kg)*1.25(ml/kg)/(2.5*SG)*1 (Tablet)/Volume(mL)
#Rounds the dosage to the next highest tablet.
N=np.ceil(N);
return D, N