How to install pymatgen-in-developmental-mode


#1

How to install pymatgen-in-developmental-mode

system
Linux platforms
Red Hat Enterprise Linux

first I started to install pymatgen-in-developmental-mode

I followed

1- bash Miniconda3-latest-Linux-x86_64.sh
2-source activate my_pymatgen
3-conda install --channel matsci pymatgen
4-conda install --channel matsci bader
conda install --channel matsci enumlib
5-Install pymatgen in developmental mode
6- I installed all requirements

and reach to
[dsherif@192 ~]$ pip install cython
Requirement already satisfied: cython in ./anaconda3/lib/python3.6/site-packages
[dsherif@192 ~]$

**Now I would like to know how to test that the installation worked,and to run the example how to get to write this input and run it **

In [1]: from pymatgen.analysis.defects.point_defects import Interstitial

In [2]: from pymatgen.core.structure import Structure

In [3]: structure = Structure.from_file(’/path/to/file’)

In [4]: radii, valences = {}, {}

In [5]: for element in structure.composition.elements:
…: radii[element.symbol] = element.atomic_radius
…: valence = element.group # Just a first guess…
…: if element.group > 12:
…: valence -= 10
…: valences[element.symbol] = valence

In [6]: interstitial = Interstitial(structure, radii=radii, valences=valences)

In [7]: interstitial._defect_sites:

Tried this
[dsherif@192 bin]$ pip install numpy
Requirement already satisfied: numpy in /home/dsherif/anaconda3/lib/python3.6/site-packages
[dsherif@192 bin]$ pip install pymatgen
Requirement already satisfied: pymatgen in /home/dsherif/anaconda3/lib/python3.6/site-packages
Requirement already satisfied: numpy>=1.9 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: six in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: requests in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: ruamel.yaml>=0.15.6 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: monty>=0.9.6 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: scipy>=1.0.0 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: pydispatcher>=2.0.5 in /home/dsherif/anaconda3/lib/python3.6/site-packages/PyDispatcher-2.0.5-py3.6.egg (from pymatgen)
Requirement already satisfied: tabulate in /home/dsherif/anaconda3/lib/python3.6/site-packages/tabulate-0.8.2-py3.6.egg (from pymatgen)
Requirement already satisfied: spglib>=1.9.9.44 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: matplotlib>=1.5 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: palettable>=2.1.1 in /home/dsherif/anaconda3/lib/python3.6/site-packages/palettable-3.1.0-py3.6.egg (from pymatgen)
Requirement already satisfied: sympy in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: pandas in /home/dsherif/anaconda3/lib/python3.6/site-packages (from pymatgen)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from requests->pymatgen)
Requirement already satisfied: idna<2.7,>=2.5 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from requests->pymatgen)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from requests->pymatgen)
Requirement already satisfied: certifi>=2017.4.17 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from requests->pymatgen)
Requirement already satisfied: python-dateutil>=2.1 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from matplotlib>=1.5->pymatgen)
Requirement already satisfied: pytz in /home/dsherif/anaconda3/lib/python3.6/site-packages (from matplotlib>=1.5->pymatgen)
Requirement already satisfied: cycler>=0.10 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from matplotlib>=1.5->pymatgen)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/dsherif/anaconda3/lib/python3.6/site-packages (from matplotlib>=1.5->pymatgen)

Thank you v. much

Sherif Yehia


#2

Hi Sherif,

Can you clarify what you mean by development mode? Are you trying to install the source so you can edit the code and use it? Also, can you tell us exactly what is going wrong when you try to do this?


#3

Hi Joseph
Thanks v. much for your answer to clarify
I am trying to calculate the Debye temperature for RFe2 compounds. As you advised previously we have to do it via the elastic tensor where I need to use this genus code and test it running. And I can put the data for the compound and get elastic tensor calculated
Please correct me if I misunderstood
So I moved to the site
http://pymatgen.org/installation.html#step-2-install-pymatgen-in-developmental-mode
I followed everything there couldn’t figure out how to test that the installation worked
I noticed as well I have to work with Git-Hub but still I must be doing something wrong
I am not able to reach here??
from pymatgen import MPRester
from pymatgen.analysis.elasticity import ElasticTensor

mpr = MPRester() # or with your API key
data = mpr.get_data(“mp-13”)[0]
structure = mpr.get_structure_by_material_id(“mp-13”)
et = ElasticTensor.from_voigt(data[‘elasticity’][‘elastic_tensor’])
print(et.debye_temperature_from_sound_velocities(structure))
Thanks v. much for all the effort to help
Sherif Yehia


#4

Certainly, we’re happy to help. As far as tests, if you can import pymatgen, i. e. import pymatgen doesn’t give an error, that typically means your installation is working.

In order to help you, I will need more a more explicit description of exactly what is going wrong. Is there some step of the developmental installation that fails, or is the execution of the code you’ve pasted resulting in an error? Please provide a more detailed description.

Also, just to clarify, is there a reason you want to install pymatgen in development mode? The only reason for this is if you want to edit the code yourself, you don’t have to install pymatgen in development mode in order to execute the code you’ve pasted.


#5

Hello Joseph

  • The spirit of helping other tremendously wonderful thank you. Now as you mention the pasted code is working perfectly really my goal is to calculate Debye temperature for some Rare earth transition metal kindly you sent a code for iron

I tried Co seems OK
from pymatgen import MPRester
from pymatgen.analysis.elasticity import ElasticTensor

if name == “main”:

MAPI_KEY =“MY_MAPI_KEY” # You must change this to your Materials API key! (or set MAPI_KEY env variable)
mpr = MPRester(MAPI_KEY)
data = mpr.get_data(“mp-102”)[0]
structure = mpr.get_structure_by_material_id(“mp-102”)
et = ElasticTensor.from_voigt(data[‘elasticity’][‘elastic_tensor’])
print(et.debye_temperature_from_sound_velocities(structure))
504.35658036473995

Now when I try other GdFe2 (mp-20089) gave the following error

Traceback (most recent call last):
File “1Tensor.py”, line 11, in
et = Elastic Tensor.from_voigt(data[‘elasticity’][‘elastic_tensor’])
Type Error: ‘None Type’ object is not subscript-able

is not working as far as I know (Not supported by the code)
I need to learn more as you advise (machine learning model for bulk and shear moduli ) I decided to learn in developmental mode still learning. WAITING YOUR ADVICE IF I AM in the right track.

Thank you

MOD EDIT: removed your API key from the code text, please do not share your personal API key in posts


#6

Ah, thanks for the clarification. The source of the error isn’t pymatgen, it’s the web data. The reason this code produces an error is because GdFe2 does not have an elastic tensor available on the web site (more specifically, data[‘elasticity’] is a null value because there isn’t elastic tensor data with GdFe2).

Currently, the MP database includes ~7000 elastic tensors, meaning that ~63000 materials do not have elastic tensor data. For GdFe2, you can request the bulk and shear moduli of the material using the “get predictions” button (see the image below).

If you’d prefer to use the API, you can the predicted bulk and shear moduli this way:

data = mpr.get_data("mp-20089", data_type='pred', prop="elastic_moduli")[0]
k = data['elastic_moduli']['K']
g = data['elastic_moduli']['G']

It’s a bit more involved, but you can estimate the debye temperature (via the speed of sound) from these quantities (the long_v, trans_v, and get_debye_temperature functions demonstrate how we calculate these from bulk/shear moduli and crystal structure). Also, note that the data includes a warning that estimates for bulk and shear moduli for F-block elements are typically not as accurate as those for non-rare-earth elements, so take these estimates with a grain of salt. Feel free to post further questions here if you’re still having issues.


Debye Temperature for Gd_Fe2 (mp-20089)