-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
159 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# pylint: disable=invalid-name | ||
"""Run simple DFT calculation""" | ||
|
||
|
||
import sys | ||
|
||
import ase.io | ||
import click | ||
from aiida.common import NotExistent | ||
from aiida.engine import run_get_node | ||
from aiida.orm import Code, Dict, StructureData | ||
from aiida.plugins import CalculationFactory | ||
|
||
GaussianCalculation = CalculationFactory("gaussian") | ||
|
||
|
||
def example_nmr_nics(gaussian_code): | ||
"""Run an NMR calculation. | ||
The geometry also includes fake/ghost atoms (X), | ||
where nucleus-independent chemical shift (NICS) is calculated. | ||
""" | ||
|
||
# structure | ||
structure = StructureData(ase=ase.io.read("./napthalene_nics.xyz")) | ||
|
||
num_cores = 1 | ||
memory_mb = 300 | ||
|
||
parameters = Dict( | ||
{ | ||
"link0_parameters": { | ||
"%chk": "aiida.chk", | ||
"%mem": "%dMB" % memory_mb, | ||
"%nprocshared": num_cores, | ||
}, | ||
"functional": "BLYP", | ||
"basis_set": "6-31g", | ||
"charge": 0, | ||
"multiplicity": 1, | ||
"dieze_tag": "#P", | ||
"route_parameters": { | ||
"nmr": None, | ||
}, | ||
} | ||
) | ||
|
||
# Construct process builder | ||
|
||
builder = GaussianCalculation.get_builder() | ||
|
||
builder.structure = structure | ||
builder.parameters = parameters | ||
builder.code = gaussian_code | ||
|
||
builder.metadata.options.resources = { | ||
"num_machines": 1, | ||
"tot_num_mpiprocs": num_cores, | ||
} | ||
|
||
# The advanced parser handles the NMR output | ||
builder.metadata.options.parser_name = "gaussian.advanced" | ||
|
||
# Should ask for extra +25% extra memory | ||
builder.metadata.options.max_memory_kb = int(1.25 * memory_mb) * 1024 | ||
builder.metadata.options.max_wallclock_seconds = 5 * 60 | ||
|
||
print("Running calculation...") | ||
res, _node = run_get_node(builder) | ||
|
||
print("NMR tensors of each atom:") | ||
for i, site in enumerate(structure.sites): | ||
print(site) | ||
print(" ", res["output_parameters"]["nmr_tensors"][i]) | ||
|
||
|
||
@click.command("cli") | ||
@click.argument("codelabel", default="gaussian@localhost") | ||
def cli(codelabel): | ||
"""Click interface""" | ||
try: | ||
code = Code.get_from_string(codelabel) | ||
except NotExistent: | ||
print(f"The code '{codelabel}' does not exist") | ||
sys.exit(1) | ||
example_nmr_nics(code) | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() # pylint: disable=no-value-for-parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
20 | ||
Properties=species:S:1:pos:R:3 napthalene=T pbc="F F F" | ||
C 0.00000000 1.42000000 0.00000000 | ||
C 0.00000000 0.00000000 0.00000000 | ||
C 1.22975600 2.13000000 0.00000000 | ||
C 2.45951200 1.42000000 0.00000000 | ||
C 2.45951200 0.00000000 0.00000000 | ||
C 1.22975600 -0.71000000 0.00000000 | ||
C 3.68926800 -0.71000000 0.00000000 | ||
C 4.91902400 0.00000000 0.00000000 | ||
C 4.91902400 1.42000000 0.00000000 | ||
H -0.98726900 1.99000000 0.00000000 | ||
H -0.98726900 -0.57000000 0.00000000 | ||
H 1.22975600 3.27000000 0.00000000 | ||
H 1.22975600 -1.85000000 0.00000000 | ||
H 3.68926800 -1.85000000 0.00000000 | ||
H 3.68926800 3.27000000 0.00000000 | ||
H 5.90629300 1.99000000 0.00000000 | ||
H 5.90629300 -0.57000000 0.00000000 | ||
C 3.68926800 2.13000000 0.00000000 | ||
X 1.22975600 0.73000000 1.00000000 | ||
X 3.68926800 0.73000000 1.00000000 |