Comments (4)
when i first tried StructureVis
1-2 years ago i got the same behavior. not sure when it was last working. bug fix PRs welcome!
from pymatgen.
I've discovered that the issue is two-fold.
- I failed to read the documentation correctly and didn't realize that I needed to use the set_structure function on the newly created StructureVis object to actually give it something to render. That was why it was just showing a blank white window. My script should have been written like this.
from pymatgen.vis.structure_vtk import StructureVis
from pymatgen.core import Structure
structure = Structure.from_file("Ca2CuO3.cif")
vis = StructureVis()
vis.set_structure(structure)
vis.show()
- However, this script also errors out because of the add_polyhedron function in the structure_vtk module which gets called because
show_polyhedron = True
by default. When trying to figure out how to color the polyhedron, the module tries to make the polyhedron the same color as the center atom, but when the occupations of the center atom are fractional it will use the color of the center atom with the highest occupation.
if color == "element":
# If partial occupations are involved, the color of the specie with
# the highest occupation is used
max_occu = 0.0
for specie, occu in center.species.items():
if occu > max_occu:
max_specie = specie
max_occu = occu
color = [i / 255 for i in self.el_color_mapping[max_specie.symbol]]
ac.GetProperty().SetColor(color)
else:
ac.GetProperty().SetColor(color)
The main issue here is that the "color" variable is an array of fractional rgb values (ex: [1,0,0]), and I can't seem to find where this comparison against a string "element" comes from or why that was used. This can be solved relatively easily by either setting show_polyhedron = False
when creating the StructureVis object, or by changing the condition to if len(center.species.items()) > 1:
.
I don't have a lot of experience contributing to open source projects on github but I can try to submit a bug fix PR in the next couple days.
from pymatgen.
Update, I actually may have misrepresented the issue slightly. It doesn't actually have anything to do with whether the center atom has multiple occupations or not, it all just comes down to that check of if color == "element":
and that at no point in the code does color ever seem to be stored as a string. I don't think the proposed solution should be any different though.
from pymatgen.
Yes, I don’t know that this is actively used. I would usually point people towards Crystal Toolkit since it has native support for Structure
visualisation in Jupyter etc., however it’s in need of some updated documentation.
from pymatgen.
Related Issues (20)
- Monthly issue metrics report
- StructureMatcher might be wrong when used to check if two structures are equal. HOT 3
- Error in CP2K output parser structure parsing
- Bug in `core.composition` comparison
- Argument `check_occu` is not working as intended (in `_get_structure` and `parse_structures`) HOT 15
- Check inputs provided to MPRester functions
- `.as_dict()` method on `VaspInput` causes an `AttributeError`
- A minor document error in `POTCAR Setup`.
- Incorrect letter cases for memory in `core.units`
- GaussianOutput.read_excitation_energies() method for obtaining TDDFT results ([(energie (eV), lambda (nm), oscillatory strength), ... ]) error
- Adapt LobsterSets to latest potcars
- Support parsing of NBANDS from a VASP OUTCAR file
- determine crystal space group error
- Incorrect SpaceGroup symbol attribute for 16 space group types HOT 7
- Why does OUTCAR only parse the final magnetic moments? HOT 1
- Species.full_electronic_structure is incorrect HOT 2
- electronic_structure energy ordering is incorrect HOT 1
- Slab termination in coherent_interfaces.py
- TypeError: deprecated() got an unexpected keyword argument 'deadline' HOT 5
- [CI] All unit tests failing perhaps related to lastest `chgnet` 0.3.7 release HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymatgen.