To THW and friends: gonuke, animal1, kmo, redbeard, spidr, slayer, nicopresto, wolfman , blackbeard, johnnyb, jdangerx, punkish, radio, crbates, 3rdbit, fastmath, and others, this one is for you.
Foreword
Right now, somewhere, a grad student is struggling to make sense ofsome badly formatted data in a bunch of folders called final,final_revised, and final_updated. Nearby, her supervisor has justspent four hours trying to reconstruct the figures in a paper shewrote six months ago so that she can respond to Reviewer Number Two.Down the hall, the lab intern is pointing and clicking in a GUI torun an analysis program for the thirty-fifth of two hundred inputfiles. He wont realize that he used the wrong alpha for all of themuntil Thursday
This isnt science: its what scientists do when they dont have theequivalent of basic lab skills for scientific computing. They spendhours, days, or even weeks doing things that the computer could do forthem, or trying to figure out what they or their colleagues did lasttime when the computer could tell them. Whats worse, they usuallyhave no idea when theyre done how reliable their results are.
Starting with their work at the Hacker Within, a grassroots group atthe University of Wisconsin that they helped found, Katy and Anthonyhave shown that none of this pain is necessary. A few basic toolslike the command shell and version control, and a few basic techniqueslike writing modular code, can save scientists hours or days of work per weektoday, and simultaneously make it easier for others (including theirfuture selves) to reproduce and build on their work tomorrow.
This book wont make you a great programmernot on its ownbutit will make you a better programmer. It will teach you how to doeveryday tasks without feeling like youre wading through mud, andgive you the background knowledge you need to make effective use ofthe thousands of tutorials and Q&A forums now available on the Web.I really wish I had written it, but if I had, I couldnt have done abetter job than Anthony and Katy. I hope you enjoy it as much as Ihave.
Gregory V. Wilson
Preface
Welcome to Effective Computation in Physics. By reading this book, you willlearn the essential software skills that are needed by anyone in a physics-basedfield. From astrophysics to nuclear engineering, this book will take you from notknowing how to make a computer add two variables together to being thesoftware development guru on your team.
Physics and computation have a long history together. In many ways, computersand modern physics have co-evolved. Only cryptography can reallyclaim the same timeline with computers as physics. Yet in spite of this shared growth,physicists are not the premier software developers that you wouldexpect. Physicists tend to suffer from two deadly assumptions:
Software development and software engineering are easy.
Simply by knowing physics, someone knows how to write code.
While it is true that some skills are transferablefor example, being able to reason aboutabstract symbols is important to boththe fundamental concerns, needs, interests,and mechanisms for deriving the truth of physics and computation are often distinct.
For physicists, computers are just another tool in the toolbox.Computation plays a role in physics that is not unlike the role of mathematics.You can understand physical concepts without a computer, but knowinghow to speak the language(s) of computers makes practicing physics much easier.Furthermore, a physical computer is not unlike a slide rule or aphoton detector or an oscilloscope. It is an experimental device that canhelp inform the science at hand when set up properly. Because computers aremuch more complicated and configurable than any previous experimental device, however,they require more patience, care, and understanding to properly set up.
More and more physicists are being asked to be software developersas part of their work or research. This book aims to make growing as a softwaredeveloper as easy as possible. In the long run, this will enable you to bemore productive as a physicist.
On the other end of the spectrum, computationalmodeling and simulation have begun to play an important part in physics.When experiments are too big or expensive to perform in statistically significantnumbers, or when theoretical parameters need to be clamped down, simulation sciencefills a vital role. Simulations help tell experimenters where to look and canvalidate a theory before it ever hits a bench. Simulation is becoming a middlepath for physicists everywhere, separate from theory and experiment.Many simulation scientists like to think of themselves as being more theoretical.In truth, though, the methods that are used in simulationsare more similar to experimentalism.
What Is This Book?
All modern physicists, no matter how experimental, rely on a computer in somepart of their scientific workflow. Some researchers only use computersas word processing devices. Others may employ computers that tirelessly collectdata and churn analyses through the night, outpacing most other members of theirresearch teams. This book introduces ways to harness computers to accomplishand automate nearly any aspect of research, and should be used as a guideduring each phase of research.
Reading this book is a great way to learn about computational physics from allangles. It will help you to gain and hone softwaredevelopment skills that will be invaluable in the context of your work as a physicist. To the best of our knowledge, another book like this does not exist. This is not a physics textbook.This book is not the only way to learn about Python and other programming concepts.This book is about what happens when those two worlds inelastically collide.This book is about computational physics. You are in for a treat!