We use cookies to distinguish you from other users and to provide you with a better experience on our websites. Close this message to accept cookies or find out how to manage your cookie settings.
To save content items to your account,
please confirm that you agree to abide by our usage policies.
If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account.
Find out more about saving content to .
To save content items to your Kindle, first ensure no-reply@cambridge.org
is added to your Approved Personal Document E-mail List under your Personal Document Settings
on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part
of your Kindle email address below.
Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations.
‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi.
‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
This text is intended as an entry-level treatment of engineering problem-solving and programming using C and Fortran, the predominant computer languages of engineering. Although C is presented as the language of choice for program development, a reading knowledge of Fortran (77) is emphasized. The text assumes that any Fortran code encountered by the reader is operational and debugged; hence, an emphasis is placed on a reading knowledge of this language. Fundamental approaches to engineering problem-solving using the computer are developed, and appendixes that serve as ready reference for both languages are included. A basic premise of this book is that the engineer, regardless of discipline, is more interested in fast program prototyping and accurate data outputs than in program elegance or structure. The novice engineering programmer is concerned principally with modeling physical systems or phenomena and processing accurate data pertaining to those systems or phenomena. These are basic tenets of engineering programming that are subscribed to in this book.
In the introductory chapter, an understanding of basic computer architecture using the von Neumann model is developed as a register–ALU–memory (Arithmetic Logic Unit) transfer system. This concept is then integrated into an explanation of Tannenbaum's virtual machine hierarchy to illustrate the multiple levels of translation and interpretation that exist in modern computers. The relationship of programming languages to this hierarchy is then explained through diagrams and illustrations to enable the reader to develop a strong mental picture of computer function through language.
In this final chapter we examine two programs that have a fair degree of complexity and will serve to bring together many of the concepts of the text. The first program is an adaptation of a simpler program to compute either the height of the tide, given a time of day, or the time that the tide will be at a given height. This type of program finds use in many applications of ocean engineering and is called a modeling program, for it models the behavior of a physical phenomenon. Modeling is related to simulation, in which case the computer is used to simulate a process or device. The techniques of computer modeling and simulation are major aspects of engineering practice because they allow us to design and analyze systems in the laboratory before making a high-value commitment to a physical prototype. Modeling and simulation are also useful when working in potentially dangerous and hazardous environments to evaluate risk and develop protective appliances and procedures for personnel who may be exposed to those environments.
The second program shows you how to use a console to plot functions in time. This type of programming is called visualization and entails the use of the computer to enhance the presentation of data for analysis or design purposes. Visualization is used in all fields of engineering practice primarily owing to the huge volume of data that engineers must deal with on a day-to-day basis.
Interpretation of data is an important element in the process of describing how the computer acts upon data. If this interpretation is faulty, control structures will not operate properly or data will be misrepresented on output. The definitions of Fortran and C types were explained in Chapter 3; however, the underlying assumption was that types of variables would not be mixed. In other words, calculations involving real variables would only use real variables, and those involving integers would only use integers. Also, the size of variables, or how large a value a variable can hold, was not considered in any detail other than the observation that a double variable is twice the size of a float, and so forth. This chapter will explore the nature of type mixing and the importance of knowing the usage rules for type conversion.
As you know, a program is a set of instructions to perform a task. Large tasks can require programs of huge scope and size; thus, it is useful to be able to partition programs into logical segments. Subroutines or functions represent a useful way to achieve the partitioning of programs to add readability, manageability, and overall structure to a program. This is not all that functions allow us to achieve, for they also save the programmer from useless repetition of program code that is used often and in various places in a program. Finally, they allow for an elegant and efficient way to include mathematical functions in computer programs.
Access to files allows a program to exploit the largest memory subsystem available to contemporary machines, that of the hard disk, CDROM, or tape drives. The file, regardless of which type of media that it resides on, can be thought of as a massive array of data. You can read from this data source, write to it, and create new instances and eliminate them from within your programs. Two primary modes of access to files are available: the low-level operations that work with bytes of data, and high-level operations that utilize data streams to store and retrieve the values of variables. We explore both methods in this chapter.
Low-Level File Operations
A file can be considered a document that has been stored and that will be accessed as a stream of bytes, such as depicted in Figure 7.1. Files are operating system (OS) resources, and requests must be made to the operating system for access to them. The operating system assigns a filename to a file, and the specifics of what characters are permitted in the name as well as the length are system-dependent. Typically, filenames have a prefix and suffix, and by now you have probably encountered this in your programming. The prefix describes the contents of the file, such as “myprog,” to describe a program that you are writing. The suffix indicates the type of file, such as “.c” for C source or “.for” for Fortran source, and so on.
It is useful to be completely at home with the properties of waves because they occur in so many different fields of physics. Thus quantum mechanics, optics, electromagnetism, stretched strings and membranes, seismology and sound are just some of the topics in which waves are very common. Even from the limited viewpoint of doing well in examinations, it pays to learn about waves because they are likely to occur in many different types of physics problems, as well as in mathematics papers.
For concreteness, most of the language we will use will be that for transverse waves on an elastic string; with suitable modification it can be applied to other types of examples. The string is taken as lying along the x axis when no wave is present, and in order to avoid end-effects will usually be assumed to extend to infinity in both directions. The transverse displacement is in the y direction. Thus we are interested in how y varies as we look at the wave; it will be a function of both the position x along the string and the instant t that we look at it.
Waves can usually be of almost any shape. For example, we could arrange that the initial displacement on the string (i.e. what would be seen in a photograph of the string) looks like a single square pulse, an infinite repetition of square pulses, five cycles of a sine wave, some arbitrary complicated shape, or an infinitely repeating sinusoidal wave (see fig. 14.1).
The ideas that motivated me to write this text, and my philosophy about what it should contain and how it should be used, were expounded at length in the Preface to Volume 1. Here I would like only to reemphasise that, in order to derive optimum benefit from this book, it is essential for the reader to work through the problems at the end of each chapter. This is the only way of making sure that the material covered has been absorbed. The problems are relatively few in number, so that it should be reasonable to attempt them all.
I wish to express my thanks to the various people who have offered me advice concerning the topics covered in this volume. They include David Acheson, Ian Aitchison, David Andrews, Peter Clifford, Gideon Engler, Raymond Hide, Moshe Kugler, Elaine Lyons, John Roe, Lee Segal, Robert Thorne and Andrew Tolley, as well as the Jesus College first-year physics students of 1996 who read and commented on the text.
I am most grateful to Brenda Willoughby for her sterling work in typing this document, and to Irmgard Smith for producing the beautiful diagrams.
It is tea-time, and you have decided to make some smoked salmon sandwiches. A slight inconvenience is that you have only just removed the loaf of bread from the freezer and need to let it defrost. How long is this going to take?
The way in which the temperature rises for any small region in the interior of the loaf depends on the rate at which heat is conducted into that region. This in turn depends on the temperature gradients within the loaf. Thus there is a relationship between the spatial and the time derivatives of the temperature T of the bread. This relationship is a partial differential equation in that it involves partial derivatives of T (with respect to x and with respect to t).
This is typical of partial differential equations. In contrast to ordinary differential equations, which have only one independent variable (see Chapter 5), here we consider differential equations which involve at least two independent variables. Because the dependent variable of our partial differential equation (T in the above example) is a function of these independent variables, the derivatives are necessarily partial ones. The solution of the equation then involves finding a specific functional dependence for, say, T in terms of position and time, which satisfies the particular requirements of the given problem.
Specific examples
Here we describe and derive some of the more common examples of partial differential equations.