Foundations of Programming and Software Engineering for Molecular Science#

This course provides an overview of topics relevant to programming and creating software projects. Students will become familiar with tools and practices commonly used in software development such as version control, documentation, and testing. Central to this course is a hands-on molecular simulation project where students work in groups to create a software package using concepts taught in the course.

Pre-Bootcamp: Set-Up#

Lesson Title

Questions

Objectives

Computer Set-Up

  • How do I set up my computer?

  • How do I set up git and GitHub?

  • What text editor should I use?

  • Use conda to create an environment and install packages.

  • Install compilers for operating system.

  • Set up credentials for GitHub.

Day 1#

Lessons#

Lesson Title

Questions

Objectives

Introduction to the Command Line

  • What is the command line?

  • How can I navigate files and directories on the command line?

  • Learn basic shell commands for navigating and creating files and directories.

Introduction to Version Control with Git

  • What is version control?

  • How do I use git to keep a record of my project?

  • What is a branch and why would I use one?

  • How do I tell git to ignore files?

  • Explain the purpose of version control

  • Introduce common git commands.

  • Understand how to view and check out previous versions of files.

Using GitHub

  • How is git different than GitHub?

  • How do I use git and GitHub?

  • Explain difference between git and GitHub.

  • Learn how to use and manage a repository on GitHub.

Code Collaboration using GitHub

  • How can others contribute to my project on GitHub?

  • How can I contribute to the projects of others?

  • Explain collaboration workflow on GitHub.

  • Understand how to open and review a pull request.

Discussions and Assignments#

Type

Description

Discussion

Command Line and Git Review

Group Assignment

Submitting a Pull Request to a Central Repository

Day 2#

Lessons#

Lesson Title

Objectives

Questions

Intro to Monte Carlo Methods

  • Explain Monte Carlo methods.

  • Apply Monte Carlo method to calculate pi.

  • Apply Monte Carlo to calculate integrals

  • What are Monte Carlo methods?

  • How can I use Monte Carlo to estimate pi?

The Lennard Jones Equation

  • Understand the Lennard Jones potential.

  • Understand periodic boundary conditions.

  • How can Monte Carlo be applied to a thermodynamic problem?

  • How do we model the interaction of nonbonded atoms?

Discussions and Assignments#

Type

Description

Class Warm-up

Get to Know your Group

Group Assignment

Tasks: Monte Carlo Error,Lennard Jones,Distance Calculation

Individual Assignment 1

Contains the link to start Individual Assignment 1.

Day 3#

Lessons#

Lesson Title

Objectives

Questions

Lennard Jones Energy of Atomic System

  • Write Python code to calculate the Lennard Jones energy.

  • How do I use the Lennard Jones equation to calculate the energy of an atomic system?

Discussions and Assignments#

Type

Description

Class Warm-up

Think Python and Energy Calculations

Group Discussion and Assignment

Simulation Cut-offs and Periodic Boundaries

Day 4#

Lessons#

Lesson Title

Objectives

Questions

Total Energy Comparison

  • Apply a cut-off and periodic boundaries to the energy calculation and compare it to values reported by NIST.

  • Does my total energy agree with the values reported from NIST?

Monte Carlo for a Lennard Jones Fluid

  • Use the Metropolis algorithm to sample configurations of LJ particles

  • How do I write a Monte Carlo simulation?

Discussions and Assignments#

Type

Description

Class Warm-up

Explain XCKD and Code Changes

Group Assignment and Discussion

Acceptance probability, Performance, Starting configurations

Day 5#

Lessons#

Lesson Title

Objectives

Questions

Working with Numpy Arrays

  • Be able to name the differences between Python lists and numpy arrays.

  • Understand the idea of broadcasting.

  • What are the differences between NumPy arrays and lists?

  • How can I use NumPy to do calculations?

Rewriting the Distance Function

  • Rewrite calculate distance function for numpy arrays

  • How can I rewrite functions to take advantage of NumPy element-wise operation and broadcasting?

Creating a Python Module

  • Put Python code into a module (.py file)

  • Import functions from our module.

  • What is a Python module?

Discussions and Assignments#

Type

Description

Class Warm-up

Warm Up Quiz and Debugging

Group Assignment and Discussion

NumPy and MC Calculations

Individual Assignment 2

Individual Assignment 2

Day 6#

Lessons#

Lesson Title

Objectives

Questions

Introduction to C++

  • Explain static and dynamic typing

  • Explain basic C++ structure and syntax, comparing/contrasting with python

  • Introduce compiling from the command line

  • What is the difference between compiled and interpreted languages?

  • What are the main advantages of C++ vs python?

  • What are some similarities between python and C++?

First C++ Program

  • Be able to write and build a minimal C++ program

  • Be able to debug compiler errors

  • How do I write and compile a minimal C++ program?

  • What are the basic constructs of C++?

  • How do I handle compile errors?

Discussions and Assignments#

Type

Description

Class Warm-up

Counting function calls

Group Assignment

Python and C++ Discussion and Integration via Summation

Day 7#

Lessons#

Lesson Title

Objectives

Questions

Common data types

  • Learn about the built-in data types in C++, and what they are used for

  • What are the common, built-in data types in C++pointers and references in C++

  • When should I use each data type?

Arrays, Pointers, Memory, and Vectors

  • To learn about pointers

  • To learn about different ways of representing lists/arrays of data

  • What are pointers and references in C++

  • Why/when should I use a pointer or reference?

  • Pitfalls of using pointer

Discussions and Assignments#

Type

Description

Class Warm-up

Programming Design Recipe

Group Assignment

Monte Carlo C++ rewrite

Individual Assignment

Individual Assignment 3

Day 8#

Lessons#

Lesson Title

Objectives

Questions

Function Calling and Arguments

  • Learn about C++ functions and argument passing

  • Learn about the const keyword

  • Learn about returning multiple things from a function

  • How do functions differ in C++ and Python?

  • How are arguments passed in C++?

  • How can we protect variables (and function arguments) from changing?

Namespaces

  • Learn about grouping functions and objects with namespaces

  • How can we group functions together under a single collection?

  • How can I prevent collisions with functions having the same name in other libraries?

Exceptions

  • Learn about throwing and catching exception in C++

  • How do we handle major errors in C++?

  • How do exceptions differ from python?

Discussions and Assignments#

Type

Description

Class Warm-up

UC Berkeley Libraries

Group Assignment

Monte Carlo C++ rewrite

Final Project

Final Project Assignment

Day 9#

Lessons#

Lesson Title

Objectives

Questions

Multi-file projects

  • Learn how the C++ compiler preprocesses files

  • Learn the difference between header and source files

  • Learn how to include intra-project header files

  • How can we split a large C++ project into multiple files

Discussions and Assignments#

Type

Description

Class Warm-up

Python and C++ - Function Arguments

Individual Assignment

Individual Assignment 4