D for project in computational chemistry

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 16 06:29:17 PDT 2015


On 17/08/2015 1:11 a.m., Yura wrote:
> Good afternoon, gentlemen,
>
> just want to describe my very limited experience. I have re-written
> about half of my Python code into D. I got it faster by 6 times. This is
> a good news.
>
> However, I was amazed by performance of D vs Python for following simple
> nested loops (see below). D was faster by 2 order of magnitude!
>
> Bearing in mind that Python is really used in computational
> chemistry/bioinformatics, I am sure D can be a good option in this
> field. In the modern strategy for the computational software python is
> used as a glue language and the number crunching parts are usually
> written in Fortran or C/C++. Apparently, with D one language can be used
> to write the entire code. Please, also look at this article:
>
> http://www.worldcomp-proceedings.com/proc/p2012/PDP3426.pdf
>
> Also, I wander about the results of this internship:
>
> http://forum.dlang.org/post/laha9j$pc$1@digitalmars.com
>
> With kind regards,
> Yury
>
>
> Python:
>
> #!/usr/bin/python
> import sys, string, os, glob, random
> from math import *
>
> a = 0
>
> l = 1000
>
> for i in range(l):
>          for j in range(l):
>                  for m in range(l):
>                          a = a +i*i*0.7+j*j*0.8+m*m*0.9
>
> print a
>
> D:
>
> import std.stdio;
> // command line argument
> import std.getopt;
> import std.string;
> import std.array;
> import std.conv;
> import std.math;
>
> // main program starts here
> void main(string[] args) {
>
>
> int l = 1000;
> double a = 0;
> for (auto i=0;i<l;i++){
>          for (auto j=0;j<l;j++) {
>                  for (auto m=0;m<l;m++) {
>                          a = a + i*i*0.7+j*j*0.8+m*m*0.9;
>                          }
>
>          }
> }
> writeln(a);
> }

Any chance for when you get the time/content, to create a research paper 
using your use case?
It would be amazing publicity and even more so to get it published!

Otherwise, we could always do with another user story :)


More information about the Digitalmars-d mailing list