Skip to content

JOSS Review: Example Python script is missing properties #23

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

Closed
Andrew-S-Rosen opened this issue Mar 13, 2021 · 2 comments
Closed

JOSS Review: Example Python script is missing properties #23

Andrew-S-Rosen opened this issue Mar 13, 2021 · 2 comments

Comments

@Andrew-S-Rosen
Copy link

Andrew-S-Rosen commented Mar 13, 2021

RE: openjournals/joss-reviews#3089

In the main README, the example Python code crashes at isosurface.properties_norms because the surface does not have face properties. I would suggest one of two options:

  1. Remove isosurface.properties_norms and isosurface.scalar_projection((0, 0, 1) to exclude the property mapping altogether or
  2. Add property (e.g. velocity) data prior to calculating the norm of the vectors. A modified script is below that should work.
from pymatgen.io.vasp.outputs import Vasprun
from ifermi.surface import FermiSurface
from ifermi.interpolate import FourierInterpolator
from ifermi.plot import FermiSlicePlotter, FermiSurfacePlotter, save_plot, show_plot
from ifermi.kpoints import kpoints_from_bandstructure

# load VASP calculation outputs
vr = Vasprun("vasprun.xml")
bs = vr.get_band_structure()

# interpolate the energies onto a dense k-point mesh
interpolator = FourierInterpolator(bs)
dense_bs, velocities = interpolator.interpolate_bands(return_velocities=True)
dense_kpoints = kpoints_from_bandstructure(dense_bs)

# generate the Fermi surface and calculate the dimensionality
fs = FermiSurface.from_band_structure(
  dense_bs, mu=0.0, wigner_seitz=True, calculate_dimensionality=True,
  property_data=velocities, property_kpoints=dense_kpoints
)

# number of isosurfaces in the Fermi surface
fs.n_surfaces

# number of isosurfaces for each Spin channel
fs.n_surfaces_per_spin

# the total area of the Fermi surface
fs.area

# the area of each isosurface
fs.area_surfaces

# loop over all isosurfaces and check their properties
# the isosurfaces are given as a list for each spin channel
for spin, isosurfaces in fs.isosurfaces.items():
  for isosurface in isosurfaces:
    # the dimensionality (does the surface cross periodic boundaries)
    isosurface.dimensionality

    # what is the orientation
    isosurface.orientation

    # does the surface have face properties
    isosurface.has_properties

    # calculate the norms of the properties
    isosurface.properties_norms

    # calculate scalar projection of properties on to [0 0 1] vector
    isosurface.scalar_projection((0, 0, 1))

    # uniformly sample the surface faces to a consistent density
    isosurface.sample_uniform(0.1)

# plot the Fermi surface
fs_plotter = FermiSurfacePlotter(fs)
plot = fs_plotter.get_plot()

# generate Fermi slice along the (0 0 1) plane going through the Γ-point.
fermi_slice = fs.get_fermi_slice((0, 0, 1))

# number of isolines in the slice
fermi_slice.n_lines

# do the lines have segment properties
fermi_slice.has_properties

# plot slice
slice_plotter = FermiSlicePlotter(fermi_slice)
plot = slice_plotter.get_plot()

save_plot(plot, "fermi-slice.png")  # saves the plot to a file
show_plot(plot)  # displays an interactive plot
@utf
Copy link
Collaborator

utf commented Mar 13, 2021

Thanks @arosen93. This is a great catch. I will update the script to include the projections.

@utf
Copy link
Collaborator

utf commented Mar 13, 2021

Ok, the README has been updated.

@utf utf closed this as completed Mar 13, 2021
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