开发者

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

开发者 https://www.devze.com 2023-01-17 07:35 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

开发者_StackOverflow中文版

Closed 4 years ago.

Improve this question

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


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.


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.


Have a look at OpenModelica.

0

精彩评论

暂无评论...
验证码 换一张
取 消