% $Id: intro.tex 1322 2007-04-19 01:28:02Z paultcochrane $

% Copyright (C) 2000-2007
%
% Code contributed by Greg Collecutt, Joseph Hope and the xmds-devel team
%
% This file is part of xmds.
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software 
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

\chapter{Introduction}

Unfortunately, appropriate mathematical models for the majority of
natural phenomenon generate equations that are {\em non-integrable}.
This means that the solutions to the problem cannot be written as
exact analytic expressions, and those who would seek solutions must
appeal to the modern computer to calculate them by a numerical
procedure. The capability of modern computers continues to grow at a
phenomenal rate, and hence so also does the field of computational
physics. In fact it has been described by some as a ``third way of
doing physics'', in addition to the more standard theoretical and
experimental approaches. Computational physics represents an unusual
marriage of these two approaches (which traditionally have always been
rivals) in that the governing equations must be based on believable
theory, yet each simulation is very much like an experiment to
determine what actually happens.  However, due perhaps to its rapid
growth, computational physics is in need of improvement in at least
one particular area. In a recent review titled {\em Microscopic
simulations in physics}~\cite{Ceperley:1999:1} Ceperley writes:

{\em Sadly, the lore of experimental and theoretical physics has not
yet fully penetrated into computational physics. Before the field can
advance, certain standards, which are commonplace in other technical
areas, need to be adopted so that people and codes can work together.}

Here Ceperley is addressing the issue of standards and reproducibility
within computational physics. The results of one group must be able to
be independently verified by another group, and should one group cease
working in a particular area it should be not unnecessarily difficult
for another group to pick up where they left off. However, code
writing is inherently individualistic and does not naturally lend
itself to these properties. Further, the range of problems that
encompass every physical phenomenon known to our species is not small,
and if every problem had to be individually coded into a detailed
computer program, checked, and debugged---well, the future would look
bleak.

What is needed is to be able to specify the generalities of the
problem without having to continually reprogram the detailed
mechanisms of solving it. This approach is known as {\em high level}
programming, and there are a variety of both commercial and public
license packages based on this approach. Unfortunately, to achieve the
necessary flexibility these packages tend to be ``interpreters'', and
thus they are seldom efficient at calculating the solution. And for
some problems, those that take fast computers days and weeks to solve,
efficiency is paramount. The only way to obtain efficiency is to
directly compile a well written {\em low level} program, letting the
compiler do the optimisation -- which is what compilers are very good
at. What many mathematicians and scientists would wish to have is
their own personal expert computer programmer, who takes their high
level description of the problem and writes a low level program
specifically dedicated to solving it. Further, it is essential that
this process is {\em error free}.

Presented here is a solution to these difficulties. \xmds is a
computer program that {\em generates} computer programs. \xmds
interprets a high level description of a problem, and in turn writes a
low level computer program that a compiler can compile and
optimise. The executable file produced then solves the problem as
quickly and efficiently as possible. Further, once \xmds is debugged,
the process of code generation, at least from the high level script
onwards, becomes error free. Of course, \xmds cannot be written to be
able to process absolutely any problem; \xmds has its own scope of
capability, which is outlined in \Chap{chap:functionality}.

We begin by outlining some of the basic theory involved in numerical
modelling, and then follow on with the develpoment strategy behind
\xmds and the structure of the source code. We then look at the
functionality of \xmds, and illustrate this with worked examples. We
close with a brief outlook for future development.

