GithubHelp home page GithubHelp logo

pycp2k's People

Contributors

irista56 avatar lauri-codes avatar marchunter avatar mjvansetten avatar waveman68 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycp2k's Issues

Pls help!!! what is wrong with pycp2k run

I have installed pycp2k in Ubuntu successfully, and can run the examples included . But I can not run my python format input file . PLs help me to find out what is wrong with the input. The corresponding CP2K format input can be run The following is the input. and the error messages :

from pycp2k import CP2K

#===============================================================================

Setup calculator

calc = CP2K()
calc.working_directory = "./"
calc.project_name = "H2O_py3"
calc.mpi_n_processes = 4

#===============================================================================

Create shortcuts for the most used subtrees of the input.

CP2K_INPUT = calc.CP2K_INPUT
GLOBAL = CP2K_INPUT.GLOBAL
FORCE_EVAL = CP2K_INPUT.FORCE_EVAL_add()
SUBSYS = FORCE_EVAL.SUBSYS
MOTION = CP2K_INPUT.MOTION
DFT = FORCE_EVAL.DFT
FORCEFIELD = FORCE_EVAL.MM.FORCEFIELD

GLOBAL.Run_type = "GEO_OPT"
GLOBAL.Print_level = "LOW"

FORCE_EVAL.Method = "QuickStep"

DFT.Basis_set_file_name = "/home/dell/Softrun/cp2k-6.1/GTH_BASIS_SETS"
DFT.Potential_file_name = "/home/dell/Softrun/cp2k-6.1/GTH_POTENTIALS"
DFT.MGRID.Cutoff = 250
DFT.SCF.Eps_scf = 1.0E-6
DFT.XC.XC_FUNCTIONAL = "BLYP"
DFT.XC.XC_GRID.Xc_smooth_rho = "NN10"

SUBSYS.CELL.Abc = [15.0,15.0,15.0]
SUBSYS.COORD.Default_keyword = [["O",0,0,0],["H",0.7,0.7,0], ["H",-0.7,0.7,0]]
h_kind = SUBSYS.KIND_add("H")
h_kind.Basis_set = "TZVP-GTH"
h_kind.Potential = "GTH-BLYP-q1"

h_kind =SUBSYS.KIND_add("O")
h_kind.Basis_set = "TZVP-GTH"
h_kind.Potential = "GTH-BLYP-q6"

#calc.write_input_file()

calc.run()


The following is the error messages:

CP2K version check...
Creating CP2K input file...
Traceback (most recent call last):
File "h2o.py", line 47, in
calc.run()
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/cp2k.py", line 288, in run
self.write_input_file()
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/cp2k.py", line 251, in write_input_file
input_file.write(self.get_input_string())
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/cp2k.py", line 257, in get_input_string
input_string = self.CP2K_INPUT._print_input(-1)
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/inputsection.py", line 176, in _print_input
substring = subsection._print_input(level + 1)
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/inputsection.py", line 168, in _print_input
substring = value._print_input(level + 1)
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/inputsection.py", line 168, in _print_input
substring = value._print_input(level + 1)
File "/usr/local/lib/python3.7/site-packages/pycp2k-0.2.1-py3.7.egg/pycp2k/inputsection.py", line 168, in _print_input
substring = value._print_input(level + 1)
AttributeError: 'str' object has no attribute '_print_input'

Support reading molecule through MDAnalysis?

Currently, the ASE is used for loading coordinate, box size and element information. I wonder if it is possible to load the data through MDAnalysis.Universe?
The coordinate, cell, atom type can be accessed via

>>> from MDAnalysis import Universe
>>> from MDAnalysis.tests.datafiles import CRD
>>> u = Universe(CRD)
>>> u.dimensions
array([0., 0., 0., 0., 0., 0.], dtype=float32)
>>> u.atoms.positions
array([[-11.921,  26.307,  10.41 ],
       [-11.447,  26.741,   9.595],
       [-12.44 ,  27.042,  10.926],
       ...,
       [-12.616,  28.099,  21.258],
       [-13.786,  28.568,  21.198],
       [-12.417,  26.877,  21.494]], dtype=float32)
>>> u.atoms.types
array(['N', 'H', 'H', ..., 'C', 'O', 'O'], dtype=object)

problem in manual install from cp2k 8.2 xml file

thanks for the package we really enjoy using.

when running install from a 8.2 xml file I got errors. the problem actually lives in cp2k. the self_energy keyword has an emty name tag in the default keyword, it does have an alias defined which is self_energy. Maybe the pycp2k should somehow provide a usefully error message or a fix.

tx

Suggestion for syntax check

I have been using this package quite a bit lately and I find it extremely useful. I have recently come across a minor issue whenever I wish to restart a calculation from a previous one using an external restart file. I solved it by modifying line 291 to

if "SUCCESS" not in syntax_result:

This problem originates in the output that cp2k gives if you do a syntax check when restarting from an external file. In this case the first 7 characters are not "SUCCESS" but instead cp2k prints information about the quantities that will be restarted, which means that the current test

if syntax_result[0:7] != "SUCCESS":

fails even if there is no problem with the input file.

Exception for Empty Keywords

Believe it or not, there are keywords in cp2k without a default NAME, but an alias. This causes a TypeError in the:

validify_keyword(string) function in inputparser.py

I currently do not have access, so I have forked the code base. In short, I propose catching this in the function with an if statement:

Proposal for function line 39:

def validify_keyword(string):
    """Modifies the keyword name so that it can be used as a valid attribute
    name in a python class.
    """
    original = string
    changed = False

    if string == None:
        print("    Keyword None replaced with NO_DEFAULT")
        return "NO_DEFAULT"

...

Catch non-visible check by adding name != None at line 181:

            if keytype == "default":
                default_name = newname
                if name != None and name.startswith("__"):
                    visible = False

Currently:

    newname = validify_keyword(name)
            if keytype == "default":
                default_name = newname
                if name.startswith("__"):
                    visible = False

Currently:

def validify_keyword(string):
    """Modifies the keyword name so that it can be used as a valid attribute
    name in a python class.
    """
    original = string
    changed = False

    if "-" in string:
        changed = True
        string = string.replace("-", "_")

    if "+" in string:
        changed = True
        string = string.replace("+", "PLUS")

    if string[0].isdigit():
        changed = True
        string = "NUM" + string

    if changed:
        print("    Keyword {} replaced with {}".format(original, string))

    string = string.capitalize()
    return string

How to use parse?

I read CP2K.Parse.doc, it seems to tell me that "parse" can read the existing CP2K INPUT. so I write some line to test .It goes wrong.

import ase

from pycp2k import CP2K

#===============================================================================

Setup calculator

calc = CP2K()
calc.working_directory = "./"
#calc.project_name = "H2O.out"
calc.mpi_n_processes = 4
#calc.input_path = "./"
calc.parse = "H2O_GOPT.inp"

calc.write_input_file()

calc.run()

CP2K INPUT FILE:

@set SYSTEM H2O_GOPT

@set LIBDIR /home/dell/cp2k-6.1/data

&GLOBAL

 PROJECT ${SYSTEM}          # Name of calculation: run H2O-GOPT 
 RUN_TYPE GEO_OPT           # Perform a geometry optimization
 PRINT_LEVEL LOW            # Do not output too much information

&END GLOBAL

&FORCE_EVAL

 METHOD QuickStep
 &DFT                       # Use density functional theory
    BASIS_SET_FILE_NAME ${LIBDIR}/GTH_BASIS_SETS
    POTENTIAL_FILE_NAME ${LIBDIR}/GTH_POTENTIALS
    &MGRID
         CUTOFF 250    # plane-wave cutoff for the charge density [Rydbergs]
    &END MGRID  
    &SCF                     
         EPS_SCF 1.0E-6         # convergence threshold for total energy
    &END SCF
    &XC    # parameters for exchange-correlation functional
         &XC_FUNCTIONAL BLYP
         &END XC_FUNCTIONAL
         &XC_GRID # some tricks to speed up the calculation of the xc potential
                                                                                               XC_DERIV       SPLINE2_smooth
               XC_SMOOTH_RHO  NN10
        &END XC_GRID
      &END XC
 &END DFT
                                                                                 &SUBSYS
      &CELL   # box containing the molecule: 15x15x15 Angstroms
        ABC [angstrom] 15 15 15
      &END CELL
      &COORD  # coordinates of the atoms in the box [Angstroms]
           O  0 0 0
           H  0.7 0.7 0
           H -0.7 0.7 0
      &END COORD
      &KIND H # basis sets and pseudo-potentials for atomic species
           BASIS_SET TZVP-GTH
           POTENTIAL GTH-BLYP-q1
      &END KIND
      &KIND O
           BASIS_SET TZVP-GTH
           POTENTIAL GTH-BLYP-q6
      &END KIND
 &END SUBSYS

&END FORCE_EVAL

problems with exchange correlation functional classes in 8.2

pycp2k tries to set the 0,1,2 the elements of none existing lists in subclasses of inputsection for some exchange correlation functionals.
I added them like:

init of inputsection
self._pp = 3*[None]

but this just moves the problem a long the way...

I have three problems that need your help urgently!!!!!

I hope to translate the following cp2k scripts into Python format. I have three problems:
(1) I can not find the corresponding PYTHON INPUTS to replace " COMPONENTS_TO_FIX XYZ" in the CONSTRAINT SECTION;
(2) cp2k inputs can use COSTUM units such as " ABC [angstrom] 9.1 12.0 17.8" in the CELL SECTION, how can I use PYTHON FORMAT INPUT to declare CUSTOM UNITS?
(3)I do not why PYTHON FORMAT can not run when I add "calc.write_input_file()"?

The following is my PYTHON FORMAT INPUTS:

#!/usr/bin/env python3

-- coding: utf-8 --

"""
Created on Fri Jan 3 16:47:06 2020

@author: dell
"""

import ase

from pycp2k import CP2K

#============================================================

Setup calculator

calc = CP2K()
calc.working_directory = "./"
calc.project_name = "Al2O3_py_1"
calc.mpi_n_processes = 4

#===============================================================

Create shortcuts for the most used subtrees of the input.

CP2K_INPUT = calc.CP2K_INPUT
GLOBAL = CP2K_INPUT.GLOBAL
FORCE_EVAL = CP2K_INPUT.FORCE_EVAL_add()
SUBSYS = FORCE_EVAL.SUBSYS
MOTION = CP2K_INPUT.MOTION
DFT = FORCE_EVAL.DFT
FORCEFIELD = FORCE_EVAL.MM.FORCEFIELD

GLOBAL.Run_type = "GEO_OPT"
GLOBAL.Print_level = "LOW"

FORCE_EVAL.Method = "QuickStep"

DFT.Basis_set_file_name = "/home/dell/Softrun/cp2k-6.1/data/BASIS_MOLOPT"
DFT.Potential_file_name = "/home/dell/Softrun/cp2k-6.1/data/GTH_POTENTIALS"
DFT.MGRID.Cutoff = 250
DFT.MGRID.Ngrids = 4
DFT.MGRID.Rel_cutoff = 40
DFT.SCF.Eps_scf = 1.0E-6
DFT.XC.XC_FUNCTIONAL.Section_parameters = "BLYP"
DFT.XC.XC_GRID.Xc_smooth_rho = "NN10"

DFT.SCF.Scf_guess = "ATOMIC"
DFT.SCF.Eps_scf = 1.0E-06
DFT.SCF.Max_scf = 300

OT = DFT.SCF.OT
OT.Minimizer = "DIIS"
OT.Preconditioner = "FULL_ALL"

DFT.SCF.OUTER_SCF.Eps_scf = 1.0E-06
DFT.SCF.OUTER_SCF.Max_scf = 30

#DFT.SCF.PRINT.RESTART = "OFF"

SUBSYS.COORD.Unit = "angstrom"
SUBSYS.CELL.Abc = [9.1,12.0,17.8] #how to use CUSTOM UNITS?

SUBSYS.COORD.Default_keyword = [
["O", 5.72813,11.98165,8.24775],
["O", 8.10763,7.86025,8.24775],
["O", 5.72813, 6.48642, 12.57804],
["O", 8.10763,10.60782,12.57804],
["O", 5.72813, 9.23408, 16.90846],
["O", 8.10763, 5.11268, 16.90846],
["O", 5.72813, 6.26115, 8.24775],
["O", 8.10763, 10.38255, 8.24775],
["O", 5.72813, 9.00872, 12.57804],
["O", 8.10763, 13.13012, 12.57804],
["O", 5.72813, 11.75638, 16.90846],
["O", 8.10763, 7.63498, 16.90846],
["O", 5.92325, 9.1214, 8.24775],
["O",8.30275, 5, 8.24775],
["O", 5.92325, 11.86897, 12.57804],
["O", 8.30275, 7.74757, 12.57804],
["O", 5.92325, 6.37383, 16.90846],
["O", 8.30275, 10.49523, 16.90846],
["O", 6.65137, 10.38255, 14.74325],
["O", 9.03087, 6.26115, 14.74325],
["O", 6.65137, 13.13012, 6.08254],
["O", 9.03087, 9.00872, 6.08254],
["O", 6.65137, 7.63498, 10.41296],
["O", 9.03087, 11.75638, 10.41296],
["O", 6.65137, 7.86025, 14.74325],
["O", 9.03087, 11.98165, 14.74325],
["O", 6.65137, 10.60782, 6.08254],
["O", 9.03087, 6.48642, 6.08254],
["O", 6.65137, 5.11268, 10.41296],
["O", 9.03087, 9.23408, 10.41296],
["O", 6.45625, 13.2428, 14.74325],
["O", 8.83575, 9.1214,14.74325],
["O", 6.45625, 7.74757, 6.08254],
["O", 8.83575, 11.86897, 6.08254],
["O", 6.45625, 10.49523, 10.41296],
["O", 8.83575, 6.37383, 10.41296],
["Al",5, 5, 9.57283],
["Al", 7.3795, 9.1214, 9.57283],
["Al", 5, 7.74757, 13.90312],
["Al", 7.3795, 11.86897, 13.90312],
["Al", 5, 10.49523, 5.24254],
["Al", 7.3795, 6.37383, 5.24254],
["Al", 5, 5, 6.92267],
["Al", 7.3795, 9.1214, 6.92267],
["Al", 5, 7.74757, 11.25296],
["Al", 7.3795, 11.86897, 11.25296],
["Al ",5, 10.49523, 15.58338],
["Al", 7.3795, 6.37383, 15.58338],
["Al", 5, 5, 13.41817],
["Al", 7.3795, 9.1214, 13.41817],
["Al", 5, 7.74757, 17.74846],
["Al", 7.3795, 11.86897, 17.74846],
["Al", 5, 10.49523, 9.08788],
["Al", 7.3795, 6.37383, 9.08788],
["Al", 5, 5, 16.06833],
["Al", 7.3795, 9.1214, 16.06833],
["Al", 5, 7.74757, 7.40762],
["Al", 7.3795, 11.86897, 7.40762],
["Al", 5, 10.49523, 11.73804],
["Al", 7.3795, 6.37383, 11.73804]
]

h_kind = SUBSYS.KIND_add("O")
h_kind.Basis_set = "DZVP-MOLOPT-SR-GTH"
h_kind.Potential = "GTH-BLYP-q6"

h_kind =SUBSYS.KIND_add("Al")
h_kind.Basis_set = "DZVP-MOLOPT-SR-GTH"
h_kind.Potential = "GTH-BLYP-q3"

GEO_OPT = MOTION.GEO_OPT

GEO_OPT.Type = "MINIMIZATION"
GEO_OPT.Max_dr = 1.0E-03
GEO_OPT.Max_force = 1.0E-03
GEO_OPT.Rms_dr = 1.0E-03
GEO_OPT.Rms_force = 1.0E-03
GEO_OPT.Optimizer = "LBFGS"

CONSTRAINT = MOTION.CONSTRAINT
#CONSTRAINT....... = "XYZ" //How to express: COMPONENTS_TO_FIX XYZ
CONSTRAINT.FIXED_ATOMS_list = 1

#calc.write_input_file() //When I add this line ,it can not RUN,why?

calc.run()

==========================================================

ORGINAL CP2K INPUTS:

&GLOBAL
PROJECT Al2O3_1
RUN_TYPE GEO_OPT
PRINT_LEVEL LOW
&END GLOBAL
&FORCE_EVAL
METHOD QS
&SUBSYS
&CELL
ABC [angstrom] 9.1 12.0 17.8
&END CELL
&COORD
O 5.72813 11.98165 8.24775
O 8.10763 7.86025 8.24775
O 5.72813 6.48642 12.57804
O 8.10763 10.60782 12.57804
O 5.72813 9.23408 16.90846
O 8.10763 5.11268 16.90846
O 5.72813 6.26115 8.24775
O 8.10763 10.38255 8.24775
O 5.72813 9.00872 12.57804
O 8.10763 13.13012 12.57804
O 5.72813 11.75638 16.90846
O 8.10763 7.63498 16.90846
O 5.92325 9.1214 8.24775
O 8.30275 5 8.24775
O 5.92325 11.86897 12.57804
O 8 .30275 7.74757 12.57804
O 5.92325 6.37383 16.90846
O 8.30275 10.49523 16.90846
O 6.65137 10.38255 14.74325
O 9.03087 6.26115 14.74325
O 6.65137 13.13012 6.08254
O 9.03087 9.00872 6.08254
O 6.65137 7.63498 10.41296
O 9.03087 11.75638 10.41296
O 6.65137 7.86025 14.74325
O 9.03087 11.98165 14.74325
O 6.65137 10.60782 6.08254
O 9.03087 6.48642 6.08254
O 6.65137 5.11268 10.41296
O 9.03087 9.23408 10.41296
O 6.45625 13.2428 14.74325
O 8.83575 9.1214 14.74325
O 6.45625 7.74757 6.08254
O 8.83575 11.86897 6.08254
O 6.45625 10.49523 10.41296
O 8.83575 6.37383 10.41296
Al 5 5 9.57283
Al 7.3795 9.1214 9.57283
Al 5 7.74757 13.90312
Al 7.3795 11.86897 13.90312
Al 5 10.49523 5.24254
Al 7.3795 6.37383 5.24254
Al 5 5 6.92267
Al 7.3795 9.1214 6.92267
Al 5 7.74757 11.25296
Al 7.3795 11.86897 11.25296
Al 5 10.49523 15.58338
Al 7.3795 6.37383 15.58338
Al 5 5 13.41817
Al 7.3795 9.1214 13.41817
Al 5 7.74757 17.74846
Al 7.3795 11.86897 17.74846
Al 5 10.49523 9.08788
Al 7.3795 6.37383 9.08788
Al 5 5 16.06833
Al 7.3795 9.1214 16.06833
Al 5 7.74757 7.40762
Al 7.3795 11.86897 7.40762
Al 5 10.49523 11.73804
Al 7.3795 6.37383 11.73804

&END COORD
&KIND O
 ELEMENT O
  #BASIS_SET DZVP-GTH-PADE
   BASIS_SET DZVP-MOLOPT-SR-GTH
  #POTENTIAL GTH-PADE-q6
   POTENTIAL GTH-BLYP-q6
&END KIND
&KIND Al
  ELEMENT	Al
  BASIS_SET DZVP-MOLOPT-SR-GTH
  POTENTIAL GTH-BLYP-q3
&END KIND

&END SUBSYS
&DFT
BASIS_SET_FILE_NAME BASIS_MOLOPT
POTENTIAL_FILE_NAME GTH_POTENTIALS
&QS
EPS_DEFAULT 1.0E-6
&END QS
&MGRID
CUTOFF 250
NGRIDS 4
REL_CUTOFF 40
&END MGRID
&SCF
SCF_GUESS ATOMIC
EPS_SCF 1.0E-06
MAX_SCF 300
&OT
MINIMIZER DIIS
PRECONDITIONER FULL_ALL
#STEPSIZE 0.02
&END OT
&OUTER_SCF
EPS_SCF 1.0E-06
MAX_SCF 30
&END OUTER_SCF
# &MIXING
# METHOD PULAY_MIXING
# ALPHA 0.5
# NPULAY 5
# &END MIXING
&PRINT
&RESTART OFF
&END RESTART
&END PRINT
&END SCF
&XC
&XC_FUNCTIONAL BLYP
&END XC_FUNCTIONAL
&END XC
&END DFT
&END FORCE_EVAL
&MOTION
&GEO_OPT
TYPE MINIMIZATION
MAX_DR 1.0E-03
MAX_FORCE 1.0E-03
RMS_DR 1.0E-03
RMS_FORCE 1.0E-03
MAX_ITER 200
OPTIMIZER LBFGS
#&CG
#MAX_STEEP_STEPS 0
#RESTART_LIMIT 9.0E-01
#&END CG
&END GEO_OPT
&CONSTRAINT
&FIXED_ATOMS
COMPONENTS_TO_FIX XYZ
LIST 1
&END FIXED_ATOMS
&END CONSTRAINT
&END MOTION

xTB parameter in DFT.QS section

If one would like to use GFN1-xTB

    &QS
      METHOD xTB
      &xTB
        CHECK_ATOMIC_CHARGES F #xTB calculation often crashes without setting this to false
        &PARAMETER
          DISPERSION_PARAMETER_FILE dftd3.dat
          PARAM_FILE_NAME xTB_parameters
        &END PARAMETER
      &END xTB
    &END QS

The xTB attribute is not present in CP2K.CP2K_INPUT.FORCE_EVAL.DFT.QS.

json/yaml support

I'm using DVC to make my workflows reproducible. Therefore, I need machine-readable parameter files such as json or yaml. Is it possible to convert the PyCP2K object into/load from a serialiezable dictionary or even import/export json/yaml directly?

Multiple Basis Set File Names

Hello,

I have found a bug in your code. If you have multiple BASIS_SET_FILE_NAMEs in your input file and use the pycp2k parser, it reads only the last variable in that section. The variable probably requires a list implementation (I'm not sure how it currently works).

It would seem that you already have the idea of making the variable a list but it wasn't parsed correctly by CP2KInputParser.parse .

The variable is from the following tree:
&FORCE_EVAL
&DFT
BASIS_SET_FILE_NAME
BASIS_SET_FILE_NAME
....

Long lines in input files

As I am calculating really big systems I have found out, that the cp2k itself (at least until version 7.1) has a limit on the length of line, during its reading procedure (old fortran reading style ... ) . So if I create a large list of atoms, that is supposed to be fixed, and this list is longer than (~200 atoms), than the later numbers is not recognised by cp2k itself. E.g. this is a problem:

LIST 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022

As all the atoms from 243 onwards were not fixed in my calculations.

So it would be good, to make something like this:

      LIST 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
      LIST 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
      LIST 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
      LIST 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
      LIST 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 249 250 251
      LIST 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
      LIST 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 
      LIST 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
      LIST 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
      LIST 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
      LIST 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
      LIST 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
      LIST 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
      LIST 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
      LIST 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
      LIST 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
      LIST 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 
      LIST 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 
      LIST 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 
      LIST 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 
      LIST 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 
      LIST 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 
      LIST 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022

which seems to be working fine. I've tried to really quickly look into the code, didn't find anything useful. Do you have a time to look at it, or should I go for it (it will take me approximately 1 day to figure that out)?

Additional FORCE_EVAL parameters not being added to the input

I am trying to use this python interface iteratively to perform cutoff, rel-cutoff, and ngrid optimization with cp2k. I have written code to loop over values, update the relevant attribute of the CP2K() calculator object, and then run the analysis.
When I run this code however and look at the input file, none of the new MGRID sections. I have included a simplified view of what my code is doing when it tries to update the attributes below:

Code Samples

self.calculator = CP2K()
self.calculator.project_name = 'optimize'
self.calculator.working_directory = './'
self.force_eval = CP2K().CP2K_INPUT.FORCE_EVAL_add()
self.m_grid = self.force_eval.DFT.MGRID
self.calculator.parse(self.template_file)

DFT = self.force_eval.DFT
DFT.MGRID.Cutoff = 10
DFT.MGRID.Ngrids = 5
DFT.MGRID.Rel_cutoff = 6
self.calculator.write_input_file()

Other information

I have also played around with the format of the input file, but it seems that pycp2k is just returning the input file that I parsed to it when I call write_input_file.

Parsed input file

@SET PROJ_NAME IDEAL

### ####################### ###
### Set the global settings ###
### ####################### ###

&GLOBAL
    PROJECT ${PROJ_NAME}
    PREFERRED_FFT_LIBRARY FFTW
    FFTW_PLAN_TYPE MEASURE
    RUN_TYPE ENERGY_FORCE
    PRINT_LEVEL LOW
&END GLOBAL

### ###################### ###
### Restart file if needed ###
### ###################### ###

#&EXT_RESTART
#    RESTART_FILE_NAME ${PROJ_NAME}-1.restart
#&END EXT_RESTART

### ################### ###
### Force Eval Settings ###
### ################### ###

&FORCE_EVAL
    &DFT
        CHARGE 0
        BASIS_SET_FILE_NAME /beegfs/work/stovey/Software/cp2k_data/BASIS_MOLOPT
        POTENTIAL_FILE_NAME /beegfs/work/stovey/Software/cp2k_data/GTH_POTENTIALS
        #&MGRID
        #    CUTOFF 10
        #    NGRIDS 2
        #    REL_CUTOFF 5
        #&END MGRID
        &SCF
            SCF_GUESS RESTART
            MAX_SCF 100
            EPS_SCF 1.0E-6
            &OT
                MINIMIZER DIIS
                PRECONDITIONER FULL_SINGLE_INVERSE
            &END OT
            &OUTER_SCF
                MAX_SCF 100
                EPS_SCF 1.0E-6
            &END OUTER_SCF
            &PRINT
                &RESTART  OFF
                    ADD_LAST NUMERIC
                    &EACH
                        QS_SCF 0
                    &END EACH
                &END RESTART
            &END PRINT
        &END SCF
        &XC
          &XC_FUNCTIONAL PBE
          &END XC_FUNCTIONAL
          &vdW_POTENTIAL
             DISPERSION_FUNCTIONAL NON_LOCAL
             &NON_LOCAL
               TYPE RVV10
               PARAMETERS 6.3 0.0093
               VERBOSE_OUTPUT
               KERNEL_FILE_NAME /beegfs/work/stovey/Software/cp2k_data/rVV10_kernel_table.dat
               CUTOFF  100
             &END NON_LOCAL
          &END vdW_POTENTIAL
        &END XC
        #&PRINT
        #    &FORCES ON
        #    &END FORCES
        #&END PRINT
    &END DFT&SUBSYS
        &TOPOLOGY
            COORD_FILE_NAME emim_f.xyz
            COORD_FILE_FORMAT XYZ
            &GENERATE
            &END GENERATE
        &END TOPOLOGY
        &CELL
            ABC [angstrom] 12.58 12.58 12.58
        &END CELL
        &KIND N
             BASIS_SET DZVP-MOLOPT-SR-GTH
             POTENTIAL GTH-PBE-q5
        &END KIND
        &KIND C
            BASIS_SET DZVP-MOLOPT-SR-GTH
            POTENTIAL GTH-PBE-q4
        &END KIND
        &KIND H
            BASIS_SET DZVP-MOLOPT-SR-GTH
            POTENTIAL GTH-PBE-q1
        &END KIND
        &KIND F
            BASIS_SET DZVP-MOLOPT-SR-GTH
            POTENTIAL GTH-PBE-q7
        &END KIND
    &END SUBSYS
    STRESS_TENSOR ANALYTICAL
&END FORCE_EVAL

Returned input file

&GLOBAL
  FFTW_PLAN_TYPE MEASURE
  PRINT_LEVEL LOW
  PREFERRED_FFT_LIBRARY FFTW
  PROJECT_NAME IDEAL
  RUN_TYPE ENERGY_FORCE
&END GLOBAL
&FORCE_EVAL
  STRESS_TENSOR ANALYTICAL
  &SUBSYS
    &CELL
      ABC [angstrom] 12.58 12.58 12.58
    &END CELL
    &TOPOLOGY
      COORD_FILE_FORMAT XYZ
      COORD_FILE_NAME emim_f.xyz
    &END TOPOLOGY
    &KIND N
      POTENTIAL GTH-PBE-q5
      BASIS_SET DZVP-MOLOPT-SR-GTH
    &END KIND
    &KIND C
      POTENTIAL GTH-PBE-q4
      BASIS_SET DZVP-MOLOPT-SR-GTH
    &END KIND
    &KIND H
      POTENTIAL GTH-PBE-q1
      BASIS_SET DZVP-MOLOPT-SR-GTH
    &END KIND
    &KIND F
      POTENTIAL GTH-PBE-q7
      BASIS_SET DZVP-MOLOPT-SR-GTH
    &END KIND
  &END SUBSYS
  &DFT
    POTENTIAL_FILE_NAME /beegfs/work/stovey/Software/cp2k_data/GTH_POTENTIALS
    CHARGE 0
    BASIS_SET_FILE_NAME /beegfs/work/stovey/Software/cp2k_data/BASIS_MOLOPT
    &XC
      &VDW_POTENTIAL
        POTENTIAL_TYPE NON_LOCAL
        &NON_LOCAL
          KERNEL_FILE_NAME /beegfs/work/stovey/Software/cp2k_data/rVV10_kernel_table.dat
          PARAMETERS 6.3 0.0093
          TYPE RVV10
          CUTOFF 100
          VERBOSE_OUTPUT
        &END NON_LOCAL
      &END VDW_POTENTIAL
      &XC_FUNCTIONAL PBE
      &END XC_FUNCTIONAL
    &END XC
    &SCF
      EPS_SCF 1.0E-6
      MAX_SCF 100
      SCF_GUESS RESTART
      &PRINT
        &RESTART OFF
          ADD_LAST NUMERIC
          &EACH
            QS_SCF 0
          &END EACH
        &END RESTART
      &END PRINT
      &OUTER_SCF
        EPS_SCF 1.0E-6
        MAX_SCF 100
      &END OUTER_SCF
      &OT
        PRECONDITIONER FULL_SINGLE_INVERSE
        MINIMIZER DIIS
      &END OT
    &END SCF
  &END DFT
&END FORCE_EVAL

get_forces() function

Hello,

I am interested in using pycp2k for my research and I have seen that it was possible to extract the forces from a calculation using something like calc.get_forces(), however I can't seem to find this functionality anymore in the master release of the package. Has the way of accessing this feature changed or is it not available anymore?

MB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.