Universidad de Puerto Rico, Recinto de Río Piedras

Facultad de Ciencias Naturales, Departamento de Física

 

Título:              Tópicos Especiales en Física I: Introduction to Scientific Computing in Python

Código:            PHYS 4041

Créditos:         3

Profesor:         Julian Velev

Office: Natural Sciences II, C-346

Email:  julian.velev@upr.edu

 

Hours:             Tuesday, Thursday 8:30-9:50; C-311

Office hours:  Tuesday, Thursday 13:00-14:00; C-346

 

Prerequisites: Sufficient preparation in calculus and physics to understand the examples. Basic computer literacy such as text editing, administering the computing environment (installing applications and libraries), executing code from the command prompt, etc. Access to a computer where the Python programming environment and libraries could be installed (preferably a laptop). It is the students’ responsibility to setup their own working Python environment.

 

Course description: The goal of this course is to develop basic programming proficiency for science majors. In class the students will learn the main programming paradigms: data representation (data types and data structures), program control (branching and loops); input and output (files and visualization); error handling (exceptions); and the basics of object-oriented programming (classes).

This will be done in the context of examples taken from mathematics, physics, biology, and economics. The unifying theme of the examples is that they are statistical in nature. They include numerical methods such as Monte Carlo integration, Monte Carlo simulations of thermodynamic equilibrium, game theory and evolutionary game theory.  The students will immediately apply the concepts by implementing the examples in class and also developing applications at home as homework.

The course will use the Python programming language because of its remarkable power coupled with very clean and concise syntax. Python shortens the learning curve allowing the students to quickly progress to the stage of producing meaningful applications. At the same time is a very good foundation for those who will continue to use other programming languages such as C++, Java, and Fortran.

 

Textbooks: 

(1) H. P. Langtangen, A primer on scientific programming with Python, 5nd edition, (Springer, 2016), ISBN 978-3662498866;

(2) H. P. Langtangen, Python scripting for computational science, 3nd edition, (Springer, 2009), ISBN 978-3540739159

 

 

Tentative schedule:

Week

Title

Reading

1

Preliminaries

Setup working python environment

 

2

Introduction:

General introduction to computing

Hands on: Setup the Python environment. First program

1.1,2

3

Data structures:

Variables. Operators. Standard data types. Math library

Hands on: Celsius-Fahrenheit conversion; Ball thrown vertically

1.1,3,6; 6.3

4

Program elements:

Branching. Loops

Hands on: Calculation of functions using Taylor expansions

3.2; 2.1

 

Assignment 1 (TBA)

 

5

Data structures:

Tuples and lists

Hands on: Celsius-Fahrenheit (table)

2.2-5; 6.2

6

Data structures:

Arrays, strings, and dictionaries. NumPy library

Hands on: Polynomial evaluation

5.1,2,5,6

7

Program elements:

Functions. Modules

Hands on: Numerical differentiation. Interest rates.

1.4; 3.1; 4.4

 

Assignment 2 (TBA)

 

8

Input/Output:

Standard input/output. Command line. Files

Hands on: Stock returns

6.1,5; 5.3,4

9

Input/Output:

Visualization. Matplotlib library

Hands on: Normal distribution. Stock returns (plots)

 

10

Error handling: Exceptions

Hands on:

4.3

 

Assignment 3 (TBA)

 

11

Numerical methods:

Random numbers

Hands on: Uniform and normal distribution histogram

8.1-3

12

Applications:

Monte Carlo sampling

Hands on: Numerical integration. Monte Carlo integration

8.5

13

Applications:

Metropolis Monte Carlo. Importance sampling

Hands on: Ising model

8.6,7

14

Applications:

Game theory. Evolutionary game theory

Hands on: Cournot duopoly. Hawk-dove game

 

 

Assignment 4 (TBA)

 

Grading: The grade will be based on four homework assignments, each contributing 25% of the grade. Collaboration on the assignments is not allowed unless the project is explicitly assigned to a group.  All assignments will require the student to produce working codes. The assignments should be submitted in a report form with introduction, design, implementation and results sections. The grading scheme is A, B, C, D, F.

 

University policies:

Los estudiantes que requieren acomodo razonable o reciben servicios de Rehabilitación Vocacional deben comunicarse con el profesor al inicio del semestre para planificar el acomodo y equipo necesario conforme a las recomendaciones de la oficina que atiende los asuntos para personas con impedimentos en la unidad.

 

La Universidad de Puerto Rico promueve los más altos estándares de integridad académica y científica. El artículo 6.2 del Reglamento General de Estudiantes de la UPR (Certificación Núm. 13, 2009-2010, de la Junta de Síndicos) establece que "la deshonestidad académica incluye, pero no se limita a: acciones fraudulentas, la obtención de notas o grados académicos valiéndose de falsas o fraudulentas simulaciones, copiar total o parcialmente la labor académica de otra persona, plagiar total o parcialmente el trabajo de otra persona, copiar total o parcialmente las respuestas de otra persona a las preguntas de un examen, haciendo o consiguiendo que otro tome en su nombre cualquier prueba o examen oral o escrito, así como la ayuda o facilitación para que otra persona incurra en la referida conducta". Cualquiera de estas acciones estará sujeta a sanciones disciplinarias en conformidad con el procedimiento disciplinario establecido en el Reglamento General de Estudiantes de la UPR vigente.

 

La Universidad de Puerto Rico prohíbe el discrimen par razón de sexo y género en todas sus modalidades, incluyendo el hostigamiento sexual. Según la Política institucional contra el Hostigamiento Sexual en la Universidad de Puerto Rico, Certificación Núm. 130, 2014-2015 de la Junta de Gobierno, si un estudiante está siendo o fue afectado por conductas relacionadas a hostigamiento sexual, puede acudir ante la Oficina de la Procuraduría Estudiantil, el Decanato de Estudiantes o la Coordinadora de Cumplimiento con Titulo IX para orientación y/o presentar una queja