https://anaconda.org/conda-forge/opencvthere are multiple ways to install OpenCV try the other ones
CLSE – 115
Cory D. Jensen
Assignment #6
Project Progress Point 2
100 points
Due February 16th, 2022
1. Python
Setting up your Python Project (Project 1)
Report:
to be submitted as a PDF, named using the method described in the Syllabus, with a numbered list
containing the following:
1) A screenshot of the IDE with the content of step 3 without any error
2) Run a copy of the example code (see supplementary material for easy copy-paste) saved to a file
named “test.py” and take a screenshot of the output as well as copy the text of the output and
paste into the report
3) Description of the purposes of each of the 3 libraries/packages you install – what are they used
for, in particular to the context of Project 1?
Extra Credit (+5pts): Write a few lines of code to produce the same value as the two sum functions in the
example code, run it and compare the outputs of your code and the two methods used in the example
code.
Instructions:
1) If not already done, download Anaconda: https://www.anaconda.com/products/individual
This is a package of resources to begin coding in Python, including the Spyder IDE, Jupyter Notebook,
and environment management (an environment is a location for installed libraries and other
components. It allows for several projects to be hosted on the same machine without worrying about
interferences between instillations and dependencies). You can manage these resources through the
app:
Fig 1. Home page of the Anaconda Navigator App on Windows 10
Fig 2. Environment page of the Anaconda Navigator App on Windows 10. This shows different libraries
that are installed on the Base or Root Environment – What is automatically used when starting a project.
Libraries include, e.g., Numpy, Pandas, MatPlotLib, and OpenCV.
From here you should decide if you want to use the Spyder IDE or if you would rather use PyCharm
(Kaitlin’s Preferred IDE, link to download: https://www.jetbrains.com/pycharm/download/ choose the
“community edition”), or even Jupyter Notebook. Comparison images on Windows 10 shown below:
Fig 3. Spyder running the example script. Spyder version 3.3.6 on Windows 10.
Fig 4. PyCharm running the example script. PyCharm version 2019.3.1 on Windows 10.
2) Once Anaconda is installed, install the necessary libraries to your Root environment (if you
feel comfortable making a new environment, something very easy to do in PyCharm, you may
do so)
https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/installing-withconda.html
libraries to be installed:
• Numpy: https://anaconda.org/anaconda/numpy
• MatPlotLib: https://anaconda.org/anaconda/matplotlib
• OpenCV: https://anaconda.org/conda-forge/opencv
General library instillation on Windows 10 using command line and conda install (mac should follow 4-6
in the native command line rather than the anaconda command line):
1. Open the anaconda command line (Anaconda Prompt) using the start bar search
2. This window should appear:
3. Get the necessary conda install code from conda forge (example: matplotlib
https://anaconda.org/conda-forge/matplotlib )
4. The code for this example is: “conda install -c conda-forge matplotlib”, paste this into the
command line:
5. Press enter and it will check if you have the library or if you need any updates.
6. Type in y and press enter again. It will install the packages and show the same initial line upon
completion:
3) Check that the libraries installed correctly. Open your IDE of choice and call the packages and
if an error doesn’t occur, it should be correctly installed. Use the following lines of code to
check:
import matplotlib.pyplot as plt
import cv2
import numpy as np
Example Code:
“””This is an example script to compare PyCharm and Spyder for CLSE 115
Spring 2022″””
print(‘==================\nBegin Code\n==================’)
# import the needed libraries
import numpy as np
# make an example list
example_list = [1, 2, 3, 4]
# add values to list using for loop
for i in range(4):
example_list.append(i+5)
# print the list
print(‘after the for loop, the list is:’, example_list, sep=’ ‘)
# print the sum of the list using the native sum function
print(‘using “sum”, the sum of the list is {}’.format(sum(example_list)))
# print the sum of the list using the imported numpy library
# API ref.: https://numpy.org/doc/stable/reference/generated/numpy.sum.html
print(‘using “np.sum”, the sum of the list is
{}’.format(np.sum(example_list)))
print(‘==================\nEnd Code\n==================’)
2. Robocode
Import a robot into Robocode, demonstrate that it can be used in a battle. Include
in an answer to this problem:
a. the location where the robot was downloaded from
b. the name of the robot
c. the downloaded robot battle results.
Hint: make use of the Import Robot electronic resource in Canvas.
Problem 0.1
Background: Excel uses specific syntax to represent functions (such as those shown below) into an Excel work
Problem: First, convert the following expressions into the Excel sheet (below – Syntax Conversion Solutions).
expressions in the solution box below. Second, calculate your expressions with the values: -1, 0, 3, and A
they mean? Cite any reference used.
Example: 𝑓 𝑥 = 𝐴1 ∗ 𝑥
Expression 1. 𝑓 𝑥 = 𝑥 3
Expression 2. 𝑓 𝑥 = 𝑥!
Expression 3. 𝑓 𝑥 = 𝑒 4𝑥
Expression 4. 𝑓 𝑥 = 𝑙𝑜𝑔2 𝑥 −
𝑥3
𝑥!
Syntax Conversion Solutions:
Example: = A * A1
1.
2.
3.
4.
5.
Calculation Table
A1 values
Function (fx)
1
2
3
4
5
-1
0
3
A
ow) into an Excel workbook sheet.
onversion Solutions). Use reference to cell “A1” as your x-value when writing your
1, 0, 3, and A. What are the outputs from excel, are there any errors? If so, what do
Problem 0.2
Background: Excel includes built in functions making engineering calculations easier to perform, here we will dem
in engineering and science, both a measurement’s value and standard error are typically provided:
𝑦 = 𝑦ത ±
Where 𝑦ത is the arithmeatic mean of all measurments, and 𝜎𝑦 is the standard deviation between measurments.
Problem: Using the grades for an imaginary class of students calculate the average and standard deviations of ea
population. (Hint: This will utilize two different functions for standard deviation, why use which one and where?
error, how is this interpretted? Use proper formatting
Student:
Grade 1
Grade 2
Grade 3
Grade 4
Grade 5
Grade 6
Grade 7
Grade 8
Grade 9
Grade 10
Grade 11
Grade 12
Grade 13
Grade 14
Grade 15
Grade 16
Grade 17
Grade 18
Grade 19
Grade 20
Grade 21
Grade 22
Grade 23
Grade 24
Grade 25
Grade 26
Grade 27
Grade 28
Grade 29
Grade 30
Grade 31
Grade 32
Grade 33
Grade 34
1
67
89
45
99
45
89
75
23
67
76
87
98
35
98
89
92
93
84
46
67
65
56
98
35
98
89
92
93
84
46
67
76
87
98
2
23
35
35
35
45
45
46
46
67
67
67
67
75
76
76
76
84
84
87
87
54
89
89
89
89
89
92
67
93
93
98
98
98
88
3
87
87
87
89
89
89
89
89
92
92
93
93
98
67
98
98
67
98
78
87
70
87
89
89
89
89
89
92
92
93
93
65
98
76
4
45
89
75
23
67
76
87
98
35
98
89
92
93
84
46
67
76
87
45
89
65
23
67
76
87
98
35
98
89
92
93
84
46
67
5
45
45
46
46
67
67
67
67
75
76
76
76
84
84
87
87
87
89
45
45
46
46
67
67
67
67
75
76
76
76
84
84
87
87
6
89
89
89
89
92
92
93
93
98
98
98
98
98
98
99
87
87
87
89
89
65
89
92
92
93
93
98
98
98
98
98
98
99
87
7
99
45
89
75
23
67
76
87
98
35
98
89
92
93
84
46
67
76
87
98
45
98
89
92
93
84
46
67
76
92
93
84
46
67
8
35
45
45
46
46
67
67
67
67
75
76
76
76
84
84
87
87
87
89
89
65
89
89
92
92
93
93
98
98
92
92
93
93
55
Grade 35
Grade 36
Grade 37
35
98
89
98
98
75
98
87
98
76
87
87
87
45
53
87
87
87
76
93
84
98
92
93
1
2
3
4
5
6
7
8
Solution
Student
average
σ
Population
average
σ
perform, here we will demonstrate this attribute using two statistic functions. When reporting numbers
ly provided:
ത ± 𝜎𝑦
between measurments.
d standard deviations of each student sample, as well as the average and standard deviations of the total
use which one and where?). Report the student population grade in terms of the mean and standard
9
89
89
89
89
89
92
92
93
93
98
98
98
98
98
98
99
87
87
87
89
66
89
89
89
70
61
93
93
98
89
92
92
93
93
10
23
67
76
87
98
35
98
89
92
93
84
46
67
76
87
45
89
75
23
67
73
87
98
35
98
89
92
93
84
35
98
89
92
93
11
46
67
67
67
67
75
76
76
76
84
84
87
87
87
89
45
45
46
46
67
41
67
67
75
76
76
76
84
84
75
76
76
76
84
12
89
92
92
93
93
98
78
98
98
98
89
99
87
87
87
89
89
89
89
92
56
93
93
98
98
98
78
98
98
98
98
98
98
98
13
56
76
56
66
67
87
82
65
60
67
87
88
98
67
65
78
68
76
78
56
65
45
65
69
76
67
66
78
65
45
65
67
87
63
98
92
92
84
98
89
84
76
76
98
98
98
67
76
76
9
10
11
12
13
Problem 0.3
Background: When you deposit or borrow money you are paid or pay interest. The compound interest formula can be g
𝐴=𝑃∗ 1
Where;
𝑃 − 𝑖𝑛𝑖𝑡𝑖𝑎𝑙 𝑖𝑛𝑣𝑒𝑠𝑡𝑚𝑒𝑛𝑡
𝑟 − 𝑖𝑛𝑡𝑒𝑟𝑒𝑠𝑡
𝑛 − 𝑟𝑎𝑡𝑒 𝑜𝑓 𝑐𝑜𝑚𝑝𝑜𝑢𝑛𝑑𝑖𝑛𝑔
𝑡 − 𝑢𝑛𝑖𝑡 𝑜𝑓
Problem: Create a user form that allows the user to input the initial principle, interest rate, compound rate, and time th
and output cell(s). Using your amazing user form, calculate the total amount apperciated given an interest rate of 2.80 %
of $30,000.0
Solution
Compound Interest Calculator
Initial Investment
Interest Rate (%)
Compound Rate (periods)
Time (yr)
Amount apperciated
Color Indicates User Entry
Color Indicates Calculation Output
nterest formula can be given as:
1+
𝑟
𝑛
𝑛𝑡
𝑖𝑛𝑣𝑒𝑠𝑡𝑚𝑒𝑛𝑡 𝑜𝑟 𝑝𝑟𝑖𝑛𝑐𝑖𝑝𝑙𝑒
𝑖𝑛𝑡𝑒𝑟𝑒𝑠𝑡 𝑟𝑎𝑡𝑒
𝑐𝑜𝑚𝑝𝑜𝑢𝑛𝑑𝑖𝑛𝑔 𝑝𝑒𝑟 𝑢𝑛𝑖𝑡 𝑡𝑖𝑚𝑒
𝑢𝑛𝑖𝑡 𝑜𝑓 𝑡𝑖𝑚𝑒
pound rate, and time that calculates and displays the total amount apperciated. Create a key to differeniate input
an interest rate of 2.80 % (annually), weekly compounding, over the course of 7.00 years, with an initial investiment
Problem 0.4
Background
Separations are fundamental to several chemical enginering unit operations. A common type of separation
understood for sizing, efficiency, and cleaning/clearing/replacement purposes.
Problem Statement
Your process makes use of a membrane specified to separate 500 gallons per square foot per day. Also, your process m
product can separate 260 L per meter per an hr. Both membranes have a similar service lifetimes. Could this new prod
will expand to double its capacity within two years. The existing membrane is half the cost of the new membrane. Wh
SOLUTION
TABLE 1: Existing Membrane
Gallons
Area (ft2)
Time (d)
Table 2: New Membrane
L
2
Area (m )
CONVERT function table
Gal
ft2
New Membrane Metric
Gal/ft2*d
Time (h)
d
Membranes Filtrate [=] gal / day
type of separation involves membranes. The rate of membrane separation processes needs to be
e foot per day. Also, your process makes use of 20 membranes. A quote you recieved indicates their
vice lifetimes. Could this new product be suitable for your process? You anticipate that your process
he cost of the new membrane. Which woould you choose considering your process expansion and why?
CLSE -115
Cory D. Jensen
Assignment #4
Excel Basics Review
February 1st, 2022
Due February 4th, 2022 11AM
Problem 1
1. Create a new Microsoft Excel Workbook, name it per HW instructions.
Problem 2
2. Name a sheet: Graph.
3. Enter the following information into the Graph sheet
Concentration [=] mol/L
2
Time [=] min
1
4
2
6
3
7
4
6
5
10
6
9
7
12
8
4. Plot Concentration vs. Time in an XY scatter plot, include a chart title and labels.
5. Add a trendline to the chart and include an R2 value.
Problem 3
6. Create a new sheet in your workbook, name it: Prblm
7. For two moles of ideal gas at 40C, calculate volume over a range of pressure 1 to 30 pounds per
square inch (incremented by 1). Set up your problem following the “Front end load your
problem” methodology. Use absolute and relative cell referencing for your calculation. Show
your calculation’s dimensional analysis on the sheet: Prblm.
Problem 4
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
Create a new sheet in your workbook, name it: Pic.
Place your cursor in cell C17, type =
Select the Prblm sheet, select the cell for the volume calculated at 25 pounds per square inch.
Press Enter.
Select cell C17 in the Pic sheet.
Take a screen shot of the formula bar.
Paste the screen shot above cell 17. Crop your image if necessary.
Enter a range of concentrations (mol/L) from 10 to 100 in D17:D26 respectively.
Calculate moles using the value in C17 and range of concentrations, in the range E17:E26.
Click on the cell in the Prblm sheet. Select the cell for the Volume calculation at 17 pounds per
square inch. Click in the formula bar. Take a screen shot. Press enter. Paste the screen shot in
the Pic sheet to the right of your calculations.
Problem 1.1
Background: Hooke’s law gives the relationship between the force exprienced by a spring when it is dis
Where k is a spring constant and x is the distance from the equilbrium position. The work associated wi
Problem:
Using the given expressions calculate the force and work. Plot both of these quantities on seperate
0.5, utilize 𝑘 = 250.0 𝑁/𝑓𝑡.
F (N)
Force of spring vs. displacment from
W (J)
1.2
1.0
Spring force (N)
x (m)
0.8
0.6
0.4
0.2
0.0
0.0
0.2
0.4
0.6
Equilbrium displacment (m)
y a spring when it is displaced from it’s equilbrium position. The force can be expressed as:
𝐹𝑠𝑝𝑟𝑖𝑛𝑔 = −𝑘𝑥
The work associated with spring being moved from an equilbrium positon can be expressed as:
𝑘
𝑊𝑠𝑝𝑟𝑖𝑛𝑔 = − 𝑥 2
2
antities on seperate graphs including units, rounding, and chart titles. Plot x from -10.0 to 10.0 meters in increments of
Work by Spring vs. displacment from equilbrium
s. displacment from equilbrium
1.2
Spring work (J)
1.0
0.8
0.6
0.4
0.2
0.0
0.6
0.8
Equilbrium displacment (m)
1.0
1.2
0.0
0.2
0.4
0.6
0.8
Equilbrium displacment (m)
1.0
n increments of
equilbrium
1.0
1.2
Problem 1.2
Background: For ideal gases, molar fraction (yi) corresponds to partial pressure (p
𝑦𝑖 =
𝑃𝑖
𝑃𝑡𝑜𝑡𝑎𝑙
; Ptotal = Spi
The overall ideal gas law for a mixture can be expressed as:
EQN 1
𝑃𝑡𝑜𝑡𝑎𝑙 𝑉𝑡𝑜𝑡𝑎𝑙 = 𝑛
Problem: Utilizing the data from Table 1 for an ideal gas mixture, fill in data for Table 2. T
kg/m3. Assume a basis of one mole. How does this compare to the density of liquid wate
Consider significant figures in calculations and include references. HINT: Calculate total p
2). Describe the result in words.
TABLE 1: DATA
T (°C)
Species
1
70.00
Chemical Formula
N2
Partial Pressure (bar)
0.43
2
NH3
0.17
3
O2
0.30
4
CH4
0.20
Molar Fraction
Total volume (L)
MW
SOLUTION
TABLE 2
Total pressure (bar)
Species
1
2
3
4
Total mass (g)
ρ (g/L)
ρ (kg/m3)
ρwater (kg/m3)
ρ/ρwater
Mass (g)
V (L)
NOTE: Use online calculator to estimate density of water:
e.g. https://www.omnicalculator.com/physics/water-density
al pressure (pi) of a chemical species in a mixture.
𝑛𝑡𝑜𝑡𝑎𝑙 𝑅𝑇
EQN 2
in data for Table 2. Then, calculate the total density of the mixture in units
ensity of liquid water at the same conditions?
INT: Calculate total pressure (EQN 1) and total volume of the system first (EQN
Problem 1.3
Background: Use conditional formatting to improve data visualization.
Problem Statment: Data below represents Parameterr 1 and likelihood of a desired outcome (Re
conducting the research is screening Results as follows: under 70 as INNEFECTIVE, between 70 an
as SIGNIFICANT, and greater than 90 as EXCEPTIONAL. Using an IF statement, create a column ne
outcome’s categorization. Then, use conditional formatting to highlight each cell with a color cor
key. Use built-in functions to determine the slope and intercept of these data
Parameter 1 (x) that yields Result of 89 and 90 (y – values). Using the RSQ function calculate the r
derive indicates about the model and an additional analysis if appropriate.
Experiment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Parameter 1
3.4
1.8
4.6
2.3
3.1
4.3
0.7
3
2.6
4.3
2.1
1.1
6.1
5.6
3.8
4.2
2.8
Result
65.8
42.3
89.1
76.9
72.5
86.3
43.4
77.7
80.4
79.2
88.7
34.7
98.3
93.2
73.9
89.3
78.3
BUILT IN FUNCTION REGRESSION
slope
intercept
x (y = 89)
x (y=90)
r2
Categorization
ualization.
likelihood of a desired outcome (Result) given experimental circumstances. The agency
er 70 as INNEFECTIVE, between 70 and 80 ans NEEDS MODIFICATION, betwen 80 and 90
an IF statement, create a column next to the data indicating the experimental
o highlight each cell with a color corresponding to it’s Result category, use the provided
ept of these data – this will provide a linear model of the data. Then calculate value of
sing the RSQ function calculate the r2. Explain what r2 measures and what the value you
f appropriate.
KEY
INNEFECTIVE
NEEDS MODIFICATION
ACCEPTABLE
EXCEPTIONAL
Problem 1.4
Background: There are various equations of states (EOS), the simplest is the ideal gas equation. At lower tem
equations of state are needed to create predictive models. The first EOS proposed for a real gas was the Van
𝑃=
Where:
𝑎=
𝑏=
And Tc and Pc are the critical temperature and pressure of the given chemical species.
As a side note, % Difference is defined as:
% 𝐷𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒 =
100
Problem: Given Tc and Pc are -147 °C and 34 bar for N2 and -82.6 °C and 46.5 bar for CH4, calculate a and b fo
calculated values for the pressure of both species at -170 °C through a molar volume range of 5 to 2 L*mol
gas law.
Calculate the percent difference in molar volume values between each EOS for both species. What can you c
SOLUTION
TABLE 1: Parameters
-1
-1
R (bar*L*K *mol )
Temperature (K)
Species
Tc (K)
Pc (bar)
a
b
VD N2
VD CH4
N2
CH4
TABLE 2: Pressure Analysis (bar)
IG N2
IG CH4
V (L*mol-1)
% Dif. N2 % Dif. CH4
5
4.75
4.5
4.25
4
3.75
3.5
3.25
3
2.75
2.5
2.25
2
gas equation. At lower temperatures and higher pressures, this model breaks down, and more complicated
real gas was the Van der Waals equation of state, given as:
𝑅𝑇
𝑎
= 𝑉−𝑏 − 𝑉 2
EQN 1
27 𝑅𝑇𝑐 2
64𝑃𝑐
EQN 2
=
𝑅𝑇
𝑏 = 8𝑃𝑐
𝑐
100∗|𝑥1 −𝑥2 |
𝑥1
EQN 3
EQN4
, calculate a and b for both species and use absolute and relative cell referencing to create a table with
me range of 5 to 2 L*mol-1, increments of -.25 L*mol-1, using both the Van der Waals equation of state and ideal
th species. What can you conclude about that species relative to the other?
IG – Ideal Gas Law
VD – Van der Waals Equation of State
and ideal
IMPORT BOTS
Some students able to install Robocode, did not have robots installed. One solution could be to upload robots
to Robocode.
Background Information
1. The Robocode Wiki is a great place to start for information on how to download robots:
https://robowiki.net/wiki/Robocode/Downloading_Robots
List of Robocode robots
2. A more complete listing of robots associated with Robocode can be found on another wiki page:
https://robowiki.net/wiki/Category:Open_Source_Bots
Some robot (i.e., .jar files) may not be available but it a .jar file is available it can be downloaded.
Importing robots
3. Once a robot .jar file is downloaded, it must then be uploaded into Robocode. To do so, select the Robot
menu in Robocode, then Import robot or team.
Select the location of the robot file you would like to upload, and click Import.
Cory D. Jensen
CLSE 115 Spring 2022
1
Example of a Robot download, Import and Battle
4. Newly imported robots should be available for battles immediately. The following image illustrate battle
results from three separate robots that were imported to Robocode and placed in a battle together.
Cory D. Jensen
CLSE 115 Spring 2022
2