I found a second error in lj_cstyle

t is calculated wrongly:
 t = 1./s*s*s != 1/s^3

It probably should be t = 1.0 / (s * s * s)

t = 1.0 / (s*s*s)
E += t*t - 2.*t
dJ = -12.0 *(t*t - t) / s

cstyle is on my machine still two times faster then my optimized variant of 
jl_pretty 

Best Valentin

On Sunday, 30 November 2014 20:54:58 UTC+1, Valentin Churavy wrote:
>
> Nice work!
>
> Regarding the pretty Julia version of Lennard-Jones MD.
>
> You can shape of another second (on my machine) by not passing in the lj 
> method as a parameter, but directly calling it. 
>
> I tried to write an optimize version of your lj_pretty function by 
> analysing it with @profile and rewriting the slow parts. You can see my 
> results here: https://gist.github.com/vchuravy/f42f458717a7a49395a5 
> I went step for step through it and applied one optimization at a time. 
> You can also see the time computation time spend at each line as a comment. 
> Mostly I just removed temporary array allocation and then applied your math 
> optimization.
>
> One question though. In lj_cstyle(x) you calculate dJ = -12.*(t*t - t) * 
> s , shouldn't it be dJ = -12.*(t*t - t) / s? 
>
> Kind regards,
> Valentin
>
>
>
>
>
> On Sunday, 30 November 2014 12:51:31 UTC+1, Christoph Ortner wrote:
>>
>> Belated update to this thread:
>>
>> I have now finished a first draft of three tutorial-like numerical PDE 
>> notebooks; they can be viewed at 
>>      http://homepages.warwick.ac.uk/staff/C.Ortner/index.php?page=julia
>> I have two more coming up in the near future, one on spectral methods, 
>> the other on an optimisation problem. For the moment, I am using them 
>> primarily for my research group to learn Julia, and to show it to 
>> colleagues when they are interested.  
>>
>> Q1: May I use the Julia logo on that website, as well as for any 
>> tutorials / courses that I teach based on Julia?
>>
>> Q2: Eventually I think it would be good to have a "Julia Examples" page 
>> such as
>> http://www.mathworks.com/examples/
>>
>> Q3: I'd of course be interested in feedback.
>>
>>
>>
>>
>>
>>
>>

Reply via email to