GithubHelp home page GithubHelp logo

python-madelungconstant's Introduction

python-MadelungConstant

Use python to calculate the madelung constant for NaCl.

This program is an answer to exercise 2.8 (pg. 73) of Chapter 2, Python Programming for Physists, of Computational Physics

The prompt is: Write a program to calculate and print the Madelung constant for sodium chloride. Use as large a value of L as you can, while still having your program run in reasonable time—say in a minute or less.

madelung.py is the fastest, but consumes a large amount of memory madelung-v2-betterExplanation.py explains some of what is happening and why, but isn't as fast.

The last is a while loop version that is highly inefficient.

python-madelungconstant's People

Contributors

kkirsche avatar

Stargazers

Guodong Yu avatar Jesús Ramírez avatar

Watchers

James Cloos avatar  avatar Jesús Ramírez avatar  avatar

python-madelungconstant's Issues

Madelung constant not entirely correct?

Thank you for your code. I adapted it for my own project. I think the Madelung constant you get is not entirely correct. To get a better approximation I have averaged the last and second last value, i.e. (Madelung(N) + Madelung(N-1))/2. With N=100 I got a very good approximation of the reported value of 1.7476.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.