-
Notifications
You must be signed in to change notification settings - Fork 28
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
1 parent
dc00d64
commit a7a1271
Showing
6 changed files
with
363 additions
and
10 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 |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
"""AiiDA-CP2K workchains""" | ||
|
||
from .base import Cp2kBaseWorkChain | ||
from .bands import Cp2kBandsWorkChain |
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,83 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################### | ||
# Copyright (c), The AiiDA-CP2K authors. # | ||
# SPDX-License-Identifier: MIT # | ||
# AiiDA-CP2K is hosted on GitHub at https://github.com/cp2k/aiida-cp2k # | ||
# For further information on the license, see the LICENSE.txt file. # | ||
############################################################################### | ||
"""Work chain to compute a band structure using CP2K.""" | ||
from __future__ import absolute_import | ||
import six | ||
|
||
from aiida.common import AttributeDict | ||
from aiida.engine import WorkChain, ToContext | ||
from aiida.orm import BandsData, Dict, StructureData | ||
from aiida.plugins import WorkflowFactory | ||
|
||
from aiida_cp2k.utils import seekpath_structure_analysis, update_input_dict_for_bands | ||
|
||
Cp2kBaseWorkChain = WorkflowFactory('cp2k.base') # pylint: disable=invalid-name | ||
|
||
|
||
class Cp2kBandsWorkChain(WorkChain): | ||
"""Compute Band Structure of a material.""" | ||
|
||
@classmethod | ||
def define(cls, spec): | ||
super(Cp2kBandsWorkChain, cls).define(spec) | ||
spec.expose_inputs(Cp2kBaseWorkChain, | ||
namespace='cp2k_base', | ||
exclude=('cp2k.structure', 'cp2k.parameters', 'cp2k.metadata.options.parser_name')) | ||
spec.input('structure', valid_type=StructureData) | ||
spec.input("parameters", valid_type=Dict) | ||
spec.input('cp2k_base.cp2k.metadata.options.parser_name', | ||
valid_type=six.string_types, | ||
default='cp2k_advanced_parser', | ||
non_db=True, | ||
help='Parser of the calculation: the default is cp2k_advanced_parser to get the bands.') | ||
spec.outline( | ||
cls.setup, | ||
cls.run_seekpath, | ||
cls.prepare_bands_calculation, | ||
cls.run_bands_calculation, | ||
cls.return_results, | ||
) | ||
spec.output('output_bands', valid_type=BandsData) | ||
|
||
def setup(self): | ||
"""Perform initial setup.""" | ||
self.ctx.structure = self.inputs.structure | ||
|
||
def run_seekpath(self): | ||
"""Run Seekpath to get the primitive structure | ||
N.B. If, after cell optimization the symmetry change, | ||
the primitive cell will be different!""" | ||
|
||
seekpath_parameters = Dict(dict={}) | ||
|
||
seekpath_result = seekpath_structure_analysis(self.ctx.structure, seekpath_parameters) | ||
self.ctx.seekpath_analysis = seekpath_result['parameters'] | ||
self.ctx.structure = seekpath_result['primitive_structure'] | ||
|
||
def prepare_bands_calculation(self): | ||
"""Prepare all the neccessary input links to run the calculation.""" | ||
|
||
# Add molecular orbitals and kpoints path that was generated by seekpath | ||
self.ctx.parameters = update_input_dict_for_bands(self.inputs.parameters, self.ctx.seekpath_analysis, | ||
self.ctx.structure) | ||
|
||
def run_bands_calculation(self): | ||
"""Run cp2k calculation.""" | ||
|
||
inputs = AttributeDict(self.exposed_inputs(Cp2kBaseWorkChain, namespace='cp2k_base')) | ||
inputs.cp2k.structure = self.ctx.structure | ||
inputs.cp2k.parameters = self.ctx.parameters | ||
|
||
# Create the calculation process and launch it | ||
running = self.submit(Cp2kBaseWorkChain, **inputs) | ||
self.report("Submitted Cp2kBaseWorkChain for band structure calculation.") | ||
return ToContext(calculation=running) | ||
|
||
def return_results(self): | ||
"""Extract output_parameters.""" | ||
self.out('output_bands', self.ctx.calculation.outputs.output_bands) |
Oops, something went wrong.