Difference between revisions of "CompSciSpring2017"
(→Notes) |
m (→Notes) |
||
Line 126: | Line 126: | ||
** [https://predictivestatmech.org/code/example.dcd Example DCD File] |
** [https://predictivestatmech.org/code/example.dcd Example DCD File] |
||
* [[Media:Week-5.2017.pdf|Week 5 Notes]] |
* [[Media:Week-5.2017.pdf|Week 5 Notes]] |
||
− | ** [Code:PyTesting] |
+ | ** [[Code:PyTesting]] |
<source lang="python"> |
<source lang="python"> |
Revision as of 12:22, 6 February 2017
Introduction to Scientific Computing
Course Info
- Course Numbers CHM 4932-004/6938-010, CRN: 21864/21865
- Credit Hours: 3
- Meeting Dates: January 9 - April 26, 2017
- No Class Jan. 16 or Mar. 13-17
- Meeting Times: Mon. and Wed., 12:30-13:45 in SCA 222
- Lab Session & Office Hours: Fri. 12:30-13:45 in IDR 214 (or SCA 222 by announcement)
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
TBA - see previous years (e.g. CompSciSpring2016) for a general idea.
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
- Introduction Notes
- Week 2-3 Notes
- Week 4: read through function syntax in 2016 Week 2 and for-loops in 2016 Week 3-4
- In-Class Examples
- Week 5 Notes
<source lang="python">
- Loop examples
T = [500, 100, 200, 300, 400, 100] Q = [0]*5 print(len(T)) print(len(Q))
k = 0.5 Q[0] = (T[1]-T[0])*(-k) Q[1] = (T[2]-T[1])*(-k) Q[2] = (T[3]-T[2])*(-k) Q[3] = (T[4]-T[3])*(-k) Q[4] = (T[5]-T[4])*(-k)
- or use a for-loop!
r = 0.25 x = 0.5 x = r*x*(1-x) x = r*x*(1-x) x = r*x*(1-x) x = r*x*(1-x) x = r*x*(1-x) x = r*x*(1-x)
out = "" for i in [0,4,13,32,64,128]:
out = out + str(i) + ", "
- Hint for Homework 3
def dcd_info(f):
# file -> string d = f.read() frames = unpack("<i", d[?]) # string -> int timestep = unpack("f", d[?]) # string -> float N = unpack("<i", d[?]) # string -> int return [frames, timestep, N]
</source>
Homework
- Homework will be assigned through Repl.IT
- Homework 1 is due Friday, Jan. 20
- Homework 2 is due Friday, Jan 27