Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices when implementing a scientific simulation methodology from scratch [closed]

in the field of scientific simulations (physics) I am thinking about developing some new simulation package in C/C++. What do you think would be the best practices when starting here from scratch? Can you recommend some bibliography?

Thanks

like image 888
Open the way Avatar asked Sep 22 '10 12:09

Open the way


3 Answers

Here's something of a reading list. Not sure if it's too basic for you:

Writing Scientific Software: a good follow-on to a basic 'Learn to Program in C++' or whatever.

Parallel Scientific Computing in C++ and MPI: if you are not planning to parallelise your application, you should be.

Engineering and Scientific C++: a good, domain-specific, introduction to programming in C++. A bit dated in language details, but the overall approach hasn't aged.

I suggest that you read through the SO answers to questions such as 'How should I design a large C++ program ?' for advice on other books which may be of interest.

As to best practices, here are some suggestions. Again, I'm not sure of your starting point so some of this may be too basic:

  • As I wrote above, you should be planning from the outset to develop a parallel program. If message-passing on a cluster is not your cup of tea, at least consider shared memory programming for a multi-core desktop. OpenMP is worth investigating.
  • Make yourself familiar with existing work. The BOOST libraries are probably essential. While I applaud your intention to roll-your-own, don't ignore existing well-established numerical libraries such as BLAS and LAPACK which you'll find at Netlib. Depending on your development platform and toolset you may find them already installed.
  • If you are coming from a scientific background, you may want to improve your knowledge of and skills in software engineering. Matters such as: source code control; testing; code profiling and optimisation; deep knowledge of what your compiler(s) can do. In my experience many computational scientists have a weak background in all of this stuff.
  • You should be planning to spend (approximately) as much time on designing and testing your program as on actually coding it. Even working on your own it is essential to have a good plan of action before you start coding. There's no reason why it has to be complete in every detail at the beginning but never enter territory without a map.
  • You are silent on the aspect(s) of the physical world you want to simulate. There is a lot of prior art in all sorts of physical simulations, if you were a bit more specific SO might be able to provide some more specific suggestions.
like image 129
High Performance Mark Avatar answered Nov 20 '22 03:11

High Performance Mark


Start with Numerical recipes: the art of scientific computing. A pretty comprehensive tome. However, keep in mind two things:

  • It contains both C++ and Fortran 90 code samples.
  • Forget about actually using any of the code samples in your project, though - AFAIK they are copyrighted and must be licensed for reuse separately.

Still, if you need it for educational purposes, this book is a highly recommended reading.

like image 38
dpq Avatar answered Nov 20 '22 05:11

dpq


Have a look at OpenModelica.

like image 1
Wilhelm Medetz Avatar answered Nov 20 '22 04:11

Wilhelm Medetz