ion-CSP 2.1.3__py3-none-any.whl → 2.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ion_CSP/__init__.py CHANGED
@@ -1,8 +1,8 @@
1
1
  __author__ = "Ze Yang"
2
2
  __contact__ = "yangze1995007@163.com"
3
3
  __license__ = "MIT"
4
- __version__ = "2.1.3"
5
- __date__ = "2025-06-11"
4
+ __version__ = "2.1.5"
5
+ __date__ = "2025-06-16"
6
6
 
7
7
 
8
8
  try:
ion_CSP/gen_opt.py CHANGED
@@ -4,11 +4,12 @@ import time
4
4
  import shutil
5
5
  import logging
6
6
  import subprocess
7
+ import importlib.resources
8
+ from typing import List
7
9
  from ase.io import read
10
+ from dpdispatcher import Machine
8
11
  from pyxtal import pyxtal
9
12
  from pyxtal.msg import Comp_CompatibilityError, Symm_CompatibilityError
10
- from dpdispatcher import Machine
11
- from typing import List
12
13
  from ion_CSP.log_and_time import redirect_dpdisp_logging
13
14
 
14
15
 
@@ -18,30 +19,32 @@ class CrystalGenerator:
18
19
  Initialize the class based on the provided ionic crystal composition structure files and corresponding composition numbers.
19
20
  """
20
21
  redirect_dpdisp_logging(os.path.join(work_dir, "dpdispatcher.log"))
21
- self.script_dir = os.path.dirname(__file__)
22
- self.mlp_opt_file = os.path.join(self.script_dir, "mlp_opt.py")
23
- self.model_file = os.path.join(self.script_dir, "../../model/model.pt")
22
+ # self.script_dir = os.path.dirname(__file__)
23
+ # self.mlp_opt_file = os.path.join(self.script_dir, "mlp_opt.py")
24
+ # self.model_file = os.path.join(self.script_dir, "../../model/model.pt")
25
+ self.mlp_opt_file = importlib.resources.files("ion_CSP").joinpath("mlp_opt.py")
26
+ self.model_file = importlib.resources.files("ion_CSP.model").joinpath("model.pt")
24
27
  # 获取当前脚本的路径以及同路径下离子晶体组分的结构文件, 并将这一路径作为工作路径来避免可能的错误
25
28
  self.base_dir = work_dir
26
29
  os.chdir(self.base_dir)
27
30
  self.ion_numbers = ion_numbers
28
31
  self.species = species
29
32
  self.species_paths = []
30
- ion_atomss, species_atomss = [], []
33
+ ion_atomss, species_atoms = [], []
31
34
  # 读取离子晶体各组分的原子数,并在日志文件中记录
32
35
  for ion, number in zip(self.species, self.ion_numbers):
33
36
  species_path = os.path.join(self.base_dir, ion)
34
37
  self.species_paths.append(species_path)
35
38
  species_atom = len(read(species_path))
36
- species_atomss.append(species_atom)
37
- species_atoms = species_atom * number
38
- ion_atomss.append(species_atoms)
39
+ species_atoms.append(species_atom)
40
+ ion_atoms = species_atom * number
41
+ ion_atomss.append(ion_atoms)
39
42
  self.cell_atoms = sum(ion_atomss)
40
43
  logging.info(
41
44
  f"The components of ions {self.species} in the ionic crystal are {self.ion_numbers}"
42
45
  )
43
46
  logging.info(
44
- f"The number of atoms for each ion is: {species_atomss}, and the total number of atoms is {self.cell_atoms}"
47
+ f"The number of atoms for each ion is: {species_atoms}, and the total number of atoms is {self.cell_atoms}"
45
48
  )
46
49
  self.generation_dir = os.path.join(self.base_dir, "1_generated")
47
50
  os.makedirs(self.generation_dir, exist_ok=True)
@@ -199,14 +202,10 @@ class CrystalGenerator:
199
202
  logging.info("Start running phonopy processing ...")
200
203
  for _, filename in POSCAR_file_index_pairs:
201
204
  self._single_phonopy_processing(filename=filename)
202
- # 准备dpdispatcher运行所需的文件,将其复制到primitive_cell文件夹中
203
- self.required_files = [self.mlp_opt_file, self.model_file]
204
- for file in self.required_files:
205
- shutil.copy(file, self.primitive_cell_dir)
205
+ # 在 phonopy 成功进行对称化处理后,删除 1_generated/POSCAR_Files 文件夹以节省空间
206
206
  logging.info(
207
207
  "The phonopy processing has been completed!!\nThe symmetrized primitive cells have been saved in POSCAR format to the primitive_cell folder."
208
208
  )
209
- # 在 phonopy 成功进行对称化处理后,删除 1_generated/POSCAR_Files 文件夹以节省空间
210
209
  shutil.rmtree(self.POSCAR_dir)
211
210
  except FileNotFoundError:
212
211
  logging.error(
@@ -215,6 +214,7 @@ class CrystalGenerator:
215
214
  raise FileNotFoundError(
216
215
  "There are no POSCAR structure files after generating.\nPlease check the error during generation"
217
216
  )
217
+
218
218
 
219
219
  def dpdisp_mlp_tasks(self, machine: str, resources: str, nodes: int = 1):
220
220
  """
@@ -222,6 +222,10 @@ class CrystalGenerator:
222
222
  """
223
223
  # 调整工作目录,减少错误发生
224
224
  os.chdir(self.primitive_cell_dir)
225
+ # 准备dpdispatcher运行所需的文件,将其复制到primitive_cell文件夹中
226
+ self.required_files = [self.mlp_opt_file, self.model_file]
227
+ for file in self.required_files:
228
+ shutil.copy(file, self.primitive_cell_dir)
225
229
  # 读取machine和resources的参数
226
230
  if machine.endswith(".json"):
227
231
  machine = Machine.load_from_json(machine)
ion_CSP/model/model.pt ADDED
Binary file
@@ -0,0 +1,5 @@
1
+ # 目录 ./model
2
+ 用于存放所调用的机器学习势文件,文件名必须为 model.pt。
3
+
4
+ # 目录 ./model/options
5
+ 用于存放其他机器学习势文件,文件名任意。
ion_CSP/param/INCAR_0 ADDED
@@ -0,0 +1,16 @@
1
+ SYSTEM = ION_CSP
2
+ NPAR = 4
3
+ PREC = Accurate
4
+ ENCUT = 800
5
+ EDIFF = 1e-4 # 1e-6
6
+ IBRION = -1
7
+ ISMEAR = 0 ; SIGMA = 0.05
8
+ #No writing charge density and wavefunction
9
+ LCHARG = FALSE
10
+ LWAVE = FALSE
11
+ #Target Pressure
12
+ #PSTRESS = 100
13
+ #Finer optimization
14
+ EDIFFG = -0.05 # 1e-4
15
+ KSPACING = 0.25
16
+ IVDW = 11
ion_CSP/param/INCAR_1 ADDED
@@ -0,0 +1,19 @@
1
+ SYSTEM = ION_CSP
2
+ NPAR = 4
3
+ PREC = Accurate
4
+ ENCUT = 600 # 800
5
+ EDIFF = 1e-4 # 1e-6
6
+ IBRION = 2
7
+ ISIF = 8
8
+ NSW = 300 # 200
9
+ ISMEAR = 0 ; SIGMA = 0.05
10
+ POTIM = 0.05
11
+ #No writing charge density and wavefunction
12
+ LCHARG = FALSE
13
+ LWAVE = FALSE
14
+ #Target Pressure
15
+ #PSTRESS = 100
16
+ #Finer optimization
17
+ EDIFFG = -0.05 # 1e-4
18
+ KSPACING = 0.7 # 0.25
19
+ IVDW = 12
ion_CSP/param/INCAR_2 ADDED
@@ -0,0 +1,19 @@
1
+ SYSTEM = ION_CSP
2
+ NPAR = 4
3
+ PREC = Accurate
4
+ ENCUT = 800
5
+ EDIFF = 1e-6
6
+ IBRION = 2
7
+ ISIF = 8
8
+ NSW = 300 # 200
9
+ ISMEAR = 0 ; SIGMA = 0.05
10
+ POTIM = 0.05
11
+ #No writing charge density and wavefunction
12
+ LCHARG = FALSE
13
+ LWAVE = FALSE
14
+ #Target Pressure
15
+ #PSTRESS = 100
16
+ #Finer optimization
17
+ EDIFFG = -0.02
18
+ KSPACING = 0.5
19
+ IVDW = 12
ion_CSP/param/INCAR_3 ADDED
@@ -0,0 +1,19 @@
1
+ SYSTEM = ION_CSP
2
+ NPAR = 4
3
+ PREC = Accurate
4
+ ENCUT = 800
5
+ EDIFF = 1e-6
6
+ IBRION = 2
7
+ ISIF = 3
8
+ NSW = 300 # 200
9
+ ISMEAR = 0 ; SIGMA = 0.05
10
+ POTIM = 0.05
11
+ #No writing charge density and wavefunction
12
+ LCHARG = FALSE
13
+ LWAVE = FALSE
14
+ #Target Pressure
15
+ #PSTRESS = 100
16
+ #Finer optimization
17
+ EDIFFG = -0.02
18
+ KSPACING = 0.5
19
+ IVDW = 12