Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'ase' #95

Open
Vahid999 opened this issue Dec 26, 2024 · 3 comments
Open

ModuleNotFoundError: No module named 'ase' #95

Vahid999 opened this issue Dec 26, 2024 · 3 comments

Comments

@Vahid999
Copy link

Vahid999 commented Dec 26, 2024

Following the instructions on solid_dmft/doc/tutorials/correlated_bandstructure
/plot_correlated_bands.ipynb for SVO, I prepared the following script to extract the Im(Sigma) versus energy from the .h5 file:

`# Import the modules:
from IPython.display import display
from IPython.display import Image
import numpy as np
import importlib, sys
import matplotlib.pyplot as plt
from matplotlib import cm
from timeit import default_timer as timer

from ase.io.espresso import read_espresso_in

from h5 import HDFArchive
from solid_dmft.postprocessing import plot_correlated_bands as pcb

freq_mesh_kslice = {'window': [-0.5, 0.5], 'n_w': int(1e6)}
freq_mesh_bands = {'window': [-5, 5], 'n_w': int(1e3)}
freq_mesh = freq_mesh_kslice if kslice else freq_mesh_bands

dmft_path = './Ca2N.h5'

proj_on_orb = orbital_order_to.index(proj_on_orb) if proj_on_orb else None
sigma_dict = {'dmft_path': dmft_path, 'it': 'last_iter', 'orbital_order_dmft': orbital_order_to, 'spin': 'up',
'block': 0, 'eta': 0.0, 'w_mesh': freq_mesh, 'linearize': False, 'proj_on_orb' : proj_on_orb}

with HDFArchive(dmft_path, 'r') as h5:
sigma_freq = h5['DMFT_results']['last_iter']['Sigma_freq_0']

fig, ax = plt.subplots(1, 2, figsize=(10,2), squeeze=False, dpi=200)

orb = 0
sp = 'up_0'
freq_mesh = np.array([w.value for w in sigma_freq[sp][orb,orb].mesh])

ax[0,0].plot(freq_mesh, sigma_freq[sp][orb,orb].data.real)
ax[0,1].plot(freq_mesh, -sigma_freq[sp][orb,orb].data.imag)

ax[0,0].set_ylabel(r'Re$\Sigma(\omega)$')
ax[0,1].set_ylabel(r'Im$\Sigma(\omega)$')
for ct in range(2):
ax[0,ct].grid()
ax[0,ct].set_xlim(-2, 2)
ax[0,ct].set_xlabel(r'$\omega$ (eV)')`

I get the following error:

from ase.io.espresso import read_espresso_in ModuleNotFoundError: No module named 'ase'

Maybe the tutorial is for a different version of the code. My dmft_config.toml file is

`[general]
seedname = "Ca2N"
jobname = "triqs"
csc = true

eta = 0.5
n_iw = 1025
n_tau = 10001

n_iter_dmft_first = 2
n_iter_dmft_per = 1
n_iter_dmft = 10

block_threshold = 1e-05

h_int_type = "kanamori"
U = 2.5
J = 0.0
beta = 60
prec_mu = 0.0001

sigma_mix = 1.0
g0_mix = 1.0
dc_type = 0
dc = true
dc_dmft = true
calc_energies = true

h5_save_freq = 1

store_solver = false
enforce_off_diag = false
h_int_basis = "qe"

[solver]
type = "hubbardI"
n_l = 15
measure_G_l = false
measure_density_matrix = true

[dft]
dft_code = "qe"
n_cores = 64
mpi_env = "openmpi"
projector_type = "w90"
dft_exec = "pw.x"
w90_tolerance = 1e-2`

The iterations finish successfully.

If I remove "from ase.io.espresso import read_espresso_in" from the script, I get the following error:

File "/gpfs/scratch/vaskarpo/DMFT/new/test.py", line 17, in <module> import solid_dmft.postprocessing.plot_correlated_bands as pcb File "/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v4/MPI/gcc12/openmpi4/triqs/3.3.1/lib/python3.11/site-packages/solid_dmft/postprocessing/plot_correlated_bands.py", line 46, in <module> import skimage.measure ModuleNotFoundError: No module named 'skimage'

Thank you,
Vahid

@Vahid999
Copy link
Author

After several attempts, the following script works for the 3.3.1 version of Triqs:

`import os
import sys
from itertools import product
import numpy as np
np.set_printoptions(precision=4,suppress=True, linewidth=140)
import scipy

import matplotlib.pyplot as plt

from h5 import HDFArchive
from triqs.gf import *
from triqs.gf.descriptors import Fourier, Omega
from triqs.plot.mpl_interface import plt,oplot
from triqs.lattice.utils import TB_from_wannier90, k_space_path
import solid_dmft.postprocessing.maxent_sigma as sigma_maxent

dmft_path = './Ca2N.h5'

with HDFArchive(dmft_path, 'r') as h5:

fig, ax = plt.subplots(dpi=150, figsize=(6,3))

ax.oplot(Sigma_imp_iw['up_0'].imag, '-o', c='C0', label='s')

ax.set_ylabel(r"Im $\Sigma (i \omega)$")
ax.set_xlim(0,10)
plt.savefig('Sigma.pdf')`

The self-energy seems very small and flat. Somehow I expected it to be larger and drop near the origin. Any thoughts on this would be appreciated.

Vahid
Sigma.pdf

@the-hampel
Copy link
Member

Hi Vahid,

sry for the slow response. I was on vacation during the break. In fact the postprocessing routines of solid_dmft do require the module skimage, which you can simply install via pip:

pip install scikit-image

https://pypi.org/project/scikit-image/

And for some part of the tutorial we also do require ASE, which you can also install via pip:

pip install ase

https://pypi.org/project/ase/

@the-hampel
Copy link
Member

Regarding your question for the shape of the self-energy:

The self-energy seems very small and flat. Somehow I expected it to be larger and drop near the origin. Any thoughts on this would be appreciated.
I saw in your config file that you are using the hubbardI impurity solver. This will result in strictly no imaginary part (except the broadening due to temperature). So the plot you attached is perfectly reasonable. If you plot the real part of the self energy you should see also a flat line but at a finite value. The hubbardI solver neglects the bath coupling of the impurity and thus the self-energy has no frequency dependence. Only if you use a different solver, e.g. cthyb you will see some frequency dependence and imaginary part.

Let me know if you have any questions.

Best,
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants