rmc-dft 0.7.1__tar.gz

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.
Files changed (39) hide show
  1. rmc_dft-0.7.1/PKG-INFO +119 -0
  2. rmc_dft-0.7.1/README.md +91 -0
  3. rmc_dft-0.7.1/pyproject.toml +54 -0
  4. rmc_dft-0.7.1/setup.cfg +4 -0
  5. rmc_dft-0.7.1/setup.py +99 -0
  6. rmc_dft-0.7.1/src/rmc_dft/__init__.py +40 -0
  7. rmc_dft-0.7.1/src/rmc_dft/config.py +139 -0
  8. rmc_dft-0.7.1/src/rmc_dft/rmc_dft.py +218 -0
  9. rmc_dft-0.7.1/src/rmc_dft/rmc_pot/__init__.py +33 -0
  10. rmc_dft-0.7.1/src/rmc_dft/rmc_pot/util/__init__.py +13 -0
  11. rmc_dft-0.7.1/src/rmc_dft/rmc_pot_dat_top.py +1208 -0
  12. rmc_dft-0.7.1/src/rmc_dft/util/__init__.py +25 -0
  13. rmc_dft-0.7.1/src/rmc_dft/util/check_restart_rmc_vasp.py +68 -0
  14. rmc_dft-0.7.1/src/rmc_dft/util/check_restart_rmc_vasp_.py +196 -0
  15. rmc_dft-0.7.1/src/rmc_dft/util/check_rmc_and_vasp.py +74 -0
  16. rmc_dft-0.7.1/src/rmc_dft/util/find_next_log_index.py +139 -0
  17. rmc_dft-0.7.1/src/rmc_dft/util/logs_exist.py +33 -0
  18. rmc_dft-0.7.1/src/rmc_dft/util.py +19 -0
  19. rmc_dft-0.7.1/src/rmc_dft/vasp/__init__.py +17 -0
  20. rmc_dft-0.7.1/src/rmc_dft/vasp/util/__init__.py +11 -0
  21. rmc_dft-0.7.1/src/rmc_dft/vasp/util/copy_contcar_to_vasp.py +35 -0
  22. rmc_dft-0.7.1/src/rmc_dft/vasp/util/copy_vasp_to_poscar.py +38 -0
  23. rmc_dft-0.7.1/src/rmc_dft/vasp/util/ensure_vasp5_format.py +70 -0
  24. rmc_dft-0.7.1/src/rmc_dft/vasp/util/make_potcar.py +26 -0
  25. rmc_dft-0.7.1/src/rmc_dft/vasp/util/poscar2cfg.py +345 -0
  26. rmc_dft-0.7.1/src/rmc_dft/vasp/util/xdatcar2poscar.py +100 -0
  27. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp.py +704 -0
  28. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_incar.py +393 -0
  29. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_kpoints.py +340 -0
  30. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_log.py +332 -0
  31. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_outcar.py +473 -0
  32. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_poscar.py +514 -0
  33. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_poscar_analyzer.py +631 -0
  34. rmc_dft-0.7.1/src/rmc_dft/vasp/vasp_potcar.py +223 -0
  35. rmc_dft-0.7.1/src/rmc_dft.egg-info/PKG-INFO +119 -0
  36. rmc_dft-0.7.1/src/rmc_dft.egg-info/SOURCES.txt +37 -0
  37. rmc_dft-0.7.1/src/rmc_dft.egg-info/dependency_links.txt +1 -0
  38. rmc_dft-0.7.1/src/rmc_dft.egg-info/requires.txt +18 -0
  39. rmc_dft-0.7.1/src/rmc_dft.egg-info/top_level.txt +1 -0
rmc_dft-0.7.1/PKG-INFO ADDED
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: rmc_dft
3
+ Version: 0.7.1
4
+ Summary: rmc_dft is a Python package for performing Reverse Monte Carlo modeling and ab initio molecular dynamics / relaxation using VASP code.
5
+ Author: K.Kobayashi, Kengo NAKADA
6
+ Author-email: Kengo NAKADA <kengo.nakada@email.com>, Kentaro Kobayashi <kobayashi@mat.shimane-u.ac.jp>
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: xlogger-py
10
+ Requires-Dist: packmol_util
11
+ Requires-Dist: rmc_util
12
+ Requires-Dist: pymatgen
13
+ Requires-Dist: dataclasses
14
+ Requires-Dist: coloredlogs
15
+ Requires-Dist: colorlog
16
+ Requires-Dist: pytest
17
+ Requires-Dist: pytest-asyncio
18
+ Requires-Dist: pyyaml
19
+ Requires-Dist: toml
20
+ Requires-Dist: nest_asyncio
21
+ Requires-Dist: sphinx
22
+ Requires-Dist: myst-parser
23
+ Requires-Dist: sphinx-autobuild
24
+ Requires-Dist: sphinx-rtd-theme
25
+ Requires-Dist: sphinxcontrib-napoleon
26
+ Requires-Dist: linkify-it-py
27
+ Dynamic: author
28
+
29
+ # rmc_vasp
30
+
31
+ [![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/shimane-dev/rmc_vasp/blob/main/README.md)
32
+ [![ja](https://img.shields.io/badge/lang-ja-yellow.svg)](https://github.com/shimane-dev/rmc_vasp/blob/main/README.ja.md)
33
+
34
+ "rmc_vasp" iteratively performs the ab initio molecular dynamics (MD)/ geometry optimization and the reverse monte carlo
35
+ modeling (RMC).
36
+ It is based on Structure Analysis Environment package (
37
+ https://github.com/shimane-dev/sae.git ).
38
+
39
+ ## Requirements
40
+
41
+ ### VASP
42
+
43
+ VASP need to be installed.
44
+ (https://www.vasp.at/).
45
+ Tested versions: 6.4.2, 5.3.5.
46
+
47
+ #### Input files
48
+
49
+ VASP input files.
50
+
51
+ ### RMC
52
+
53
+ RMC POT need to be installed.
54
+ (https://www.szfki.hu/~nphys/rmc++/opening.html).
55
+ Tested version: 2023.1.
56
+
57
+ #### Input files
58
+
59
+ RMC POT input files especially experimental data.
60
+ (Xray diffraction, Neutron diffraction and so on. )
61
+
62
+ ### Initial structure
63
+
64
+ Density, number of atoms (system size).
65
+ (Initial structure can be generated using Packmol. (https://m3g.github.io/packmol/). For random structure, set minimal
66
+ interatomic distance to about 2Å, avoiding error.)
67
+
68
+ ## Install
69
+
70
+ Download https://github.com/shimane-dev/rmc_vasp/ .
71
+ Also, https://github.com/shimane-dev/x_logger .
72
+ Install using pip:
73
+
74
+ ````
75
+ $ pip install x_logger
76
+ $ pip install rmc_vasp
77
+ ````
78
+
79
+ ## Using without installation
80
+
81
+ Download https://github.com/shimane-dev/rmc_vasp/ .
82
+ Also, https://github.com/shimane-dev/x_logger .
83
+ Put "x_logger/" under "rmc_vasp/src/rmc_vasp/"
84
+
85
+ ## How to run
86
+
87
+ Put input files in a folder (work??) and open python:
88
+
89
+ ````
90
+ $ python3
91
+ ````
92
+
93
+ then,
94
+
95
+ ````
96
+ >>> import rmc_vasp
97
+ ````
98
+
99
+ and,
100
+
101
+ ````
102
+ >>> run()
103
+ ````
104
+
105
+ ### Beta version (Middle of August, 2025)
106
+
107
+ We put input files at "rmc_vasp/src/rmc_vasp/" and run the code as follows:
108
+
109
+ ````
110
+ $ python ./main.py
111
+ ````
112
+
113
+ ### Output
114
+
115
+ The output files are placed in the log0, log1, log2, ... folders.
116
+ The output files include the RMC POT input files, VASP input files, and ...
117
+ aaa.chi : Chi value of RMC modeling. Agreement of S(Q) with experimental data or something else depending on the RMC
118
+ input data.
119
+ grep_E0_OSZICAR.txt : Energy
@@ -0,0 +1,91 @@
1
+ # rmc_vasp
2
+
3
+ [![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/shimane-dev/rmc_vasp/blob/main/README.md)
4
+ [![ja](https://img.shields.io/badge/lang-ja-yellow.svg)](https://github.com/shimane-dev/rmc_vasp/blob/main/README.ja.md)
5
+
6
+ "rmc_vasp" iteratively performs the ab initio molecular dynamics (MD)/ geometry optimization and the reverse monte carlo
7
+ modeling (RMC).
8
+ It is based on Structure Analysis Environment package (
9
+ https://github.com/shimane-dev/sae.git ).
10
+
11
+ ## Requirements
12
+
13
+ ### VASP
14
+
15
+ VASP need to be installed.
16
+ (https://www.vasp.at/).
17
+ Tested versions: 6.4.2, 5.3.5.
18
+
19
+ #### Input files
20
+
21
+ VASP input files.
22
+
23
+ ### RMC
24
+
25
+ RMC POT need to be installed.
26
+ (https://www.szfki.hu/~nphys/rmc++/opening.html).
27
+ Tested version: 2023.1.
28
+
29
+ #### Input files
30
+
31
+ RMC POT input files especially experimental data.
32
+ (Xray diffraction, Neutron diffraction and so on. )
33
+
34
+ ### Initial structure
35
+
36
+ Density, number of atoms (system size).
37
+ (Initial structure can be generated using Packmol. (https://m3g.github.io/packmol/). For random structure, set minimal
38
+ interatomic distance to about 2Å, avoiding error.)
39
+
40
+ ## Install
41
+
42
+ Download https://github.com/shimane-dev/rmc_vasp/ .
43
+ Also, https://github.com/shimane-dev/x_logger .
44
+ Install using pip:
45
+
46
+ ````
47
+ $ pip install x_logger
48
+ $ pip install rmc_vasp
49
+ ````
50
+
51
+ ## Using without installation
52
+
53
+ Download https://github.com/shimane-dev/rmc_vasp/ .
54
+ Also, https://github.com/shimane-dev/x_logger .
55
+ Put "x_logger/" under "rmc_vasp/src/rmc_vasp/"
56
+
57
+ ## How to run
58
+
59
+ Put input files in a folder (work??) and open python:
60
+
61
+ ````
62
+ $ python3
63
+ ````
64
+
65
+ then,
66
+
67
+ ````
68
+ >>> import rmc_vasp
69
+ ````
70
+
71
+ and,
72
+
73
+ ````
74
+ >>> run()
75
+ ````
76
+
77
+ ### Beta version (Middle of August, 2025)
78
+
79
+ We put input files at "rmc_vasp/src/rmc_vasp/" and run the code as follows:
80
+
81
+ ````
82
+ $ python ./main.py
83
+ ````
84
+
85
+ ### Output
86
+
87
+ The output files are placed in the log0, log1, log2, ... folders.
88
+ The output files include the RMC POT input files, VASP input files, and ...
89
+ aaa.chi : Chi value of RMC modeling. Agreement of S(Q) with experimental data or something else depending on the RMC
90
+ input data.
91
+ grep_E0_OSZICAR.txt : Energy
@@ -0,0 +1,54 @@
1
+ [build-system]
2
+ requires = ["setuptools>=71.0", "coloredlogs"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rmc_dft"
7
+ version = "0.7.1"
8
+
9
+ description = "rmc_dft is a Python package for performing Reverse Monte Carlo modeling and ab initio molecular dynamics / relaxation using VASP code."
10
+ authors = [
11
+ { name = "Kengo NAKADA", email = "kengo.nakada@email.com" },
12
+ { name = "Kentaro Kobayashi", email = "kobayashi@mat.shimane-u.ac.jp" }
13
+ ]
14
+ readme = "README.md"
15
+ # requires-python = ">=3.8"
16
+ requires-python = ">=3.10"
17
+ dependencies = [
18
+ # my-modules
19
+ #"x_logger",
20
+ "xlogger-py",
21
+ "packmol_util",
22
+ "rmc_util",
23
+ # fnc
24
+ "pymatgen",
25
+ # basic
26
+ "dataclasses",
27
+ "coloredlogs",
28
+ "colorlog",
29
+ "pytest",
30
+ "pytest-asyncio",
31
+ "pyyaml",
32
+ "toml",
33
+ # "grpcio",
34
+ "nest_asyncio",
35
+ # pages
36
+ "sphinx",
37
+ "myst-parser",
38
+ "sphinx-autobuild",
39
+ "sphinx-rtd-theme",
40
+ "sphinxcontrib-napoleon",
41
+ "linkify-it-py"
42
+ ]
43
+
44
+ [tool.pytest.ini_options]
45
+ pythonpath = ["src"]
46
+
47
+ # ここでpytestのiniと同じようにオプションが書ける
48
+ # 例えばテストマーク、フィルタ、カバレッジなども追記可能
49
+
50
+ [tool.black]
51
+ line-length = 88
52
+
53
+ [tool.isort]
54
+ profile = "black"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
rmc_dft-0.7.1/setup.py ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env python
2
+ """
3
+ python 3.6 環境のための setup.py
4
+ """
5
+
6
+ __author__ = "K.Kobayashi, Kengo NAKADA"
7
+ __maintainer__ = "Kengo NAKADA"
8
+ __credits__ = ["Kengo NAKADA"]
9
+ __email__ = "kengo.nakada@gmail.com"
10
+ # __email__ = "kengo.nakada@spring8.or.jp"
11
+ # __copyright__ = "Copyright 2014-2018 Kengo NAKADA"
12
+ __license__ = "Apache2"
13
+ __status__ = "alpha"
14
+
15
+ from setuptools import setup, find_packages
16
+ import glob
17
+ import re
18
+ import os
19
+ import shutil
20
+
21
+ # --- クリーン処理 ---
22
+ for path in ["build", "dist"]:
23
+ if os.path.exists(path):
24
+ shutil.rmtree(path)
25
+
26
+ for name in os.listdir("."):
27
+ if name.endswith(".egg-info"):
28
+ shutil.rmtree(name)
29
+
30
+
31
+ # version = __version__
32
+ # from StructureAnalysisEnvironment import __version__
33
+ def read_version_from_toml() -> str:
34
+ with open("pyproject.toml", encoding="utf-8") as f:
35
+ for line in f:
36
+ if line.strip().startswith("version"):
37
+ m = re.search(r'version\s*=\s*["\']([^"\']+)["\']', line)
38
+ if m:
39
+ return m.group(1)
40
+ raise RuntimeError("version not found in pyproject.toml")
41
+
42
+
43
+ __version__ = read_version_from_toml()
44
+ long_description = "RMC_DFT"
45
+ description = "RMC_DFT"
46
+
47
+ # パッケージ指定
48
+ # packages = find_packages(exclude=["StructureAnalysisEnvironment.bin"])
49
+ packages = find_packages("src")
50
+ package_dir = {"": "src"}
51
+
52
+ setup(
53
+ name="rmc_dft",
54
+ # packages=find_packages(),
55
+ packages=packages,
56
+ package_dir=package_dir,
57
+ # package_dir = {'':'StructureAnalysisEnvironment'},
58
+ # include_package_data=True,
59
+ # package_data = { '': ['LICENSE.txt', 'README.md']},
60
+ # package_data=package_data,
61
+ # data_files=[(package_src_dir, files)],
62
+ # scripts=__script__,
63
+ version=__version__,
64
+ description=description,
65
+ long_description=long_description,
66
+ author=__author__,
67
+ # author_email = ['kengo.nakada@gmail.com','kengo.nakada@spring8.or.jp'],
68
+ # author_email = 'kengo.nakada@gmail.com',
69
+ # author_email='kengo.nakada@spring8.or.jp',
70
+ author_email=__email__,
71
+ license=__license__,
72
+ # python 3.11 などと違う環境にする
73
+ install_requires=[
74
+ "dataclasses",
75
+ "coloredlogs",
76
+ "colorlog",
77
+ # python 3.6 だと test を入れない
78
+ "pytest; python_version > '3.7'",
79
+ "pytest-asyncio; python_version > '3.7'",
80
+ "pyyaml",
81
+ "toml",
82
+ # "grpcio",
83
+ "nest_asyncio",
84
+ # わざわざ python 3.6 環境(setup.py)だと入れない
85
+ "sphinx; python_version > '3.7'",
86
+ "myst-parser; python_version > '3.7'",
87
+ "sphinx-autobuild; python_version > '3.7'",
88
+ "sphinx-rtd-theme; python_version > '3.7'",
89
+ "sphinxcontrib-napoleon; python_version > '3.7'",
90
+ "linkify-it-py; python_version > '3.7'", # for sphinx
91
+ ],
92
+ #
93
+ # platforms = ['linux','OSX','Window'],
94
+ # classifiers = [
95
+ # 'Programming Language :: Python :: 2.7',
96
+ # 'Intended Audience :: Science/Research',
97
+ # 'License :: OSI Approved :: MIT License'
98
+ # ]
99
+ )
@@ -0,0 +1,40 @@
1
+ """
2
+ K.NAKADA, kengo.nakada@gmail.com
3
+ """
4
+
5
+ from rmc_dft.rmc_dft import RmcDft
6
+
7
+ from rmc_dft.vasp.vasp import Vasp
8
+ from rmc_dft.vasp.vasp_log import VaspLog
9
+ from rmc_dft.vasp.vasp_incar import VaspIncar
10
+ from rmc_dft.vasp.vasp_kpoints import VaspKpoints
11
+ from rmc_dft.vasp.vasp_potcar import VaspPotcarBuilder
12
+ from rmc_dft.vasp.vasp_outcar import VaspOutcar
13
+
14
+ from rmc_dft.vasp.vasp_poscar import VaspPoscar
15
+ from rmc_dft.vasp.vasp_poscar_analyzer import VaspPoscarAnalyzer
16
+
17
+ from rmc_dft.rmc_pot.rmc_pot import RmcPot
18
+ from rmc_dft.rmc_pot.rmc_pot_log import RmcPotLog
19
+ from rmc_dft.rmc_pot.rmc_pot_dat import RmcPotDat
20
+ from rmc_dft.rmc_pot.rmc_pot_fit import RmcPotFit
21
+ from rmc_dft.rmc_pot.rmc_pot_hst import RmcPotHst
22
+ from rmc_dft.rmc_pot.rmc_pot_ppcf import RmcPotPpcf
23
+
24
+ # from rmc_dft.packmol.packmol import Packmol
25
+ # from rmc_dft.packmol.packmol_inp import PackmolInp
26
+
27
+ from rmc_dft.config import Config
28
+
29
+ from rmc_dft.util import poscar2cfg
30
+ from rmc_dft.util import ensure_vasp5_format
31
+ from rmc_dft.util import check_rmc_and_vasp
32
+ from rmc_dft.util import find_next_log_index
33
+ from rmc_dft.util import next_log_dir_name
34
+ from rmc_dft.util import logs_exist
35
+
36
+
37
+ # from .vasp.vasp import Vasp
38
+ # from .vasp.collect_result import VaspLog
39
+ # from .rmc.rmc_pot import RmcPot
40
+ # from .rmc.collect_result import RmcPotLog
@@ -0,0 +1,139 @@
1
+ """
2
+ K.NAKADA, kengo.nakada@gmail.com (1st, 3rd varsion)
3
+ K.KOBAYASHI (2nd version)
4
+ """
5
+
6
+ from typing import Any, Dict, List, Optional, Union, Tuple, Callable, Sequence
7
+ import yaml
8
+ import os
9
+
10
+ from x_logger import XLogger
11
+
12
+
13
+ class Config:
14
+ max_rmc_dft_loop: int = 10
15
+
16
+ N_tot: int = 400 # セルサイズ(原子数)
17
+ # mass_density_g_cm3: float = 7.35 # 質量密度
18
+ mass_density_g_cm3: float = 7.3336 # 質量密度
19
+ # number_density_A3: float = 0.0915 # 数密度
20
+ number_density_A3: float = 0.09119 # 数密度
21
+ # element_info: Union[str, Sequence[str]] = "label.txt"
22
+ element_info: Union[str, Sequence[str]] = ["Fe", "Si", "B"]
23
+ # ratios: Sequence[int] = [80, 9, 11]
24
+ ratios: Sequence[int] = [82, 4, 14]
25
+
26
+ # RMC parameter mirror
27
+ rmc_comment: Optional[str] = None
28
+ rmc_cutoffs: Optional[Sequence[float]] = None
29
+ rmc_max_moves: Optional[Sequence[float]] = None
30
+ rmc_r_spacing: Optional[float] = None
31
+ rmc_moveout_option: Optional[bool] = None
32
+ rmc_time_and_save: Optional[Tuple[float, int]] = None
33
+ rmc_data_flags: Optional[Sequence[int]] = None
34
+ rmc_exp_range: Optional[Tuple[int, int]] = None
35
+ rmc_sigma_factor: Optional[float] = None
36
+ rmc_num_atoms_per_move: Optional[int] = None
37
+
38
+ # VASP parameter mirror
39
+ vasp_incar_tags: Dict[str, Any] = {}
40
+ vasp_kpoints_mode: Optional[str] = None
41
+ vasp_kpoints_grid: Optional[Tuple[int, int, int]] = None
42
+ vasp_kpoints_shift: Optional[Tuple[int, int, int]] = None
43
+ vasp_kpoints_comment: Optional[str] = None
44
+
45
+ # ---------- RMC -----------
46
+ rmc_code: str = "RmcPot"
47
+ rmc_log_dir: str = "rmc_log"
48
+ cfg_name: str = "aaa" # aaa.cfg
49
+ rmc_exp_filename: str = "ascast.xsq"
50
+
51
+ # ------- DFT (VASP) --------
52
+ dft_code: str = "Vasp"
53
+ dft_log_dir: str = "vasp_log"
54
+ vasp_name: str = "aaa" # aaa.vasp
55
+ run_mode: str = "local"
56
+
57
+ #
58
+ # RMCPOT path
59
+ #
60
+ # rmc_bin = "/home/k/Downloads/Source_RMC_POT_lin_2023.1/rmcp.exe"
61
+ # rmc_bin = "/usr/local/src/RMCPOT/rmcp.exe"
62
+ rmc_bin: str = "rmcp.exe"
63
+
64
+ #
65
+ # VASP path
66
+ #
67
+ # dft_bin = f"/home/hpc/vasp/bin/vasp-gamma"
68
+ # dft_bin = f"/home/k/Downloads/vasp.6.4.2/bin/vasp_gam"
69
+ # dft_bin = "/home/hpc/vasp/bin/vasp"
70
+ dft_bin: Optional[str] = f"vasp_gam"
71
+
72
+ num_procs: Optional[int] = 1
73
+
74
+ mpi_cmd: Optional[str] = "mpirun"
75
+ # mpi = f"mpirun -np {num_procs} {os.path.expanduser('/home/hpc/vasp/bin/vasp')}"
76
+
77
+ mpi_flag: Optional[str] = "-np"
78
+
79
+ rmc_omp_num_threads: Optional[int] = None
80
+ dft_omp_num_threads: Optional[int] = None
81
+
82
+ # default job_name
83
+ job_cmd: Optional[str] = "qsub job_hpcs2024_node2.sh"
84
+
85
+ # 自動セーブ
86
+ auto_write: bool = True
87
+
88
+ def __init__(
89
+ self,
90
+ yaml_path: Optional[str] = None,
91
+ *,
92
+ logger: Optional[XLogger] = XLogger(),
93
+ ):
94
+ """
95
+
96
+ Args:
97
+ yaml_path (str):
98
+ logger (XLogger):
99
+ """
100
+ self._logger = logger
101
+
102
+ # インスタンスで使いたいときだけ、ここで個別設定
103
+ if yaml_path:
104
+ self._load_yaml(yaml_path)
105
+
106
+ @classmethod
107
+ def load_yaml(cls, yaml_path=None):
108
+ if yaml_path is None:
109
+ yaml_path = os.environ.get("RMC_DFT_CONFIG_YAML")
110
+ if yaml_path is None:
111
+ return
112
+ # with open(yaml_path, "r") as f:
113
+ with open(yaml_path, "r", encoding="utf-8") as f:
114
+ data = yaml.safe_load(f)
115
+ for k, v in data.items():
116
+ if hasattr(cls, k):
117
+ setattr(cls, k, v)
118
+ else:
119
+ print("NO SUCH VAR:", k)
120
+
121
+ def _load_yaml(self, yaml_path=None):
122
+ # インスタンス用:インスタンスdictにのみ上書き
123
+ self._logger.info(f"load_yaml: {yaml_path}")
124
+ if yaml_path is None:
125
+ yaml_path = os.environ.get("RMC_DFT_CONFIG_YAML")
126
+ if yaml_path is None:
127
+ return
128
+ yaml_path = os.path.abspath(yaml_path)
129
+ self._logger.info(f"abspath: {yaml_path}")
130
+ with open(yaml_path, "r") as f:
131
+ data = yaml.safe_load(f)
132
+ for k, v in data.items():
133
+ setattr(self, k, v)
134
+
135
+
136
+ if __name__ == "__main__":
137
+ config = Config("config.yml")
138
+ print(config.num_procs)
139
+ print(type(config.num_procs))