Difference between revisions of "CompSciSpring2016"
m (→Midterm) |
m (→Notes) |
||
(25 intermediate revisions by the same user not shown) | |||
Line 91: | Line 91: | ||
=== Final === |
=== Final === |
||
− | TBA |
||
+ | A description for the final project is now available [[Media:final.pdf|here]]. The due date for the final will be Friday, April 29. |
||
== Textbooks and Resources == |
== Textbooks and Resources == |
||
Line 118: | Line 118: | ||
Interactive Interpreters: |
Interactive Interpreters: |
||
* [http://www.codewars.com CodeWars] Recommended for building experience with practice problems. |
* [http://www.codewars.com CodeWars] Recommended for building experience with practice problems. |
||
+ | * [http://codecombat.com/ CodeCombat] A very visual way to interact with your python code. |
||
* [http://exercism.io Exercism] A command-line client with a similar learn-through-challenge philosophy. |
* [http://exercism.io Exercism] A command-line client with a similar learn-through-challenge philosophy. |
||
* [http://repl.it repl.it] A read-eval-print loop for several computer languages. |
* [http://repl.it repl.it] A read-eval-print loop for several computer languages. |
||
Line 158: | Line 159: | ||
** determining which variable names are in scope |
** determining which variable names are in scope |
||
* All that's left is learning common uses, patterns and even more syntax! |
* All that's left is learning common uses, patterns and even more syntax! |
||
+ | * [[Media:Week7-8.pdf|Notes]] for Week 7-8 |
||
+ | * [[Media:Week9-10.pdf|Notes]] for Week 9-10 |
||
+ | * [[Media:Week11.pdf|Notes]] for Week 11 |
||
+ | * [[Media:Week12.pdf|Notes]] for Week 12 |
||
+ | * [[Media:Week13.pdf|Notes]] for Week 13 |
||
+ | * [[Media:Week14.pdf|Notes]] for Week 14 |
||
+ | * [[Media:Week15.pdf|Notes]] for Week 15 |
||
+ | |||
+ | * In-Class Examples |
||
+ | * [[Gorillaz Code]] |
||
+ | * [[File:Wat3-ccsd.txt]] Output of Multiwfn for a Na+(H20)_3 molecular cluster. |
||
+ | * [[File:water_rdf.txt]] Water center of mass radial distribution function. |
||
=== Homework === |
=== Homework === |
||
Line 164: | Line 177: | ||
* [[CompSciHW2|Homework 2]] is due Monday, February 8. |
* [[CompSciHW2|Homework 2]] is due Monday, February 8. |
||
* [[CompSciHW3|Homework 3]] is due Friday, February 19. |
* [[CompSciHW3|Homework 3]] is due Friday, February 19. |
||
+ | * [[CompSciHW4|Homework 4]] is due Friday, February 26. |
||
+ | * [[CompSciHW5|Homework 5]] is due Friday, March 4. |
||
+ | * [[CompSciHW6|Homework 6]] is due Wednesday, March 30. |
||
+ | * [[CompSciHW7|Homework 7]] is due Friday, April 1. |
||
+ | * [[CompSciHW8|Homework 8]] is due Friday, April 8. |
||
+ | * [[CompSciHW9|Homework 9]] is due Friday, April 15. |
||
+ | * [[CompSciHW10|Homework 10]] is due Friday, April 22. |
||
== Group Work Pages == |
== Group Work Pages == |
||
Line 172: | Line 192: | ||
Group 4 [https://docs.google.com/document/d/1hGlNlg1w7_3qCo6LE-y9rSZx1Chwc0FBUoxK6cyzWW8/edit?usp=sharing] |
Group 4 [https://docs.google.com/document/d/1hGlNlg1w7_3qCo6LE-y9rSZx1Chwc0FBUoxK6cyzWW8/edit?usp=sharing] |
||
− | Substitution problem notes: |
||
+ | * [[Code:Vectors|Interactive Vector Example]] |
||
− | <pre> |
||
− | Requirements: |
||
− | 1. Python object representing a spreadsheet |
||
− | 2. Ability to show the whole sheet (formulas) |
||
− | 3. Ability to compute the whole sheet (values) |
||
− | 4. Ability to update formula stored in a cell |
||
− | |||
− | Cells: Example Cell Content: "A1 - B2*C2" |
||
− | A B C |
||
− | 1 A1 B1 C1 |
||
− | 2 A2 B2 C2 |
||
− | 3 A3 B3 C3 |
||
− | |||
− | Hint 1: |
||
− | use str.replace : str -> str -> str -> str |
||
− | * fixed replacement order: A1, B1, C1, A2, B2, C2, ... |
||
− | "A1 - B2*C2".replace("A1", "5") |
||
− | |||
− | Hint 2: |
||
− | use eval : str -> Object |
||
− | eval("5*3 - 4") |
||
− | |||
− | vals = ["3", "4", "5", |
||
− | "A1", "A1 - 2*A2", "5", |
||
− | "", "", ""] |
||
− | |||
− | vals = {"" : "3", } #? |
||
− | |||
− | Hint 3: OK to print the easy way -- |
||
− | A1 = 5 + 2 |
||
− | A2 = A1*4 |
||
− | A3 = A1 - A2 |
||
− | |||
− | Hint 4: Compute values in a separate sheet object. |
||
− | formulas -> values -- |
||
− | values["A1"] = formulas["A1"] |
||
− | |||
− | values["B1"] = formulas["B1"].replace("A1", values["A1"]) |
||
− | |||
− | values["C1"] = formulas["C1"].replace("B1", values["B1"]) |
||
− | values["C1"] = values["C1"].replace("A1", values["A1"]) |
||
− | |||
− | values["A2"] = formulas["A2"] |
||
− | values["A2"] = values["A2"].replace("C1", values["C1"]) |
||
− | values["A2"] = values["A2"].replace("B1", values["B1"]) |
||
− | values["A2"] = values["A2"].replace("A1", values["A1"]) |
||
− | |||
− | # Build the value of B2 from its formula. |
||
− | values["B2"] = formulas["B2"] |
||
− | values["B2"] = values["B2"].replace("A2", values["A2"]) |
||
− | values["B2"] = values["B2"].replace("C1", values["C1"]) |
||
− | values["B2"] = values["B2"].replace("B1", values["B1"]) |
||
− | values["B2"] = values["B2"].replace("A1", values["A1"]) |
||
− | </pre> |
Latest revision as of 10:56, 27 April 2016
Introduction to Scientific Computing
Course Info
- Course Numbers CHM 4932-004/6938-010, CRN: 22347/22348
- Credit Hours: 3
- Meeting Dates: January 22 - April 27, 2016
- No Class Jan. 18 or Mar. 14-19
- Meeting Times: Mon. and Wed., 12:30-13:45 in SCA 222
- Lab Session & Office Hours: Fri. 12:30-13:45 in SCA 222 (or SCA 433)
Contents
Overview
Mathematical models in the natural sciences take many shapes and forms. The moment they become more complicated than tracking a few variables over time, we have to put away our Excel spreadsheets and make use of a solid foundation in computational science. The course establishes this foundation by introducing data structures and algorithms used in everyday scientific computing using examples in the python scripting language. By the end of the Semester, students will be able to navigate the Linux command-line to go from a mathematical model to a numerical solution. Best practices for working with computer code and visualizing data will also be covered.
Topics
- Languages
- bash (shell)
- python (scripting)
- stack & register-based machine languages: overview of C and Fortran syntax & compiling with gcc, ‘thread safety’
- Shared libraries & language inter-operability (FFI)
- Algorithms
- Horner’s algorithm for polynomials
- Newton’s root finding algo.
- Overview of general optimization algo-s (example: linear & nonlin. least-squares)
- Numerical integration (scripted, plus gnu ODE)
- Communication (how HTTP get/put works)
- Data Structures
- Linked Lists
- Trees (file system hierarchies)
- Graphs
- Arrays (dense & sparse) example: vectors & rotations / transpositions, densities and difference operators
- Presentation & visualization
- Flat CSV files (and excel)
- Working with binary data
- Python matplotlib (2D images)
- Binning histograms & weighted averages
- Best Practices
- High-level code design (modularity, interface specifications, unit testing, etc.)
- Code audit: open-source libraries, ex. Gnu Scientific Library, qsort in libc, Boost
- Source code versioning (example: git or mercurial)
- gdb & execution profiling
- documentation
- Makefiles
Grading
Grading Scale (out of 400 points possible)
Grade | Undergraduate | Graduate |
---|---|---|
A | 230 | 300 |
B | 180 | 230 |
C | 150 | 180 |
D | 120 | 150 |
- Points Possible:
- 10 homework assignments (20 points per homework)
- 2 projects / competitions (100 points per project)
- Homework Rules
- For work done in groups, credit is divided equally among participants - so the max homework grade for a group of 2 is 10 points each.
- For each homework, 1 re-do at full credit can be sent at any time after the due date, but must present a unique solution to previous work from yourself or others.
- All work must cite co-group members (if any) and the source of any code snippets used online.
Grading Rationale
Homework points will only be awarded for correct, working code and correct algorithmic analysis, while the homework problems will become progressively tougher. Undergraduates should be able to pass the course with an A if they have correctly answered most of the homework, and made a strong attempt at one of the projects. Graduate students should both perform well on the homework and successfully complete one or two projects. Essentially, this means you should do your own homework when possible and may do a project in a small group. The re-grading and group options for homework allow making up for missed assignments, and encourage returning to core concepts at a later point in the class. Students who have completed significant portions of the homework have thus demonstrated programming proficiency, and are qualified for at least B/C grades.
Projects
Midterm
A description for the midterm project is now available here. The MD section will be updated as we discuss it in class. The due date for the midterm will be Friday, March 11.
Final
A description for the final project is now available here. The due date for the final will be Friday, April 29.
Textbooks and Resources
- Beginning Python, Hetland, 2005 (eBook avail. from USF Library)
- Python Algorithms, Hetland, 2010 (eBook avail. from USF Library)
- The Architecture of Open Source Applications
- Python Documentation
- Google Introductory Python Notes
- Tao of Programming
Other (possibly useful) materials:
- The Jargon File
- Chapters 7&8 of Modelling and Simulation, Birta and Arbez, Springer 2007 (eBook avail. from USF Library).
- Chapters 4-6 of Models and Algorithms for Intelligent Data Analysis, Runkler, Springer 2012 (eBook avail. from USF Library).
- Guide to Scientific Computing in C++, Francis and Whiteley, Springer, 2012. (eBook avail. from USF Library)
- Extra info. On the basics:
- Chapters 3 and 7 of Mathematics in Computing, Regan, Springer 2013. (eBook avail. from USF Library)
- Instant feedback graphical programming with Khan Academy
- Local PyBulls Meetings
Code:
- Python Libraries Useful for Geospatial Problems
- Python Libraries Useful for Computational Chemistry (very small list at present)
Interactive Interpreters:
- CodeWars Recommended for building experience with practice problems.
- CodeCombat A very visual way to interact with your python code.
- Exercism A command-line client with a similar learn-through-challenge philosophy.
- repl.it A read-eval-print loop for several computer languages.
- CppReference Documentation with an online evaluator for C++ code.
Notes
- Notes for Week 1
- Over the first two weeks or so, we'll be practicing the basics - so read through Chapters 1-3 of Hetland's Beginning Python during this time.
- Important Definitions
- Notes for Week 2
- Oware code
- Solutions for some problems in Week 2's notes:
<source lang="python">
- simple data types
"a string" # : str x = [1, 2, 3] # : [int]
- compound data type
(1, "name", (x, x)) # : (int, str, ([int], [int]))
- add_one : int -> int
- str.__add__ : str -> str -> str
- str.split : str -> [str]
- str.__mod__ : str -> (Objects) -> str
</source>
- Notes for Week 3-4
- Reading assignment - read through Chapter 5 and 6 (and practice dictionaries from Ch. 4)
- Abstracting patterns in for loops.
- Notes for Week 5-6
- Reading assignment - Read Chapter 10-11 (and refer to Ch. 4)
- By this point, we've covered all the basics:
- base types: str, int, float, [a]
- variables and substitution: j vs "4" vs 4
- indexing and slicing into lists / strings: x[1:4] or x[i:j]
- control flow: if and for syntax
- functions implementing patterns: def next(r, x): return r*x*(1-x)
- You should be able to use these for:
- finding and abstracting the pattern
- naming the type of a function
- determining which variable names are in scope
- All that's left is learning common uses, patterns and even more syntax!
- Notes for Week 7-8
- Notes for Week 9-10
- Notes for Week 11
- Notes for Week 12
- Notes for Week 13
- Notes for Week 14
- Notes for Week 15
- In-Class Examples
- Gorillaz Code
- File:Wat3-ccsd.txt Output of Multiwfn for a Na+(H20)_3 molecular cluster.
- File:Water rdf.txt Water center of mass radial distribution function.
Homework
- Homework 1 is due Monday, January 25.
- Homework 2 is due Monday, February 8.
- Homework 3 is due Friday, February 19.
- Homework 4 is due Friday, February 26.
- Homework 5 is due Friday, March 4.
- Homework 6 is due Wednesday, March 30.
- Homework 7 is due Friday, April 1.
- Homework 8 is due Friday, April 8.
- Homework 9 is due Friday, April 15.
- Homework 10 is due Friday, April 22.