# Introduction to Computational Physics for Undergraduates

- Omair Zubairi, Fridolin Weber

- March 2018

### Description

This is an introductory textbook on computational methods and techniques intended for undergraduates at the sophomore or junior level in the fields of science, mathematics, and engineering. It provides an introduction to programming languages such as FORTRAN 90/95/2000 and covers numerical techniques such as differentiation, integration, root finding, and data fitting. The textbook also entails the use of the Linux/Unix operating system and other relevant software such as plotting programs, text editors, and mark-up languages such as LaTeX. It includes multiple homework assignments.### About Editors

Fridolin Weber is a Distinguished Professor of Physics at San Diego State University and a Research Scientist at the University of California at San Diego. He has a PhD in theoretical nuclear physics and a PhD in theoretical astrophysics, both from the Ludwig Maximilian University of Munich, Germany. He has published two books, is the author or co-author of almost 200 publications, and has given around 300 talks at conferences and physics schools.

Omair Zubairi received his BS and MS in physics from San Diego State University. He obtained his PhD in computational science from Claremont Graduate University and San Diego State University where he primarily worked on compact star physics. He is currently an Assistant Professor of Physics at Wentworth Institute of Technology. His other research interests include general relativity, numerical astrophysics and computational methods and techniques.

### Table of Contents

1 The Linux/Unix Operating System

1.1 Introduction

1.2 Files and Directories

1.2.1 Pathnames and Working Directories

1.2.2 Filenames

1.3 Overview of Unix/Linux Commands

1.3.1 Executables and Paths

1.3.2 Special Files

1.4 Basic Commands

1.4.1 Getting Help and Information

1.4.2 Communicating With Other Computers

1.4.3 Creating, Manipulating and Viewing Files and Directories

1.5 More on the C-Shell

1.5.1 Shell Variables

1.5.2 Environment Variables

1.5.3 C-shell Pattern Matching

1.5.4 Using the C-shell History and Event Mechanisms

1.5.5 Standard Input, Standard Output and Standard Error

1.5.6 Redirecting Input and Output

1.5.7 Pipelines

1.5.8 Usage of Quotes

2 Text Editors

2.1 Vi

2.2 Emacs

3 The Fortran 90 Programming Language

3.1 Introduction

3.1.1 Early Development

3.1.2 Standardization

3.1.3 Fortran 90

3.1.4 Strengths and Weaknesses

3.2 Compilers

3.2.1 File Extensions and Compiling Commands

3.3 Program Layout

3.4 Variable Declaration

3.4.1 Naming Conventions

3.4.2 Data Types

3.5 Basic Expressions

3.5.1 Arithmetic Operators and Expressions

3.5.2 Relational Operators

3.5.3 Logical Expressions

3.6 Input and Output

3.6.1 The READ Statement

3.6.2 The WRITE Statement

3.6.3 The FORMAT Specification

3.6.4 File Input and Output (I/O)

3.7 Control Structures

3.7.1 IF-Blocks

3.7.2 DO Loops

3.7.3 Nested Loops

3.8 Modular Programming

3.8.1 Intrinsic Functions

3.8.2 Intrinsic Subroutines

3.8.3 External Functions

3.8.4 External Subroutines

3.8.5 Program Units

3.8.6 Internal Procedures

3.8.7 External Procedures

3.8.8 Modules

3.9 Arrays

3.9.1 Declaration of Arrays

3.9.2 Vectors

3.9.3 Using Arrays

3.9.4 Array Operations

3.9.5 Elemental Functions

3.9.6 The WHERE Statement

3.9.7 FORALL (Fortran 95)

3.9.8 Array Intrinsic Functions

3.9.9 Allocatable Arrays

3.9.10 Pointers

4 Numerical Techniques

4.1 Curve Fitting–Method of Least Squares

4.1.1 The Linear Least-Squares Approximation

4.1.2 The Quadratic Least-Squares Approximation

4.2 Numerical Differentiation

4.3 Numerical Integration

4.3.1 The Trapezoidal rule

4.3.2 Simpson's Rule

4.4 Matrix Operations

4.5 Finding Roots

4.6 Solving Ordinary Differential Equations

4.6.1 The Euler Method

4.6.2 The Midpoint Method

4.6.3 The Runge-Kutta Method

4.6.4 Boundary Value Problems

5 Problem Solving Methodologies

5.1 General Guidelines

5.2 Projectile Motion Example

6 Worksheet Assignments

6.1 Coding a Mathematical Expression

6.2 Comparing two Functions

6.3 Bessel Functions of the First Kind

6.4 Logical IF Statements

6.5 Lead Concentration in Humans (Data Analytics)

6.6 Nested Do Loops and Double Summations

6.7 Ionic Crystals

6.8 Least Squares Fit

6.9 Numerical Derivatives

6.10 Numerical Integration

6.11 Finding Roots of a non-linear equation

6.12 Ordinary Differential Equations

6.13 Projectile in a Viscous Medium

6.14 Damped Harmonic Oscillator

6.15 RLC Circuit

7 Homework Assignments

7.1 Fresnel Coefficients

7.2 Earth Atmosphere Model

7.3 Magnetic Permeability

7.4 Maxwell-Boltzmann Distribution

7.5 Kinetic Friction

7.6 Compton Scattering

7.7 Radioactive Decay

7.8 Halley's Comet

7.9 Rocket Equation

7.10 Hydrostatic Equilibrium and Relativistic Stars

7.11 Massive Stars

7.12 Isothermal Gas Spheres

7.13 Proton in Constant Electric and Magnetic Fields

7.14 Square Voltage Pulse applied to a RC Circuit

7.15 Mutual Inductance of Two Coils

A Summary of Fortran Features

B Plotting using Python

C Fortran 90 Sample Program Illustrating Good Programming

### Bibliographic

Paperback ISBN: 9780750329064

Ebook ISBN: 9781681748955

DOI: 10.1088/978-1-6817-4896-2

Publisher: Morgan & Claypool Publishers