Example #1
0
def json2Settings(xs):
    """
    transform a string containing some data in JSON format
    to a Settings object
    """
    if isinstance(xs, bytes):
        xs = xs.decode()
    s = json.loads(xs)  # Json object must be string
    return dict2Setting(s)
Example #2
0
def test_templates():
    """
    Test that the JSON files are read properly.
    """
    fun = lambda x: dict2Setting(settings2Dict(x))
    b1 = freq == fun(freq)
    b2 = geometry == fun(geometry)
    b3 = singlepoint == fun(singlepoint)
    b4 = ts == fun(ts)

    assert all([b1, b2, b3, b4])
Example #3
0
def get_template(template_name):
    """
    The function :func:`pkg_resources.resource_string` search for the location
    of the ``template_name`` file inside the installation directory an returns
    a strings with its contain. This string is subsequently converted in a
    python *dict* object using :func:`json.loads` and finally recursively
    transform into a |Settings| object.
    Using this function there are created the default templates for the
    following common calculations:

    * Singlepoint
    * Geometry optimization
    * Transition State optimization
    * Frequencies
    """
    path = join("data/templates", template_name)
    xs = pkg.resource_string("qmworks", path)
    s = json.loads(xs.decode())  # Json object must be string
    return dict2Setting(s)
Example #4
0
cp2k_main = dict2Setting({
    'cell_parameters': 28.0,
    'potential': 'GTH-PBE',
    'basis': 'DZVP-MOLOPT-SR-GTH',
    'specific': {
        'cp2k': {
            'force_eval': {
                'subsys': {
                    'cell': {
                        'periodic': 'None'
                    }
                },
                'dft': {
                    'print': {
                        'mo': {
                            'mo_index_range': '248 327'
                        }
                    },
                    'scf': {
                        'eps_scf': 0.0005,
                        'max_scf': 200,
                        'added_mos': 30
                    }
                }
            }
        }
    },
    'cell_angles': [90.0, 90.0, 90.0]
})