Chapter 2
The Computational Environment: Tools and Infrastructure
These links help you choose and use a computational environment. Begin with one language, an editor or interactive environment, and a way to plot results. Add other tools when your work needs them. Follow the project documentation for installation on your operating system and consult the documentation matching your installed version.
Languages and computing environments
Use an environment supported by your course or research group when one is specified. You do not need to install every language listed here.
On a narrow screen, scroll horizontally to view the tables.
| Environment | What it provides | Getting started |
|---|---|---|
| MATLAB | An integrated environment for numerical work and plotting. A license is required; check institutional access. Some toolboxes require additional licenses. | Install MATLAB; get started |
| Python | A free, open-source language. Scientific packages are installed separately. | Download Python; language tutorial. The tutorial assumes some programming experience. |
| C++ | Compiled programs; an editor and a C++ compiler are separate components. | C++ setup guides for VS Code; compiling with GNU g++ |
| Fortran | Compiled programs for numerical work. GNU Fortran is a free, open-source compiler. | GNU Fortran; Fortran-lang quickstart |
Editors and notebooks
- Visual Studio Code: an editor with language extensions and debugging support. The editor does not replace a Python interpreter or a C++ or Fortran compiler.
- JupyterLab and Jupyter Notebook: interactive documents combining code, explanations, and figures. A notebook also needs a kernel for its language. Use the installation guide for the interface you choose.
- MATLAB includes its own editor, debugger, and interactive environment; a separate editor is optional.
For Python, use a project environment and install packages into the same interpreter used by your editor or notebook. Before adding more software, check that you can run a small program, save its output, and make a plot.
Scientific libraries
These resources introduce the main building blocks. Detailed solver choices and benchmark problems are collected on the numerical chapters’ resources pages. MATLAB includes many numerical functions in its core environment; check toolbox requirements for specialized functions.
| Resource | Main use | Practical starting point |
|---|---|---|
| NumPy | Arrays, array operations, and linear algebra in Python. | Start with array creation, indexing, shapes, and elementwise operations. |
| SciPy | Scientific algorithms built on NumPy, including integration, interpolation, optimization, and sparse matrices. | Choose a routine by its assumptions and required inputs; inspect its status and error information. |
| BLAS and LAPACK | Vector and matrix operations, factorizations, linear systems, and eigenvalue problems. | Often accessed through a higher-level environment. Direct C++ or Fortran use requires an appropriate build and linking setup. |
| FFTW | Discrete Fourier transforms of real and complex data. | Consult the documentation for the interface and linking instructions for your language. |
| GNU Scientific Library (GSL) | A collection of numerical routines for C and C++ programs. | Start with the manual's examples and build instructions; check each routine's assumptions and error handling. |
| Netlib | A repository of numerical software and documentation. | Useful for established algorithms and source code. Check each package’s interface, documentation, and license. |
Plotting and visualization
- Matplotlib tutorials: curves, scatter plots, images, and other standard scientific plots in Python.
- MATLAB plot documentation: basic line plots, labels, and formatting examples in the MATLAB environment.
- ParaView: an open-source application for exploring field data and larger three-dimensional datasets.
- OVITO user manual: visualization and analysis of particle configurations and trajectories. OVITO Basic is available free of charge; OVITO Pro requires a license.
For ordinary curves and tables, start with the plotting tools in your working environment. For particle or field data, choose a tool that reads your output format. Label quantities and units, and check color scales before interpreting a figure.
Supporting tools
- Pro Git: a free online guide to version control. Start with recording changes and recovering earlier versions of a small local project.
- Debugging: MATLAB debugging, Python pdb, and GNU GDB for compiled programs, including C++ and Fortran. Breakpoints and variable inspection help locate the first point where a calculation departs from expectations.
- Profiling: MATLAB profiling, Python profiling documentation, and GNU gprof for compiled programs on supported systems. Measure where execution time is spent before trying to optimize a program; follow the documentation for your installed software and platform.
- Testing: pytest getting started and MATLAB testing frameworks. Small tests can check known results and detect accidental changes. They complement physical and numerical checks.
Further resources
- Julia documentation: an additional scientific programming environment, including installation, language guidance, and package management.
- SymPy introductory tutorial: symbolic algebra and calculus in Python, useful for checking expressions and derivatives.
- Mathematica: a proprietary environment for symbolic computation, numerical work, and visualization. A license is required; check institutional access.
- Slurm quick start: orientation to submitting and monitoring jobs on clusters that use Slurm. Follow your institution’s local instructions for accounts, storage, software modules, and job limits.