Skip to content

Commit

Permalink
Update main (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
galjos authored Jun 9, 2024
2 parents 8d13e04 + c0e4f93 commit b2eae82
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 94 deletions.
37 changes: 17 additions & 20 deletions ThermoScreening/calculator/dftbplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,8 @@ def potential_energy(self):
Potential energy of the optimized geometry.
"""
self.atoms.calc = self
return (
self.atoms.get_potential_energy()
* PhysicalConstants["eV"]
/ PhysicalConstants["H"]
)
return (self.atoms.get_potential_energy() * PhysicalConstants["eV"] /
PhysicalConstants["H"])

def read(self):
"""
Expand Down Expand Up @@ -263,18 +260,16 @@ def write(self):
"""

# use f-strings to write the modes_in.hsd file
string = (
"Geometry = GenFormat {\n"
f" <<< {self.geometry}\n"
"}\n"
"\n"
"Hessian = {\n"
f" <<< {self.hessian}\n"
"}\n"
"\n"
"Atoms = 1:-1\n"
"\n"
)
string = ("Geometry = GenFormat {\n"
f" <<< {self.geometry}\n"
"}\n"
"\n"
"Hessian = {\n"
f" <<< {self.hessian}\n"
"}\n"
"\n"
"Atoms = 1:-1\n"
"\n")

with open("modes_in.hsd", "w") as f:
f.write(string)
Expand Down Expand Up @@ -329,13 +324,12 @@ def read(self):


# --------------------------------------------------------------------------- #

"""
DFTB+ parameters for the 3ob-3-1 Slater-Koster files.
"""

dftb_3ob_parameters = dict(
# SCC
# SCC
Hamiltonian_SCC="Yes",
Hamiltonian_MaxSCCIterations=250,
Hamiltonian_SCCTolerance='1.0e-7',
Expand Down Expand Up @@ -374,4 +368,7 @@ def read(self):
Analysis_="",
Analysis_CalculateForces="Yes",
Analysis_MullikenAnalysis="Yes",
)

# Parser options
ParserOptions_ParserVersion=12,
)
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

8 changes: 8 additions & 0 deletions examples/Notebooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore dftbplus output files
*.out
*.xyz
*.gen
*.hsd
*.bin
*.cosmo
*.tag
93 changes: 22 additions & 71 deletions examples/Notebooks/dftbplus/ThermoScreening.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -26,9 +26,10 @@
"from ase.io import read, write\n",
"\n",
"import os\n",
"\n",
"skf_dir = 'skf-files/3ob-3-1'\n",
"\n",
"# set DFTB perfix and path \n",
"# set DFTB perfix and path\n",
"os.environ['DFTB_PREFIX'] = os.path.join(os.environ['HOME'], skf_dir)\n",
"os.environ['OMP_NUM_THREADS'] = '6'"
]
Expand All @@ -42,18 +43,17 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dftb_parameters = dict(\n",
" # SCC \n",
" # SCC\n",
" Hamiltonian_SCC=\"Yes\",\n",
" Hamiltonian_MaxSCCIterations=250,\n",
" Hamiltonian_SCCTolerance='1.0e-6',\n",
" Hamiltonian_ReadInitialCharges=\"No\",\n",
"\n",
" Hamiltonian_ShellResolvedScc = \"No\",\n",
" Hamiltonian_ShellResolvedScc=\"No\",\n",
"\n",
" # Fermi smearing\n",
" Hamiltonian_Filling=\"Fermi {\",\n",
Expand Down Expand Up @@ -81,20 +81,20 @@
" Hamiltonian_MaxAngularMomentum_=\"\",\n",
"\n",
" # Solvation model\n",
" Hamiltonian_Solvation_ = \"Cosmo\",\n",
" Hamiltonian_Solvation_Radii = \"VanDerWaalsRadiiD3 {}\",\n",
" Hamiltonian_Solvation_RadiiScaling = 1.55,\n",
" Hamiltonian_Solvation_AngularGrid = 110,\n",
" Hamiltonian_Solvation_Solver = \"DomainDecomposition{\",\n",
" Hamiltonian_Solvation_Solver_MaxMoment = 10,\n",
" Hamiltonian_Solvation_Solver_Accuracy = 1.0e-8,\n",
" Hamiltonian_Solvation_Solver_Regularisation = 0.2,\n",
" Hamiltonian_Solvation_=\"Cosmo\",\n",
" Hamiltonian_Solvation_Radii=\"VanDerWaalsRadiiD3 {}\",\n",
" Hamiltonian_Solvation_RadiiScaling=1.55,\n",
" Hamiltonian_Solvation_AngularGrid=110,\n",
" Hamiltonian_Solvation_Solver=\"DomainDecomposition{\",\n",
" Hamiltonian_Solvation_Solver_MaxMoment=10,\n",
" Hamiltonian_Solvation_Solver_Accuracy=1.0e-8,\n",
" Hamiltonian_Solvation_Solver_Regularisation=0.2,\n",
" Hamiltonian_Solvation_Solvent=\"\"\"FromConstants{\n",
" Epsilon = 37.0,\n",
" MolecularMass [amu] = 73.1,\n",
" Density [kg/l] = 0.95\n",
" }\"\"\",\n",
" Hamiltonian_Solvation_empty = \"FreeEnergyShift [kcal/mol] = 0.0\",\n",
" Hamiltonian_Solvation_empty=\"FreeEnergyShift [kcal/mol] = 0.0\",\n",
"\n",
" # Hubbard derivatives\n",
" Hamiltonian_ThirdOrderFull=\"Yes\",\n",
Expand All @@ -120,45 +120,11 @@
" Analysis_CalculateForces=\"Yes\",\n",
" Analysis_MullikenAnalysis=\"Yes\",\n",
"\n",
" # Parser options\n",
" # ParserOptions_ParserVersion=\"14\"\n",
" \n",
" \n",
" # ParserVersion\n",
" ParserOptions_ParserVersion=12,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"\n",
"TODO:\n",
"- install `wfl` - not in pypi >:( - https://github.com/libAtoms/workflow\n",
"- rdkit NOT in dependencies of `wfl`\n",
"- restart kernel after installation\n",
"\n",
"Commands to install `wfl` and `rdkit`:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# pip install git+https://github.com/libAtoms/workflow.git"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# pip install rdkit"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -168,12 +134,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from wfl.generate import smiles\n",
"from ase.calculators.dftb import Dftb\n",
"\n",
"# quinone smile\n",
"smile = 'C1=CC(=O)C=CC1=O'\n",
Expand All @@ -191,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -246,26 +211,12 @@
"# hartree to j/mol\n",
"hartree = 2625500.2\n",
"\n",
"redox1 = - (neg1 - zero) * hartree / F\n",
"redox2 = - (neg2 - neg1) * hartree / F\n",
"redox1 = -(neg1 - zero) * hartree / F\n",
"redox2 = -(neg2 - neg1) * hartree / F\n",
"\n",
"print(f'{smile} redox1: {redox1} V')\n",
"print(f'{smile} redox2: {redox2} V')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -284,7 +235,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"beartype",
"ase",
"rdkit",
"wfl@git+https://github.com/libAtoms/workflow.git",
"wfl",
]

[project.optional-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
# (c) Jakob Gamper


@pytest.fixture(scope="function")
def tmpdir():

Expand Down Expand Up @@ -35,4 +36,4 @@ def test_with_data_dir(example_dir):
yield tmpdir

os.chdir("..")
shutil.rmtree(tmpdir)
shutil.rmtree(tmpdir)

0 comments on commit b2eae82

Please sign in to comment.