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

自古美人都是妖i 提交于 2020-01-12 03:49:06

问题


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


回答1:


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.



回答2:


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.




回答3:


Have a look at OpenModelica.



来源:https://stackoverflow.com/questions/3769372/best-practices-when-implementing-a-scientific-simulation-methodology-from-scratc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!