Skip to content

[WIP] Implementation of 2D crystal former #7

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

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
57b6816
giggle edit
Oct 30, 2024
2f39564
try.py
Oct 30, 2024
3265736
3d worked
Oct 31, 2024
4416137
wyckoff.py changed to layer group
Oct 31, 2024
d261ed3
lattice.py modified to layer group
Nov 2, 2024
12b6193
lattice.py modify
Nov 2, 2024
7b0c8d3
meeting
Nov 5, 2024
3eaf53e
run problem on mac os solved
Nov 6, 2024
e5ed851
gaussian sample added
Nov 8, 2024
e3f4893
loss.py z-axis changed to gaussian
Nov 10, 2024
7a3379f
save
Nov 11, 2024
d0f300d
need to define obj
Nov 11, 2024
d39c173
edit loss.py to obj orin
Nov 11, 2024
8dbd881
loss.py, sample.py, mcmc.py changed to class SpaceGroup
Nov 12, 2024
67950eb
merge to main
Nov 12, 2024
b5901d2
merge
Nov 12, 2024
7ae2553
changed to layer group
Nov 15, 2024
69e1c43
roll back
Nov 19, 2024
863a13d
update
Nov 19, 2024
e4816f3
update
Nov 19, 2024
d377a7f
update
Nov 19, 2024
9264a73
update
Nov 19, 2024
7184e1c
update
Nov 19, 2024
75974d4
up
Nov 19, 2024
78fa26b
remove data
Nov 19, 2024
f49c13f
remove data
Nov 19, 2024
e5ff593
remove data
Nov 19, 2024
73be251
add tables as attributes
Nov 19, 2024
c85df0d
up
Nov 20, 2024
b59e090
modify the tests
Nov 20, 2024
a1fe51b
tests modified
Nov 20, 2024
6f7ab11
up
Nov 20, 2024
1caf726
finished
Nov 21, 2024
bed0fda
layer group and tests
Nov 22, 2024
f3dc2ba
c2db data process
Nov 24, 2024
a242b1c
c2db data process
Nov 24, 2024
5a8e0cc
use spglib to process c2db dataset
Dec 5, 2024
64553cc
process c2db using spglib
Dec 5, 2024
5b334d7
editing awl2struct
Dec 5, 2024
d2e473c
add GLAWX -> Structure
Dec 6, 2024
2126713
argsort the wyckoff number
Dec 9, 2024
c2e8a8c
test utils and awl2struct
Dec 9, 2024
c49dbb1
test awl2struct
Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
job*
*.out
__pycache__/
./mp_20/*.csv
375 changes: 375 additions & 0 deletions .ipynb_checkpoints/try-checkpoint.ipynb

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default: test

.PHONY: test test-% train sample

TESTS = $(shell find ./tests -name "test_*.py")

test-%:
python ./tests/test_$*.py

test:
@for TEST in $(TESTS); do \
echo "run $$TEST"; \
python $$TEST; \
done

train:
python ./main.py --folder ./data/ --train_path ./mp_20/train_layer_test.csv --valid_path ./mp_20/val_layer_test.csv --epochs 200

sample:
python ./main.py --optimizer none --test_path ./mp_20/test_layer_test.csv --restore_path ./data/adam_bs_100_lr_0.0001_decay_0_clip_1_A_119_W_28_N_21_a_1_w_1_l_1_Nf_5_Kx_16_Kl_4_h0_256_l_16_H_16_k_64_m_64_e_32_drop_0.5/epoch_000100.pkl --spacegroup 65 --num_samples 10 --batchsize 200 --temperature 1.0 --elements C
Binary file added c2db/.DS_Store
Binary file not shown.
Binary file added c2db/A/.DS_Store
Binary file not shown.
Binary file added c2db/A/2C/.DS_Store
Binary file not shown.
44 changes: 44 additions & 0 deletions c2db/A/2C/1/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"folder": "/home/niflheim2/cmr/C2DB-ASR/tree/A/C/C2-a6735a4a3797",
"uid": "2C-1",
"olduid": "C2-a6735a4a3797",
"international": "P6/mmm",
"number": 191,
"pointgroup": "6/mmm",
"has_inversion_symmetry": true,
"lgnum": 80,
"layergroup": "p6/mmm",
"bravais_type": "Hexagonal (hp)",
"thickness": 3.224913225352566e-08,
"label": "original03-18",
"gap": 0.0003000685114302737,
"gap_dir": 0.0003000685114309398,
"gap_dir_nosoc": 0.000308946496943463,
"evac": 2.3363375983102452,
"efermi": -4.248481577688634,
"vbm": -4.248631611944349,
"cbm": -4.2483315434329185,
"minhessianeig": -7.00605419619458e-12,
"dyn_stab": "Yes",
"gap_hse": 0.0002564957267392476,
"gap_dir_hse": 0.0002564957267392476,
"efermi_hse": -4.213085568171573,
"vbm_hse": -4.213213816034942,
"cbm_hse": -4.212957320308203,
"alphax_el": 6.574592003348396,
"alphay_el": 6.574592003348392,
"alphaz_el": 0.1533681498711251,
"plasmafrequency_x": 0.0,
"plasmafrequency_y": 0.0,
"energy": -18.453766945888727,
"icsd_id": 96620,
"cod_id": 9012705,
"doi": "10.1126/science.1102896",
"is_magnetic": false,
"spin_axis": "z",
"dE_zx": 0.0,
"dE_zy": 0.0,
"topology": "Z2=1,C_M=1",
"ehull": 0.0,
"hform": -0.007391614814171277
}
4 changes: 4 additions & 0 deletions c2db/A/2C/1/magmoms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"folder": "/home/niflheim2/cmr/C2DB-ASR/tree/A/C/C2-a6735a4a3797",
"uid": "2C-1"
}
7 changes: 7 additions & 0 deletions c2db/A/2C/1/read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import re

def lattice_from_file(file_path):
f = open(file_path, "r")
lines = f.readlines()
lattice_str = re.search(r'Lattice="([^"]+)"', lines[1]).group(1)
lattice_list = [eval(v) for v in lattice_str]
108 changes: 108 additions & 0 deletions c2db/A/2C/1/results-asr.stiffness.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"object_id": "asr.stiffness::Result",
"constructor": "asr.stiffness::Result",
"args": [],
"kwargs": {
"data": {
"speed_of_sound_x": 21373.063352135574,
"speed_of_sound_y": 21370.856641622737,
"c_11": 345.6538905582198,
"c_12": 70.60779871921024,
"c_13": 0.0005778599312093563,
"c_14": null,
"c_15": null,
"c_16": null,
"c_21": 70.56537570227611,
"c_22": 345.58251859948973,
"c_23": 5.3339141915441094e-05,
"c_24": null,
"c_25": null,
"c_26": null,
"c_31": -1.48020629620793e-13,
"c_32": -3.171870634731279e-14,
"c_33": 275.09324474892543,
"c_34": null,
"c_35": null,
"c_36": null,
"c_41": null,
"c_42": null,
"c_43": null,
"c_44": null,
"c_45": null,
"c_46": null,
"c_51": null,
"c_52": null,
"c_53": null,
"c_54": null,
"c_55": null,
"c_56": null,
"c_61": null,
"c_62": null,
"c_63": null,
"c_64": null,
"c_65": null,
"c_66": null,
"__links__": {
"strains--1.0%-xx": "C2-b088c34acc1b",
"strains-+1.0%-xx": "C2-df0c254be7f9",
"strains--1.0%-yy": "C2-65c455263aaa",
"strains-+1.0%-yy": "C2-2fc059f556fa",
"strains--1.0%-xy": "C2-9ec52112fdfe",
"strains-+1.0%-xy": "C2-92a5b8f033fd"
},
"stiffness_tensor": {
"__ndarray__": [
[
3,
3
],
"float64",
[
345.6538905582198,
70.60779871921024,
0.0005778599312093563,
70.56537570227611,
345.58251859948973,
5.3339141915441094e-05,
-1.48020629620793e-13,
-3.171870634731279e-14,
275.09324474892543
]
]
},
"eigenvalues": {
"__ndarray__": [
[
3
],
"float64",
[
416.20479762329126,
275.03161153441835,
275.09324474892543
]
]
},
"dynamic_stability_stiffness": "high"
},
"metadata": {
"asr_name": "asr.stiffness",
"resources": {
"time": 0.05871438980102539,
"ncores": 1,
"tstart": 1605182101.3158286,
"tend": 1605182101.374543
},
"params": {
"strain_percent": 1.0
},
"code_versions": {
"asr": "0.4.1-fef8a0ce2ab711c3284f5dbfd158907b17f534e9",
"ase": "3.21.0b1-8a83b7f6a6fd68b95b9f542d7c054fa7204d764a",
"gpaw": "20.10.1b1-7ff8d570c9d25f2af1c40c00271000e3ab505f1c"
},
"creates": {}
},
"strict": true
}
}
4 changes: 4 additions & 0 deletions c2db/A/2C/1/structure.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2
Lattice="2.4672312604313453 -1.7550685731635223e-20 0.0 -1.233615630215672 2.1366849485446453 0.0 1.118374734265682e-17 0.0 15.0" Properties=species:S:1:pos:R:3 energy=-18.453766945888727 dipole="0.8699688255098961 -0.5022767355947244 3.473501422988429e-08" free_energy=-18.45387516640614 pbc="T T F"
C 0.00000000 0.00000000 7.49999997
C 1.23361563 0.71222832 7.50000001
72 changes: 72 additions & 0 deletions c2db_problem.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"C2DB dataset has two components: `data.json` and `structure.xyz`.\n",
"The `data.json` file stores properties of the material:\n",
"```\n",
"{\n",
" \"folder\": \"/home/niflheim2/cmr/C2DB-ASR/tree/A/C/C2-a6735a4a3797\",\n",
" \"uid\": \"2C-1\",\n",
" \"olduid\": \"C2-a6735a4a3797\",\n",
" \"international\": \"P6/mmm\",\n",
" \"number\": 191,\n",
" \"pointgroup\": \"6/mmm\",\n",
" \"has_inversion_symmetry\": true,\n",
" \"lgnum\": 80,\n",
" \"layergroup\": \"p6/mmm\",\n",
" \"bravais_type\": \"Hexagonal (hp)\",\n",
" \"thickness\": 3.224913225352566e-08,\n",
" \"label\": \"original03-18\",\n",
" \"gap\": 0.0003000685114302737,\n",
" \"gap_dir\": 0.0003000685114309398,\n",
" \"gap_dir_nosoc\": 0.000308946496943463,\n",
" \"evac\": 2.3363375983102452,\n",
" \"efermi\": -4.248481577688634,\n",
" \"vbm\": -4.248631611944349,\n",
" \"cbm\": -4.2483315434329185,\n",
" \"minhessianeig\": -7.00605419619458e-12,\n",
" \"dyn_stab\": \"Yes\",\n",
" \"gap_hse\": 0.0002564957267392476,\n",
" \"gap_dir_hse\": 0.0002564957267392476,\n",
" \"efermi_hse\": -4.213085568171573,\n",
" \"vbm_hse\": -4.213213816034942,\n",
" \"cbm_hse\": -4.212957320308203,\n",
" \"alphax_el\": 6.574592003348396,\n",
" \"alphay_el\": 6.574592003348392,\n",
" \"alphaz_el\": 0.1533681498711251,\n",
" \"plasmafrequency_x\": 0.0,\n",
" \"plasmafrequency_y\": 0.0,\n",
" \"energy\": -18.453766945888727,\n",
" \"icsd_id\": 96620,\n",
" \"cod_id\": 9012705,\n",
" \"doi\": \"10.1126/science.1102896\",\n",
" \"is_magnetic\": false,\n",
" \"spin_axis\": \"z\",\n",
" \"dE_zx\": 0.0,\n",
" \"dE_zy\": 0.0,\n",
" \"topology\": \"Z2=1,C_M=1\",\n",
" \"ehull\": 0.0,\n",
" \"hform\": -0.007391614814171277\n",
"}\n",
"```\n",
"And the `structure.xyz` file stores information about the cell and the lattice:\n",
"```\n",
"2\n",
"Lattice=\"2.4672312604313453 -1.7550685731635223e-20 0.0 -1.233615630215672 2.1366849485446453 0.0 1.118374734265682e-17 0.0 15.0\" Properties=species:S:1:pos:R:3 energy=-18.453766945888727 dipole=\"0.8699688255098961 -0.5022767355947244 3.473501422988429e-08\" free_energy=-18.45387516640614 pbc=\"T T F\"\n",
"C 0.00000000 0.00000000 7.49999997\n",
"C 1.23361563 0.71222832 7.50000001\n",
"```\n"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
7 changes: 7 additions & 0 deletions c2db_try.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import matplotlib.pyplot as plt
from ase.db import connect

db = connect('c2db.db')
rows = db.select('layergroup')

rows.layergroup
11 changes: 11 additions & 0 deletions crystalformer.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Metadata-Version: 2.1
Name: crystalformer
Version: 0.3
Summary: CrystalFormer is a transformer-based autoregressive model specifically designed for space group-controlled generation of crystalline materials.
Home-page: https://github.com/deepmodeling/CrystalFormer
Author: iopcompphys
Author-email: zdcao@iphy.ac.cn, wanglei@iphy.ac.cn
License: Apache License
Keywords: Crystal Generation
Platform: any
License-File: LICENSE
38 changes: 38 additions & 0 deletions crystalformer.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
LICENSE
README.md
setup.py
crystalformer/__init__.py
crystalformer.egg-info/PKG-INFO
crystalformer.egg-info/SOURCES.txt
crystalformer.egg-info/dependency_links.txt
crystalformer.egg-info/top_level.txt
crystalformer/data/layer.csv
crystalformer/data/wyckoff_list.csv
crystalformer/data/wyckoff_symbols.csv
crystalformer/extension/__init__.py
crystalformer/extension/experimental.py
crystalformer/extension/loss.py
crystalformer/extension/mcmc.py
crystalformer/extension/model.py
crystalformer/extension/train.py
crystalformer/extension/transformer.py
crystalformer/src/__init__.py
crystalformer/src/attention.py
crystalformer/src/checkpoint.py
crystalformer/src/elements.py
crystalformer/src/lattice.py
crystalformer/src/loss.py
crystalformer/src/mcmc.py
crystalformer/src/sample.py
crystalformer/src/sym_group.py
crystalformer/src/train.py
crystalformer/src/transformer.py
crystalformer/src/utils.py
crystalformer/src/von_mises.py
crystalformer/src/wyckoff.py
tests/test_fc_mask.py
tests/test_lattice.py
tests/test_sampling.py
tests/test_transformer.py
tests/test_utils.py
tests/test_wyckoff.py
1 change: 1 addition & 0 deletions crystalformer.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions crystalformer.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crystalformer
Binary file added crystalformer/.DS_Store
Binary file not shown.
Loading