{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# PHYS 5P10 - Introduction to Scientific Computing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
• \n", "Also offered as MATH 5P69 and PHYS 4P10; the expectations for assignments and projects are different.\n", "
• \n", "See http://www.physics.brocku.ca/Courses/5P10/ for administrative details\n", "
• \n", "This course covers\n", "
\n", "
• A common toolbox\n", "
\n", "
• interacting with the OS; CLI vs GUI
• \n", "
• Linux as a collection of small tools + pipes between them
• \n", "
• the basics of programming: shell, C, scripting languages
• \n", "
• code development: edit, compile, run, make and Makefile structure, elementary debugging, linking to program libraries
• \n", "
• visualization with gnuplot and other graphing tools
• \n", "
\n", "
• Numerical methods
• \n", "
• Case studies/projects
• \n", "
\n", "
\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "Most problem solving in science and engineering uses scientific computing. A\n", "scientist might devise a system of differential equations to model a physical\n", "system, then use a computer to calculate their solutions. An engineer might\n", "develop a formula to predict cost as a function of several variables, then use a\n", "computer to find the combination of variables that minimizes that cost. A scientist\n", "or engineer needs to know science or engineering to make the models. He or she\n", "needs the principles of scientific computing to find out what the models predict.\n", "

\n", "Scientific computing is challenging partly because it draws on many parts of\n", "mathematics and computer science. Beyond this knowledge, it also takes\n", "discipline and practice. A problem-solving code is built and tested procedure by\n", "procedure. Algorithms and program design are chosen based on considerations\n", "of accuracy, stability, robustness, and performance. Modern software\n", "development tools include programming environments and debuggers,\n", "visualization, profiling, and performance tools, and high-quality libraries. The\n", "training, as opposed to just teaching, is in integrating all the knowledge and the\n", "tools and the habits to create high quality computing software “solutions.”\n", "

\n", "Principles of Scientific Computing, by\n", "David Bindel and Jonathan Goodman\n", "

\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Linux is the (invisible) operating system layer" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", "
 R.Stallman L.Torvalds
\n", "\n", "
\n", "
• \n", "Unix is a multitasking, multi-user computer operating\n", "system originally developed in 1969 by a group of\n", "AT&T employees at Bell Labs.\n", "
• \n", "Most of the world’s servers run some variant of Unix\n", "or Linux. The Android phone and the Kindle run Linux.\n", "
• \n", "Linux is an OS core written from scratch by Linus Torvalds and others, and ...\n", "
• \n", "... a set of small programs (the GNU utilities, http://www.gnu.org/) written by Richard Stallman and others.\n", "
• \n", "We use RedHat, Enterprise Edition v.7 (RHEL 7)\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Linux has a hierarchical architecture\n", "

\n", "\n", "\n", " \n", "

From www.tutorialspoint.com/unix/

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
• Kernel: the heart of the operating system\n", "
\n", "
• interacts with hardware\n", "
• performs memory management, task scheduling and file management\n", "
\n", "
• Shell: the utility that processes user requests\n", "
\n", "
• the shell interprets the command and calls the program that you want\n", "
\n", "
• Commands and Utilities: cp, mv, cat and grep etc.\n", "
• Files and Directories:\n", "
\n", "
• all data in UNIX is organized into files\n", "
• all files are organized into directories\n", "
• these directories are organized into a tree-like structure called the filesystem \n", "
\n", "
• All commands are files, somewhere in the filesystem\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Linux is a \"collection of small programs that do one thing well\"\n", "
\n", "
• Network: ssh, sftp, scp, ping, ifconfig, nslookup, wget\n", "
• Shells: bash, tcsh, alias, watch, clear, history, chsh, echo, set, setenv, xargs\n", "
• System Information: w, whoami, man, info, which, free, echo, date, cal, df, free, man, info\n", "
• Command Help/Information: man, info\n", "
• Special Characters & Pipes:
`|, >, >>, <, &, >&, 2>&1, ;, ~, ., .., \$!, !:<n>, !<n> `
\n", "
• Filters: grep, more, less, head, tail, sed\n", "
• Hotkeys: ctrl-c, ctrl-d\n", "
• File System: ls, mkdir, cd, pwd, mv, ln, touch, cat, file, find, diff, cmp, mount, du, df, chmod, chown\n", "
• File Editors: vi (vim), gedit\n", "
\n", "\n", "

\n", "Open a terminal window to interact with Linux\n", "\n", "

\n", "
• \"shell\" is just another program\n", "
• comes in flavours: sh (Bourne shell), ksh (Korn shell), csh (C-like shell), etc.\n", "
• we use bash (Bourne Again shell, an enhanced sh), it's in /usr/bin/bash\n", "
" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz\n" ] } ], "source": [ "%%bash\n", "whereis bash" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-rwxr-xr-x. 1 root root 960632 Aug 3 09:36 /usr/bin/bash\n" ] } ], "source": [ "%%bash\n", "ls -la /usr/bin/bash" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Linux file system\n", "\n", "\n", "
\n", "
• file system is a hierarchical directory structure, resembles an upside-down tree\n", "
• directories are collections of files and other directories\n", "
• the structure is recursive with many levels\n", "
• every directory has a parent except for the root directory\n", "
• many directories have children directories\n", "
\n", "\n", "Typical Linux directories\n", "
\n", "
• / - \"root\" of the filesystem\n", "
• /bin - System binaries, including the command shell\n", "
• /boot - Boot-up routines\n", "
• /dev - Device files for all your peripherals\n", "
• /etc - System configuration files\n", "
• /home - User directories\n", "
• /lib, /lib64 - Shared libraries and modules\n", "
• /lost+found - Lost-cluster files, recovered from a disk-check\n", "
• /mnt - Mounted file-systems (other disks, network drives)\n", "
• /opt - Optional software\n", "
• /proc - Kernel-processes pseudo file-system\n", "
• /root - Administrator’s home directory\n", "
• /sbin - System administration binaries\n", "
• /usr - User-oriented software\n", "
• /var - Various other files: mail, spooling and logging\n", "

\n", "

• ~ - user's home directory, e.g. /home/pstudent\n", "
• . - this (current) directory\n", "
• .. - parent of the current directory\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A tutorial on basic shell commands\n", "\n", "By next Thursday:\n", "
\n", "
• cover all sections until the \"Advanced Unix/Linux\" from www.tutorialspoint.com/unix/\n", "
• develop a personal \"cheat sheet\" of useful commands\n", "
• choose an editor (vi or gedit) and learn its basics\n", "
• optional: use \"jupyter notebook\" to keep notes in this class\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.5" } }, "nbformat": 4, "nbformat_minor": 2 }