AIforGreatGood / charge3net

Higher-order equivariant neural networks for charge density prediction in materials
https://www.nature.com/articles/s41524-024-01343-1
MIT License
29 stars 8 forks source link

RuntimeError:The number of scaling factors must be 1 or 3. #5

Open kk154 opened 3 weeks ago

kk154 commented 3 weeks ago

Hello, when I use NMC and MP, I get RuntimeError: The number of scaling factors must be 1 or 3. Please tell me how should I solve this problem,thanks

kk154 commented 3 weeks ago

This problem occurs from date.py--->"vasp_charge = VaspChargeDensity(filename=tmppath)", File "/home/kk/data/code/charge3net-mp-download-fix/scripts/batch_pickle_mp_charge_density.py", line 42, in main density, atoms, origin = read_vasp(dec, read_spin=read_spin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kk/data/code/charge3net-mp-download-fix/scripts/data.py", line 131, in read_vasp vasp_charge = VaspChargeDensity(filename=tmppath) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kk/anaconda3/envs/py3.11/lib/python3.11/site-packages/ase/calculators/vasp/vasp_auxiliary.py", line 39, in init self.read(filename) File "/home/kk/anaconda3/envs/py3.11/lib/python3.11/site-packages/ase/calculators/vasp/vasp_auxiliary.py", line 90, in read atoms = aiv.read_vasp(fd) ^^^^^^^^^^^^^^^^^ File "/home/kk/anaconda3/envs/py3.11/lib/python3.11/site-packages/ase/utils/init.py", line 577, in iofunc obj = func(fd, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kk/anaconda3/envs/py3.11/lib/python3.11/site-packages/ase/io/vasp.py", line 147, in read_vasp raise RuntimeError('The number of scaling factors must be 1 or 3.') RuntimeError: The number of scaling factors must be 1 or 3.

keeganq commented 3 weeks ago

scripts/batch_pickle_mp_charge_density.py is written to preprocess the materials project dataset, where the charge density data is in CHGCAR format. This stage of preprocessing is not needed for NMC or QM9, which are downloaded as .tar files, and can be read directly from those .tar files using our provided configs and dataloaders

kk154 commented 3 weeks ago

When I use "python scripts/batch_pickle_mp_charge_density.py --raw_data_dir ./data/mp_raw --pkl_data_dir ./data/mp/" to convert the CHGCAR files from MP dataset and use "python src/train_from_config.py -cd configs/charge3net -cn train_nmc_e3_final.yaml" to train NMC dataset ,it will appear “RuntimeError: The number of scaling factors must be 1 or 3.". But When I look at the files within the dataset the scaling factor seems to be correct.

Hayley2000s commented 2 weeks ago

I ran into the same bug too. but I find it can be solved by installing ase==3.22.1 instead of ase==3.23.0(the latest). hope this is helpful to you.

keeganq commented 2 weeks ago

Thanks for figuring this out @Hayley2000s. It seems like an issue with the latest release of ase.

Looks like there's a related issue and patch on the ase development branch.