100% found this document useful (1 vote)
14 views

Introduction to Modeling and Simulation with MATLAB and Python 1st Edition Steven I. Gordon download

Ebook access

Uploaded by

alesiyuukiz6
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
14 views

Introduction to Modeling and Simulation with MATLAB and Python 1st Edition Steven I. Gordon download

Ebook access

Uploaded by

alesiyuukiz6
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Introduction to Modeling and Simulation with

MATLAB and Python 1st Edition Steven I. Gordon


download

https://textbookfull.com/product/introduction-to-modeling-and-
simulation-with-matlab-and-python-1st-edition-steven-i-gordon/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Introduction to Radar Using Python and MATLAB Lee


Andrew (Andy) Harrison

https://textbookfull.com/product/introduction-to-radar-using-
python-and-matlab-lee-andrew-andy-harrison/

An Introduction to Reservoir Simulation Using MATLAB


GNU Octave User Guide for the MATLAB Reservoir
Simulation Toolbox MRST Lie

https://textbookfull.com/product/an-introduction-to-reservoir-
simulation-using-matlab-gnu-octave-user-guide-for-the-matlab-
reservoir-simulation-toolbox-mrst-lie/

Network Modeling Simulation And Analysis In MATLAB


Theory And Practices Dac-Nhuong Le

https://textbookfull.com/product/network-modeling-simulation-and-
analysis-in-matlab-theory-and-practices-dac-nhuong-le/

Simulation of Dynamic Systems with MATLAB and Simulink


Harold Klee

https://textbookfull.com/product/simulation-of-dynamic-systems-
with-matlab-and-simulink-harold-klee/
Introduction to Linear Programming with MATLAB 1st
Edition Shashi Kant Mishra

https://textbookfull.com/product/introduction-to-linear-
programming-with-matlab-1st-edition-shashi-kant-mishra/

Environmental Modeling with Stakeholders: Theory,


Methods, and Applications 1st Edition Steven Gray

https://textbookfull.com/product/environmental-modeling-with-
stakeholders-theory-methods-and-applications-1st-edition-steven-
gray/

Introduction to GIS Programming and Fundamentals with


Python and ArcGIS 1st Edition Chaowei Yang

https://textbookfull.com/product/introduction-to-gis-programming-
and-fundamentals-with-python-and-arcgis-1st-edition-chaowei-yang/

Modeling and Simulation of Thermal Power Plants with


ThermoSysPro A Theoretical Introduction and a Practical
Guide Baligh El Hefni

https://textbookfull.com/product/modeling-and-simulation-of-
thermal-power-plants-with-thermosyspro-a-theoretical-
introduction-and-a-practical-guide-baligh-el-hefni/

Introduction to Scientific Programming with Python


Joakim Sundnes

https://textbookfull.com/product/introduction-to-scientific-
programming-with-python-joakim-sundnes/
Introduction to Modeling
and Simulation with
MATLAB® and Python
Chapman & Hall/CRC
Computational Science Series
SERIES EDITOR

Horst Simon
Deputy Director
Lawrence Berkeley National Laboratory
Berkeley, California, U.S.A.

PUBLISHED TITLES

COMBINATORIAL SCIENTIFIC COMPUTING


Edited by Uwe Naumann and Olaf Schenk
CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE
TOWARD EXASCALE
Edited by Jeffrey S. Vetter
CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE
TOWARD EXASCALE, VOLUME TWO
Edited by Jeffrey S. Vetter
DATA-INTENSIVE SCIENCE
Edited by Terence Critchlow and Kerstin Kleese van Dam
ELEMENTS OF PARALLEL COMPUTING
Eric Aubanel
THE END OF ERROR: UNUM COMPUTING
John L. Gustafson
EXASCALE SCIENTIFIC APPLICATIONS: SCALABILITY AND
PERFORMANCE PORTABILITY
Edited by Tjerk P. Straatsma, Timothy J. Williams, and Katerina Antypas
FROM ACTION SYSTEMS TO DISTRIBUTED SYSTEMS: THE REFINEMENT APPROACH
Edited by Luigia Petre and Emil Sekerinski
FUNDAMENTALS OF MULTICORE SOFTWARE DEVELOPMENT
Edited by Victor Pankratius, Ali-Reza Adl-Tabatabai, and Walter Tichy
FUNDAMENTALS OF PARALLEL MULTICORE ARCHITECTURE
Yan Solihin
THE GREEN COMPUTING BOOK: TACKLING ENERGY EFFICIENCY AT LARGE SCALE
Edited by Wu-chun Feng
GRID COMPUTING: TECHNIQUES AND APPLICATIONS
Barry Wilkinson
HIGH PERFORMANCE COMPUTING: PROGRAMMING AND APPLICATIONS
John Levesque with Gene Wagenbreth
PUBLISHED TITLES CONTINUED

HIGH PERFORMANCE PARALLEL I/O


Prabhat and Quincey Koziol
HIGH PERFORMANCE VISUALIZATION:
ENABLING EXTREME-SCALE SCIENTIFIC INSIGHT
Edited by E. Wes Bethel, Hank Childs, and Charles Hansen
INDUSTRIAL APPLICATIONS OF HIGH-PERFORMANCE COMPUTING:
BEST GLOBAL PRACTICES
Edited by Anwar Osseyran and Merle Giles
INTRODUCTION TO COMPUTATIONAL MODELING USING C AND
OPEN-SOURCE TOOLS
José M Garrido
INTRODUCTION TO CONCURRENCY IN PROGRAMMING LANGUAGES
Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen
INTRODUCTION TO ELEMENTARY COMPUTATIONAL MODELING: ESSENTIAL
CONCEPTS, PRINCIPLES, AND PROBLEM SOLVING
José M. Garrido
INTRODUCTION TO HIGH PERFORMANCE COMPUTING FOR SCIENTISTS
AND ENGINEERS
Georg Hager and Gerhard Wellein
INTRODUCTION TO MODELING AND SIMULATION WITH MATLAB® AND PYTHON
Steven I. Gordon and Brian Guilfoos
INTRODUCTION TO REVERSIBLE COMPUTING
Kalyan S. Perumalla
INTRODUCTION TO SCHEDULING
Yves Robert and Frédéric Vivien
INTRODUCTION TO THE SIMULATION OF DYNAMICS USING SIMULINK®
Michael A. Gray
PEER-TO-PEER COMPUTING: APPLICATIONS, ARCHITECTURE, PROTOCOLS,
AND CHALLENGES
Yu-Kwong Ricky Kwok
PERFORMANCE TUNING OF SCIENTIFIC APPLICATIONS
Edited by David Bailey, Robert Lucas, and Samuel Williams
PETASCALE COMPUTING: ALGORITHMS AND APPLICATIONS
Edited by David A. Bader
PROCESS ALGEBRA FOR PARALLEL AND DISTRIBUTED PROCESSING
Edited by Michael Alexander and William Gardner
PROGRAMMING FOR HYBRID MULTI/MANY-CORE MPP SYSTEMS
John Levesque and Aaron Vose
PUBLISHED TITLES CONTINUED

SCIENTIFIC DATA MANAGEMENT: CHALLENGES, TECHNOLOGY, AND DEPLOYMENT


Edited by Arie Shoshani and Doron Rotem
SOFTWARE ENGINEERING FOR SCIENCE
Edited by Jeffrey C. Carver, Neil P. Chue Hong, and George K. Thiruvathukal
Introduction to Modeling
and Simulation with
MATLAB® and Python

Steven I. Gordon
Brian Guilfoos

A CHAPMAN & HALL BOOK


MATLAB ® and Simulink® are trademarks of the MathWorks, Inc. and are used with permission. The
MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or
discussion of MATLAB ® and Simulink® software or related products does not constitute endorsement
or sponsorship by the MathWorks of a particular pedagogical approach or particular use of the
MATLAB ® and Simulink® software.

CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742

© 2017 by Taylor & Francis Group, LLC


CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works

Printed on acid-free paper

International Standard Book Number-13: 978-1-4987-7387-4 (Hardback)

This book contains information obtained from authentic and highly regarded sources. Reasonable
efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication
and apologize to copyright holders if permission to publish in this form has not been obtained. If any
copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access www.
copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC),
222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that
provides licenses and registration for a variety of users. For organizations that have been granted a
photocopy license by the CCC, a separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are
used only for identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com

and the CRC Press Web site at


http://www.crcpress.com
Contents

Preface, xiii
Authors, xvii

Chapter 1 ◾ Introduction to Computational Modeling 1


1.1 THE IMPORTANCE OF COMPUTATIONAL SCIENCE 1
1.2 HOW MODELING HAS CONTRIBUTED
TO ADVANCES IN SCIENCE AND ENGINEERING 3
1.2.1 Some Contemporary Examples 8
1.3 THE MODELING PROCESS 9
1.3.1 Steps in the Modeling Process 11
1.3.2 Mathematical Modeling Terminology and
Approaches to Simulation 14
1.3.3 Modeling and Simulation Terminology 14
1.3.4 Example Applications of Modeling and Simulation 15
EXERCISES 17
REFERENCES 18

Chapter 2 ◾ Introduction to Programming Environments 21


2.1 THE MATLAB® PROGRAMMING ENVIRONMENT 21
2.1.1 The MATLAB® Interface 21
2.1.2 Basic Syntax 23
2.1.2.1 Variables and Operators 23
2.1.2.2 Keywords 25
2.1.2.3 Lists and Arrays 26
2.1.3 Common Functions 28
vii
viii ◾ Contents

2.1.4 Program Execution 28


2.1.5 Creating Repeatable Code 29
2.1.6 Debugging 30
2.2 THE PYTHON ENVIRONMENT 30
2.2.1 Recommendations and Installation 30
2.2.2 The Spyder Interface 31
2.2.3 Basic Syntax 32
2.2.3.1 Variables and Operators 32
2.2.3.2 Keywords 34
2.2.3.3 Lists and Arrays 35
2.2.4 Loading Libraries 38
2.2.5 Common Functions 39
2.2.6 Program Execution 40
2.2.7 Creating Repeatable Code 40
2.2.8 Debugging 41
EXERCISES 42

Chapter 3 ◾ Deterministic Linear Models 45


3.1 SELECTING A MATHEMATICAL REPRESENTATION
FOR A MODEL 45
3.2 LINEAR MODELS AND LINEAR EQUATIONS 46
3.3 LINEAR INTERPOLATION 49
3.4 SYSTEMS OF LINEAR EQUATIONS 51
3.5 LIMITATIONS OF LINEAR MODELS 51
EXERCISES 52
REFERENCES 53

Chapter 4 ◾ Array Mathematics in MATLAB® and Python 55


4.1 INTRODUCTION TO ARRAYS AND MATRICES 55
4.2 BRIEF OVERVIEW OF MATRIX MATHEMATICS 56
4.3 MATRIX OPERATIONS IN MATLAB® 58
4.4 MATRIX OPERATIONS IN PYTHON 59
EXERCISES 60
Contents ◾ ix

Chapter 5 ◾ Plotting 61
5.1 PLOTTING IN MATLAB® 61
5.2 PLOTTING IN PYTHON 68
EXERCISES 76

Chapter 6 ◾ Problem Solving 79


6.1 OVERVIEW 79
6.2 BOTTLE FILLING EXAMPLE 80
6.3 TOOLS FOR PROGRAM DEVELOPMENT 81
6.3.1 Pseudocode 82
6.3.2 Top–Down Design 82
6.3.3 Flowcharts 83
6.4 BOTTLE FILLING EXAMPLE CONTINUED 84
EXERCISES 85

Chapter 7 ◾ Conditional Statements 87


7.1 RELATIONAL OPERATORS 87
7.2 LOGICAL OPERATORS 88
7.3 CONDITIONAL STATEMENTS 89
7.3.1 MATLAB ® 89
7.3.2 Python 92
EXERCISES 95

Chapter 8 ◾ Iteration and Loops 97


8.1 FOR LOOPS 97
8.1.1 MATLAB Loops
® 97
8.1.2 Python Loops 98
8.2 WHILE LOOPS 99
8.2.1 MATLAB® While Loops 99
8.2.2 Python While Loops 99
8.3 CONTROL STATEMENTS 100
8.3.1 Continue 100
8.3.2 Break 100
EXERCISES 100
x ◾ Contents

Chapter 9 ◾ Nonlinear and Dynamic Models 101


9.1 MODELING COMPLEX SYSTEMS 101
9.2 SYSTEMS DYNAMICS 101
9.2.1 Components of a System 102
9.2.2 Unconstrained Growth and Decay 104
9.2.2.1 Unconstrained Growth Exercises 106
9.2.3 Constrained Growth 108
9.2.3.1 Constrained Growth Exercise 110
9.3 MODELING PHYSICAL AND SOCIAL PHENOMENA 111
9.3.1 Simple Model of Tossed Ball 112
9.3.2 Extending the Model 113
9.3.2.1 Ball Toss Exercise 114
REFERENCES 115

Chapter 10 ◾ Estimating Models from Empirical Data 117


10.1 USING DATA TO BUILD FORECASTING MODELS 117
10.1.1 Limitations of Empirical Models 118
10.2 FITTING A MATHEMATICAL FUNCTION TO DATA 120
10.2.1 Fitting a Linear Model 122
10.2.2 Linear Models with Multiple Predictors 125
10.2.3 Nonlinear Model Estimation 126
10.2.3.1 Limitations with Linear
Transformation 130
10.2.3.2 Nonlinear Fitting and Regression 130
10.2.3.3 Segmentation 131
EXERCISES 131
FURTHER READINGS 132
REFERENCES 132

Chapter 11 ◾ Stochastic Models 133


11.1 INTRODUCTION 133
11.2 CREATING A STOCHASTIC MODEL 134
Contents ◾ xi

11.3 RANDOM NUMBER GENERATORS IN


MATLAB® AND PYTHON 136
11.4 A SIMPLE CODE EXAMPLE 137
11.5 EXAMPLES OF LARGER SCALE STOCHASTIC
MODELS 139
EXERCISES 142
FURTHER READINGS 143
REFERENCES 143

Chapter 12 ◾ Functions 145


12.1 ®
MATLAB FUNCTIONS 145
12.2 PYTHON FUNCTIONS 147
12.2.1 Functions Syntax in Python 147
12.2.2 Python Modules 148
EXERCISES 149

Chapter 13 ◾ Verification, Validation, and Errors 151


13.1 INTRODUCTION 151
13.2 ERRORS 152
13.2.1 Absolute and Relative Error 152
13.2.2 Precision 153
13.2.3 Truncation and Rounding Error 153
13.2.4 Violating Numeric Associative and
Distributive Properties 155
13.2.5 Algorithms and Errors 155
13.2.5.1 Euler’s Method 156
13.2.5.2 Runge–Kutta Method 158
13.2.6 ODE Modules in MATLAB ®

and Python 159


13.3 VERIFICATION AND VALIDATION 159
13.3.1 History and Definitions 160
13.3.2 Verification Guidelines 162
xii ◾ Contents

13.3.3 Validation Guidelines 163


13.3.3.1 Quantitative and Statistical
Validation Measures 164
13.3.3.2 Graphical Methods 166
EXERCISES 166
REFERENCES 167

Chapter 14 ◾ Capstone Projects 169


14.1 INTRODUCTION 169
14.2 PROJECT GOALS 170
14.3 PROJECT DESCRIPTIONS 171
14.3.1 Drug Dosage Model 171
14.3.2 Malaria Model 172
14.3.3 Population Dynamics Model 174
14.3.4 Skydiver Project 176
14.3.5 Sewage Project 178
14.3.6 Empirical Model of Heart Disease Risk Factors 180
14.3.7 Stochastic Model of Traffic 180
14.3.8 Other Project Options 181
REFERENCE 181

INDEX, 183
Preface

M odeling and simulation using computation or computational


science has become an essential part of the research and develop-
ment process in the physical, biological, and social sciences and engi-
neering. It allows the exploration of physical and biological systems at
the micro- and molecular level that increase our understanding of their
function and the discovery of new materials and new drugs. It allows us
to understand the interactions of components in complex systems from
those we engineer and build to our ecosystems and climate. In recent
years, computational science has produced enormous advances in almost
all fields of scientific and technological inquiry, including DNA sequenc-
ing, behavioral modeling, global climatic predictions, drug design, finan-
cial systems, and medical visualization. At the same time, it has become
critical in the design, testing, and manufacturing of new products and
services, saving millions of dollars in development costs and getting new
products to market more rapidly.
Scientists, social scientists, and engineers must have an understand-
ing of both modeling and computer programming principles so that
they appropriately apply those techniques in their practice. Several sets
of knowledge and skills are required to achieve that understanding. How
do we translate the relationships within a system being modeled into a
set of mathematical functions that accurately portray the behavior of
that system? How are the mathematics translated into computer code
that correctly simulates those relationships? What is the nature of errors
introduced by simplifying the depiction of the system, introduced by
the computer algorithm used to solve the equations, and limited by our
knowledge of the system behavior? How accurate is the model? How do
we know the model is logically correct and follows from the physical and
mathematical laws used to create it (verification)? How do we demonstrate

xiii
xiv ◾ Preface

that the model correctly predicts the phenomena modeled (validation)?


These are the underlying questions that are the focus of this book.
The book is intended for students and professionals in science, social
science, and engineering who wish to learn the principles of computer
modeling as well as basic programming skills. For many students in these
fields, with the exception of computer science students and some engineer-
ing students, enrollment in an introductory programming course may be
impractical or difficult. At many institutions, these courses are focused
primarily on computer science majors and use a programming language
such as Java that is not readily applicable to science and engineering prob-
lems. We have found that teaching programming as a just-in-time tool
used to solve real problems more deeply engages those students to master
the programming concepts. Combining that effort with learning the prin-
ciples of modeling and simulation provides the link between program-
ming and problem solving while also fitting more readily into a crowded
curriculum.
For students from all fields, learning the basic principles of modeling
and simulation prepares them for understanding and using computer
modeling techniques that are being applied to a myriad of problems. The
knowledge of the modeling process should provide the basis for under-
standing and evaluating models in their own subject domain. The book
content focuses on meeting a set of basic modeling and simulation compe-
tencies that were developed as part of several National Science Foundation
grants (see http://hpcuniversity.org/educators/undergradCompetencies/).
Even though computer science students are much more expert program-
mers, they are not often given the opportunity to see how those skills are
being applied to solve complex science and engineering problems, and may
also not be aware of the libraries used by scientists to create those models.
We have chosen to use MATLAB® and Python for several reasons. First,
both offer interfaces that the intended audience should find intuitive. Both
interfaces provide instant feedback on syntax errors and extensive help
documents and tutorials that are important for novice programmers.
Although MATLAB is a commercially licensed program, whereas Python
is open source, many campuses currently have a site license for MATLAB.
Students can also purchase the student version of MATLAB relatively
cheaply.
Perhaps most importantly, both programs are extensively used by the
science and engineering community for model development and test-
ing. Even though neither program scales as efficiently as C, Fortran,
Preface ◾ xv

or other languages for large-scale modeling on current parallel comput-


ing architectures, they do offer a stepping stone to those environments.
Both have extensive toolkits and scientific and mathematical libraries that
can be invoked to reduce the amount of coding required to undertake
many modeling projects. Although we use these programming environ-
ments to teach rudimentary programming techniques without applying
a large number of these tools, they are available to students for develop-
ing capstone projects or for use in more advanced courses later in their
curriculum.

ORGANIZATION OF THE BOOK


The book interleaves chapters on modeling concepts and related exercises
with programming concepts and exercises. We start out with an introduc-
tion to modeling and its importance to current practices in the sciences
and engineering. We then introduce each of the programming environ-
ments and the syntax used to represent variables and compute math-
ematical equations and functions. As students gain more programming
expertise, we go back to modeling concepts, providing starting code for a
variety of exercises where students add additional code to solve the prob-
lem and provide an analysis of the outcomes. In this way, we build both
modeling and programming expertise with a “just-in-time” approach so
that by the end of the book, students can take on relatively simple model-
ing example on their own.
Each chapter is supplemented with references to additional read-
ing, tutorials, and exercises that guide students to additional help and
allow them to practice both their programming and analytical modeling
skills. The companion website at http://www.intromodeling.com provides
updates to instructions when there are substantial changes in software
versions as well as electronic copies of exercises and the related code.
Solutions to the computer exercises are available to instructors on the
publisher’s website.
Each of the programming-related chapters is divided into two parts—
one for MATLAB and one for Python. We assume that most instructors
will choose one or the other so that students can focus only on the lan-
guage associated with their course. In these chapters, we also refer to addi-
tional online tutorials that students can use if they are having difficulty
with any of the topics.
The book culminates with a set of final project exercise suggestions that
incorporate both the modeling and the programming skills provided in
xvi ◾ Preface

the rest of the volume. These projects could be undertaken by individuals


or small groups of students. They generally involve research into a par-
ticular modeling problem with suggested background reading from the
literature. Each exercise has a set of starting code providing a very simplis-
tic view of the system and suggestions for extending the model by adding
additional components to relax some of the assumptions. Students then
complete the program code and use the model to answer a number of
questions about the system, complete model verification and validation
where possible, and present a report in written and oral form.
The website also offers a space where people can suggest additional
projects they are willing to share as well as comments on the existing proj-
ects and exercises throughout the book. We hope that the combination of
materials contributes to the success of those interested in gaining model-
ing and simulation expertise.

MATLAB® is a registered trademark of The MathWorks, Inc. For product


information, please contact:

The MathWorks, Inc.


3 Apple Hill Drive
Natick, MA 01760-2098 USA
Tel: 508 647 7000
Fax: 508-647-7001
E-mail: [email protected]
Web: www.mathworks.com
Authors

Steven I. Gordon is a professor emeritus of the City and Regional Planning


and Environmental Science Programs at the Ohio State University, Columbus,
Ohio. He earned a bachelor’s degree from the University at Buffalo, Buffalo,
New York, in 1966 and a PhD degree from Columbia University, New York, in
1977. He also serves as the senior education lead at the Ohio Supercomputer
Center. In that and other roles at OSC, he has focused primarily on the
integration of computational science into the curricula at higher education
institutions in Ohio and throughout the United States. He has worked with
multiple institutions through a variety of grants from the National Science
Foundation, including the Extreme Science and Engineering Discovery
Environment (XSEDE) and Blue Waters project.
Dr. Gordon is also one of the founders and first chair of the Association of
Computing Machinery (ACM) Special Interest Group High Performance
Computing (SIGHPC) Education Chapter and serves as a representative
of the SIGHPC on the ACM Education Council. He has published exten-
sively on topics related to environmental planning and the applications of
modeling and simulation in education and research.

Brian Guilfoos serves as the High Performance Computing (HPC) Client


Services manager for the Ohio Supercomputer Center (OSC), Columbus,
Ohio. Guilfoos leads the HPC Client Services Group, which provides train-
ing and user support to facilitate the use of computational science by the
center’s user communities. He earned a master’s degree in public policy and
administration in 2014 and a bachelor’s degree in electrical engineering in
2000, both from the Ohio State University, Columbus, Ohio. He also works
directly with OSC clients to help convert computer codes and develop
batch scripting, compiling, and code development so that these researchers
can efficiently use the center’s supercomputers and licensed software.

xvii
xviii ◾ Authors

Guilfoos developed and delivered training in MATLAB® as a part of the


U.S. Department of Defense High Performance Computing Modernization
Program support.
Prior to joining OSC, he was contracted by the Air Force Research
Laboratory (AFRL) to focus on software development in support of
unmanned aerial vehicle interface research. He was a key technical mem-
ber of a team that was awarded the 2004 Scientific and Technological
Achievement Award by the AFRL’s Human Effectiveness Directorate.
Chapter 1

Introduction to
Computational Modeling

1.1 THE IMPORTANCE OF COMPUTATIONAL SCIENCE


Advances in science and engineering have come traditionally from the
application of the scientific method using theory and experimentation
to pose and test our ideas about the nature of our world from multiple
perspectives. Through experimentation and observation, scientists develop
theories that are then tested with additional experimentation. The cause and
effect relationships associated with those discoveries can then be represented
by mathematical expressions that approximate the behavior of the system
being studied.
With the rapid development of computers, scientists and engineers
translated those mathematical expressions into computer codes that
allowed them to imitate the operation of the system over time. This pro-
cess is called simulation. Early computers did not have the capability of
solving many of the complex system simulations of interest to scientists
and engineers. This led to the development of supercomputers, comput-
ers with higher level capacity for computation compared to the general-
purpose computers of the time. In 1982, a panel of scientists provided
a report to the U.S. Department of Defense and the National Science
Foundation urging the government to aid in the development of super-
computers (Lax, 1982). They indicated that “the primacy of the U.S. in sci-
ence, engineering, and computing technology could be threatened relative
to that of other countries with national efforts in supercomputer access

1
2 ◾ Modeling and Simulation with MATLAB® and Python

and development.” They recommended both investments in research and


development and in the training of personnel in science and engineering
computing.
The capability of the computer chips in your cell phone today far
exceeds that of the supercomputers of the 1980s. The Cray-1 super-
computer released in 1975 had a raw computing power of 80 million
floating-point operations per second (FLOPS). The iPhone 5s has a graph-
ics processor capable of 76.8 Gigaflops, nearly one thousand times more
powerful (Nick, 2014). With that growth in capability, there has been a
dramatic expansion in the use of simulation for engineering design and
research in science, engineering, social science, and the humanities. Over
the years, that has led to many efforts to integrate computational science
into the curriculum, to calls for development of a workforce prepared
to apply computing to both academic and commercial pursuits, and to
investments in the computer and networking infrastructure required
to meet the demands of those applications. For example, in 2001 the
Society for Industrial and Applied Mathematics (SIAM) provided a
review of the graduate education programs in science and engineering
(SIAM, 2001). They defined computational science and engineering as a
multidisciplinary field requiring expertise in computer science, applied
mathematics, and a subject field of science and engineering. They pro-
vided examples of emerging research, an outline of a curriculum, and
curriculum examples from both North America and Europe.
Yasar and Landau (2001) provided a similar overview of the interdisci-
plinary nature of the field. They also describe the possible scope of programs
at the both the undergraduate and graduate levels and provide a survey of
existing programs and their content. More recently, Gordon et al. (2008)
described the creation of a competency-based undergraduate minor pro-
gram in computational science that was put into place at several institutions
in Ohio. The competencies were developed by an interdisciplinary group of
faculty and reviewed by an industry advisory committee from the perspective
of the skills that prospective employers are looking for in students entering
the job market. The competencies have guided the creation of several other
undergraduate programs. They have also been updated and augmented
with graduate-level computational science competencies and competencies
for data-driven science. The most recent version of those competencies can
be found on the HPC University website (HPC University, 2016).
More recently, there have been a number of national studies and
panels emphasizing the need for the infrastructure and workforce
Introduction to Computational Modeling ◾ 3

required to undertake large-scale modeling and simulation (Council on


Competitiveness, 2004; Joseph et al., 2004; Reed, 2005; SBES, 2006). This book
provides an introduction to computational science relevant to students across
the spectrum of science and engineering. In this chapter, we begin with a
brief review of the history or computational modeling and its contributions
to the advancement of science. We then provide an overview of the modeling
process and the terminology associated with modeling and simulation.
As we progress through the book, we guide students through basic
programming principles using two of the widely used simulation
environments—MATLAB® and Python. Each chapter introduces either
a new set of programming principles or applies them to the solution of
one class of models. Each chapter is accompanied by exercises that help
to build both basic modeling and programming skills that will provide a
background for more advanced modeling courses.

1.2 HOW MODELING HAS CONTRIBUTED


TO ADVANCES IN SCIENCE AND ENGINEERING
There are a myriad of examples documenting how modeling and simulation
has contributed to research and to the design and manufacture of new prod-
ucts. Here, we trace the history of computation and modeling to illustrate
how the combination of advances in computing hardware, software, and
scientific knowledge has led to the integration of computational modeling
techniques throughout the sciences and engineering. We then provide a few,
more recent examples of advances to further illustrate the state-of-the-art.
One exercise at the end of the chapter provides an opportunity for students
to examine additional examples and share them with their classmates.
The first electronic programmable computer was the ENIAC built for
the army toward the end of World War II as a way to quickly calculate
artillery trajectories. Herman Goldstine (1990), the project leader, and
two professors from the University of Pennsylvania, J. Presper Eckert,
and John Mauchly sold the idea to the army in 1942 (McCartney, 1999).
As the machine was being built and tested, a large team of engineers and
mathematicians was assembled to learn how to use it. That included six
women mathematicians who were recruited from colleges across the
country. As the machine was completed in 1945, the war was near an end.
ENIAC was used extensively by the mathematician John von Neumann
not only to undertake its original purposes for the army but also to create
the first weather model in 1950. That machine was capable of 400 floating-
point operations per second and needed 24 hours to calculate the simple
4 ◾ Modeling and Simulation with MATLAB® and Python

daily weather model for North America. To provide a contrast to the


power of current processors, Peter and Owen Lynch (2008) created a
version of the model that ran on a Nokia 6300 mobile phone in less than
one second!
It is impossible to document all of the changes in computational
power and its relationship to the advancements in science that have
occurred since this first computer. Tables 1.1 and 1.2 show a timeline

TABLE 1.1 Timeline of Advances in Computer Power and Scientific Modeling (Part 1)
Example Hardware Max. Speed Date Weather and Climate Modeling
ENIAC 400 Flops 1945
1950 First automatic weather forecasts
UNIVAC 1951
IBM 704 12 KFLOP 1956
1959 Ed Lorenz discovers the chaotic
behavior of meteorological processes
IBM7030 Stretch; 500-500 KFLOP ~1960
UNIVAC LARC
1965 Global climate modeling underway
CDC6600 1 Megaflop 1966
CDC7600 10 MFLOP 1975
CRAY1 100 MFLOP 1976
CRAY-X-MP 400 MFLOP
1979 Jule Charney report to NAS
CRAY Y-MP 2.67 GFLOP
1988 Intergovernmental Panel on Climate
Change
1992 UNFCCC in Rio
IBM SP2 10 Gigaflop 1994
ASCII Red 2.15 TFLOP 1995 Coupled Model Intercomparison
Project (CMIP)
2005 Earth system models
Blue Waters 13.34 PFLOP 2014
Sources: Bell, G., Supercomputers: The amazing race (a history of supercomputing, 1960–2020),
2015, http://research.microsoft.com/en-us/um/people/gbell/MSR-TR-2015-2_
Supercomputers-The_Amazing_Race_Bell.pdf (accessed December 15, 2016).
Bell, T., Supercomputer timeline, 2016, https://mason.gmu.edu/~tbell5/page2.html
(accessed December 15, 2016).
Esterbrook, S., Timeline of climate modeling, 2015, https://prezi.com/pakaaiek3nol/
timeline-of-climate-modeling/ (accessed December 15, 2016).
Introduction to Computational Modeling ◾ 5

TABLE 1.2 Timeline of Advances in Computer Power and Scientific Modeling (Part 2)
Date Theoretical Chemistry Aeronautics and Structures Software and Algorithms
1950 Electronic wave functions
1951 Molecular orbital theory
(Roothan)
1953 One of the first
molecular simulations
(Metropolis et al.)
1954 Vector processing
directives
1956 First calculation of
multiple electronic
states of a molecule on
EDSAC (Boys)
1957 FORTRAN created
1965 Creation of ab initio
molecular modeling
(People)
1966 2D Navier-Stokes
simulations; FLO22;
transonic flow over a
swept wing
1969 UNIX created
1970 2D Inviscid Flow Models;
design of regional jet
1971 Nastran (NASA
Structural Analysis)
1972 C programming
language created
1973 Matrix computations
and errors
(Wilkinson)
1975 3D Inviscid Flow Models;
complete airplane
solution
1976 First calculation of a DYNA3D which became
chemical reaction LS-DYNA (mid-70s)
(Warshel)
1977 First molecular dynamics Boeing design of 737-500
of proteins (Karplus)
First calculation of a
reaction transition state
(Chandler)
(Continued)
6 ◾ Modeling and Simulation with MATLAB® and Python

TABLE 1.2 (Continued) Timeline of Advances in Computer Power and Scientific


Modeling (Part 2)
Date Theoretical Chemistry Aeronautics and Structures Software and Algorithms
1979 Basic Linear Algebra
Subprograms (BLAS)
library launched
1980s Journal of Computational 800,000 mesh cells
Chemistry first published around a wing, FLO107
1984 MATLAB created
1985 Design of Boeing 767,777 GNU project launched
(free Software
foundation)
1991 Linux launched
1993 Message passing
interface (MPI)
specification
1994 Python created
1995 First successful
computer-based drug
design (Kubinyi)
1997 Open multiprocessing
(OpenMP)
specification
2000 Discontinuous finite
element methods;
turbulent flow; design
of airbus
2007 CUDA launched
2014 Open accelerator
(OpenACC)
specification
Sources: Bartlett, B.N., The contributions of J.H. Wilkinson to numerical analysis. In S.G. Nash,
(Ed.), A History of Scientific Computing, ACM Press, New York, pp. 17–30, 1990.
Computer History Museum, Timeline of computer history, software and languages,
2017, http://www.computerhistory.org/timeline/software-languages/ (accessed January
2, 2017).
Dorzolamide, 2016, https://en.wikipedia.org/wiki/Dorzolamide (accessed December
15, 2016).
Jameson, A., Computational fluid dynamics, past, present, and future, 2016, http://
aero-comlab.stanford.edu/Papers/NASA_Presentation_20121030.pdf (accessed
December 15, 2016).
Prat-Resina, X., A brief history of theoretical chemistry, 2016, https://sites.google.
com/a/r.umn.edu/prat-resina/divertimenti/a-brief-history-of-theoretical-chemistry
(accessed December 15, 2016).
Vassberg, J.C., A brief history of FLO22, http://dept.ku.edu/~cfdku/JRV/Vassberg.
pdf (accessed December 15, 2016).
Introduction to Computational Modeling ◾ 7

of the development of selected major hardware advances, software and


algorithm development, and scientific applications from a few fields.
Looking at the first column in Table 1.1, one can see the tremendous
growth in the power of the computers used in large-scale scientific
computation. Advances in electronics and computer design have brought
us from the ENIAC with 400 flops to Blue Waters with 13.34 petaflops,
an increase in the maximum number of floating-point operations per
second of more than 1015!
Tracing weather and climate modeling from von Neumann’s first model
on ENIAC, we can see that the computational power has allowed scien-
tists to make rapid progress in the representation of weather and climate.
In 1959, Lorenz laid the foundation for the mathematics behind weather
events. By 1965, further advances in computing power and scientific
knowledge provided the basis for the first global climate models. These
have grown in scope to the present day to earth system models that cou-
ple atmospheric and ocean circulation that provide for the basis for the
climate change forecasts of the international community.
Table 1.2 documents similar developments in computational chem-
istry, aeronautics and structures, and selected achievements in software
and algorithms. The scientific advances were made possible not only by
improvements in the hardware but also by the invention of program-
ming languages, compilers, and the algorithms that are used to make
the mathematical calculations underlying the models. As with weather
modeling, one can trace the advancement of computational chemis-
try from the first simulation of molecules to the screening of drugs by
modeling their binding to biomolecules. In aeronautics, the simulation
of airflow over a wing in two dimensions has advanced to the three-
dimensional simulation of a full airplane to create a final design. Similar
timelines could be developed for every field of science and engineering
from various aspects of physics and astronomy to earth and environ-
mental science, to every aspect of engineering, and to economics and
sociological modeling.
For those just getting introduced to these concepts, the terminology
is daunting. The lesson at this point is to understand that computation
has become an essential part of the design and discovery process across
a wide range of scientific fields. Thus, it is essential that everyone under-
stands the basic principles used in modeling and simulation, the mathe-
matics underlying modeling efforts, and the tools of modeling along with
their pitfalls.
8 ◾ Modeling and Simulation with MATLAB® and Python

1.2.1 Some Contemporary Examples


Although this book will not involve the use of large-scale models on
supercomputers, some contemporary examples of large-scale simulations
may provide insights into the need for the computational power described
in Table 1.1. We provide four such examples.
Vogelsberger et al. created a model of galaxy formation comprised of
12 billion resolution elements showing the evolution of the universe from
12 million years after the Big Bang evolving over a period of 13.8 billion
years (Vogelsberger et al., 2014). The simulation produced a large variety of
galaxy shapes, luminosities, sizes, and colors that are similar to observed
population. The simulation provided insights into the processes associated
with galaxy formation. This example also illustrates how computation can
be applied to a subject where experimentation is impossible but where
simulation results can be compared with scientific observations.
Drug screening provides an example of how computer modeling can
shorten the time to discovery. The drug screening pipeline requires a
model of a target protein or macromolecular structure that is associated
with a specific disease mechanism. A list of potential candidate com-
pounds is then tested to see which have the highest affinity to bind to that
protein, potentially inhibiting the medical problem. Biesiada et al. (2012)
provide an excellent overview of the workflow associated with this process
and the publically available software for accomplishing those tasks. The
use of these tools allows researchers to screen thousands of compounds
for their potential use as drugs. The candidate list can then be pared down
to only a few compounds where expensive experimental testing is used.
The reports on global warming use comprehensive models of the
earth’s climate including components on the atmosphere and hydro-
sphere (ocean circulation and temperature, rainfall, polar ice caps) to
forecast the long-term impacts on our climate and ecosystems (Pachauri
and Meyer, 2014). The models:

reproduce observed continental-scale surface temperature patterns


and trends over many decades, including the more rapid warming
since the mid-20th century and the cooling immediately following
large volcanic eruptions (very high confidence) (IPC, 2013, p. 15).

Modeling and simulation has also become a key part of the process and
designing, testing, and producing products and services. Where the build-
ing of physical prototypes or the completion of laboratory experiments
Introduction to Computational Modeling ◾ 9

may take weeks or months and cost millions of dollars, industry is instead
creating virtual experiments that can be completed in a short time at
greatly reduced costs. Proctor and Gamble uses computer modeling to
improve many of its products. One example is the use of molecular mod-
eling to test the interactions among surfactants in their cleaning products
with a goal of producing products that are environmentally friendly and
continue to perform as desired (Council on Competiveness, 2009).
Automobile manufacturers have substituted modeling for the building
of physical prototypes of their cars to save time and money. The build-
ing of physical prototypes called mules is expensive, costing approxi-
mately $500,000 for each vehicle with 60 prototypes required before
going into production (Mayne, 2005). The design of the 2005 Toyota
Avalon required no mules at all—using computer modeling to design and
test the car. Similarly, all of the automobile manufacturers are using mod-
eling to reduce costs and get new products to market faster (Mayne, 2005).
These examples should illustrate the benefits of using modeling and
simulation as part of the research, development, and design processes for
scientists and engineers. Of course, students new to modeling and simula-
tion cannot be expected to effectively use complex, large-scale simulation
models on supercomputers at the outset of their modeling efforts. They
must first understand the basic principles for creating, testing, and using
models as well as some of the approaches to approximating physical real-
ity in computer code. We begin to define those principles in Section 1.3
and continue through subsequent chapters.

1.3 THE MODELING PROCESS


Based on the examples discussed earlier, it should be clear that a model
is an abstraction or simplification of a real-world object or phenomenon
that helps us gain insights into the state or behavior of a complex sys-
tem. Each of us creates informal, mental models all the time as an aid to
making decisions. One example may be deciding on a travel route that
gets us to several shopping locations faster or with the fewest traffic head-
aches. To do this, we analyze information from previous trips to make an
informed decision about where there may be heavy traffic, construction,
or other impediments to our trip.
Some of our first formal models were physical models. Those include sim-
plified prototypes of objects used to evaluate their characteristics and behav-
iors. For example, auto manufacturers built clay models of new car designs
to evaluate the styling and to test the design in wind-tunnel experiments.
10 ◾ Modeling and Simulation with MATLAB® and Python

Mississippi Basin Model


Vertical scale - 1:100; horizontal scale - 1:2000. Looking upstream on the Ohio River from Evansville. Indiana,
Tennessee, and Cumberland Rivers are in the foreground showing the site of the Kentucky and Barkley Dams.
Tradewater and Green Rivers are shown center. File No. 1270–4

FIGURE 1.1 Photo of portion of Mississippi River Basin model.

One of the most ambitious physical models ever built was a costly 200 acre
model of the Mississippi River Basin used to simulate flooding in the
watershed (U.S. Army Corps of Engineers, 2006). A photo of a portion
of this model is shown in Figure 1.1. It included replicas of urban areas,
the (Fatherree, 2006) stream bed, the underlying topography, levees, and
other physical characteristics. Special materials were used to allow flood
simulations to be tested and instrumented.
Through theory and experimentation, scientists and engineers also
developed mathematical models representing aspects of physical behaviors.
These became the basis of computer models by translating the mathemat-
ics into computer codes. Over time, mathematical models that started
as very simplistic representations of complex systems have evolved into
systems of equations that more closely approximate real-world phenomena
such as the large-scale models discussed earlier in this chapter.
Creating, testing, and applying mathematical models using computa-
tion require an iterative process. The process starts with an initial set of
simplifying assumptions and is followed by testing, alteration, and applica-
tion of the model. Those steps are discussed in Section 1.3.1.
Exploring the Variety of Random
Documents with Different Content
imagination. In moderate language, and in his most lucid manner, he
answered his opponents, and expounded his own reasons for
advising the Parliament of England to naturalise the Scottish nation.
There were, he said, three objections to doing so. In the first place,
it was thought that if the Scots were no longer aliens, they would
settle in England in such numbers that the country would be over-
populated. But, he answered, four years had passed since the Union
of the Crowns, which was “the greatest spring-tide for the
confluence and entrance of that nation”; and during these four years
the only Scotsmen who had come to live in England were those
immediately connected with the Court. Again, England, he declared,
was not yet fully peopled. London was overcrowded; but the rest of
the country showed signs of a want of inhabitants, in the shape of
swamps and waste places. The Commons themselves might bear in
mind “how many of us serve here in this place for desolate and
decayed boroughs.” And, besides, what was the worst effect which
could follow too great an increase of the population? Nothing more
than some honourable war for the enlargement of our borders.
The second objection to naturalising the Scots was that the laws
of England and Scotland were different, that the Articles of Union
left them different, and that it was unreasonable to admit the Scots
to the privileges of English citizens without making them adopt the
laws of England. But, he argued, naturalisation must come first. The
inhabitants of Ireland, of the Isle of Man, and of Jersey and
Guernsey, had the benefits of naturalisation; but the laws of England
were not yet in force among them. An union of laws might be
brought about both in these places and in Scotland, but only in
course of time.
The third objection was that there was so much inequality
between England and Scotland that the Union would not be fair to
England. This inequality, Bacon declared, consisted only in gold and
silver, the external goods of fortune. “In their capacities and
undertakings,” he said, “they are a people ingenious, in labour
industrious, in courage valiant, in body hard, active, and comely.” If
Scotland was, after all, to gain by the Union, then England might
find that it was more blessed to give than to receive.
Having thus answered the objections to naturalisation, he next
maintained that if naturalisation did not follow the Union of the
Kingdoms under the same Crown, danger would be the result.
History, he argued, teaches us that whenever kingdoms have been
united by the link of the Crown alone, if that union has not been
fortified by something more, and most of all by naturalisation,
separation takes place. The Romans and the Latins were united; but
the Latins were not made citizens of Rome. War was the result.
Sparta was ruined by attempting to maintain a league with States
whose peoples she jealously regarded as aliens. The history of
Aragon and Castile, of Florence and Pisa, taught us the same lesson.
And on the other hand, we find that where States have been united,
and that union strengthened by the bond of naturalisation, they
never separate again.
He ended his speech by saying that, in future times, England,
“having Scotland united and Ireland reduced,” would be one of the
greatest monarchies in the world.[62]
But this appeal was unheeded by the House; and though Coke
brought all his great authority as a common lawyer to the same side
as Bacon, the members would not be convinced. James on two
occasions expostulated with them. He said he was willing, if it would
help on the Union, to live one year in Scotland and another in
England, or to live at York, or on the Borders. But the Commons
were intractable, although the Lords were ready to agree to the
Union, and to the naturalisation of the Scots.
Something, however, was accomplished. The questions of trade
and of naturalisation were left unsettled; but an Act was passed
which gave effect to the first part of the Treaty of Union, by
repealing a number of statutes hostile to Scotland (such as those
which forbade the leasing of lands to Scotsmen, and the exporting of
arms or horses to Scotland), on condition that the Scottish
Parliament, when it met, was to repeal the Scottish Acts, of a similar
nature, which were hostile to England.[63]
With this small concession James had to be contented; and at
the beginning of July he dismissed the Parliament, but not without a
farewell warning that the Union was, in the long-run, inevitable.
“These two kingdoms,” he said, “are so conjoined that, if we should
sleep in our beds, the Union should be, though we would not. He
that doth not love a Scotsman as his brother, or the Scotsman that
loves not an Englishman as his brother, he is traitor to God and the
king.”
The Scottish Parliament met in the first week of August. The
Scots were, on the whole, rather proud to think that their king had
gone to rule over England. Yet the old wrongs could not easily be
forgotten, and it is probable that the Estates were very nearly as
much against the Union as the House of Commons was. The Privy
Council had, some months before, given the king a hint of this;[64]
and a trivial circumstance may be mentioned to show how jealous
the Scots were of England. A pattern of the new flag which James
had ordered to be prepared for the United Kingdom, had been sent
from England; and great offence had been taken when it was found
that the Cross of Saint Andrew was covered, and, it was said, hidden
by the Cross of St. George. Scottish seamen, the king was told,
could not be induced to receive the flag.[65]
There can be little doubt that most Scotsmen sympathised with
the national feeling which this trifling incident disclosed. But the
private opinion of a member of the Scottish Parliament was one
thing, and his public conduct was another. The Estates were
submissive to the royal will. The Articles of Union were agreed to;
and all the laws hostile to England were repealed.[66]
Thus, so far as it lay within the power of the Scottish
Parliament, the king had got what he wanted. All that remained was
for the English Parliament to be equally complaisant; and the
kingdoms would have been united in 1607 instead of a century later.
But it was not to be. In neither country was there any genuine
desire for union. The free traditions of the House of Commons
enabled the members to say what they thought; and the subject,
gradually dropping out of sight, was not again seriously debated
during the reign of James. The antiquary may still inspect a brown
and shrivelled parchment which is preserved in the Register House
at Edinburgh, all that remains of the Treaty of 1607. The time had
not yet come when the Parliaments of the two nations were to see
that it was impossible for the resources of Scotland to be developed
while she remained separate from England, and that it was equally
impossible for England to attain a position of permanent security so
long as Scotland remained poor and discontented, debarred, by
commercial restrictions, from the advantages of trade with the
colonies and with England, and with no outlet for that splendid
energy of her people which, after the Union, changed the Lothians
from a desert to a garden, made Edinburgh famous throughout
Europe as a school of letters, and founded on the banks of the Clyde
one of the great commercial cities of the world.
The question of naturalisation, which could not be left
undecided, was settled by the judges in a test case in the law courts.
The action related to a tenement in Shoreditch, and the point at
issue was whether the plaintiff, a child born in Scotland since the
Union of the Crowns, was an alien, and, therefore, not entitled to
bring an action for real property in England. Bacon was the leading
counsel for the plaintiff; and the most important opinion was
delivered by Lord Chancellor Ellesmere. The Court, by a majority,
found for the plaintiff, holding that all the post-nati, or persons born
in Scotland since the Union of the Crowns, were naturalised and
entitled to all the rights of Englishmen in England. The ante-nati,
those born in Scotland before the accession of James, still remained
in the position of aliens.[67]
The effects of the removal of the Court to London were
apparent in Scotland for many years to come. The houses of the
nobles and the gentry were neglected. Gardens and pleasure-
grounds, which had begun to appear in some places, were allowed
to run to waste. The inns, poor at all times, fell into ruins. Merchants
found their business at a standstill; and the shipping trade
languished. What made all this peculiarly galling to the Scottish
people was that England, though not occupying under the Stuarts
the lofty position which she had occupied under the Tudors, was,
year after year, enlarging her bounds and adding to the sources of
her wealth. On the southern side of the Borders, the industries of
Yorkshire were showing signs of what they were to become. The
East India Company, now firmly established, was extending its
operations. Far across the seas Nova Scotia was colonised by
Scotsmen whom poverty had driven from their homes; and the
plantations of Virginia became a rich addition to the resources of the
English Crown. And besides suffering from the evils of poverty,
Scotland was harassed almost from the day on which James
ascended the throne of England by those ecclesiastical disputes
which plunged the country into so much misery during the
seventeenth century.
The king had been compelled, by the force of public opinion in
England, to abandon the Union. But with the object to which he
devoted the rest of his life even those Englishmen who doubted the
wisdom of his policy were inclined to sympathise. The Scottish
Reformation, unlike that of England, had been the work of the
aristocracy, in opposition to the Crown. It had, at the same time,
been a deeply religious movement; and these two forces, working
together, had developed, as the distinguishing features of the
Reformed Church of Scotland, a denial of the royal supremacy in
ecclesiastical affairs, and the assertion of the spiritual independence
of the Church. Sir James Mackintosh has said that the peculiar
theories of Berkeley were a touch-stone of metaphysical sagacity,
meaning, apparently, by this phrase, that those who were without it
could not understand the meaning or the tendency of those theories.
In like manner, spiritual independence is the touch-stone of a
capacity for understanding the history of the Scottish Church. The
words “spiritual independence” expressed for Scotsmen what was,
on the one hand, a part of their constitutional law, set forth in the
statutes of the realm, and on the other hand, an article of faith,
received by the people as an essential part of their religion, involving
the principle of loyalty to the great founder of the Christian faith, as
the only head of the Church. They believed—and for this belief
thousands laid down their lives—that there were two authorities, the
one civil and the other spiritual. Both were based upon a divine
sanction; and each was to be obeyed within its own sphere. The civil
magistrate was to bear rule and to be obeyed in civil affairs; but if
he attempted to interfere with the spiritual jurisdiction of the Church,
he was to be resisted to the death. This principle of spiritual
independence, which, neither at the Union of the Crowns, nor at the
Union of the Kingdoms, nor during that memorable crisis which, in
the middle of the nineteenth century, rent asunder the Church of
Scotland, Englishmen were able to understand, was taught in the
first Confession of Faith drawn up by the Scottish Reformers, and
laid before the Estates in 1560.[68] After some years, when the long
controversy between the king and the Church had begun, the two
jurisdictions, civil and ecclesiastical, were still more carefully defined.
[69]

Principles such as these were intolerable to James. By the law of


England the king was head of the Church; and it was, therefore, his
policy to introduce an uniformity of ecclesiastical government over
the whole island. For more than twenty years before the Union of
the Crowns he had been engaged in fighting the Scottish clergy.
Sometimes he won, and sometimes he was defeated. The great
point at issue was whether the Scottish Church was to be
Presbyterian or Episcopal; for he had found that if the Presbyterian
system was allowed to exist, the royal supremacy would never be
acknowledged in Scotland. Accordingly he came to the throne of
England with a firm resolution that he would use his new position so
as to secure the establishment of Episcopacy in the north; and,
though he artfully concealed it, we may be sure that one of his chief
reasons for proposing the Union was that he believed it would be
followed by the accomplishment of this object. Henceforth the policy
of extending the Anglican system to Scotland became the hereditary
policy of the Stuarts. Three years after the Union of the Crowns, the
boldest leaders of the clergy having been driven into exile, the
Scottish Parliament acknowledged the royal supremacy over all
persons and all causes. It was not long before Episcopacy was
established; and James had the gratification of seeing a few of his
new bishops humbly consenting to receive consecration from the
hands of English prelates, and returning to Scotland to confer upon
their brethren the virtues of the apostolical succession. But the
system which was thus set up had no hold upon the people. It would
be impossible to point out in the catalogue of Scottish bishops the
names of a dozen men who were either popular, or famous for
learning, or eminent on account of their public services. The history
of Christendom contains no story so humiliating as the story of
Prelacy in Scotland during the seventeenth century.
The real meaning of the struggle between the Scottish people
and the English Government which followed the Union of the Crowns
cannot be understood unless we remember that, for most of those
who suffered, the question at issue was a question of conscience. It
is easy to find upon the surface of these events the materials from
which to construct an explanation of a different kind. Envy at the
sight of so much power in the hands of the priesthood, and the love,
so strong in the Scottish character, of freedom from control, might
influence some. But no one who looks below the surface, or reads
the history of that period with an impartial mind, can fail to perceive
that what brought the people of Scotland into a position of such
stern antagonism to the English system of Church government, and,
still more, what kept them there, was the fact that to accept
Episcopacy was to give up spiritual independence, to admit the royal
supremacy, and to abandon the principle of a divine head of the
Church. It was for that principle that men and women died during
the period between the Restoration and the Revolution, and not
merely in defence of one form of Church government against
another. And in the meantime, during the first half of the
seventeenth century, it was the obstinate and persistent tyranny of
James, and the infatuation of Charles the First and his advisers,
which roused that memorable outburst of national resentment which
scattered their policy to the winds. An uniformity in Church
government and in ritual was the end aimed at by Charles and Laud.
That end was, indeed, so far accomplished; but not by them. Having
resolved to extend the Anglican system permanently to Scotland,
they lived just long enough to see the Scottish system on the point
of being extended to England, and the two kingdoms suddenly
bound together by that solemn league which, conceived, though it
may have been, in a spirit of intolerance, was nevertheless, for more
than two generations, the watchword of the Whigs of Scotland, who
afterwards, through the years of darkness and tempest, held high
the blue banner of the Covenants, the rallying-point of Scottish
freedom.
During a few years the Presbyterian Church was established,
and the ecclesiastical affairs of Scotland were administered in
accordance with the long-cherished aspirations of the native clergy.
But the alliance between the English Parliament and the Scottish
Parliament and Church did not long survive the execution of Charles.
Their ideas had always been different. “The English were for a civil
league, we for a religious covenant,” Baillie had written six years
before. The Scottish Parliament protested against the execution. The
Scottish Church was willing to receive Charles the Second, if he
would declare himself a Presbyterian and sign the Covenants. “If his
Majesty,” Baillie writes, “may be moved to join with us in this one
point, he will have all Scotland ready to sacrifice their lives for his
service.” Charles consented. He subscribed the Covenants, and
bound himself, by an oath, to maintain the Presbyterian Church. But
the royal cause was hopeless. Cromwell’s victory at Dunbar was a
crushing blow; and the battle of Worcester left Scotland at the mercy
of the English army.
CHAPTER III
THE UNION DURING THE COMMONWEALTH
When the battle of Worcester was fought exactly a year had passed
since the battle of Dunbar. The events of that year were not such as
to reconcile Scotland to the Union which was now proposed by the
Government of England. All trade between the two countries had
been forbidden. Edinburgh had been taken, the royal palace of
Holyrood, turned into barracks, had been set on fire through the
carelessness of the soldiers, and almost totally destroyed. The
churches had been desecrated, their pulpits and seats torn down
and used as firewood. The edifice which George Heriot had directed
his executors to raise for the benefit of the poor of Edinburgh was
seized, while still in the builder’s hands, and turned into a military
hospital. The castle had been surrendered into the hands of the
invader. In the Parliament House, English troopers prayed and
preached. The garrison of Stirling Castle had capitulated; the public
records of the kingdom had been removed to the Tower of London;
and the whole country south of the Forth and Clyde was subdued.
Dundee held out to the last; but just two days before the battle of
Worcester the town was stormed by Monk.
The slaughter at Dundee, and the news brought home by those
who had escaped from the field of Worcester, extinguished all hopes
of further resistance. In the Highlands alone there remained some
faint show of adherence to the cause of the Stuarts, which
afterwards found an outlet in the rising under Glencairn; and the
Marquis of Argyll strove, for a time, to stem the tide which was
overwhelming Scotland. But, to all intents and purposes, the country
was now thoroughly subdued.
Eight commissioners, among whom were young Sir Harry Vane,
Lambert, and Monk, were appointed to arrange an Union. They
found everything in confusion. The last meeting of the Scottish
Parliament had taken place on the 6th of June. The Court of Session
had not sat since February 1650. Many towns were without
magistrates. The Church was torn by internal dissensions. When
proclamation was made, at the market-cross of Edinburgh, that
Scotland was to be united, in one Commonwealth, with England, the
announcement was received in gloomy silence. But there was an
under-current of feeling in favour of the Union, of which the
commissioners were doubtless aware. Delegates from the counties
and burghs were summoned to meet at Dalkeith, to consider the
Tender of Union which the commissioners were empowered to offer
on behalf of the Parliament of England; and the result was that, of
thirty-one counties, twenty-eight, and of fifty-eight burghs, forty-four
assented to the Union.[70] Their assent must in some degree be
ascribed to motives of prudence; for it was known that those
counties and burghs which failed to send delegates favourable to
union would be disfranchised; but it was from Glasgow alone, which,
more than any other place in Scotland, was ultimately to benefit
from the Union with England, that any formal and serious objection
came. By some a scheme was suggested, which Fletcher of Saltoun
would have warmly supported in 1707, for declining an incorporating
Union and making Scotland a republic in friendly alliance with
England. But the proposers of this scheme, one of whom was the
noted Covenanter, Sir Archibald Johnston of Warriston, ultimately
agreed to the Union.
The chief opponents of the new arrangement were the clergy. It
was on the 23rd of February 1652 that the delegates assembled at
Dalkeith; and on the following day Baillie writes: “All the ministers of
Edinburgh prays still for the king, and preaches very freely and
zealously against the way of the English; this they are very angry at,
and threatens to remeed it.” But the ministers were divided against
each other. Some resisted the Union because they were Royalists,
some because they could not tolerate the idea of uniting with a
country in which the Independents and other “Sectaries” had so
much power, and others because they thought that the result of the
Union would be that the Church would become subordinate to the
State. But their resistance was of no avail; and they could only
lament the defection of so many of the laity. “Good Sir John Seaton,”
Baillie writes in reference to the Conference at Dalkeith, “was the
first that subscribed his free and willing acceptance of the
incorporation for East Louthian. The two Swintons followed for the
Merse, Stobs for Tiviotdale, Dundas for West Louthian, William
Thomson and Fairbairne, I think, have done the like for Edinburgh,
and its like almost all burghs and shyres will, under their hand,
renounce their Covenant; Glasgow and the West purposes to refuse,
for which we are like deeply to suffer; but the will of the Lord be
done.”[71]
The result of the meeting of delegates was reported to
Parliament; and the Council of State was instructed to prepare a Bill
for the union of the two countries. Deputies were sent from Scotland
to Westminster to adjust the details of the measure, and, in
particular, to fix the number of members who were to represent
Scotland in the Parliament of the United Commonwealth. A series of
conferences were held between these deputies and a Committee of
Parliament, at which the demands of Scotland were discussed. There
was great difficulty in settling the question of representation.[72] The
English proposal was that, in the united Parliament, England should
be represented by four hundred members, Scotland by thirty, and
Ireland by thirty. The number of commoners in the Scottish
Parliament had been one hundred and twenty; and the deputies
wished sixty Scottish members to have seats in the House of
Commons. The English Government, however, refused to admit more
than thirty. This was agreed to; and the Union Bill was about to
pass, when, on the 20th of April 1653, Cromwell put an end to the
Long Parliament.
In the Little Parliament, Barebones’ Parliament, Scotland was
represented by five members, and some progress was made in the
matter of the Union. It was resolved that there should be complete
free trade between England and Scotland. The Government ordered
all money raised in Scotland to be spent in Scotland for local
purposes;[73] and that on the passing of the Union Bill, an
enactment, which had come into force three years before, under
which all Scotsmen were banished from England, should be
repealed.[74] But the further progress of the Union Bill came to an
end when Parliament was dissolved, and the control of all affairs
passed into the hands of Cromwell as “Lord Protector of the
Commonwealth of England, Scotland, and Ireland,” a title which
assumed that the Union had already taken place.
In the following spring an ordinance was framed for completing
the Union. It set forth that the people of Scotland, having been
invited to unite with England, had, through their deputies, accepted
the invitation; that Scotland was, therefore, to be now incorporated
and declared one Commonwealth with England; and that, in every
Parliament which was held for the Commonwealth, thirty members
were to serve for Scotland. To secure the more effectual
preservation of the Union, and the freedom of the country, the
people of Scotland were relieved from all allegiance to the Stuarts.
The title of King of Scotland was abolished. The right of the Estates
to assemble in Parliament was annulled. It was ordained that, “as a
badge of this Union,” the arms of Scotland should form a part of the
arms of the Commonwealth; and that all seals of office, and the
seals of the corporations in Scotland, should henceforth bear the
arms of the Commonwealth. All taxes were to be levied
proportionably from the whole people of the Commonwealth.
Vassalage was abolished, and lands were to be held by deed or
charter for rent. The whole system of hereditary jurisdictions, by
which there had been transmitted from father to son, in many
families of the landowners, the power of holding courts and inflicting
punishments, even that of death, was swept away. An immense
boon was conferred on Scotland by the establishment of complete
free trade between the countries, and by the declaration that in all
matters relating to commerce England and Scotland were
thenceforth equal.[75]
This ordinance was proclaimed at Edinburgh on the 4th of May
1654. The town-cross, at which the ceremony took place, was
surrounded by troops under the command of Monk. An immense
crowd of the townsfolk assembled to witness the proceedings. The
Lord Provost and the Magistrates, clad in their scarlet robes, were in
attendance. Henry Whalley, Judge Advocate to the English army,
read the proclamation; and at the conclusion of the ceremony, Monk
and his friends were entertained at a sumptuous banquet in the
Parliament House, where the Magistrates stood and served them.
Later in the evening there was a display of fireworks at the town-
cross.
The Union having been thus proclaimed, the Council of State at
Whitehall proceeded to arrange the distribution of seats in Scotland.
[76]
Of the thirty seats, twenty were allotted to the counties, and ten
to the burghs. The more populous counties each returned a member.
The rest were divided into groups. Of the burghs, Edinburgh alone
returned two members; but all the other towns were grouped into
districts.
When the Protector’s first Parliament met, in July 1654, twenty-
one members from Scotland attended. Of these, both the members
for Edinburgh, and several others, were Englishmen; and while the
Union lasted, the members from Scotland were either quiet and
peaceful Scotsmen, ready to support the Protector’s measures, or
English officials.[77]
The Council in Scotland managed the elections there. The full
number of thirty members was returned to the Parliament of 1656;
but many of them were Englishmen. Argyll opposed the Council, and
endeavoured to secure the return of Scotsmen only, but in vain. He
failed to obtain a seat himself until Richard Cromwell’s Parliament of
1658, when thirteen county and eight burgh members seem to have
attended. Argyll then represented Aberdeenshire in the House of
Commons; but the members for Perthshire, Inverness-shire,
Linlithgow, Stirlingshire, Clackmannan, Dumbartonshire, Argyllshire,
Bute, and Midlothian were all Englishmen; and a majority of the
burgh members came from Westminster or the Inns of Court.[78]
The executive government in Scotland, during the Union, was
vested in a Council of State, to whom elaborate instructions were
issued by the Protector. They were to inquire into the best means for
preserving the Union; to promote the cause of religion, taking care
that the clergy were regularly paid, and that all schools had able and
pious teachers; to encourage learning and reform the universities; to
remove from the corporations disaffected or ill-behaved magistrates,
and replace them by suitable persons; to see that equal justice was
administered to all men, and to promote the Union by assimilating
the procedure in the courts of Scotland to that of the courts of
England; to investigate the state of the revenue, and see that the
Exchequer was not defrauded; to study economy in the public
service; to encourage the fishing industry, the manufactures, and the
commerce of Scotland.
The Council consisted of nine members, of whom only two,
Lockhart and Swinton, were Scotsmen. Roger Boyle, Lord Broghill,
third son of the Earl of Cork, was President, with a salary of two
thousand pounds a year; and the great Scottish offices of State,
most of which were retained, were generally filled by Englishmen.
Lord Broghill appears to have been popular. “He has gained,” Baillie
writes, “more on the affections of the people than all the English
that ever were among us.”[79]
An army of English soldiers, nearly as numerous as that which
occupied Ireland, was spread over Scotland. Forts were built at
Leith, Glasgow, Ayr, and Inverness; and the castle of Inverlochy was
repaired and filled by a garrison which overawed the Western
Highlands. The strictest discipline was maintained. “I remember,”
Burnet says, “three regiments coming to Aberdeen. There was an
order and discipline, and a face of gravity and piety among them,
that amazed all people.” Burnet attributes the flourishing state of
Scotland during the Union to the money spent by the army; so does
Fletcher of Saltoun. And it must have had a considerable effect on
the financial state of the country, as the pay of the troops amounted
to two hundred and fifty thousand pounds yearly, an immense sum
for the Scotland of those days.
In the judicial system sweeping changes were introduced. The
exercise of jurisdiction in Scotland was prohibited, except under the
authority of the Parliament of England. The powers of the Court of
Session, the supreme tribunal of the country, were handed over to a
bench of Commissioners for the Administration of Justice to the
People of Scotland. These judges were seven in number, four
Englishmen and three Scotsmen. At first the Scottish Bar joined the
clergy in opposing the Union, and refused to plead; but by the
autumn of 1656 most of the advocates had returned to business.
The manner in which the “English judges,” as the
Commissioners were called, performed their duties seems to have
given great satisfaction. The Court of Session had been so tyrannical
and corrupt that the fairness and purity of the new Court astonished
the country. “Justice,” we are told, “was wont to be free and open
for none but great men, but now it flows equally for all.” Circuit
courts were held throughout the country; and, while crime was
firmly punished, the extreme severity of the Scottish criminal system
was avoided. Prosecutions for witchcraft were still frequent, but the
English judges received the evidence with suspicion; and on one
occasion no less than sixty persons, whom the superstition of their
own countrymen would have condemned to the flames, were
acquitted.
The merchants of Scotland were, by the terms of the Union,
admitted to all the trading privileges which Englishmen enjoyed.
Goods of every description passed duty-free from England to
Scotland and from Scotland to England; and there was no restriction
on the foreign and colonial trade of Scotland. But these advantages
were not fully appreciated; for Scottish commerce was still in its
infancy. The Glasgow of to-day, with its miles of wharves and
warehouses, its forest of masts, its shipbuilding yards, its crowded
streets and handsome squares, had no existence. The merchants of
the small town upon the Clyde traded with Ireland, in open boats,
for meal, oats, and butter. They shipped coal, herrings, and woollen
goods to France in exchange for paper and prunes. They sent to
Norway for timber, and to Barbadoes for sugar. But the river Clyde
was then so shallow that their ships could not come nearer to the
town than a spot fourteen miles distant, where they were unloaded,
and the cargoes carried up the river on rafts or in small boats.
The English were astonished at the poverty of Scotland. The
whole revenue from Customs and Excise was under fifty thousand
pounds a year.[80] A monthly assessment of seventy thousand
pounds was levied in the towns and counties of England, while
Scotland was assessed at only six thousand pounds. The yearly
expenditure in Scotland exceeded the revenue; and the balance was
paid out of the English treasury. Nevertheless the time of the Union
during the Commonwealth was regarded as a time of prosperity. The
trade of Glasgow began to flourish. Leith, then the chief port in
Scotland, Dundee, and Aberdeen made considerable progress in
wealth; and there can be little doubt that if the commercial policy of
Cromwell had not been reversed at the Restoration, the merchants
of Scotland would have made, during the second half of the
seventeenth century, that remarkable advance towards opulence and
importance which they made after the Union of 1707.
When, fifty years later, the Union was finally accomplished, one
of the most difficult questions which the statesmen of the two
countries had to discuss was the question of the Church. But the
ordinance of April 1654 contains no reference to that question. The
Council for Scotland was instructed, in general terms, to promote the
cause of religion, and to see that the clergy were paid regularly; but
no formal settlement was attempted. Though the stipends of the
Scottish clergy were small, their social position was far higher than
that of the English clergy. They associated, on terms of equality, with
the first families of the laity, and so great was their influence that, if
they had been united among themselves, they might have held their
own against the Independents who came to Scotland with Cromwell.
But they were powerless, because they were divided, split up into
two parties, and engaged in a dispute which was conducted with a
warmth unusual even in the quarrels of Churchmen.
This dispute had its origin in the Engagement for the relief of
Charles the First. The Scottish Parliament of 1649 had passed an Act
which declared all those who approved of the Engagement incapable
of holding any public office.[81] This statute, known as the Act of
Classes, had incapacitated a number of persons from serving in the
army. After the battle of Dunbar, the General Assembly passed
resolutions in favour of readmitting to the public service, particularly
in military employments, those who had been proscribed; and
Parliament, taking the same view as the majority of the clergy,
repealed the Act of Classes. Against this the defeated minority of the
clergy protested. Two parties were formed, the one known as
Resolutioners, and the other as Protesters; and the contest passed
from the ranks of the clergy to the ranks of the people. Which party
had the larger following among the people it is difficult to say; but,
apparently, while the Resolutioners formed a majority of the clergy,
the Protesters were more popular, especially in the south-western
counties, afterwards the stronghold of the Covenanters during the
period which followed the Restoration.
The Church of Scotland was rent in twain, and there were two
factions in almost every parish. The induction of a minister was
seldom accomplished without opposition; and on many occasions
disgraceful scenes took place in the churches, riots, stone-throwing,
and even bloodshed. The differences between the parties extended
from the original cause of quarrel to questions of rites and
ceremonies, always a fruitful source of bad feeling. The country was
flooded with controversial pamphlets, in which the disputants
attacked each other in the most acrimonious terms. One of the
Protesters, indeed, a young divine named Binning, published a book
on Christian Love, in the hope, apparently, of preparing the way for
a reconciliation, but his advances were rejected with scorn.
Some members of the Council of State proposed that means
should be taken to re-unite these factions; but Vane advised a very
different course. Let them fight it out, he said, in the inferior courts
of their Church. By this means their attention will be diverted from
secular matters, with which they are too fond of interfering, and
confined to their own private squabbles. At the same time, if we
forbid the General Assembly to meet, they will be powerless for
either good or evil. This policy was carried into effect. The Assembly
met at Edinburgh, and the members were about to proceed to
business, when an officer entered, and asked by what authority they
had met. Was it by the authority of the Parliament of England, or of
the commander of the English forces, or of the English judges in
Scotland? The ministers answered that the Assembly was an
ecclesiastical court, deriving its authority from God and established
by the law of the land. The officer said that he had orders to
dissolve the meeting, and ordered those present to follow him, or he
would drag them by force out of the room.
Uttering protests against this violence, the members rose and
followed him. A guard of soldiers surrounded them, and led them
along the streets, “all the people gazing and mourning, as at the
saddest spectacle they had ever seen.” Presently a halt was called.
The names of the ministers were taken down; and they were told
that all future meetings were forbidden. On the following morning,
by sound of trumpet, they were commanded to leave the town, on
pain of instant imprisonment if they disobeyed.[82]
In this summary fashion the supreme court of the Church of
Scotland was dissolved; and while the Union lasted the English army
was supreme in Church affairs. The clergy were forbidden to pray for
the king, and ordered to pray for the Protector. This order was at
once obeyed by the Protesters; but the Resolutioners did not submit
until they were informed that their stipends would be withdrawn,
when they came to the conclusion that as the king could not protect
them nor pay them they need no longer pray for him.
Excommunication lost its terrors when the secular arm could no
longer be invoked to give civil effect to the sentence of a Church
court. The stool of repentance, which stood in every church, and on
which sinners had to sit and listen to a public rebuke, was derided
by the rough troopers, who either broke it to pieces, or sat on it
themselves, to show their contempt for a kind of discipline which
was akin to penance in the Church of Rome. The English soldiers did
not admire either the Church or the religious character of the Scots.
“A Kirk whose religion is formality, and whose government is tyranny,
a generation of very hypocrites and vipers whom no oaths or
covenants can bind, no courtesies or civilities oblige,” was their
verdict.[83] Magnificent and fruitful of results as the Covenanting
movement was, there can be no doubt that side by side with the
genuine religious devotion of some there was to be found the deep
hypocrisy of others. Cromwell saw this at once, and complained that
where he had expected to find “a conscientious people,” he had
found one “given to the most impudent lying and frequent swearing,
as is incredible to be believed.”[84]
The persecuting principles of the Scottish clergy, too, alienated
the Independent ministers who accompanied the army. Even so
good a man as Samuel Rutherford argued against toleration with
almost as much bigotry as Edwards had displayed in the Gangræna;
and Baillie lamented that “the hand of power is not heavy on any for
matters of religion.”[85] Principles such as these were, of course,
hateful to the Independents, with whom liberty of conscience was an
article of faith; and the fact that such principles were held by the
Scottish clergy was one of the chief reasons why, during the
Commonwealth, the Scottish Church was powerless.
Among the duties intrusted to the Council of State for Scotland
were the encouragement of learning and the reform of the
universities. Commissioners visited the universities, and changes
were made. Resolutioners were turned out, and Protesters put in
their places. Leighton, afterwards Bishop of Dunblane, became
Principal of Edinburgh University. At Glasgow, Patrick Gillespie was
appointed against the remonstrances of Baillie and his party; but
even Baillie afterwards admitted that the appointment was a wise
one. “The matters of our college,” he writes, “this year were
peaceable; our gallant building going on vigorously; above twenty-
six thousand pounds are already spent upon it; Mr. Patrick Gillespie,
with a very great care, industrie, and dexterity, managing it as good
as alone.” A grant of two hundred pounds a year was made to the
Universities both of Edinburgh and of Glasgow; and before his death
the Protector had taken the first steps towards founding a College of
Physicians for Scotland.
In 1659 it was resolved to put the Union, the terms of which
rested only on the ordinance promulgated by Oliver Cromwell five
years before, on a more constitutional footing; and for that purpose
two Bills “for perfecting the Union between England and Scotland”
were brought into Parliament.[86] But neither of these Bills became
an Act of Parliament; and at the Restoration, the Union came to an
end.
As to the general effect of this Union on the state of Scotland
we have conflicting accounts; but the weight of evidence goes to
show that it was a time, not only of quiet, which has never been
denied, but also of prosperity. Baillie tells a dismal tale. The peers
were in exile or reduced to poverty; the people were burdened by
heavy taxation, and suffering from want of money and want of
trade. But Baillie was a Resolutioner; and the Protesters were
favoured by the Government. Therefore, for Baillie, the times were
out of joint, and he exclaims, “What shall we do for a testimony
against the English?” Yet he is forced to admit that food was cheap
and plentiful; and he gives an account of the state of Glasgow,
where he lived, from which it appears that the town was highly
prosperous. The magistrates were rapidly paying off the public debt,
and spending money on public works.[87]
To the historian Kirkton, who was on the other side, everything
seemed bright. It was a period of “deep tranquillity.” Every parish
had a minister; every village had a school; almost every family had a
Bible. The voice of singing and of prayer was heard in every house.
From the taverns alone came the sound of lamentation; for the
happiness and sobriety of the people were such that the trade in
strong drink was ruined.[88]
Burnet agrees with Kirkton. “We always reckon,” he says, “those
eight years of usurpation a time of great peace and prosperity.”
Defoe took special pains to make himself acquainted with the affairs
of Scotland, and the information which he received was to the same
effect. “Scotland flourished, justice had its uninterrupted course,
trade increased, money plentifully flowed in.”[89] Cromwell himself, in
1658, gave a favourable account of the state of things, on which
Carlyle’s comment is, “Scotland is prospering; has fair play and
ready-money;—prospering though sulky.”[90]
In England the Union, if not unpopular, was regarded with
indifference. In the Protector’s “House of Lords” there were three
Scotsmen, Lord Casselis, Sir William Lockhart, and Johnston of
Warriston, the last of whom seems to have wearied the House with
long and frequent speeches. In the House of Commons the
members from Scotland gave no trouble, and are said, indeed, never
to have opened their lips. The commercial advantages, however,
which Scotland had secured by the Union caused great jealousy
among the English merchants; and on the English side of the border
the establishment of free trade between the countries was viewed
with disfavour. But, on the whole, the broad current of English life
flowed on, undisturbed by the existence of the Union.
CHAPTER IV
FROM THE RESTORATION TO THE
REVOLUTION
At the Restoration the advisability of continuing the Union was
discussed. In England it was maintained that the smaller country
must give up its Parliament and its separate system of laws, or that
it must, at all events, make the first advance, and say definitely on
what terms it would unite. In Scotland it was foreseen that not only
would the native Parliament and the native laws be destroyed in the
event of a union, but that also, in all probability, the Church would
be sacrificed. But the prosperity which the country was beginning to
enjoy might have reconciled many of the people to these changes.
[91]

The Restoration was hailed with joy by the nobles, who hoped
that they would again have their Parliament and their Privy Council,
by means of which their families were aggrandised, and their
hereditary jurisdictions and feudal rights, which gave them so much
authority over their tenants and retainers. The clergy, smarting
under the indignities to which they had lately been subjected, and
believing that Charles would keep faith with them and establish
Presbytery, welcomed the change, and at once began to pray again
for the king. Clarendon, however, was of opinion that the majority of
Scotsmen were in favour of the continuance of the Union. He himself
was in favour of leaving things as they were. “But the king,” he says,
“would not build according to Cromwell’s models, and had many
reasons to continue Scotland within its own limits and bounds, and
sole dependence upon himself, rather than unite it to England with
so many hazards and dangers as would inevitably have accompanied
it, under any government less tyrannical than that of Cromwell.”[92]
Lauderdale, whose influence in Scottish affairs was now well-
nigh supreme, was strongly in favour of removing all traces of the
Commonwealth government. To begin with, he insisted that the
fortresses which Cromwell had built should be demolished and their
garrisons withdrawn. The time might come, he told the king, when
he would be in need of Scottish garrisons in England, and to
maintain an English army in Scotland would alienate the affections of
the Scottish people. The fortresses were, accordingly, dismantled,
and the army of occupation was disbanded. Every trace of the Union
soon disappeared. The Estates met in the Parliament House once
more; and the judges took their places on the bench of the Court of
Session.
On the question of the Church, Lauderdale’s advice was not
followed. His view was that, instead of aiming at an Union, either
civil or religious, between the two countries, the object of the
Government should be to disunite them by all possible means, and,
at the same time, to keep the people of Scotland in good humour by
giving them whatever form of Church government they wanted, in
order that they might be willing to serve the king, if necessary,
against the Parliament of England. Such was the advice of
Lauderdale. Charles himself, though he detested Presbytery, was at
first inclined to take it. But, in the end, the intrigues of the Episcopal
faction prevailed; and it was resolved to establish an Episcopal
Church in Scotland. The Chancellor explained to Lauderdale that it
was intended to set up only a modified form of prelacy. “My Lord,”
he sternly answered, “since you are for bishops and must have
them, bishops you shall have, and higher than ever they were in
Scotland.”
These words came true. If the statesmen of England had asked,
By what means shall we most easily irritate and exasperate the
Scottish people? how can we alienate them from England? how can
we render the royal family unpopular? how can we destroy the trade
of Scotland, which is beginning to improve? how can we throw the
country, which is settling down, back into anarchy and confusion?
how can we most successfully unite against the Church of England
the whole body of the Scottish people? how can we produce a
profound distrust in all measures which are proposed by the Council
in London? by what means, in short, can we best make the people
of Scotland disloyal, poverty-stricken, and rebellious?—if these
questions had been asked, some evil councillor might have answered
them thus: Pass, he might have said, an Act of Parliament which will
destroy their commerce; abolish the Union, and thus destroy free
trade between them and the English; restore to the owners of the
soil the jurisdictions by means of which they tyrannised over their
dependants in the past, and by means of which they will be able to
tyrannise over them in the future; restore the tenure of lands by
military service, and thus you will, in a few years, people every
hamlet over a large portion of the country with restless and idle
clansmen, whose only business in life is to foment feuds between
their masters, and to seek plunder for themselves; above all things,
let the king destroy the Presbyterian Church which he swore to
establish when he took that solemn vow, on the faith of which the
crown of Scotland was placed upon his head; let the great noble
whose hands performed the act of coronation, and to whom a
Dukedom and a Garter were promised, be accused of treason for a
tardy compliance with the usurper, and let the rules of legal
procedure be strained in order to procure his condemnation; eject
from their livings the clergy whom the people trust; let enormous
fines, far in excess of what the country can bear, be inflicted on
every class for the offence of nonconformity; punish with death
those who listen to the clergy preaching in the fields because you
have driven them from the churches. All this, and a great deal more,
was done. The years which followed the Restoration were the most
miserable in the history of Scotland. The great source of misery was
the desperate contest between the Episcopal and the Presbyterian
Churches; but the commercial policy of the English Parliament is
what chiefly bears on the question of the Union.
Scotland had not suffered from the Navigation Act of 1651,
which forbade foreign ships to import goods into England, or to
trade with the colonies, or even to visit them without special leave.
This statute was passed, in the words of Blackstone, “to punish our
rebellious colonies, and to clip the wings of the Dutch.” It kept the
colonial trade in the hands of England, and increased the value of
English shipping. The terms of the Union during the Commonwealth
had exempted Scotland from its provisions. But now the Union was
at an end, and Scotland was once again a separate kingdom. The
Parliament of England proceeded to pass a new and even more
stringent Navigation Act, which inflicted a deadly blow upon the
trade of Scotland.[93]
Sir George Mackenzie traces the origin of this, and other laws
hostile to Scottish commerce, to the fact that Clarendon and other
English politicians were piqued by the way in which Lauderdale
prided himself on having induced the king to withdraw the army
from Scotland against their advice. “This excessive boasting,” he
says, “that he had prevailed in this over Hyde, Middletoun, and all
the English, did somewhat contribute to renew the old discords
which had formerly been entertained between the two nations; and
occasioned the making of those severe Acts, whereby the Parliament
of England debarred the Scots from freedom of trade in their
plantations, and from enjoying the benefit of natives in the privilege
of shipping.”[94]
The new law was so rigorous that no goods nor produce, of any
country, could be imported into the colonies except from England or
Wales. Irish goods could not go from Ireland, nor Scottish goods
from Scotland. Moreover, the most important products of a colony
could enter England, or another colony, only on payment of duty.
English ships alone were allowed to carry goods to and from the
colonies. The sugar, the tobacco, the cotton, in fact all the most
useful produce of the colonies, could be shipped to England only,
and could not enter an English port except in an English vessel. Nor
could goods be imported into England from the continent of Europe
except in English ships, or in ships belonging to the country which
actually produced them.
This monopoly, under which the colonies could trade with
England alone, was a grievance to the colonies. They, however, had
at least the privilege of trading with England. But to the colonial
trade of Scotland the Navigation Act was ruinous.
Other laws, hostile to the industries of Scotland, were enacted.
On some Scottish goods duties were paid equal to, or above, their
value. On others a duty was charged very much greater than the
duty levied on the same articles when they came from abroad. For
instance, the duty on Scottish salt was sixteen times that imposed
on foreign salt. Linen imported from Scotland was now so heavily
taxed that it hardly paid the producer to bring it into England. In
Northumberland and Cumberland heavy customs were levied on
horses which came from Scotland; and, on the plea that a great part
of the richest pasture land in England would fall in value if the
graziers of Scotland were allowed to find a free market in England,
Parliament was induced to cripple one of the most important
branches of Scottish industry by imposing a fine of two pounds for
every head of cattle which crossed the border between the 24th of
August and the 20th of December.[95] And there were many other
enactments framed for the purpose of excluding Scottish merchants,
whose operations were further embarrassed by a law under which all
goods sent from Scotland to England must pass through either
Berwick or Carlisle.[96]
The commercial freedom which had been enjoyed during the
period of the Commonwealth had quickened the commercial instincts
of the Scottish people, and had given them some idea of what their
country might become if they were permitted to extend their traffic
to the colonies, those highly-favoured regions of the earth from
which so large a portion of the wealth of England came. The recent
Union had been attended by circumstances which were humiliating;
but for many of these compensation had been found in the
prosperity which the Union had brought along with it. The sudden
change which the Restoration had produced was, therefore, bitterly
resented; and the Scottish merchants persuaded the Estates to
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like