« Previous | Next »
In 6.00, we will use the Python programming language. You'll also need an editor and/or development environment for writing and debugging your programs. In 6.00, we will be using IDLE, a programming environment specially designed for Python programming and included with the Python distribution. These programs are available for installation on your personal computers (see below).
Why Python?
A programming language is the tool we use to construct a sequence of instructions that will tell the computer what we want it to do. There are hundreds of programming languages in the world. Over the course of my career, I've taught programming classes using at least six different languages.
For most Unix systems, you must download and compile the source code. The same source code archive can also be used to build the Windows and Mac versions, and is the starting point for ports to all other platforms. Download the latest Python 3 and Python 2 source. The official home of the Python Programming Language. Downloads Mac OS X; Python Releases for Mac OS X. Latest Python 3 Release - Python 3.9.0; Latest Python 2 Release - Python 2.7.18; Stable Releases. Python 3.9.0 - Oct. Download macOS 64-bit installer. To create a virtual environment, pass the name of the environment with the python version to be used. Suppose we want to create an environment named Cat and want to use the Python 3.8.2 version.
There is no best language (though I could nominate some candidates for worst). Different languages are better or worse for different kinds of applications. MATLAB, for example, is a great language for manipulating vectors and matrices. C is a good language for writing the programs that control data networks.
In this course, we will use Python. Python is a relatively recent addition to the universe of languages, and is still growing in popularity. I want to emphasize that this course is not about Python. You will certainly learn Python, and that's a good thing. What is much more important, however, is that you will learn how to write programs that solve problems, given a set of basic primitives, and ways of combining them into more complex elements, that you can then abstract into primitives. This skill can be transferred to many languages.
Setting Up Python
You can install the 6.00 software on your personal computer if your operating system is GNU/Linux, Windows (7/XP), or MacOS X. For Windows, you will need Python version 2.5.4, while for OS X you'll need Python 2.7.11 (any 2.5.x, 2.6.x, or 2.7.x version of Python will work, but 3.0 versions are NOT compatible). Below are direct links to the most common Python installers:
Windows:
Download and install: Windows Installer
Mac OS X:
For OS X Yosemite and earlier, download and install: Mac Installer. For OS X El Capitan and later, download and install Anaconda with Python 2.7 for OS X. Anaconda comes with numpy and matplotlib preinstalled, along with many other python libraries, so you may ignore the installation instructions for those libraries in Pset 6.
Warning: On the Python homepage, the latest version available for download is actually 3.5. Do not install this! This version is not backwards compatible with the code that you'll be writing in this course (for example, you have to type print('test') instead of print 'test'). Instead, be sure to download the version listed above.
Using IDLE
IDLE is the standard Python development environment. Its name is an acronym of 'Integrated DeveLopment Environment'. It works well on both Unix and Windows platforms.
It has a Python shell window, which gives you access to the Python interactive mode. It also has a file editor that lets you create and edit existing Python source files.
During the following discussion of IDLE's features, instead of passively reading along, you should start IDLE and try to replicate the actions.
You can type Python code directly into this shell, at the '>>>' prompt. Whenever you enter a complete code fragment, it will be executed. For instance, typing:
>>> print'hello world'
and pressing Enter will cause the following to be displayed:
hello world
IDLE can also be used as a calculator:
>>> 4+4
8
Addition, subtraction, and multiplication operators are built into the Python language. This means you can use them right away. If you want to use a square root in your calculation, you need to import the math module. Do not worry about what it means right now; we will cover this later during the course. Below is an example of square root calculation:
>>> import math
>>> math.sqrt(16) 4.0
Math module allows you to do a number of useful operations:
>>> import math
>>> math.pow(3, 2) 9.0 >>> math.cos( 0 ) 1.0
Gopro camera control mac download. Note that you only need to execute the import command once after you start IDLE.
Exercises
For additional practice, try using IDLE to calculate:
Welcome!
This is one of over 2,200 courses on OCW. Find materials for this course in the pages linked along the left.
MIT OpenCourseWare is a free & open publication of material from thousands of MIT courses, covering the entire MIT curriculum.
No enrollment or registration. Freely browse and use OCW materials at your own pace. There's no signup, and no start or end dates.
Knowledge is your reward. Use OCW to guide your own life-long learning, or to teach others. We don't offer credit or certification for using OCW.
Made for sharing. Download files for later. Send to friends and colleagues. Modify, remix, and reuse (just remember to cite OCW as the source.)
Download pokemon roms on mac. Learn more at Get Started with MIT OpenCourseWare
Pymatgen (Python Materials Genomics) is a robust, open-source Python libraryfor materials analysis. These are some of the main features:
As of 2020, pymatgen only supports Python 3 and above.
Pymatgen is free to use. However, we also welcome your help to improve thislibrary by making your own contributions. These contributions can be in theform of additional tools or modules you develop, or feature requests and bugreports. The following are resources for pymatgen:
Offline docs¶![]()
If you would like to have an offline version of the docs for reference, thereare two options:
Matgenie & Examples¶
The Materials Virtual Lab has developed amatgenie web app whichdemonstrates some of the basic functionality of pymatgen, as well as amatgenb repository ofJupyter notebooks for common and advanced use cases. We have deprecated thepymatgen examples page in favor of this more sustainable approach going forward.One of the ways you can contribute is to fork the matgenb repo and add your ownexamples.
Below are a quick look at some of the graphical output possible.
Top: (left) Phase and (right) Pourbaix diagram from the Materials API.Bottom left: Calculated bandstructure plot using pymatgen’s parsing andplotting utilities. Bottom right: Arrhenius plot using pymatgen’sDiffusionAnalyzer.¶
Why use pymatgen?¶
There are many materials analysis codes out there, both commercial and free.So you might ask - why should I use pymatgen over others? Pymatgen offerseveral advantages over other codes out there:
Please review the coding guidelines.
Change log¶v2020.9.14¶
Getting pymatgen¶
If you are absolutely new to Python and/or are using Windows, the easiestinstallation process is using conda. If youalready have conda installed, pymatgen can be installed from the conda-forgechannel using the following command:
Note that you might need to ensure a relatively recent version of gcc isavailable to compile pymatgen. You can use conda to get that:
Pymatgen is under active development, and new features are added regularly. Toupgrade pymatgen to the latest version, use the following command:
Step-by-step instructions for all platforms are available at theinstallation page.
The version at the Python Package Index (PyPI) is always the latest stablerelease that is relatively bug-free. The easiest way to install pymatgen onany system is to use pip:
Wheels for Mac and Windows have been built for convenience. Similarly, you mightneed to ensure you have a relatively recent version of gcc.
To upgrade pymatgen via pip:
The bleeding edge developmental version is at the pymatgen Github repo. The developmentalversion is likely to be more buggy, but may contain new features. TheGithub version include complete test files. Aftercloning the source, you can type in the root of the repo:
or to install the package in developmental mode:
Detailed installation instructions, including installation ofoption dependencies, set up for POTCAR generation, Materials Project RESTinterface usage, setup for developers, etc.are given on thispage.
For some extras, you can also install the optional dependencies using:
For an always up-to-date list of extras, consult the setup.py’s extras_require.
If you are installing pymatgen on shared computing clusters, e.g., the XSEDEor NERSC resources in the US, the best way is to use conda to perform a localinstall. This guarantees the right version of python and all dependencies:
Usage¶
The figure above provides an overview of the functionality in pymatgen. Atypical workflow would involve a user converting data (structure, calculations,etc.) from various sources (first principles calculations, crystallographic andmolecule input files, Materials Project, etc.) into Python objects usingpymatgen’s io packages, which are then used to perform further structuremanipulation or analyses.
Useful aliases for commonly used objects are now provided. Supported objectsinclude Element, Composition, Structure, Molecule, Spin and Orbital. Here aresome quick examples of the core capabilities and objects:
The above illustrates only the most basic capabilities of pymatgen. Users arestrongly encouraged to explore the usage pages (toc given below).
For detailed documentation of all modules and classes, please refer to theAPI docs.
The founder and maintainer of pymatgen, Shyue Ping Ong, has conducted severalworkshops (together with Anubhav Jain) on how to effectively use pymatgen (aswell as the extremely useful custodian error management and FireWorksworkflow software. The slides for these workshops are available on theMaterials Virtual Lab.
To demonstrate the capabilities of pymatgen and to make it easy for users toquickly use the functionality, pymatgen comes with a set of useful scriptsthat utilize the library to perform all kinds of analyses. These areinstalled to your path by default when you install pymatgen through thetypical installation routes.
Here, we will discuss the most versatile of these scripts, known aspmg. The typical usage of pmg is:
At any time, you can use
'pmg--help' or 'pmgsubcommand--help' to bring up a useful help message on how to use these subcommands.With effect from v4.6.0, pmg also supports bash completion usingargcomplete, which is useful given the many options available in the cli tool.To enable argcomplete, pipinstallargcomplete and either followargcomplete’s instructions for enabling global completion, or add the followingline to your .bash_profile (this method usually works more reliably):
Here are a few examples of typical usages:
Some add-ons are available for pymatgen today:
Contributing¶
Pymatgen is developed by a team of volunteers. It is started by a teamcomprising of MIT and Lawrence Berkeley National Laboratory staff to be arobust toolkit for materials researchers to perform advanced manipulations ofstructures and analyses.
For pymatgen to continue to grow in functionality and robustness, we rely onother volunteers to develop new analyses and report and fix bugs. We welcomeanyone to use our code as-is, but if you could take a few moment to give backto pymatgen in some small way, it would be greatly appreciated. A benefit ofcontributing is that your code will now be used by other researchers who usepymatgen, and we will include an acknowledgement to you (and any relatedpublications) in pymatgen.
Reporting bugs¶
A simple way that anyone can contribute is simply to report bugs and issuesto the developing team. Please report any bugs and issues at pymatgen’sGithub Issues page.For help with any pymatgen issue, consult Stack Overflow and ifyou cannot find an answer, please post a question with the tag pymatgen.
Developing new functionality¶
Another way to contribute is to submit new code/bugfixes to pymatgen. Thebest way for anyone to develop pymatgen is by adopting the collaborativeGithub workflow (see contributing page).
How to cite pymatgen¶
If you use pymatgen in your research, please consider citing the followingwork:
Download daz install manager mac. Shyue Ping Ong, William Davidson Richards, Anubhav Jain, Geoffroy Hautier,Michael Kocher, Shreyas Cholia, Dan Gunter, Vincent Chevrier, Kristin A.Persson, Gerbrand Ceder. Python Materials Genomics (pymatgen) : A Robust,Open-Source Python Library for Materials Analysis. ComputationalMaterials Science, 2013, 68, 314–319. doi:10.1016/j.commatsci.2012.10.028
In addition, some of pymatgen’s functionality is based on scientific advances/ principles developed by various scientists. Please refer to thereferences page for citation info.
License¶Download Cadabra Science On Python Macintosh
Pymatgen is released under the MIT License. The terms of the license are asfollows:
Download Cadabra Science On Python MacrosAbout the Team¶
Shyue Ping Ong of the Materials Virtual Lab started Pymatgen in 2011, and isstill the project lead.
Download Cadabra Science On Python Macro
The Pymatgen Development Team is the set of all contributors to thepymatgen project, including all subprojects.
The full list of contributors are listed in the team page.
Copyright Policy¶
Pymatgen uses a shared copyright model. Each contributor maintains copyrightover their contributions to pymatgen. But, it is important to note that thesecontributions are typically only changes to the repositories. Thus, thepymatgen source code, in its entirety is not the copyright of anysingle person or institution. Instead, it is the collective copyright of theentire pymatgen Development Team. If individual contributors want to maintain arecord of what changes/contributions they have specific copyright on, theyshould indicate their copyright in the commit message of the change, whenthey commit the change to one of the pymatgen repositories.
Download Cadabra Science On Python Machine Learning
With this in mind, the following banner should be used in any source code fileto indicate the copyright and license terms:
Indices and tables¶Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |