Hot answers tagged

32

(Disclaimer: As one of the main authors of a Julia-based DFT code, DFTK, my opinion is definitely biased) The community of people employing Julia for materials modelling is still small, but a couple of programs exist. Probably a good overview gives https://github.com/svaksha/Julia.jl/blob/master/Chemistry.md. Many projects have only started within the last ...


31

Julia The answers above allude to what some call the "two-language problem". In materials science it takes the form of writing your code in Fortran for speed, and writing an interface to it in Python for sanity and interactivity. Fortran will not go away any time soon due to the massive amount of legacy code available. For new codes, there is a new ...


28

Understanding, deriving, writing, testing and debugging an ab initio code can be a lenghty and tedious task. I'd like to provide a starting point for you here. If you just to it for pedagocial reasons, it might be advisable to start with the atomic problem and try to solve it with DFT. The effort for that is not too big, but it covers nearly all the nesseary ...


28

Fortran A large part of materials modelling involves density functional theory and molecular mechanics. From this compilation of quantum chemistry software, the most widely used programming language seems to be Fortran. Indeed, the popular packages VASP (commercial), Quantum Espresso and Siesta (both free) all use this language.


23

Julia Okay, I have to add Julia. Everyone is saying Fortran or Python, and I love them both, but they both have issues. Fortran is easy for a compiled language to write, but I still have SIGSEGV burned into my retinas. Python is fast to write, but very slow. Learning how to cleverly make python fast (and it is still not all that fast) takes more time and ...


22

It depends on what you want to do I'll go first. For context: I do mostly Monte Carlo simulations, especially quantum Monte Carlo. My work has focused on spin systems, using techniques like the Metropolis Algorithm and stochastic series expansion QMC. For Writing Simulations: In my field there are few software packages available and the algorithms are ...


21

Python @taciteloquence has already mentioned Python for data analysis and visualization, but let me add one more angle: automation. Simulation nowadays often means high-throughput, automated simulation. Not only for large scale projects, like Materials Project but also individual projects where large amounts of data generated for screening properties, ...


18

It depends on what you want to do I think one major question that needs to be asked is "What do you want to do?". Develop new quantum chemistry codes? Use them more efficiently? Automate data processing? User @taciteloquence Has given a good answer I think. Many legacy codes are written in Fortran - newer codes will be typically written in C or C++....


18

It depends on what you want to do It depends on what you want to do. As a couple of others have pointed out, many of the computer programs used in computational chemistry and theoretical solid state physics are written in Fortran. However, that does not imply that you should learn Fortran and it does not mean that Fortran is the best language for materials ...


15

SlowQuant In your question from 2015, you mentioned PyQuante and PySCF, but I saw no mention of SlowQuant in the question or in the multiple answers. I see that while writing this, someone else answered, with mentions of PyQuante, PySCF, and Psi4 again. Still no mention of SlowQuant. The author of SlowQuant has described the program this way (emphasis mine)...


15

If you're set on using Python here are some options. I haven't used these codes so I can't speak to their ease of use. PyQyante PyQuante is a suite of programs that can not only do DFT but also Hartree-Fock, MP2, and more. Certain parts of the code are written in C for speed. A package can be downloaded and then installed with Python, but a newer version, ...


14

Cython There are currently two answers suggesting Python (by Paulie Bao and Greg). Python is a high-level, interpreted, dynamically typed, garbage collected, and general-purpose programming language. All this means is that you can have an actually working, readable piece of code in a considerably short amount of time and that this code can do pretty much ...


14

Python Python is definitely a good language for scientific calculation. The syntax is very simple. It is not hard to implement some novel method and conduct preliminary tests. The library is abundant. One could almost do everything in python. There are many open source libraries in python that implement a variety of libraries of scientific computing and ...


14

Here is the simple bash script for testing kpoint energy convergence for VASP you can use same logic in python but you can also use this. for i in `seq 1 1 5` # change the range needed do cat <<EOF >KPOINTS MONK #header file 0 M $i $i $i 0 0 0 EOF mkdir $i cp INCAR $i/ cp POSCAR $i/ cp POTCAR $i/ cp KPOINTS $i/ cd $i vasp-5.4.4 # This is vasp run ...


14

There is an example in the pyiron documentation to calculate energy volume curves: https://pyiron.readthedocs.io/en/latest/source/notebooks/energy_volume_curve.html And the corresponding jupyter notebook is available in the pyiron repository: https://github.com/pyiron/pyiron_atomistics/blob/master/notebooks/energy_volume_curve.ipynb To adjust the energy ...


13

I designed the Python program a few years back but haven't looked at it in some time. The __init__.py line can be commented out for your usage. That "model" was for my team's use case, and it looks like I got rid of it. You may be better off importing the "material_analytics.py" directly, and using those functions right on your dataset. ...


12

Compiled Languages Since all simulations are CPU and memory consuming, I recommend to not use interpreted language like Java, Julia*, Python, etc. Compiled languages are converted directly into machine code that the processor can execute. As a result, they tend to be faster and more efficient to execute than interpreted languages. They also give the ...


12

I was able to run the code on your data and got a Young's Modulus of $2.08236\times10^{-5}$. This clearly doesn't seem right for an aluminum system, though I don't know the units you are using. To get this, I had to make a few changes to both the code and your data. As suggested, by Enusi, I commented out from model import stress_strain from the __init__.py ...


12

It helps to know that in computational chemistry the collection of distance, angle and dihedral coordinates is collectively known as "z-matrix coordinates". Unless you care to reinvent the wheel (which is not a bad exercise), it suffices to perform a web search for "python internal to zmatrix coordinates". For instance, the "...


12

Easiest free tool to do this (no download necessary): What you are describing, is the conversion from XYZ format to ZMAT format. How to do this, has been asked here on the Chemistry Stack Exchange, and my answer was to use this free tool in which you just copy and paste the 3 spatial coordinates along with the name of the element, for each row of the XYZ ...


11

There probably are good Python bindings to various DMRG implementations, which allow one to run DMRG from Python. Since the implementations typically rely on lower-level C/C++/Fortran routines, the calculations run quite quickly. E.g. PySCF appears to have bindings to various DMRG programs, see https://sunqm.github.io/pyscf/dmrgscf.html. If you're talking ...


11

ASE The ASE library has an atom object with built-in get_angle, get_dihedral and get_distance methods that do just that.


11

If the crystal unit cell is in a format readable by ASE, then you can use code that looks approximately like so: from ase.io import read atoms = read("myfilename.xyz") bandpath = atoms.cell.bandpath() This bandpath object will have the relevant attributes to play with (kpoint coordinates, special point labels, special point coordinates, etc). ...


10

For molecular DFT, there are definitely several tutorials around for major pieces. The Psi4 code has a set of Jupyter notebooks called Psi4Numpy, working through each element of a quantum chemical program. This includes: Self-Consistent Field DFT grids, LDA, GGA, metaGGA One electron integrals There are a variety of other tutorials for response ...


10

Without seeing the SDF itself it's hard to be specific, but here's what the error messages are telling you, in general: the first one normally indicates a badly formed record in the SDF. If you look at around that line in the file you will, hopefully, see a misformed record. The next one, "Explicit valence" indicates that the molecule has an atom (...


10

RDKit This is pretty easy to do in RDKit. If you want the molecular formula, you can just use CalcMolFormula(): from rdkit import Chem from rdkit.Chem.rdMolDescriptors import CalcMolFormula # e.g. cysteine mol = Chem.MolFromSmiles("C([C@@H](C(=O)O)N)S") formula = CalcMolFormula(mol) It is also very easy to get all of the unique heteroatoms: from ...


10

The dipole moment is typically a vector quantity, and the "total dipole moment" which is the $A$ in your question description and the black arrow in the figure below, is the vector sum of all constituent dipole moments the system (red arrows in the figure below): In your case you have vectors such as: $26.78 \, \hat{x} -6.31\, \hat{y} + 27.17\,...


10

Consider a graphene Hamiltonian, whose dispersion looks a lot like the one in your figure. Per these notes, its k-space Hamiltonian may be written as: $$ H(k)=-t \sum_{\delta} [\cos(k\cdot\delta)\sigma_x-\sin(k\cdot\delta)\sigma_y], $$ where $k=(k_x,k_y)$, $\delta$ are nearest-neighbor vectors, $\sigma_i$ are Pauli matrices and $t$ is a hopping parameter. ...


10

This is the script I wrote for convergence testing in Quantum ESPRESSO using Bash and Python. According to Stefaan Cottenier, hydrostatic pressure on a unit cell is the property tested for convergence because it is quite sensitive to numerical precision. If this property is converged with respect to the k-mesh, many other less sensitive properties will be ...


Only top voted, non community-wiki answers of a minimum length are eligible