Questions tagged [python]

For questions about materials modeling scripts written in the Python programming language. Questions should focus on interfacing with existing packages and aspects related to modeling, not general debugging.

Filter by
Sorted by
Tagged with
36 votes
13 answers
3k views

What is a good programming language for matter modeling?

What is a good programming language for matter (e.g. molecular or materials) modeling? Since this is a broad field, I don't expect there to be only one answer.
33 votes
4 answers
7k views

How to write my own density functional theory (DFT) code in Python?

I am a DFT user and at some point in the future, I would like to write my own DFT code in Python to help gain a deeper understanding of DFT. As mentioned in a previous answer people have written their ...
  • 8,432
31 votes
2 answers
850 views

How is Julia used in matter modeling?

What are the main uses and applications of Julia in matter modeling? Python for example is used in many codes, not to mention workflow automation and data processing. Are there any available codes or ...
27 votes
3 answers
2k views

How to "get my feet wet" in Density Functional Theory by simulating a water molecule using Python

I just saw I am a beginner in Density Functional Theory. What are some resources that could help me to learn the basics? and it reminded me that few years ago I'd asked How can I calculate the charge ...
  • 1,974
23 votes
0 answers
363 views

What are the tools available for point defects calculations? [closed]

It would be appreciated if you could explain one of the tools below (or another tool not listed), in the format used here (for example): What software will allow me to combine two images? What ...
  • 491
20 votes
3 answers
3k views

How to find Young's Modulus using stress strain curve using Python?

I am trying to find the The Young's Modulus of an aluminum alloy The yield stress Below is the data for the stress-strain curve. I tried finding the region where the slope is constant and to my ...
user avatar
17 votes
6 answers
4k views

How to make a python code that can read a .xyz file and find the distance between atoms?

I want to make a python script that will load an xyz file. From the xyz parameters, I need to find the distance between atoms, angle and dihedral between atoms. The file xyz have this structure: ...
16 votes
2 answers
1k views

Open Source PyMol Conda Package: UnsatisfiableError

I'm having an issue installing the open-source version of Pymol using Anaconda on Windows. I have Python 3.8.3 installed and when I try to add the package with Conda using ...
  • 14.3k
16 votes
2 answers
1k views

Is there a more efficient hard sphere packing algorithm?

I am trying to pack hard-spheres in a unit cubical box, such that these spheres cannot overlap on each other. This is being done in Python. I am given some packing fraction ...
  • 3,957
16 votes
1 answer
328 views

How to calculate t-zero temperature using Thermo-Calc- Python (TCPython) for multiple alloys?

T-zero temperature is the temperature at which the Gibbs energies of two phases are equal. Here, I wish to find the temperature at which FCC and BCC have same Gibbs energy. Thermo-Calc console mode ...
  • 177
16 votes
0 answers
137 views

Easy ways to generate "teaching" band structures in Python?

I'd like to introduce band structure to a class of undergraduate chemists, along the lines of Roald Hoffmann's Solids and Surfaces. That is, I'd like to start with a s-band in 1D, which is easy ...
15 votes
4 answers
2k views

How to generate the high symmetry paths for band structure calculations?

Suppose I want to calculate the band structure of a material system along a specific high symmetry path in the Brillouin Zone. If the point group of the system is given, how can I easily compute the ...
  • 151
14 votes
4 answers
520 views

Is python sufficient for serious tensor network or DMRG calculations?

There are enough tensor-network/DMRG packages that support python (ALPS, OpenMPS, pyUni10) that it would seem (to an outsider) that it's possible to do some substantial work with DMRG without messing ...
14 votes
3 answers
2k views

How can I use a GUI on a supercomputer?

I am trying to make plots based to VASP simulation results, but I am struggling with how to download so much data from the server. A lot of examples on the internet are taught using the local desktop ...
  • 1,843
14 votes
1 answer
690 views

How to start a Machine Learning project for chemical properties prediction?

I know that is a very general question but I would like to start a ML project in Python to predict some chemical properties with a large set of experimental data. The compounds I would like to study ...
13 votes
3 answers
2k views

Python script for convergence test

I want to do a convergence test of Ni using a Python script in Pyiron. Can someone please suggest how to write a script to test energy and k-mesh convergence?
  • 1,525
13 votes
3 answers
2k views

How to create a 3D band structure from DFT band structure calculation?

How can I create such a 3D plot using matplotlib? Like the one in Figure (a) below: I want to create it using DFT bandstructure calculation result
  • 1,869
13 votes
1 answer
234 views

Generating numpy-compatible electron density from Molden / QC calculation

I'd like to use a variety of Python tools (e.g., matplotlib and Mayavi) to analyze orbitals plot electron density contours, etc. ...
13 votes
1 answer
706 views

How to plot a Gaussian cube file with python/matplotlib?

I know there are programs that can automatically visualize .cube files (like VMD), but I'm trying to do it myself in python/matplotlib (or equivalent) to better understand what the numbers mean. I ...
  • 231
13 votes
0 answers
321 views

How to calculate RDFs for MD trajectories without PBC, directly from coordinates?

I have been running MD simulations on water droplets with an ion in them. I am trying to implement a program that could calculate the radial distribution function from ion to oxygen (or ion to ...
  • 5,834
12 votes
1 answer
147 views

Metropolis algorithm reduces energy in molecular simulation, but does not decrease euclidean distance

I am using an open source python package openmmtools to run a simple molecular simulation problem using the metropolis algorithm. I first load a default system of particles (alanine-dipeptide in ...
  • 123
12 votes
1 answer
241 views

What is the best program to manipulate numerical DFT wavefunctions to calculate custom matrix elements?

For pedagogical reasons, I am looking for ways to calculate quantum-mechanical quantities such as $\langle m | \dot{m}\rangle, \langle m | \dot{n}\rangle, \langle m | \ddot{n}\rangle$ using ...
  • 2,091
12 votes
1 answer
204 views

How to numerically solve real-space 1D time-independent Schrodinger equation using 2D momentum-space Hamiltonian?

Consider the usual simple 2-level graphene Hamiltonian with mass in momentum-space where: $$ H(k,V)=-t \sum_{\delta} [\cos(k\cdot\delta)\sigma_x-\sin(k\cdot\delta)\sigma_y+V\sigma_z], $$ where $t$ is ...
  • 2,091
12 votes
0 answers
143 views

What are good protocols for creating a database based on python?

I am aware of software tools such as atomate, but that is quite specific to crystals. There are other equally specific workflows - I think we all have our own... What I am interested in is making my ...
  • 1,030
11 votes
3 answers
2k views

Molecular visualization software in Jupyter (IPython) Notebooks

Jupyter notebooks have always been a great way for me to create high-quality graphs, and write code. The features also continue to improve with packages such as Jupyter Lab, and now Jupyter Books, ...
  • 7,794
11 votes
1 answer
214 views

How to use wavefunctions/density to determine which orbitals lead to edge states?

I have a large matrix for a 1D zigzag edge model of an otherwise $3\times 3$ tight-binding Hamiltonian (3 basis functions, each corresponding to an atomic orbital), involving the variable $k_x$. The ...
  • 2,091
11 votes
1 answer
1k views

How should I generate a radial distribution function (RDF) for an MD trajectory with python?

I am attempting to analyse the radial distribution function (oxygen to oxygen) for a ~400ps simulation on a droplet of water (MD done with NAMD). I am using the python library MDAnalysis to do this. ...
  • 5,834
11 votes
1 answer
112 views

Pycalphad most efficient way to gather equilibirum phase data for set of alloy compositions?

What's the most efficient way to get the equilibrium phases and phase fractions for a set of alloy compositions? For context, I'm coming from Thermo-Calc/TC-Python where I would just loop through the ...
  • 621
11 votes
1 answer
126 views

Interpret 2D and 3D data from a PubChem summary of organometallic molecule? Can I "flatten" it when showing on a surface?

I need to "build" an organometallic molecule in Blender/Python then represent it resting on a crystal surface. I'm looking at a PubChem summary for Chloroaluminum phthalocyanine and I can ...
  • 1,974
11 votes
1 answer
224 views

How to get order constitution data for single equilibrium calculation in Thermo-Calc's TC Python module?

I know that it is possible to get order constitution data for phases when using Thermo-Calc's GUI (e.g. to get "BCC_B2 DISORD" instead of just "BCC_B2") for a single equilibrium ...
  • 621
10 votes
2 answers
1k views

RDkit: While converting a *.sdf file to fingerprint, I'm facing several errors

suppl = Chem.SDMolSupplier('1.sdf') for mol in suppl: if mol is None: continue # print(mol.GetNumAtoms()) fps = [Chem.RDKFingerprint(x) for x in supply] I am ...
10 votes
2 answers
259 views

Programs/Libraries for calculating solvent excluded surface and excluded volume

Given the 3D structure of a molecule (e.g. as *.mol) and a probe radius r, I want to calculate the solvent excluded surface (SES)...
  • 458
10 votes
1 answer
654 views

How to understand the wavefunction outputed by QE with HDF5 format?

Following the answer to my question: What is the best program to manipulate numerical DFT wavefunctions to calculate custom matrix elements?, I compiled Quantum ESPRESSO with the hdf5 flag on, and now ...
  • 2,091
10 votes
1 answer
333 views

Normalization condition in evaluating the radial distribution function for a hard-spheres system

I am trying to simulate a 3D hard-spheres in a box system in Python. The idea behind this is that I have to create a system in a 1x1x1 box with periodic boundary conditions and with $N = 500$ ...
  • 3,957
10 votes
1 answer
466 views

Generating SOAP descriptors in python

What is the best python package to construct Smooth Overlap of Atomic Positions (SOAP) descriptors given SMILES representation of a molecule? Is this even possible without providing 3D geometry? An ...
  • 697
10 votes
1 answer
267 views

Computing optimized 3D structures in python that take solvent into account

I have been using RDKit to generate 3D coordinates, cleaning-up the structures using a general-purpose force field as follows: ...
  • 103
10 votes
1 answer
248 views

Node features matrix with Networkx

I built a function to generate graphs from smiles strings using networkx, inserting various features on the nodes. This is the code: ...
9 votes
4 answers
3k views

How to make a python code that can read a .xyz file and find distance, angle and dihedral angle between atoms?

I want to make a python script that will load an xyz file. From the xyz parameters, I need to find the distance between atoms, angle and dihedral between atoms. If I have a xyz coordinate in this ...
9 votes
2 answers
2k views

Python program that returns elements from a SMILE string

Given a SMILES string for a molecule, I want to know the elements in the molecule, I then send this to basis_set_exchange to get a "custom" basis set for use in Gaussian. This seems like ...
  • 4,066
9 votes
2 answers
2k views

How to input 3D coordinates from xyz file and connectivity from SMILES in rdkit?

I am working on a QSAR project where the 3D structural descriptors are an input to a machine learning model. I am generating the descriptors using the python Mordred API (which uses rdkit). ...
  • 5,834
9 votes
2 answers
290 views

Numerically integrating the Hartree potential

I'm trying to write a 1D density functional theory code on Python to predict the electronic structure of certain ions using the local density approximation. I'm trying to construct the hamiltonian for ...
9 votes
1 answer
220 views

What is the right way to calculate <A><A>?

We asked a similar question somewhere else and someone advised trying here instead. How should we calculate $\langle A\rangle \langle A\rangle$ from data on dipole moments? It is a term in an ...
  • 201
9 votes
2 answers
138 views

Evaluating the MSD of my simulation

I am running a molecular dynamics simulation of water in TIP3P, and I am storing the positions of my particles in a 2D array called relevant_positions. The number ...
  • 3,957
9 votes
1 answer
420 views

How to build the [111] slab model of NiSe2 with different terminations with ASE tool?

The following figure is the bulk structure of NiSe$_2$ downloaded from the materials project database. Now I want to study the properties of its [111] plane. In detial, I cut the slab with atomic ...
  • 14k
9 votes
1 answer
830 views

Using OpenBabel or RDKIT Python API to generate conformers from a SMILES string

I have a bunch of monomers in the form of SMILES string and I want to generate conformers from them. At the moment, I am using RDKit to convert these SMILES strings to .sdf files, then using ...
  • 3,957
9 votes
0 answers
70 views

Is there a script that will suggest (hkl) indices based on distances in an electron diffraction pattern for a known crystal structure? [closed]

I am looking for a script (preferably in Python) that will suggest (hkl) indices based on distances in an electron diffraction pattern. The crystal structure is known,i.e. I have the CIF file and know ...
  • 179
9 votes
0 answers
186 views

How to interpret WannierTools Python code that generates tight-binding model in the wannier90_hr.dat format? [closed]

I am getting myself acquainted with Wannier Tools. Wannier Tools requires two inputs, a wt.in file, and a .dat file. This ...
  • 2,091
9 votes
0 answers
606 views

I wrote a Python code to do MD for a Lennard-Jones fluid but the VACF is wrong: What might be the problem? [closed]

I am trying to write a molecular dynamics simulation for a Lennard-Jones fluid in a box with periodic boundary conditions. The box has no net momentum. I am writing this in python. I have written a ...
8 votes
1 answer
523 views

Functional group detection for group contribution methods

I would like to be able to parse a molecule into its functional groups, and, also, know the number of occurrences of each. A similar question was asked on matter modelling specifically for xyz files. ...
  • 4,066
8 votes
1 answer
812 views

How to compute the synthetic accessibility score in Python?

I come from a mainly computer science background, but have become involved in a project related to artificial intelligence-based drug discovery. I made a model that generates novel molecules, for ...
user avatar