Git Product home page Git Product logo

xiaohang007 / slices Goto Github PK

View Code? Open in Web Editor NEW
36.0 1.0 4.0 229.78 MB

SLICES: An Invertible, Invariant, and String-based Crystal Representation (Text2Crystal)

Home Page: https://xiaohang007.github.io/SLICES/

License: GNU Lesser General Public License v2.1

Python 87.92% Shell 2.47% C 1.92% Jupyter Notebook 7.68%
crystallography deep-learning machine-learning materials-informatics materials-science smiles crystal representation

slices's Issues

Tokenization of SLICES strings and confusion with SMILES

Hello authors, thanks for open-sourcing this interesting work. I am interested in learning how SMILES strings can be tokenized for various language models. I was looking under HTS to understand how the RNN was trained on SLICES strings. However, all the code seems to be referring to SMILES strings. To clarify, is the code designed to operate on SMILES or SLICES data? Appreciate your clarification.

The paper states that the RNN is trained on SLICES strings, so I assume the approach here applies to that.

Error when I run on mac

Hello,

This is really great work! Excited to use slices. When I try to run on mac, this line:

reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)

Gives me the following error. Do you have any suggestions on what to do?


FileNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)

File ~/anaconda3/envs/htejk/lib/python3.11/site-packages/invcryrep/invcryrep.py:1815, in InvCryRep.SLICES2structure(self, SLICES, strategy)
1805 """Convert a SLICES string back to its original crystal structure.
1806
1807 Args:
(...)
1812 float: Energy per atom predicted with M3GNet.
1813 """
1814 self.from_SLICES(SLICES,strategy)
-> 1815 structures,final_energy_per_atom = self.to_structures()
1816 return structures[-1],final_energy_per_atom

File ~/anaconda3/envs/htejk/lib/python3.11/site-packages/invcryrep/invcryrep.py:1711, in InvCryRep.to_structures(self, bond_scaling, delta_theta, delta_x, lattice_shrink, lattice_expand, angle_weight, vbond_param_ave_covered, vbond_param_ave, repul)
1709 inner_p_target, colattice_inds, colattice_weights = self.get_inner_p_target_debug(bond_scaling)
1710 else:
-> 1711 inner_p_target, colattice_inds, colattice_weights = self.get_inner_p_target(bond_scaling)
1712 uncovered_pair = self.get_uncovered_pair(net.graph)
1713 uncovered_pair_lj = self.get_uncovered_pair_lj(uncovered_pair)

File ~/anaconda3/envs/htejk/lib/python3.11/site-packages/invcryrep/invcryrep.py:1128, in InvCryRep.get_inner_p_target(self, bond_scaling)
1113 """ Get inner product matrix, colattice indices, colattice weights.
1114
1115 (1) Get inner_p_target(inner_p matrix obtained by gfnff).
(...)
1125 list: Colattice weights.
1126 """
1127 nbf, blist = self.get_nbf_blist()
-> 1128 temp_dir = tempfile.TemporaryDirectory(dir="/dev/shm")
1129 try:
1130 with open(temp_dir.name+'/testBonds_cut.top','w') as f:

File ~/anaconda3/envs/htejk/lib/python3.11/tempfile.py:854, in TemporaryDirectory.init(self, suffix, prefix, dir, ignore_cleanup_errors)
852 def init(self, suffix=None, prefix=None, dir=None,
853 ignore_cleanup_errors=False):
--> 854 self.name = mkdtemp(suffix, prefix, dir)
855 self._ignore_cleanup_errors = ignore_cleanup_errors
856 self._finalizer = _weakref.finalize(
857 self, self._cleanup, self.name,
858 warn_message="Implicitly cleaning up {!r}".format(self),
859 ignore_errors=self._ignore_cleanup_errors)

File ~/anaconda3/envs/htejk/lib/python3.11/tempfile.py:368, in mkdtemp(suffix, prefix, dir)
366 _sys.audit("tempfile.mkdtemp", file)
367 try:
--> 368 _os.mkdir(file, 0o700)
369 except FileExistsError:
370 continue # try again

FileNotFoundError: [Errno 2] No such file or directory: '/dev/shm/tmpp6dvrbq7'

Output "ERROR - could not deal with graph with rank H1(X,Z) < 3"

Hi,

Thanks for the interesting work. I'm trying to generate slices with pymatgen structure as input. I noticed that in line 527 of invcryrep.py, it will print "ERROR - could not deal with graph with rank H1(X,Z) < 3". But that's not an error actually and I can still generate the corresponding slices. So I'm wondering why it matters to determine whether the rank of the graph is smaller than 3; even though a 3D embedding cannot be generated, I don't find such embeddings useful for building the slices representation.

Looking forward to hearing from you!

fail to load the backend

Hi, xiaohang. This is an great research and we want to using that to do some machine learning project to follow up. When I try to using SLICES following the tutorial, the install is success. But when I try to follow the examples, an error occur. Here is the command I use and the error massage, It seems that in the folder of models, no acceptable files format for the weights could be found.
`from invcryrep.utils import temporaryWorkingDirectory

from invcryrep.invcryrep import InvCryRep

from pymatgen.core.structure import Structure

with temporaryWorkingDirectory("/home/zhudan/Desktop/chengxi/temp"):

# obtaining the pymatgen Structure instance of NdSiRu

original_structure = Structure.from_file(filename='/home/zhudan/Desktop/chengxi/test.cif')

# creating an instance of the InvCryRep Class (initialization)

backend=InvCryRep()

# converting a crystal structure to its SLICES string

slices_NdSiRu=backend.structure2SLICES(original_structure)

# converting a SLICES string back to its original crystal structure and obtaining its M3GNet_IAP-predicted energy_per_atom

reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)

print('SLICES string of NdSiRu is: ',slices_NdSiRu)

print('\nOriginal_structure is: ',original_structure)

print('\nReconstructed_structure is: ',reconstructed_structure)

print('\nfinal_energy_per_atom_IAP is: ',final_energy_per_atom_IAP,' eV/atom')` 

`Traceback (most recent call last):
File "/home/zhudan/Desktop/chengxi_mace/pythonProject/main.py", line 9, in
backend=InvCryRep()

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/invcryrep/invcryrep.py", line 112, in init
self.relaxer = Relaxer(optimizer=optimizer)

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_dynamics.py", line 122, in init
potential = Potential(M3GNet.load())

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_m3gnet.py", line 363, in load
return cls.load(os.path.join(CWD, model_name))

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_m3gnet.py", line 367, in load
return cls.from_dir(model_name)

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_m3gnet.py", line 336, in from_dir
model.load_weights(model_name)

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
raise e.with_traceback(filtered_tb) from None

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/keras/src/saving/saving_api.py", line 237, in load_weights
raise ValueError(
ValueError: File format not supported: filepath=/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/MP-2021.2.8-EFS/m3gnet. Keras 3 only supports V3 .keras and .weights.h5 files, or legacy V1/V2 .h5 files.
`
would you please help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.