Skip to content

Commit

Permalink
Merge pull request #3 from kousuke-nakano/devel
Browse files Browse the repository at this point in the history
Initial public release of turbogenius
  • Loading branch information
kousuke-nakano authored Apr 24, 2023
2 parents 08ae0ce + f3d40a8 commit c9a517d
Show file tree
Hide file tree
Showing 40 changed files with 1,955 additions and 1,167 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These owners are the default owners for everything in
# the repo. Unless a later match takes precedence,
* @kousuke-nakano

17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,16 @@ and type `make html`. The document is generated in `docs/_build/html`.
`index.html` is the main page.

# Reference
K. Nakano et. al in prepareation (2022).
K. Nakano et. al in prepareation (2023).

# How to contribute

Work on the development or on a new branch
Please do not directly push your changes to `main` and `devel` branch.
Please create a pull request on GitHub from your forked repository or a new branch (e.g. `devel-#1`).

git merge <new branch> development # if you work on a new branch.
git push origin development

Check the next-version version
# How to check the version info.

# Confirm the version number via `setuptools-scm`
python -m setuptools_scm
e.g., 1.1.4.dev28+gceef293.d20221123 -> <next-version> = v1.1.4 or v1.1.4-alpha(for pre-release)

Add and push with the new tag

# Push with tag
git tag <next-version> # e.g., git tag v1.1.4 # Do not forget "v" before the version number!
git push origin development --tags # or to the new branch

Send a pull request to the main branch on GitHub.
30 changes: 15 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ classifiers =
zip_safe = False
include_package_data = True
packages = find:
python_requires = >="3.7.2"
python_requires = >=3.7.2
install_requires =
matplotlib >= "3.1.1"
numpy >= "1.20.1"
pandas >= "1.2.2"
ase >= "3.21.0"
trexio >= "1.2.0"
pymatgen >= "2021.2.16"
pytest >= "5.2.1"
gitpython >= "3.1.27"
pydriller >= "2.1"
basis-set-exchange >= "0.9"
click >= "8.1.3"
tqdm >= "4.36.1"
setuptools_scm >= "7.0.5"
psutil >= "5.0.0"
matplotlib >= 3.1.1
numpy >= 1.20.1
pandas >= 1.2.2
ase >= 3.21.0
trexio >= 1.2.0
pymatgen >= 2021.2.16
pytest >= 5.2.1
gitpython >= 3.1.27
pydriller >= 2.1
basis-set-exchange >= 0.9
click >= 8.1.3
tqdm >= 4.36.1
setuptools_scm >= 7.0.5
psutil >= 5.0.0

[options.package_data]
* = *.txt, *.rst
Expand Down
14 changes: 8 additions & 6 deletions turbogenius/convertfort10_genius.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# python modules
import os
import numpy as np
from typing import Optional

# Logger
from logging import getLogger, StreamHandler, Formatter
Expand Down Expand Up @@ -77,13 +78,12 @@ def __init__(
self.convertfort10.comment_out(parameter="ny")
self.convertfort10.comment_out(parameter="nz")
else:
# +- 7.5 bohr from the edges.
pos = self.io_fort10.f10structure.positions
Lx = np.max(pos[:, 0]) - np.min(pos[:, 0]) + 3.0
Ly = np.max(pos[:, 1]) - np.min(pos[:, 1]) + 3.0
Lz = np.max(pos[:, 2]) - np.min(pos[:, 2]) + 3.0
Lx = np.max(pos[:, 0]) - np.min(pos[:, 0]) + 6.0
Ly = np.max(pos[:, 1]) - np.min(pos[:, 1]) + 6.0
Lz = np.max(pos[:, 2]) - np.min(pos[:, 2]) + 6.0
logger.info(
"Lbox is set to +- 1.5 bohr from the edges of the molecules."
"Lbox is set to +- 3.0 bohr from the edges of the molecules."
)
logger.info(f"Lx={Lx}, Ly={Ly}, Lz={Lz}")
ax = self.grid_size
Expand Down Expand Up @@ -150,7 +150,7 @@ def run(self, input_name="convertfort10.input", output_name="out_conv"):
flags = self.convertfort10.check_results(output_names=[output_name])
assert all(flags)

def check_results(self, output_names: list = ["out_conv"]) -> bool:
def check_results(self, output_names: Optional[list] = None) -> bool:
"""
Check the result.
Expand All @@ -159,6 +159,8 @@ def check_results(self, output_names: list = ["out_conv"]) -> bool:
Returns:
bool: True if all the runs were successful, False if an error is detected in the files.
"""
if output_names is None:
output_names = ["out_conv"]
return self.convertfort10.check_results(output_names=output_names)


Expand Down
13 changes: 8 additions & 5 deletions turbogenius/convertfort10mol_genius.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# python modules
import os
import numpy as np
from typing import Optional

# Logger
from logging import getLogger, StreamHandler, Formatter
Expand Down Expand Up @@ -40,10 +41,10 @@ class Convertfort10mol_genius(GeniusIO):

def __init__(
self,
fort10="fort.10_in",
add_random_mo=True,
grid_size=0.10,
additional_mo=0,
fort10: str = "fort.10_in",
add_random_mo: bool = True,
grid_size: float = 0.10,
additional_mo: int = 0,
):

self.fort10 = fort10
Expand Down Expand Up @@ -178,7 +179,7 @@ def run(
flags = self.convertfort10mol.check_results(output_names=[output_name])
assert all(flags)

def check_results(self, output_names: list = ["out_mol"]) -> bool:
def check_results(self, output_names: Optional[list] = None) -> bool:
"""
Check the result.
Expand All @@ -187,6 +188,8 @@ def check_results(self, output_names: list = ["out_mol"]) -> bool:
Return:
bool: True if all the runs were successful, False if an error is detected in the files.
"""
if output_names is None:
output_names = ["out_mol"]
return self.convertfort10mol.check_results(output_names=output_names)


Expand Down
5 changes: 4 additions & 1 deletion turbogenius/convertpfaff_genius.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# python modules
import os
from typing import Optional

# Logger
from logging import getLogger, StreamHandler, Formatter
Expand Down Expand Up @@ -95,7 +96,7 @@ def run(
flags = self.convertpfaff.check_results(output_names=[output_name])
assert all(flags)

def check_results(self, output_names: list = ["out_pfaff"]) -> bool:
def check_results(self, output_names: Optional[list] = None) -> bool:
"""
Check the result.
Expand All @@ -104,6 +105,8 @@ def check_results(self, output_names: list = ["out_pfaff"]) -> bool:
Returns:
bool: True if all the runs were successful, False if an error is detected in the files.
"""
if output_names is None:
output_names = ["out_pfaff"]
return self.convertpfaff.check_results(output_names=output_names)


Expand Down
13 changes: 10 additions & 3 deletions turbogenius/correlated_sampling_genius.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# python modules
import os
from typing import Optional

# Logger
from logging import getLogger, StreamHandler, Formatter
Expand Down Expand Up @@ -52,8 +53,10 @@ def __init__(
num_walkers: int = -1, # default -1 -> num of MPI process.
maxtime: int = 172800,
twist_average: bool = False,
kpoints: list = [1, 1, 1, 0, 0, 0],
kpoints: Optional[list] = None,
):
if kpoints is None:
kpoints = [1, 1, 1, 0, 0, 0]

self.in_fort10 = in_fort10
self.corr_fort10 = corr_fort10
Expand Down Expand Up @@ -244,8 +247,8 @@ def run(

def check_results(
self,
vmc_output_names: list = ["out_vmc"],
readforward_output_names: list = ["out_readforward"],
vmc_output_names: Optional[list] = None,
readforward_output_names: Optional[list] = None,
) -> bool:
"""
Check the result.
Expand All @@ -256,6 +259,10 @@ def check_results(
Returns:
bool: True if all the runs were successful, False if an error is detected in the files.
"""
if vmc_output_names is None:
vmc_output_names = ["out_vmc"]
if readforward_output_names is None:
readforward_output_names = ["out_readforward"]
return self.readforward.check_results(
output_names=readforward_output_names
) + self.vmc.check_results(output_names=vmc_output_names)
Expand Down
25 changes: 19 additions & 6 deletions turbogenius/lrdmc_genius.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# python modules
import os
from typing import Optional

# Logger
from logging import getLogger, StreamHandler, Formatter
Expand All @@ -34,6 +35,7 @@ class LRDMC_genius(GeniusIO):
fort10 (str): fort.10 WF file
lrdmcsteps (int): total number of MCMC steps.
alat (float): Lattice space (Bohr)
time_branching: interval between two branching steps. (a.u.)
etry (float): Trial Energy (Ha)
num_walkers (int): The number of walkers, -1 (default) = the number of MPI processes
maxtime (int): Maxtime (sec.)
Expand All @@ -48,14 +50,17 @@ def __init__(
fort10: str = "fort.10",
lrdmcsteps: int = 100,
alat: float = -0.20,
time_branching: float = 0.10,
etry: float = 0.0,
num_walkers: int = -1, # default -1 -> num of MPI process.
maxtime: int = 172800,
twist_average: bool = False,
kpoints: list = [1, 1, 1, 0, 0, 0],
kpoints: Optional[list] = None,
force_calc_flag: bool = False,
nonlocalmoves: str = "tmove", # tmove, dla, dlatm
nonlocalmoves: str = "dla", # tmove, dla, dlatm
):
if kpoints is None:
kpoints = [1, 1, 1, 0, 0, 0]

self.force_calc_flag = force_calc_flag
self.twist_average = twist_average
Expand Down Expand Up @@ -88,7 +93,9 @@ def __init__(
self.lrdmc.set_parameter(
parameter="alat", value=alat, namelist="&dmclrdmc"
)

self.lrdmc.set_parameter(
parameter="tbra", value=time_branching, namelist="&dmclrdmc"
)
typereg, npow = get_nonlocalmoves_setting(nonlocalmoves=nonlocalmoves)
self.lrdmc.set_parameter(
parameter="typereg", value=typereg, namelist="&dmclrdmc"
Expand Down Expand Up @@ -257,7 +264,7 @@ def store_result(
bin_block: int = 10,
warmupblocks: int = 2,
correcting_factor: int = 2,
output_names: list = ["out_fn"],
output_names: Optional[list] = None,
rerun: bool = False,
) -> None:
"""
Expand All @@ -271,6 +278,8 @@ def store_result(
output_names (list): a list of output file names
rerun (bool): if true, compute energy and force again even if there are energy and force files.
"""
if output_names is None:
output_names = ["out_fn"]
self.estimated_time_for_1_generation = (
self.get_estimated_time_for_1_generation(output_names=output_names)
)
Expand Down Expand Up @@ -305,7 +314,7 @@ def compute_energy_and_forces(
)

def get_estimated_time_for_1_generation(
self, output_names: list = ["out_fn"]
self, output_names: Optional[list] = None
) -> float:
"""
This procedure stores estimated_time_for_1_generation.
Expand All @@ -316,11 +325,13 @@ def get_estimated_time_for_1_generation(
Return:
float: estimated_time_for_1_generation.
"""
if output_names is None:
output_names = ["out_fn"]
return self.lrdmc.get_estimated_time_for_1_generation(
output_names=output_names
)

def check_results(self, output_names: list = ["out_fn"]) -> bool:
def check_results(self, output_names: Optional[list] = None) -> bool:
"""
Check the result.
Expand All @@ -329,6 +340,8 @@ def check_results(self, output_names: list = ["out_fn"]) -> bool:
Return:
bool: True if all the runs were successful, False if an error is detected in the files.
"""
if output_names is None:
output_names = ["out_fn"]
return self.lrdmc.check_results(output_names=output_names)


Expand Down
Loading

0 comments on commit c9a517d

Please sign in to comment.