Computation Fundamentals
Computation Fundamentals
In professional environments, you will use a computer to perform your computations. You likely have lots of practice on calculators. There are significant similarities between the calculator and the computer but there are some important differences.
Computers and Humans
Be warned, this work can be very frustrating. To use computers effectively, we have to think in unfamiliar ways. The tools are very powerful but it can be difficult to find mistakes in your work.
Materials
You can find an interactive set of files here.
Types
The computer uses ones and zeros to represent all data. Anything stored on the computer, a poem, a photo, or a number, is represented using ones and zeros. In order to correctly interpret the ones and zeros the computer needs to know what you are storing.
Integers
These are the counting numbers. No fractions, no decimals.
Strings
This is how the computer stores words.
Floats
These are numbers with a fractional part. If you think you are using floats but are using integers, you may get strange results like one divided by two equals zero.
Variables
To make the details of a computation more clear, we can use readable names for our numbers and then use the names in the calculation.
This makes the intention of the calculation more clear to the reader.
In our language (python) the computer decides how to interpret each variable by what you put inside it.
Numerical Computing Environment
Matlab
Scientific Python
Julia
Sage Math Cloud
Learning Objectives
Able to use numerical computing environment to create and narrate computations
Able to use spreadsheets to create computations
Written
Explanation of unit factor with inches and centimeters
Unit Factor
Combinations of units
We often combine units to express new quantities
Scientific Notation
Units
Computation of physical quantities often relies on the human to define and use a consistent set of units of measurement. There are tools that allow us to add physical quantities to our calculations, but they are not as rich as I could like them to be. One good practice is to explicitly include the unit name in the variable name.
Units
There are also computer libraries that allow you to include units in the definition of your variables.
Pint python library
Defining Functions
A custom function can be created and used. The syntax for this often varies but the idea is usually the same.
For Julia:
Python has a different syntax but it is the same idea.
Narration
You can add text and mathematics to your document
# Title
makes bold text
Google Docs
be sure you have access to your new sonoma.edu drive account
access the template file that I shared
fill in the different values and sheets
Pandas
assumes mastery of single variables
now we do vector calculations (numpy or pandas?)
to do TMY calculation we need to take difference and plot
then we need to add up only the positive values
Scale of energy quantities
from IPCC Energy Primer
Energy Units
Joule
SI Unit. One Newton-Meter.
Kilowatt-Hour
Energy consumed by 1 kW load over one hour
Calorie
Energy to heat one gram of water one degree Celsius
Kilo-calorie
One thousand calories. Used in food energy content.
British Thermal Unit (BTU)
Energy to heat one pound of water by one degree Fahrenheit
Quad
One quadrillion ($10^{15}$) BTU
Unit Conversions
We may wish to compare energy units that are not consistent
Often you can look up conversions in a table
Other times you may need to recreate the conversion
Variables
single values
math expressions with variables
sympy creation of math expressions?
arrays
linspace?
treating an array like a variable
data frames (groups of arrays)
first use of conditionals (only add up positives or negatives)
fancy indexing to get positives or negatives
Worked Exercises
Exercise
Estimate the yearly use of gasoline in the US
What is our strategy?
Exercise
How many gallons do you consume?
How many persons in the US?
Problems
Last updated