diff --git a/README.md b/README.md index fc483c9..87bf966 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is a brief installation guide fo aiida-qp2. First one needs to setup properly `aiida` it should be installed when package is installed. Also RabbitMQ is importat to run `aiida`. ``` -# It is better to run it in some kind of virtual environment. +# It is better to run it in some kind of virtual environment. $ pip install aiida-qp2 ``` @@ -71,7 +71,7 @@ use_double_quotes: false image_name: 'qp2-aiida' label: 'qp2-docker' description: 'quantum package 2' -default_calc_job_plugin: +default_calc_job_plugin: - 'qp2.create' - 'qp2.run' filepath_executable: '/bin/entrypoint.sh' diff --git a/aiida_qp2/cli/__init__.py b/aiida_qp2/cli/__init__.py index 3fd66e7..dee586a 100644 --- a/aiida_qp2/cli/__init__.py +++ b/aiida_qp2/cli/__init__.py @@ -11,29 +11,41 @@ from .cli_helpers import wf_option, code_option -_QP_GROUP = "qp2_project_group" +_QP_GROUP = 'qp2_project_group' -@click.group('aiida-qp2', cls=VerdiCommandGroup, context_settings={'help_option_names': ['-h', '--help']}) -@options.PROFILE(type=types.ProfileParamType(load_profile=True), expose_value=False) + +@click.group('aiida-qp2', + cls=VerdiCommandGroup, + context_settings={'help_option_names': ['-h', '--help']}) +@options.PROFILE(type=types.ProfileParamType(load_profile=True), + expose_value=False) def cli_root(): """Manage qp2""" -@cli_root.command("create") -@click.argument("name", type=click.STRING) -@click.option("--structure", "-s", type=click.STRING, required=True, help="Structure to use") -@click.option("--basis_set", "-b", type=click.STRING, required=False, help="Basis set to use") +@cli_root.command('create') +@click.argument('name', type=click.STRING) +@click.option('--structure', + '-s', + type=click.STRING, + required=True, + help='Structure to use') +@click.option('--basis_set', + '-b', + type=click.STRING, + required=False, + help='Basis set to use') @cmdline.params.options.CODE() @decorators.with_dbenv() def create(name, structure, basis_set, code): """Create a qp2 project""" if code is None: - echo.echo_critical("Please specify a code") + echo.echo_critical('Please specify a code') return if not structure: - echo.echo_critical("Please specify a structure") + echo.echo_critical('Please specify a structure') return # Check if structure is not a path @@ -48,57 +60,61 @@ def create(name, structure, basis_set, code): try: structure = load_node(structure) except Exception as e: - echo.echo_critical(f"Error loading structure: {structure}") + echo.echo_critical(f'Error loading structure: {structure}') return if not isinstance(structure, StructureData): - echo.echo_critical(f"Invalid structure: {structure}") + echo.echo_critical(f'Invalid structure: {structure}') return - echo.echo(f"Creating project {name} ...") + echo.echo(f'Creating project {name} ...') # Find the group from aiida.orm import QueryBuilder, Group, Dict qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}) + qb.append(Group, filters={'label': _QP_GROUP}) group = qb.first() if group is None: - echo.echo_success("Group qp2 does not exist, creating it") + echo.echo_success('Group qp2 does not exist, creating it') group = Group(label=_QP_GROUP) group.store() - group.base.extras.set("active_project", None) + group.base.extras.set('active_project', None) else: group = group[0] - inputs = {"code": code, - "structure": structure, - "parameters": Dict(dict={}) } + inputs = { + 'code': code, + 'structure': structure, + 'parameters': Dict(dict={}) + } if basis_set: from aiida.orm import Str - inputs["basis_set"] = Str(basis_set) + inputs['basis_set'] = Str(basis_set) from aiida.plugins import CalculationFactory - Create = CalculationFactory("qp2.create") + Create = CalculationFactory('qp2.create') calc = Create(inputs=inputs) from aiida.engine import run ret = run(calc) - ret["wavefunction"].base.extras.set("name", name) - ret["wavefunction"].base.extras.set("default_code", code.pk) + ret['wavefunction'].base.extras.set('name', name) + ret['wavefunction'].base.extras.set('default_code', code.pk) + + group.add_nodes(ret['wavefunction']) - group.add_nodes(ret["wavefunction"]) + echo.echo_success( + f"Project {name} created with pk={ret['wavefunction'].pk}") - echo.echo_success(f"Project {name} created with pk={ret['wavefunction'].pk}") + click.confirm('Do you want to activate this project?', abort=True) + group.base.extras.set('active_project', ret['wavefunction'].pk) - click.confirm("Do you want to activate this project?", abort=True) - group.base.extras.set("active_project", ret["wavefunction"].pk) + echo.echo_success(f'Activated {name}') - echo.echo_success(f"Activated {name}") -@cli_root.command("list") +@cli_root.command('list') @decorators.with_dbenv() def list(): """List qp2 projects""" @@ -109,14 +125,19 @@ def list(): group = load_group(_QP_GROUP) qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}, tag="group") - qb.append(Wavefunction, filters={ 'attributes.wavefunction': True, - 'extras': {'has_key': 'name'}}, - with_group="group", - tag="wavefunction") - - echo.echo(f"List of qp2 projects ({qb.count()}):") - echo.echo("") + qb.append(Group, filters={'label': _QP_GROUP}, tag='group') + qb.append(Wavefunction, + filters={ + 'attributes.wavefunction': True, + 'extras': { + 'has_key': 'name' + } + }, + with_group='group', + tag='wavefunction') + + echo.echo(f'List of qp2 projects ({qb.count()}):') + echo.echo('') # Decorator @@ -128,9 +149,9 @@ def wrapper(*args, **kwargs): if args[0] % 2 == 0: return f(*args, **kwargs) else: - return f"\033[1m{f(*args, **kwargs)}\033[0m" - return wrapper + return f'\033[1m{f(*args, **kwargs)}\033[0m' + return wrapper @bolderrer def get_name(n, w): @@ -138,11 +159,12 @@ def get_name(n, w): @bolderrer def get_formula(n, w): - return w.base.attributes.all['formula'] if 'formula' in w.base.attributes.all else '' + return w.base.attributes.all[ + 'formula'] if 'formula' in w.base.attributes.all else '' @bolderrer def get_active(n, w): - return "*" if group.base.extras.all['active_project'] == w.pk else "" + return '*' if group.base.extras.all['active_project'] == w.pk else '' @bolderrer def get_code(n, w): @@ -150,29 +172,32 @@ def get_code(n, w): def get_num_wf(n, w): qb = QueryBuilder() - qb.append(Wavefunction, filters={ 'id': w.pk}, tag="mother") - qb.append(Wavefunction, with_ancestors="mother", - tag="child", - filters={'attributes.wavefunction': True}, - project=["id"]) + qb.append(Wavefunction, filters={'id': w.pk}, tag='mother') + qb.append(Wavefunction, + with_ancestors='mother', + tag='child', + filters={'attributes.wavefunction': True}, + project=['id']) # +1 for the mother return qb.count() + 1 - data = [ (get_active(n, w), - get_name(n, w), - w.pk, - w.ctime.strftime('%Y-%m-%d %H:%M:%S'), - w.user, - get_formula(n, w), - get_code(n,w), - get_num_wf(n,w)) for n, (w,) in enumerate(qb.iterall())] + data = [(get_active(n, w), get_name(n, w), w.pk, + w.ctime.strftime('%Y-%m-%d %H:%M:%S'), w.user, get_formula(n, w), + get_code(n, w), get_num_wf(n, w)) + for n, (w, ) in enumerate(qb.iterall())] import tabulate - echo.echo(tabulate.tabulate(data, headers=[" ", "Name", "ID", "Time", "User", "Formula", "Def. code", "# wfs"])) + echo.echo( + tabulate.tabulate(data, + headers=[ + ' ', 'Name', 'ID', 'Time', 'User', 'Formula', + 'Def. code', '# wfs' + ])) + -@cli_root.command("activate") -@click.argument("pk", type=click.INT) +@cli_root.command('activate') +@click.argument('pk', type=click.INT) @decorators.with_dbenv() def activate(pk): """Activate a qp2 project""" @@ -182,22 +207,24 @@ def activate(pk): try: group = load_group(_QP_GROUP) except Exception as e: - echo.echo_critical("Group qp2 does not exist") + echo.echo_critical('Group qp2 does not exist') return qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}, tag="group") - qb.append(Wavefunction, filters={ 'id': pk}, - with_group="group", - tag="wavefunction") + qb.append(Group, filters={'label': _QP_GROUP}, tag='group') + qb.append(Wavefunction, + filters={'id': pk}, + with_group='group', + tag='wavefunction') if qb.count() == 1: echo.echo_success(f"Activated {qb.first()[0].base.extras.all['name']}") - group.base.extras.set("active_project", pk) + group.base.extras.set('active_project', pk) else: - echo.echo_error(f"Project with pk={pk} not found") + echo.echo_error(f'Project with pk={pk} not found') -@cli_root.command("deactivate") + +@cli_root.command('deactivate') @decorators.with_dbenv() def deactivate(): """Deactivate a qp2 project""" @@ -207,83 +234,107 @@ def deactivate(): try: group = load_group(_QP_GROUP) except Exception as e: - echo.echo_critical("Group qp2 does not exist") + echo.echo_critical('Group qp2 does not exist') return - group.base.extras.set("active_project", None) - echo.echo_success("Deactivated project") + group.base.extras.set('active_project', None) + echo.echo_success('Deactivated project') + -@cli_root.command("run") -@click.argument("operation", type=click.STRING) +@cli_root.command('run') +@click.argument('operation', type=click.STRING) @code_option @wf_option -@click.option("--dry-run", is_flag=True, help="Do not run the operation") -@click.option("--prepend", "-p", type=click.STRING, multiple=True, help="Prepend to qp2 input") -@click.option("--do-not-store-wf", is_flag=True, help="Do not store the wavefunction") -@click.option("--trexio-bug-fix", is_flag=True, help="Fix bug where full path has to by specified in trexio_file") -@click.argument("args", nargs=-1, type=click.UNPROCESSED) +@click.option('--dry-run', is_flag=True, help='Do not run the operation') +@click.option('--prepend', + '-p', + type=click.STRING, + multiple=True, + help='Prepend to qp2 input') +@click.option('--do-not-store-wf', + is_flag=True, + help='Do not store the wavefunction') +@click.option('--trexio-bug-fix', + is_flag=True, + help='Fix bug where full path has to by specified in trexio_file' + ) +@click.argument('args', nargs=-1, type=click.UNPROCESSED) @decorators.with_dbenv() -def run(operation, code, wavefunction, dry_run, prepend, do_not_store_wf, trexio_bug_fix, args): +def run(operation, code, wavefunction, dry_run, prepend, do_not_store_wf, + trexio_bug_fix, args): """Run a qp2 operation""" - echo.echo(f"Running operation {operation} ...") - echo.echo("") + echo.echo(f'Running operation {operation} ...') + echo.echo('') if wavefunction is None: - echo.echo_critical("Please specify a wavefunction or activate a project") + echo.echo_critical( + 'Please specify a wavefunction or activate a project') return else: - echo.echo(f"Wavefunction: {wavefunction.pk} generated at {wavefunction.ctime}") + echo.echo( + f'Wavefunction: {wavefunction.pk} generated at {wavefunction.ctime}' + ) if code is None: - echo.echo_critical("Please specify a code") + echo.echo_critical('Please specify a code') return else: - echo.echo(f"Code: {code.full_label}") + echo.echo(f'Code: {code.full_label}') from aiida.plugins import CalculationFactory from aiida.orm import Dict - Calc = CalculationFactory("qp2.run") + Calc = CalculationFactory('qp2.run') builder = Calc.get_builder() builder.wavefunction = wavefunction builder.code = code - builder.parameters = Dict(dict={"run_type": operation, - "trexio_bug_fix": trexio_bug_fix, - "qp_prepend": prepend, - "qp_append": "".join(args)}) + builder.parameters = Dict( + dict={ + 'run_type': operation, + 'trexio_bug_fix': trexio_bug_fix, + 'qp_prepend': prepend, + 'qp_append': ''.join(args) + }) builder.metadata.options.store_wavefunction = not do_not_store_wf from aiida.engine import run if dry_run: - echo.echo("Dry run, not running the operation") + echo.echo('Dry run, not running the operation') return ret = run(builder) - if "output_energy" in ret: + if 'output_energy' in ret: energy_msg = f"Energy: {ret['output_energy'].value}" - if "output_energy_error" in ret: + if 'output_energy_error' in ret: energy_msg += f" +/- {ret['output_energy_error'].value}" - if "output_number_of_blocks" in ret: + if 'output_number_of_blocks' in ret: energy_msg += f" (blocks: {ret['output_number_of_blocks'].value})" - echo.echo(f"{energy_msg}") - echo.echo("") - echo.echo_success(f"Operation {operation} completed") - -@cli_root.command("show") -@click.option("--style", "-s", type=click.Choice(["plain", "tree", "graph"], case_sensitive = False), default="tree", help="Style of the output") + echo.echo(f'{energy_msg}') + echo.echo('') + echo.echo_success(f'Operation {operation} completed') + + +@cli_root.command('show') +@click.option('--style', + '-s', + type=click.Choice(['plain', 'tree', 'graph'], + case_sensitive=False), + default='tree', + help='Style of the output') @decorators.with_dbenv() def show(style): """Show active qp2 project""" from .show import show_all show_all(style) -@cli_root.command("set_default_code") -@click.argument("code", type=click.STRING) + +@cli_root.command('set_default_code') +@click.argument('code', type=click.STRING) @decorators.with_dbenv() def set_default_code(code): """Set default code for active qp2 project""" @@ -293,29 +344,32 @@ def set_default_code(code): try: code = load_code(code) except: - echo.echo_error(f"Code {code} not found") + echo.echo_error(f'Code {code} not found') return try: group = load_group(_QP_GROUP) except Exception as e: - echo.echo_critical("Group qp2 does not exist") + echo.echo_critical('Group qp2 does not exist') return qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}, tag="group") - qb.append(Wavefunction, filters={ 'id': group.base.extras.all['active_project']}, - with_group="group", - tag="wavefunction") + qb.append(Group, filters={'label': _QP_GROUP}, tag='group') + qb.append(Wavefunction, + filters={'id': group.base.extras.all['active_project']}, + with_group='group', + tag='wavefunction') if qb.count() == 1: wavefunction, = qb.first() - echo.echo(f"Setting default code for {wavefunction.base.extras.all['name']} to {code}") - wavefunction.base.extras.set("default_code", code.pk) + echo.echo( + f"Setting default code for {wavefunction.base.extras.all['name']} to {code}" + ) + wavefunction.base.extras.set('default_code', code.pk) else: - echo.echo_error(f"No active project") + echo.echo_error(f'No active project') + from ._dump import dump from ._edit import edit from ._workflow import workflow - diff --git a/aiida_qp2/cli/_dump.py b/aiida_qp2/cli/_dump.py index 6591b5c..169dafc 100644 --- a/aiida_qp2/cli/_dump.py +++ b/aiida_qp2/cli/_dump.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import click from aiida import cmdline @@ -10,16 +11,18 @@ from . import cli_root -@cli_root.group("dump") + +@cli_root.group('dump') def dump(): """ Dump the data to the file system """ pass -@dump.command("wavefunction") + +@dump.command('wavefunction') @wf_option -@click.option("--extract", "-e", is_flag=True, help="Extract the wavefunction") +@click.option('--extract', '-e', is_flag=True, help='Extract the wavefunction') @decorators.with_dbenv() def dump_wavefunction(wavefunction, extract): """Dump wavefunction to the file system (in the current directory)""" @@ -27,27 +30,30 @@ def dump_wavefunction(wavefunction, extract): from aiida.orm import SinglefileData as Wavefunction if wavefunction is None: - echo.echo_critical("Please specify a wavefunction") + echo.echo_critical('Please specify a wavefunction') return if not isinstance(wavefunction, Wavefunction): - echo.echo_critical("Invalid wavefunction") + echo.echo_critical('Invalid wavefunction') return import os if extract: import tarfile - with wavefunction.open(mode="rb") as handle_wf: - with tarfile.open(fileobj=handle_wf, mode="r:gz") as handle_tar: + with wavefunction.open(mode='rb') as handle_wf: + with tarfile.open(fileobj=handle_wf, mode='r:gz') as handle_tar: handle_tar.extractall(path=os.getcwd()) - echo.echo_success(f"Extracted wavefunction to {os.getcwd()}") + echo.echo_success(f'Extracted wavefunction to {os.getcwd()}') else: - with open(f"{os.getcwd()}/{wavefunction.pk}_wf.tar.gz", "wb") as handle_output, \ - wavefunction.open(mode="rb") as handle_input: + with open(f'{os.getcwd()}/{wavefunction.pk}_wf.tar.gz', 'wb') as handle_output, \ + wavefunction.open(mode='rb') as handle_input: handle_output.write(handle_input.read()) - echo.echo_success(f"Dumped wavefunction to {os.getcwd()}/{wavefunction.pk}_wf.tar.gz") + echo.echo_success( + f'Dumped wavefunction to {os.getcwd()}/{wavefunction.pk}_wf.tar.gz' + ) -@dump.command("output") + +@dump.command('output') @wf_option @decorators.with_dbenv() def dump_output(wavefunction): @@ -57,28 +63,36 @@ def dump_output(wavefunction): from aiida.plugins import CalculationFactory if wavefunction is None: - echo.echo_critical("Please specify a wavefunction") + echo.echo_critical('Please specify a wavefunction') return if not isinstance(wavefunction, Wavefunction): - echo.echo_critical("Invalid wavefunction") + echo.echo_critical('Invalid wavefunction') return qb = QueryBuilder() - qb.append(Wavefunction, filters={ 'id': wavefunction.pk}, tag="wf") - qb.append(CalcJobNode, with_outgoing="wf", tag="calc", project=["attributes.output_filename"]) - qb.append(FolderData, with_incoming="calc", edge_filters={"label": "retrieved"}, tag="output", project=["*"]) + qb.append(Wavefunction, filters={'id': wavefunction.pk}, tag='wf') + qb.append(CalcJobNode, + with_outgoing='wf', + tag='calc', + project=['attributes.output_filename']) + qb.append(FolderData, + with_incoming='calc', + edge_filters={'label': 'retrieved'}, + tag='output', + project=['*']) if qb.count() < 1: - echo.echo_error("No output found") + echo.echo_error('No output found') return filename, rf = qb.first() - with rf.open(filename, mode="r") as handle: + with rf.open(filename, mode='r') as handle: echo.echo(handle.read()) -@dump.command("input") + +@dump.command('input') @wf_option @decorators.with_dbenv() def dump_input(wavefunction): @@ -88,20 +102,24 @@ def dump_input(wavefunction): from aiida.plugins import CalculationFactory if wavefunction is None: - echo.echo_critical("Please specify a wavefunction") + echo.echo_critical('Please specify a wavefunction') return if not isinstance(wavefunction, Wavefunction): - echo.echo_critical("Invalid wavefunction") + echo.echo_critical('Invalid wavefunction') return qb = QueryBuilder() - qb.append(Wavefunction, filters={ 'id': wavefunction.pk}, tag="wf") - qb.append(CalcJobNode, with_outgoing="wf", tag="calc") - qb.append(Dict, with_outgoing="calc", edge_filters={"label": "parameters"}, tag="input", project=["*"]) + qb.append(Wavefunction, filters={'id': wavefunction.pk}, tag='wf') + qb.append(CalcJobNode, with_outgoing='wf', tag='calc') + qb.append(Dict, + with_outgoing='calc', + edge_filters={'label': 'parameters'}, + tag='input', + project=['*']) if qb.count() < 1: - echo.echo_error("No input found") + echo.echo_error('No input found') return params, = qb.first() diff --git a/aiida_qp2/cli/_edit.py b/aiida_qp2/cli/_edit.py index b40a58a..29139c9 100644 --- a/aiida_qp2/cli/_edit.py +++ b/aiida_qp2/cli/_edit.py @@ -12,17 +12,29 @@ from . import cli_root -@cli_root.group("edit") + +@cli_root.group('edit') def edit(): """ Edit a Wavefunction """ pass -@edit.command("operation") + +@edit.command('operation') @wf_option -@click.option("-g", "--get", type=click.STRING, nargs=1, multiple=True, help="Get the value of a parameter") -@click.option("-s", "--set", type=click.STRING, nargs=2, multiple=True, help="Set the value of a parameter") +@click.option('-g', + '--get', + type=click.STRING, + nargs=1, + multiple=True, + help='Get the value of a parameter') +@click.option('-s', + '--set', + type=click.STRING, + nargs=2, + multiple=True, + help='Set the value of a parameter') @decorators.with_dbenv() def edit_operation(wavefunction, get, set): """ @@ -30,35 +42,36 @@ def edit_operation(wavefunction, get, set): """ if not wavefunction: - echo.echo_critical("No wavefunction specified") + echo.echo_critical('No wavefunction specified') return - echo.echo(f"Editing wavefunction {wavefunction.pk}") + echo.echo(f'Editing wavefunction {wavefunction.pk}') operations = [] if set: for key, value in set: - operations.append(("set", key, value)) + operations.append(('set', key, value)) if get: for key in get: - operations.append(("get", key, None)) + operations.append(('get', key, None)) from aiida_qp2.utils.wavefunction_handler import wavefunction_handler from aiida.orm import List - ret = wavefunction_handler(wavefunction, List(operations)) + ret = wavefunction_handler(wavefunction, List(operations)) - if "data" in ret: - data = ret["data"].get_list() + if 'data' in ret: + data = ret['data'].get_list() for line in data: echo.echo_dictionary(line) - if "wavefunction" in ret: - echo.echo_success("Wavefunction edited") + if 'wavefunction' in ret: + echo.echo_success('Wavefunction edited') -@edit.command("interactive") + +@edit.command('interactive') @wf_option @decorators.with_dbenv() def edit_interactive(wavefunction): @@ -67,10 +80,10 @@ def edit_interactive(wavefunction): """ if not wavefunction: - echo.echo_critical("No wavefunction specified") + echo.echo_critical('No wavefunction specified') return - _WF_NAME = "wavefunction.wf.tar.gz" + _WF_NAME = 'wavefunction.wf.tar.gz' from aiida_qp2.utils.ezfio import ezfio import tempfile import tarfile @@ -85,42 +98,47 @@ def edit_interactive(wavefunction): # untar the wavefunction with tarfile.open(wf_path, 'r:gz') as tar: tar.extractall(temp_dir) - ezfio_path = os.path.join(temp_dir, "aiida.ezfio") + ezfio_path = os.path.join(temp_dir, 'aiida.ezfio') ezfio.set_file(ezfio_path) - echo.echo("") - echo.echo("#"*80) - echo.echo("") - echo.echo("You can now edit the wavefunction (wf) using the ezfio object") - echo.echo("") + echo.echo('') + echo.echo('#' * 80) + echo.echo('') + echo.echo( + 'You can now edit the wavefunction (wf) using the ezfio object') + echo.echo('') echo.echo("Example: wf.set_jastrow_j2e_type('Mu')") echo.echo(" wf.set_jastrow_j1e_type('None')") echo.echo(" wf.get_jastrow_j2e_type('Mu')") echo.echo(" [Out]: 'Mu'") - echo.echo("") - echo.echo_warning("This is not (yet) a calcjob! The changes are not logged, and the provenance is not tracked") - echo.echo("") - echo.echo("#"*80) - echo.echo("") - - start_ipython(argv=[], user_ns={"wf": ezfio}) - - click.confirm("Do you want to save the changes?", default=True, abort=True) + echo.echo('') + echo.echo_warning( + 'This is not (yet) a calcjob! The changes are not logged, and the provenance is not tracked' + ) + echo.echo('') + echo.echo('#' * 80) + echo.echo('') + + start_ipython(argv=[], user_ns={'wf': ezfio}) + + click.confirm('Do you want to save the changes?', + default=True, + abort=True) from aiida.orm import SinglefileData with tarfile.open(wf_path, 'w:gz') as tar: - tar.add(ezfio_path, arcname="aiida.ezfio") + tar.add(ezfio_path, arcname='aiida.ezfio') with open(wf_path, 'rb') as handle: wavefunction = SinglefileData(file=handle) - wavefunction.base.attributes.all["wavefunction"] = True + wavefunction.base.attributes.all['wavefunction'] = True wavefunction.store() - echo.echo_success(f"Wavefunction edited and stored (pk={wavefunction.pk})") - + echo.echo_success( + f'Wavefunction edited and stored (pk={wavefunction.pk})') -@edit.command("from_file") +@edit.command('from_file') @wf_option -@click.argument("file", type=click.Path(exists=True)) +@click.argument('file', type=click.Path(exists=True)) @decorators.with_dbenv() def edit_from_file(wavefunction, file): """ @@ -128,7 +146,7 @@ def edit_from_file(wavefunction, file): """ if not wavefunction: - echo.echo_critical("No wavefunction specified") + echo.echo_critical('No wavefunction specified') return from aiida.orm import SinglefileData @@ -136,34 +154,33 @@ def edit_from_file(wavefunction, file): operations = [] with open(file, 'r') as handle: - getter = re.compile(r"get\s+(\w+)") + getter = re.compile(r'get\s+(\w+)') setter = re.compile(r'set\s+(\w+)\s+"([^"]*)"') for line in handle: match = getter.match(line) if match: key = match.group(1) - operations.append(("get", key, None)) + operations.append(('get', key, None)) continue match = setter.match(line) if match: key = match.group(1) value = match.group(2) - operations.append(("set", key, value)) + operations.append(('set', key, value)) continue from aiida_qp2.utils.wavefunction_handler import wavefunction_handler from aiida.orm import List - ret = wavefunction_handler(wavefunction, List(operations)) + ret = wavefunction_handler(wavefunction, List(operations)) - if "data" in ret: - data = ret["data"].get_list() + if 'data' in ret: + data = ret['data'].get_list() for line in data: echo.echo_dictionary(line) - if "wavefunction" in ret: - echo.echo_success(f"Wavefunction edited and stored (pk={wavefunction.pk})") + if 'wavefunction' in ret: + echo.echo_success( + f'Wavefunction edited and stored (pk={wavefunction.pk})') else: - echo.echo("Wavefunction unmofified") - - + echo.echo('Wavefunction unmofified') diff --git a/aiida_qp2/cli/_workflow.py b/aiida_qp2/cli/_workflow.py index 538a776..c176bca 100644 --- a/aiida_qp2/cli/_workflow.py +++ b/aiida_qp2/cli/_workflow.py @@ -7,17 +7,21 @@ from . import cli_root -@cli_root.group("workflow") + +@cli_root.group('workflow') def workflow(): """Workflow commands""" pass -@workflow.command("jastopt") + +@workflow.command('jastopt') @wf_option @code_option -@click.option("--optimize", "-1", nargs="+", type=click.STRING, help="Jastrow parameters to optimize") +@click.option('--optimize', + '-1', + nargs='+', + type=click.STRING, + help='Jastrow parameters to optimize') @decorators.with_dbenv() def jastopt_operation(wf, code, optimize): """Jastopt operation""" - - diff --git a/aiida_qp2/cli/cli_helpers.py b/aiida_qp2/cli/cli_helpers.py index a438770..d317169 100644 --- a/aiida_qp2/cli/cli_helpers.py +++ b/aiida_qp2/cli/cli_helpers.py @@ -6,7 +6,8 @@ import click from functools import wraps -_QP_GROUP = "qp2_project_group" +_QP_GROUP = 'qp2_project_group' + def wf_option(func): """ @@ -14,84 +15,92 @@ def wf_option(func): if `--pk` is not provided, the function will try to find the active project and use the latest wavefunction """ - - @click.option("--wavefunction", "-w", type=click.STRING, default=None, help="Wavefunction to use") + @click.option('--wavefunction', + '-w', + type=click.STRING, + default=None, + help='Wavefunction to use') @wraps(func) def f(*_args, **kwargs): - if kwargs["wavefunction"] is not None: + if kwargs['wavefunction'] is not None: from aiida.orm import load_node - kwargs["wavefunction"] = load_node(kwargs["wavefunction"]) + kwargs['wavefunction'] = load_node(kwargs['wavefunction']) else: - from aiida.orm import ( QueryBuilder, - Group, - load_group, - SinglefileData as Wavefunction ) + from aiida.orm import (QueryBuilder, Group, load_group, + SinglefileData as Wavefunction) try: group = load_group(_QP_GROUP) except: - kwargs["wavefunction"] = None + kwargs['wavefunction'] = None return func(*_args, **kwargs) qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}, tag="group") - qb.append(Wavefunction, filters={ 'id': group.base.extras.all['active_project']}, - with_group="group", - tag="wavefunction") + qb.append(Group, filters={'label': _QP_GROUP}, tag='group') + qb.append(Wavefunction, + filters={'id': group.base.extras.all['active_project']}, + with_group='group', + tag='wavefunction') if qb.count() == 0: - kwargs["wavefunction"] = None + kwargs['wavefunction'] = None return func(*_args, **kwargs) wavefunction, = qb.first() qb = QueryBuilder() - qb.append(Wavefunction, filters={ 'id': wavefunction.pk}, tag="mother") - qb.append(Wavefunction, with_ancestors="mother", tag="child") - qb.order_by({"child": {'ctime': 'desc'}}) + qb.append(Wavefunction, + filters={'id': wavefunction.pk}, + tag='mother') + qb.append(Wavefunction, with_ancestors='mother', tag='child') + qb.order_by({'child': {'ctime': 'desc'}}) if qb.count() > 0: - kwargs["wavefunction"] = qb.first()[0] + kwargs['wavefunction'] = qb.first()[0] else: - kwargs["wavefunction"] = wavefunction + kwargs['wavefunction'] = wavefunction return func(*_args, **kwargs) + return f + def code_option(func): """ Decorator add click option `--code` to the function if `--code` is not provided, the function will try to find the active code """ - - @click.option("--code", "-c", type=click.STRING, default=None, help="Code to use") + @click.option('--code', + '-c', + type=click.STRING, + default=None, + help='Code to use') @wraps(func) def f(*_args, **kwargs): - if kwargs["code"] is not None: + if kwargs['code'] is not None: from aiida.orm import load_node - kwargs["code"] = load_node(kwargs["code"]) + kwargs['code'] = load_node(kwargs['code']) else: - from aiida.orm import ( QueryBuilder, - Code, - Group, - SinglefileData as Wavefunction, - load_group, - load_node) + from aiida.orm import (QueryBuilder, Code, Group, SinglefileData as + Wavefunction, load_group, load_node) try: group = load_group(_QP_GROUP) except: - kwargs["code"] = None + kwargs['code'] = None return func(*_args, **kwargs) qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}, tag="group") - qb.append(Wavefunction, filters={ 'id': group.base.extras.all['active_project']}, - with_group="group", - tag="wavefunction") + qb.append(Group, filters={'label': _QP_GROUP}, tag='group') + qb.append(Wavefunction, + filters={'id': group.base.extras.all['active_project']}, + with_group='group', + tag='wavefunction') if qb.count() == 0: - kwargs["code"] = None + kwargs['code'] = None return func(*_args, **kwargs) - kwargs["code"] = load_node(qb.first()[0].base.extras.all['default_code']) + kwargs['code'] = load_node( + qb.first()[0].base.extras.all['default_code']) return func(*_args, **kwargs) + return f diff --git a/aiida_qp2/cli/show.py b/aiida_qp2/cli/show.py index 3ac3389..1d956eb 100644 --- a/aiida_qp2/cli/show.py +++ b/aiida_qp2/cli/show.py @@ -1,10 +1,11 @@ +# -*- coding: utf-8 -*- from . import _QP_GROUP + class CalcHolder(): """ Helper class to hold information about a calculation """ - def __init__(self, child, job, name, par): self.child = child self.job = job @@ -15,7 +16,7 @@ def __init__(self, child, job, name, par): @property def energy(self): try: - return self.job.outputs["output_energy"].value + return self.job.outputs['output_energy'].value except: return None @@ -23,13 +24,13 @@ def energy(self): def label(self): wf_pk = self.child name = self.name - if name == "wavefunction_handler": - name = "edit" - msg = f"{name}: {wf_pk}" + if name == 'wavefunction_handler': + name = 'edit' + msg = f'{name}: {wf_pk}' if self.energy is not None: - msg += f" | {self.energy:.6f}" + msg += f' | {self.energy:.6f}' if self.active: - msg = "\033[1m" + msg + "\033[0m" + msg = '\033[1m' + msg + '\033[0m' return msg @property @@ -40,13 +41,14 @@ def ctime(self): def graph_label(self): wf_pk = self.child name = self.name - if name == "wavefunction_handler": - name = "edit" - msg = f"{wf_pk}\n{name}" + if name == 'wavefunction_handler': + name = 'edit' + msg = f'{wf_pk}\n{name}' if self.energy is not None: - msg += f"\n{self.energy:.6f}" + msg += f'\n{self.energy:.6f}' return msg + def show_all(style): import sys @@ -58,41 +60,57 @@ def show_all(style): group = load_group(_QP_GROUP) except Exception as e: echo.echo(e) - echo.echo_critical("Group qp2 does not exist") + echo.echo_critical('Group qp2 does not exist') return if group.base.extras.all['active_project'] is None: - echo.echo_error("No active project") + echo.echo_error('No active project') return qb = QueryBuilder() - qb.append(Group, filters={"label": _QP_GROUP}, tag="group") - qb.append(Wavefunction, filters={ 'id': group.base.extras.all['active_project']}, - with_group="group", - tag="wavefunction") + qb.append(Group, filters={'label': _QP_GROUP}, tag='group') + qb.append(Wavefunction, + filters={'id': group.base.extras.all['active_project']}, + with_group='group', + tag='wavefunction') if qb.count() == 1: wavefunction, = qb.first() echo.echo(f"Active project: {wavefunction.base.extras.all['name']}") else: - echo.echo_error(f"No active project") + echo.echo_error(f'No active project') qb = QueryBuilder() - qb.append(Wavefunction, filters={ 'id': group.base.extras.all['active_project']}, tag="mother") - qb.append(Wavefunction, with_ancestors="mother", tag="child", project=["id"]) - qb.append(CalcJobNode, with_outgoing="child", tag="calc", project=["*"]) - qb.append(Dict, with_outgoing="calc", tag="dict", project=["attributes.run_type"]) - qb.append(Wavefunction, with_outgoing="calc", tag="par", project=["id"]) + qb.append(Wavefunction, + filters={'id': group.base.extras.all['active_project']}, + tag='mother') + qb.append(Wavefunction, + with_ancestors='mother', + tag='child', + project=['id']) + qb.append(CalcJobNode, with_outgoing='child', tag='calc', project=['*']) + qb.append(Dict, + with_outgoing='calc', + tag='dict', + project=['attributes.run_type']) + qb.append(Wavefunction, with_outgoing='calc', tag='par', project=['id']) # Special case for calcfunctions qbf = QueryBuilder() - qbf.append(Wavefunction, filters={ 'id': group.base.extras.all['active_project']}, tag="mother") - qbf.append(Wavefunction, with_ancestors="mother", tag="child", project=["id"]) - qbf.append(CalcFunctionNode, with_outgoing="child", tag="calc", project=["*", "label"]) - qbf.append(Wavefunction, with_outgoing="calc", tag="par", project=["id"]) - - echo.echo(f"Number of wavefunctions: {qb.count() + qbf.count()}") - echo.echo("") - + qbf.append(Wavefunction, + filters={'id': group.base.extras.all['active_project']}, + tag='mother') + qbf.append(Wavefunction, + with_ancestors='mother', + tag='child', + project=['id']) + qbf.append(CalcFunctionNode, + with_outgoing='child', + tag='calc', + project=['*', 'label']) + qbf.append(Wavefunction, with_outgoing='calc', tag='par', project=['id']) + + echo.echo(f'Number of wavefunctions: {qb.count() + qbf.count()}') + echo.echo('') # get data nodes = [] @@ -105,22 +123,22 @@ def show_all(style): newest = sorted(nodes, key=lambda x: x.job.ctime)[-1] newest.active = True - if style == "plain": + if style == 'plain': show_plain(wavefunction, nodes) return - if style == "tree": + if style == 'tree': show_tree(wavefunction, nodes) return - if style == "graph": + if style == 'graph': show_graph(wavefunction, nodes) return def show_plain(wavefunction, nodes): from aiida.cmdline.utils import echo - echo.echo(f"Parent: {wavefunction.pk}") + echo.echo(f'Parent: {wavefunction.pk}') for ch in sorted(nodes, key=lambda x: x.job.ctime): echo.echo(ch.label) @@ -133,12 +151,14 @@ def show_tree(wavefunction, nodes): try: from treelib import Tree except ImportError: - echo.echo("Please install treelib to show the tree") - echo.echo("") + echo.echo('Please install treelib to show the tree') + echo.echo('') return tree = Tree() - tree.create_node(wavefunction.pk, wavefunction.pk, data=CalcHolder(wavefunction.pk, None, "root", None)) + tree.create_node(wavefunction.pk, + wavefunction.pk, + data=CalcHolder(wavefunction.pk, None, 'root', None)) for ch in sorted(nodes, key=lambda x: x.job.ctime): try: @@ -147,45 +167,57 @@ def show_tree(wavefunction, nodes): pass if tree.depth() > 20: - echo.echo_warning("Tree is very deep") + echo.echo_warning('Tree is very deep') - ptree = tree.show(stdout=False, data_property="label") + ptree = tree.show(stdout=False, data_property='label') # First fill white space in ptree def _length(s): - s = s.replace("\033[1m", "") - s = s.replace("\033[0m", "") + s = s.replace('\033[1m', '') + s = s.replace('\033[0m', '') return len(s) - longest_line = max(_length(x) for x in ptree.split("\n")) + longest_line = max(_length(x) for x in ptree.split('\n')) # Add white space to the end of each line - ptree = "\n".join(x + " " * (longest_line - _length(x)) + "|" for x in ptree.split("\n")) + ptree = '\n'.join(x + ' ' * (longest_line - _length(x)) + '|' + for x in ptree.split('\n')) - dtree = tree.show(stdout=False, data_property="energy", line_type="ascii-ex") - dtree = dtree.replace("\u2502", "") - dtree = dtree.replace("\u251c\u2500\u2500 ", "") - dtree = dtree.replace("\u2514\u2500\u2500 ", "") + dtree = tree.show(stdout=False, + data_property='energy', + line_type='ascii-ex') + dtree = dtree.replace('\u2502', '') + dtree = dtree.replace('\u251c\u2500\u2500 ', '') + dtree = dtree.replace('\u2514\u2500\u2500 ', '') - dtree = dtree.split("\n") + dtree = dtree.split('\n') dtree = [x.strip() for x in dtree] # This is messy (and should be done in a better way) try: from termgraph.module import Data, BarChart, Args, Colors - data_without_none = [float(x) for x in dtree if x.strip() not in ("None", "")] + data_without_none = [ + float(x) for x in dtree if x.strip() not in ('None', '') + ] if len(data_without_none) == 0: raise NotImplementedError max_data = max(data_without_none) - data = [float(x) if x.strip() not in ("None", "") else max_data for x in dtree] - labels = ["GOOD" if x.strip() not in ("None", "") else "BAAD" for x in dtree] + data = [ + float(x) if x.strip() not in ('None', '') else max_data + for x in dtree + ] + labels = [ + 'GOOD' if x.strip() not in ('None', '') else 'BAAD' for x in dtree + ] ldata = len(data) data = [abs(x) for x in data] data = [[x] for x in data] data = Data(data, labels) - colors = [ Colors.Red if ii % 2 == 0 else Colors.Red for ii in range(ldata)] + colors = [ + Colors.Red if ii % 2 == 0 else Colors.Red for ii in range(ldata) + ] chart = BarChart(data, Args(colors=colors)) @@ -199,25 +231,26 @@ def _length(s): sys.stdout = original_stdout bg = capture_output.getvalue().strip() - stree = [" " * (len(ptree.split("\n")[0]) - 1) + f"| "] + stree = [' ' * (len(ptree.split('\n')[0]) - 1) + f'| '] - bg = bg.split("\n") - bg = [ l.replace("GOOD:", "") if "GOOD" in l else "" for l in bg] + bg = bg.split('\n') + bg = [l.replace('GOOD:', '') if 'GOOD' in l else '' for l in bg] - for line, dline in zip(ptree.split("\n"), bg): - stree.append(line + " " + dline) + for line, dline in zip(ptree.split('\n'), bg): + stree.append(line + ' ' + dline) - ptree = "\n".join(stree) + ptree = '\n'.join(stree) except ImportError: - echo.echo("Please install termgraph to show the plots") - echo.echo("") + echo.echo('Please install termgraph to show the plots') + echo.echo('') except NotImplementedError: pass echo.echo(ptree) + def show_graph(wavefunction, nodes): from aiida.cmdline.utils import echo @@ -226,20 +259,23 @@ def show_graph(wavefunction, nodes): try: import asciinet as an except ImportError: - missing_modules.append("asciinet") + missing_modules.append('asciinet') try: import networkx as nx except ImportError: - missing_modules.append("networkx") + missing_modules.append('networkx') if len(missing_modules) > 0: - echo.echo(f"Please install the following modules to show the graph: {', '.join(missing_modules)}") - echo.echo("") + echo.echo( + f"Please install the following modules to show the graph: {', '.join(missing_modules)}" + ) + echo.echo('') return dict_of_nodes = {x.child: x for x in nodes} - dict_of_nodes[wavefunction.pk] = CalcHolder(wavefunction.pk, None, "root", None) + dict_of_nodes[wavefunction.pk] = CalcHolder(wavefunction.pk, None, 'root', + None) G = nx.DiGraph() @@ -249,5 +285,3 @@ def show_graph(wavefunction, nodes): G.add_edge(dict_of_nodes[ch.par].graph_label, ch.graph_label) echo.echo(an.graph_to_ascii(G)) - - diff --git a/aiida_qp2/create/calculation.py b/aiida_qp2/create/calculation.py index daef713..7d0acdc 100644 --- a/aiida_qp2/create/calculation.py +++ b/aiida_qp2/create/calculation.py @@ -47,13 +47,13 @@ def define(cls, spec): spec.input('basis_set', valid_type=Str, required=False, - default=lambda: Str("cc-pvdz"), + default=lambda: Str('cc-pvdz'), help='The basis set to use for this calculation.') spec.input('pseudo_potential', valid_type=Str, required=False, - default=lambda: Str(""), + default=lambda: Str(''), help='The pseudo potential to use for this calculation.') @@ -100,8 +100,8 @@ def prepare_for_submission(self, folder): # TODO: Check if basis set is valid with folder.open(self._INPUT_FILE, 'w') as handle: - handle.write(f"qp create_ezfio -b {basis_set} {self._INPUT_COORDS_FILE}\n") - handle.write(f"tar czf {self.metadata.options.output_wf_basename}.tar.gz *.ezfio\n") + handle.write(f'qp create_ezfio -b {basis_set} {self._INPUT_COORDS_FILE}\n') + handle.write(f'tar czf {self.metadata.options.output_wf_basename}.tar.gz *.ezfio\n') with folder.open(self._INPUT_COORDS_FILE, 'w') as handle: structure = self.inputs.structure.get_ase() @@ -124,7 +124,6 @@ def prepare_for_submission(self, folder): calcinfo.local_copy_list = [] calcinfo.retrieve_list = [self._INPUT_COORDS_FILE, self.metadata.options.output_filename, - f"{self.metadata.options.output_wf_basename}.tar.gz"] + f'{self.metadata.options.output_wf_basename}.tar.gz'] return calcinfo - diff --git a/aiida_qp2/create/parser.py b/aiida_qp2/create/parser.py index f241eb6..ac3ac06 100644 --- a/aiida_qp2/create/parser.py +++ b/aiida_qp2/create/parser.py @@ -64,12 +64,12 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals wf_file = SinglefileData(file=handle) # Read the structure from the input file - with out_folder.open("aiida.xyz", 'r') as handle: + with out_folder.open('aiida.xyz', 'r') as handle: atoms = read(handle, format='xyz') # Set the wavefunction as an attribute of the output node - wf_file.base.attributes.set("wavefunction", True) - wf_file.base.attributes.set("formula", atoms.get_chemical_formula()) + wf_file.base.attributes.set('wavefunction', True) + wf_file.base.attributes.set('formula', atoms.get_chemical_formula()) self.out('wavefunction', wf_file) diff --git a/aiida_qp2/run/calculation.py b/aiida_qp2/run/calculation.py index 189844f..6e470bc 100644 --- a/aiida_qp2/run/calculation.py +++ b/aiida_qp2/run/calculation.py @@ -120,7 +120,7 @@ def prepare_for_submission(self, folder): with folder.open(self._INPUT_FILE, 'w') as handle: self._write_input_file(handle) - with folder.open("aiida.wf.tar.gz", 'wb') as handle, self.inputs.wavefunction.open(mode='rb') as handle_wf: + with folder.open('aiida.wf.tar.gz', 'wb') as handle, self.inputs.wavefunction.open(mode='rb') as handle_wf: handle.write(handle_wf.read()) # Prepare a `CodeInfo` to be returned to the engine @@ -138,7 +138,7 @@ def prepare_for_submission(self, folder): calcinfo.local_copy_list = [] calcinfo.retrieve_list = [self.metadata.options.output_filename, - f"{self.metadata.options.output_wf_basename}.tar.gz"] + f'{self.metadata.options.output_wf_basename}.tar.gz'] return calcinfo @@ -150,36 +150,36 @@ def _write_input_file(self, handle): tbf = self.inputs.parameters.get_dict().get('trexio_bug_fix', False) append = self.inputs.parameters.get_dict().get('qp_append', '') - if run_type == "none": - raise ValueError("run_type not specified in parameters") + if run_type == 'none': + raise ValueError('run_type not specified in parameters') - code_command = "qp" - config_command = "set" - run_command = f"qp run {run_type} {append}" - ezfio = "" + code_command = 'qp' + config_command = 'set' + run_command = f'qp run {run_type} {append}' + ezfio = '' - if run_type == "qmcchem": - code_command = "qmcchem" - config_command = "edit" - run_command = "qmcchem run aiida.ezfio" - ezfio = "aiida.ezfio" + if run_type == 'qmcchem': + code_command = 'qmcchem' + config_command = 'edit' + run_command = 'qmcchem run aiida.ezfio' + ezfio = 'aiida.ezfio' - handle.write("#!/bin/bash\n") - handle.write("set -e\n") - handle.write("set -x\n") - handle.write("tar xzf aiida.wf.tar.gz\n") - handle.write(f"qp set_file aiida.ezfio\n") + handle.write('#!/bin/bash\n') + handle.write('set -e\n') + handle.write('set -x\n') + handle.write('tar xzf aiida.wf.tar.gz\n') + handle.write(f'qp set_file aiida.ezfio\n') # Iter over prepend parameters if self.inputs.parameters.get_dict().get('qp_prepend', None): for value in self.inputs.parameters.get_dict().get('qp_prepend'): - handle.write(f"{code_command} {config_command} {value} {ezfio}\n") + handle.write(f'{code_command} {config_command} {value} {ezfio}\n') - handle.write(run_command + "\n") + handle.write(run_command + '\n') if tbf: handle.write(f'sed -i "1s|^|$(pwd)/|" aiida.ezfio/trexio/trexio_file\n') handle.write(f'echo "#*#* ERROR CODE: $? #*#*"\n') - handle.write(f"tar czf {self.metadata.options.output_wf_basename}.tar.gz *.ezfio\n") + handle.write(f'tar czf {self.metadata.options.output_wf_basename}.tar.gz *.ezfio\n') #EOF diff --git a/aiida_qp2/run/parser.py b/aiida_qp2/run/parser.py index 0eafe0a..aa31e2b 100644 --- a/aiida_qp2/run/parser.py +++ b/aiida_qp2/run/parser.py @@ -16,10 +16,12 @@ QP2RunCalculation = CalculationFactory('qp2.run') -_DICTIONARIES = { "scf": "hartree_fock", - "ccsd": "ccsd", - "fci": "fci", - } +_DICTIONARIES = { + 'scf': 'hartree_fock', + 'ccsd': 'ccsd', + 'fci': 'fci', +} + class QP2RunParser(Parser): """ @@ -45,13 +47,12 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals :returns: an exit code, if parsing fails (or nothing if parsing succeeds) """ - output_filename = self.node.get_option( - 'output_filename') + output_filename = self.node.get_option('output_filename') run_type = self.node.inputs.parameters.get_dict().get('run_type') with self.retrieved.open(output_filename, 'r') as handle: - regex = re.compile(r"ERROR CODE: (\d+)") + regex = re.compile(r'ERROR CODE: (\d+)') for line in handle: match = regex.match(line) if match: @@ -61,12 +62,9 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals if run_type == 'qmcchem': return self.parse_qmcchem() - output_wf_basename = self.node.get_option( - 'output_wf_basename') + output_wf_basename = self.node.get_option('output_wf_basename') output_wf_filename = output_wf_basename + '.tar.gz' - store_wavefunction = self.node.get_option( - 'store_wavefunction') - + store_wavefunction = self.node.get_option('store_wavefunction') try: out_folder = self.retrieved @@ -84,12 +82,14 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals import tarfile method = _DICTIONARIES.get(run_type, None) if method: - path_energy = f"aiida.ezfio/{method}/energy" + path_energy = f'aiida.ezfio/{method}/energy' with out_folder.open(output_wf_filename, 'rb') as wf_out: - with tarfile.open(fileobj=wf_out, mode= "r") as tar: + with tarfile.open(fileobj=wf_out, mode='r') as tar: f_out = tar.extractfile(path_energy) if f_out is None: - raise exceptions.ParsingError(f"File {path_energy} not found in wavefunction file") + raise exceptions.ParsingError( + f'File {path_energy} not found in wavefunction file' + ) from aiida.orm import Float self.out('output_energy', Float(float(f_out.read()))) else: @@ -100,18 +100,15 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals with out_folder.open(output_wf_filename, 'rb') as handle: wf_file = SinglefileData(file=handle) - wf_file.base.attributes.set("wavefunction", True) + wf_file.base.attributes.set('wavefunction', True) self.out('output_wavefunction', wf_file) def parse_qmcchem(self, **kwargs): - output_filename = self.node.get_option( - 'output_filename') - output_wf_basename = self.node.get_option( - 'output_wf_basename') + output_filename = self.node.get_option('output_filename') + output_wf_basename = self.node.get_option('output_wf_basename') output_wf_filename = output_wf_basename + '.tar.gz' - store_wavefunction = self.node.get_option( - 'store_wavefunction') + store_wavefunction = self.node.get_option('store_wavefunction') try: out_folder = self.retrieved @@ -133,11 +130,12 @@ def parse_qmcchem(self, **kwargs): number_of_blocks = None with out_folder.open(output_filename, 'r') as handle: for line in handle: - if " E_loc :" in line: + if ' E_loc :' in line: energy = float(line.split()[2]) energy_err = float(line.split()[4]) - number_of_blocks = int(line.split()[5].replace("(","").replace(")","")) - if " E_loc_qmcvar :" in line: + number_of_blocks = int(line.split()[5].replace( + '(', '').replace(')', '')) + if ' E_loc_qmcvar :' in line: energy_qmcvar = float(line.split()[2]) energy_qmcvar_err = float(line.split()[4]) if energy: @@ -156,7 +154,7 @@ def parse_qmcchem(self, **kwargs): with out_folder.open(output_wf_filename, 'rb') as handle: wf_file = SinglefileData(file=handle) - wf_file.base.attributes.set("wavefunction", True) + wf_file.base.attributes.set('wavefunction', True) self.out('output_wavefunction', wf_file) def _json_reader(self, out_folder): diff --git a/aiida_qp2/run/qmcchem_calculation.py b/aiida_qp2/run/qmcchem_calculation.py index 5f4822b..ed7dd72 100644 --- a/aiida_qp2/run/qmcchem_calculation.py +++ b/aiida_qp2/run/qmcchem_calculation.py @@ -16,10 +16,10 @@ QP2RunCalculation = CalculationFactory('qp2.run') + class QP2QmcchemRunCalculation(QP2RunCalculation): """ AiiDA calculation plugin wrapping the Quantum Package code. """ - @classmethod def define(cls, spec): """ Define inputs and outputs of the calculation.""" @@ -27,4 +27,3 @@ def define(cls, spec): super().define(spec) spec.inputs['metadata']['options']['parser_name'].default = 'qp2.qmcchemrun' - diff --git a/aiida_qp2/run/qmcchem_parser.py b/aiida_qp2/run/qmcchem_parser.py index 9f5019f..6fb3ccc 100644 --- a/aiida_qp2/run/qmcchem_parser.py +++ b/aiida_qp2/run/qmcchem_parser.py @@ -15,9 +15,11 @@ QP2RunCalculation = CalculationFactory('qp2.run') -_DICTIONARES = { "scf": "hartree_fock", - "ccsd": "ccsd", - } +_DICTIONARES = { + 'scf': 'hartree_fock', + 'ccsd': 'ccsd', +} + class QP2QmcchemRunParser(Parser): """ @@ -42,13 +44,10 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals :returns: an exit code, if parsing fails (or nothing if parsing succeeds) """ - output_filename = self.node.get_option( - 'output_filename') - output_wf_basename = self.node.get_option( - 'output_wf_basename') + output_filename = self.node.get_option('output_filename') + output_wf_basename = self.node.get_option('output_wf_basename') output_wf_filename = output_wf_basename + '.tar.gz' - store_wavefunction = self.node.get_option( - 'store_wavefunction') + store_wavefunction = self.node.get_option('store_wavefunction') run_type = self.node.inputs.parameters.get_dict().get('run_type') @@ -68,12 +67,14 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals import tarfile method = _DICTIONARES.get(run_type, None) if method: - path_energy = f"aiida.ezfio/{method}/energy" + path_energy = f'aiida.ezfio/{method}/energy' with out_folder.open(output_wf_filename, 'rb') as wf_out: - with tarfile.open(fileobj=wf_out, mode= "r") as tar: + with tarfile.open(fileobj=wf_out, mode='r') as tar: f_out = tar.extractfile(path_energy) if f_out is None: - raise exceptions.ParsingError(f"File {path_energy} not found in wavefunction file") + raise exceptions.ParsingError( + f'File {path_energy} not found in wavefunction file' + ) from aiida.orm import Float self.out('utput_energy', Float(-1.0 * float(f_out.read()))) else: @@ -84,7 +85,7 @@ def parse(self, **kwargs): # pylint: disable=too-many-locals with out_folder.open(output_wf_filename, 'rb') as handle: wf_file = SinglefileData(file=handle) - wf_file.base.attributes.set("wavefunction", True) + wf_file.base.attributes.set('wavefunction', True) self.out('output_wavefunction', wf_file) def _json_reader(self, out_folder): diff --git a/aiida_qp2/utils/ezfio.py b/aiida_qp2/utils/ezfio.py index b608410..fe67ec1 100644 --- a/aiida_qp2/utils/ezfio.py +++ b/aiida_qp2/utils/ezfio.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- # EZFIO is an automatic generator of I/O libraries # Copyright (C) 2009 Anthony SCEMAMA, CNRS # @@ -19,8 +20,8 @@ # Anthony Scemama # LCPQ - IRSAMC - CNRS # Universite Paul Sabatier -# 118, route de Narbonne -# 31062 Toulouse Cedex 4 +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 # scemama@irsamc.ups-tlse.fr import os, sys @@ -31,2502 +32,2631 @@ import threading from functools import reduce -def version(x): - b = [int(i) for i in x.split('.')] - return b[2] + b[1]*100 + b[0]*10000 - -def size(x): - return len(x) - -def flatten(l): - res = [] - for i in l: - if hasattr(i, "__iter__") and not isinstance(i, str): - res.extend(flatten(i)) - else: - res.append(i) - return res - -def maxval(l): - return reduce(max, l, l[0]) - -def minval(l): - return reduce(min, l, l[0]) - - -def reshape(l,shape): - l = flatten(l) - for d in shape[:-1]: - buffer = [] - buffer2 = [] - i=0 - while i %s/ezfio/creation -echo $USER > %s/ezfio/user -echo %s > %s/ezfio/library"""%(filename,filename,self.LIBRARY,filename)) - - def open_write_buffer(self,dir,fil,rank): - if self.read_only: - self.error('Read-only file.') - l_filename=dir.strip()+'/'+fil+'.gz' - if self.buffer_rank != -1: - self.error('open_write_buffer','Another buffered file is already open.') - - self.buffer_rank = rank - assert (self.buffer_rank > 0) - - try: - self.file = GzipFile(filename=l_filename,mode='wb7') - except IOError: - self.error('open_write_buffer','Unable to open buffered file.') - - self.file.write("%2d\n"%(rank,)) - - - def open_read_buffer(self,dir,fil,rank): - l_filename=dir.strip()+'/'+fil+'.gz' - - if self.buffer_rank != -1: - self.error('open_read_buffer','Another buffered file is already open.') - - try: - self.file = GzipFile(filename=l_filename,mode='rb') - except IOError: - self.error('open_read_buffer','Unable to open buffered file.') - - try: - rank = eval(self.file.readline()) - except IOError: - self.error('open_read_buffer','Unable to read buffered file.') - - self.buffer_rank = rank - assert (self.buffer_rank > 0) - return rank - - def close_buffer(self): - assert (self.buffer_rank > 0) - self.buffer_rank = -1 - self.file.close() - - def read_buffer(self,isize): - - if self.buffer_rank == -1: - self.error('read_buffer','No buffered file is open.') - - indices = [] - values = [] - for i in range(isize): - try: - line = self.file.readline().split() - except: - return indices, values - if len(line) == 0: - return indices, values - indices.append ( [ int(i) for i in line[:-1] ] ) - values.append (eval(line[-1])) - return indices, values - - def write_buffer(self,indices,values,isize): - if self.read_only: - self.error('Read-only file.') - if self.buffer_rank == -1: - self.error('write_buffer','No buffered file is open.') - - for i in range(isize): - for j in indices[i]: - self.file.write("%4d "%(j,)) - self.file.write("%24.15e\n"%(values[i],)) - - - def get_version(self): - return '2.0.7' - version = property(fset=None,fget=get_version) - - - def get_path_ezfio(self): - result = self.filename.strip()+'/ezfio' - self.acquire_lock('ezfio') - try: - if not self.exists(result): - self.mkdir(result) - finally: - self.release_lock('ezfio') - return result - - path_ezfio = property(fget=get_path_ezfio) - - - def get_ezfio_creation(self): - self.acquire_lock('ezfio_creation') - try: - result = self.read_ch(self.path_ezfio,'creation') - finally: - self.release_lock('ezfio_creation') - return result - - def set_ezfio_creation(self,creation): - self.acquire_lock('ezfio_creation') - try: - self.write_ch(self.path_ezfio,'creation',creation) - finally: - self.release_lock('ezfio_creation') - - ezfio_creation = property(fset=set_ezfio_creation, fget=get_ezfio_creation) - - def has_ezfio_creation(self): - return (os.access(self.path_ezfio+'/creation',os.F_OK) == 1) - - - def get_ezfio_user(self): - self.acquire_lock('ezfio_user') - try: - result = self.read_ch(self.path_ezfio,'user') - finally: - self.release_lock('ezfio_user') - return result - - def set_ezfio_user(self,user): - self.acquire_lock('ezfio_user') - try: - self.write_ch(self.path_ezfio,'user',user) - finally: - self.release_lock('ezfio_user') - - ezfio_user = property(fset=set_ezfio_user, fget=get_ezfio_user) - - def has_ezfio_user(self): - return (os.access(self.path_ezfio+'/user',os.F_OK) == 1) - - - def get_ezfio_library(self): - self.acquire_lock('ezfio_library') - try: - result = self.read_ch(self.path_ezfio,'library') - finally: - self.release_lock('ezfio_library') - return result - - def set_ezfio_library(self,library): - self.acquire_lock('ezfio_library') - try: - self.write_ch(self.path_ezfio,'library',library) - finally: - self.release_lock('ezfio_library') - - ezfio_library = property(fset=set_ezfio_library, fget=get_ezfio_library) - - def has_ezfio_library(self): - return (os.access(self.path_ezfio+'/library',os.F_OK) == 1) - - - def get_ezfio_last_library(self): - self.acquire_lock('ezfio_last_library') - try: - result = self.read_ch(self.path_ezfio,'last_library') - finally: - self.release_lock('ezfio_last_library') - return result - - def set_ezfio_last_library(self,last_library): - self.acquire_lock('ezfio_last_library') - try: - self.write_ch(self.path_ezfio,'last_library',last_library) - finally: - self.release_lock('ezfio_last_library') - - ezfio_last_library = property(fset=set_ezfio_last_library, fget=get_ezfio_last_library) - - def has_ezfio_last_library(self): - return (os.access(self.path_ezfio+'/last_library',os.F_OK) == 1) - - - def get_path_ao_basis(self): - result = self.filename.strip()+'/ao_basis' - self.acquire_lock('ao_basis') - try: - if not self.exists(result): - self.mkdir(result) - finally: - self.release_lock('ao_basis') - return result - - path_ao_basis = property(fget=get_path_ao_basis) - - - def get_ao_basis_ao_num(self): - self.acquire_lock('ao_basis_ao_num') - try: - result = self.read_in(self.path_ao_basis,'ao_num') - finally: - self.release_lock('ao_basis_ao_num') - return result - - def set_ao_basis_ao_num(self,ao_num): - self.acquire_lock('ao_basis_ao_num') - try: - self.write_in(self.path_ao_basis,'ao_num',ao_num) - finally: - self.release_lock('ao_basis_ao_num') - - ao_basis_ao_num = property(fset=set_ao_basis_ao_num, fget=get_ao_basis_ao_num) - - def has_ao_basis_ao_num(self): - return (os.access(self.path_ao_basis+'/ao_num',os.F_OK) == 1) - - - def get_ao_basis_ao_prim_num(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_prim_num') - try: - result = self.read_array_in(self.path_ao_basis,'ao_prim_num', rank,dims,dim_max) - finally: - self.release_lock('ao_basis_ao_prim_num') - return result - - def set_ao_basis_ao_prim_num(self,ao_prim_num): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_prim_num') - try: - self.write_array_in(self.path_ao_basis,'ao_prim_num', rank,dims,dim_max,ao_prim_num) - finally: - self.release_lock('ao_basis_ao_prim_num') - - ao_basis_ao_prim_num = property(fset=set_ao_basis_ao_prim_num,fget=get_ao_basis_ao_prim_num) - - def has_ao_basis_ao_prim_num(self): - return (os.access(self.path_ao_basis+'/ao_prim_num.gz',os.F_OK) == 1) - - - def get_ao_basis_ao_nucl(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_nucl') - try: - result = self.read_array_in(self.path_ao_basis,'ao_nucl', rank,dims,dim_max) - finally: - self.release_lock('ao_basis_ao_nucl') - return result - - def set_ao_basis_ao_nucl(self,ao_nucl): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_nucl') - try: - self.write_array_in(self.path_ao_basis,'ao_nucl', rank,dims,dim_max,ao_nucl) - finally: - self.release_lock('ao_basis_ao_nucl') - - ao_basis_ao_nucl = property(fset=set_ao_basis_ao_nucl,fget=get_ao_basis_ao_nucl) - - def has_ao_basis_ao_nucl(self): - return (os.access(self.path_ao_basis+'/ao_nucl.gz',os.F_OK) == 1) - - - def get_ao_basis_ao_power(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(3) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_power') - try: - result = self.read_array_in(self.path_ao_basis,'ao_power', rank,dims,dim_max) - finally: - self.release_lock('ao_basis_ao_power') - return result - - def set_ao_basis_ao_power(self,ao_power): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(3) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_power') - try: - self.write_array_in(self.path_ao_basis,'ao_power', rank,dims,dim_max,ao_power) - finally: - self.release_lock('ao_basis_ao_power') - - ao_basis_ao_power = property(fset=set_ao_basis_ao_power,fget=get_ao_basis_ao_power) - - def has_ao_basis_ao_power(self): - return (os.access(self.path_ao_basis+'/ao_power.gz',os.F_OK) == 1) - - - def get_ao_basis_ao_prim_num_max(self): - return maxval(self.ao_basis_ao_prim_num) - - ao_basis_ao_prim_num_max = property(fget=get_ao_basis_ao_prim_num_max) - - - def get_ao_basis_ao_coef(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(self.ao_basis_ao_prim_num_max) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_coef') - try: - result = self.read_array_re(self.path_ao_basis,'ao_coef', rank,dims,dim_max) - finally: - self.release_lock('ao_basis_ao_coef') - return result - - def set_ao_basis_ao_coef(self,ao_coef): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(self.ao_basis_ao_prim_num_max) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_coef') - try: - self.write_array_re(self.path_ao_basis,'ao_coef', rank,dims,dim_max,ao_coef) - finally: - self.release_lock('ao_basis_ao_coef') - - ao_basis_ao_coef = property(fset=set_ao_basis_ao_coef,fget=get_ao_basis_ao_coef) - - def has_ao_basis_ao_coef(self): - return (os.access(self.path_ao_basis+'/ao_coef.gz',os.F_OK) == 1) - - - def get_ao_basis_ao_expo(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(self.ao_basis_ao_prim_num_max) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_expo') - try: - result = self.read_array_re(self.path_ao_basis,'ao_expo', rank,dims,dim_max) - finally: - self.release_lock('ao_basis_ao_expo') - return result - - def set_ao_basis_ao_expo(self,ao_expo): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(self.ao_basis_ao_prim_num_max) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('ao_basis_ao_expo') - try: - self.write_array_re(self.path_ao_basis,'ao_expo', rank,dims,dim_max,ao_expo) - finally: - self.release_lock('ao_basis_ao_expo') - - ao_basis_ao_expo = property(fset=set_ao_basis_ao_expo,fget=get_ao_basis_ao_expo) - - def has_ao_basis_ao_expo(self): - return (os.access(self.path_ao_basis+'/ao_expo.gz',os.F_OK) == 1) - - - def get_path_nuclei(self): - result = self.filename.strip()+'/nuclei' - self.acquire_lock('nuclei') - try: - if not self.exists(result): - self.mkdir(result) - finally: - self.release_lock('nuclei') - return result - - path_nuclei = property(fget=get_path_nuclei) - - - def get_nuclei_nucl_num(self): - self.acquire_lock('nuclei_nucl_num') - try: - result = self.read_in(self.path_nuclei,'nucl_num') - finally: - self.release_lock('nuclei_nucl_num') - return result - - def set_nuclei_nucl_num(self,nucl_num): - self.acquire_lock('nuclei_nucl_num') - try: - self.write_in(self.path_nuclei,'nucl_num',nucl_num) - finally: - self.release_lock('nuclei_nucl_num') - - nuclei_nucl_num = property(fset=set_nuclei_nucl_num, fget=get_nuclei_nucl_num) - - def has_nuclei_nucl_num(self): - return (os.access(self.path_nuclei+'/nucl_num',os.F_OK) == 1) - - - def get_nuclei_nucl_label(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('nuclei_nucl_label') - try: - result = self.read_array_ch(self.path_nuclei,'nucl_label', rank,dims,dim_max) - finally: - self.release_lock('nuclei_nucl_label') - return result - - def set_nuclei_nucl_label(self,nucl_label): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('nuclei_nucl_label') - try: - self.write_array_ch(self.path_nuclei,'nucl_label', rank,dims,dim_max,nucl_label) - finally: - self.release_lock('nuclei_nucl_label') - - nuclei_nucl_label = property(fset=set_nuclei_nucl_label,fget=get_nuclei_nucl_label) - - def has_nuclei_nucl_label(self): - return (os.access(self.path_nuclei+'/nucl_label.gz',os.F_OK) == 1) - - - def get_nuclei_nucl_charge(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('nuclei_nucl_charge') - try: - result = self.read_array_re(self.path_nuclei,'nucl_charge', rank,dims,dim_max) - finally: - self.release_lock('nuclei_nucl_charge') - return result - - def set_nuclei_nucl_charge(self,nucl_charge): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('nuclei_nucl_charge') - try: - self.write_array_re(self.path_nuclei,'nucl_charge', rank,dims,dim_max,nucl_charge) - finally: - self.release_lock('nuclei_nucl_charge') - - nuclei_nucl_charge = property(fset=set_nuclei_nucl_charge,fget=get_nuclei_nucl_charge) - - def has_nuclei_nucl_charge(self): - return (os.access(self.path_nuclei+'/nucl_charge.gz',os.F_OK) == 1) - - - def get_nuclei_nucl_coord(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - dims[1] = int(3) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('nuclei_nucl_coord') - try: - result = self.read_array_re(self.path_nuclei,'nucl_coord', rank,dims,dim_max) - finally: - self.release_lock('nuclei_nucl_coord') - return result - - def set_nuclei_nucl_coord(self,nucl_coord): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - dims[1] = int(3) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('nuclei_nucl_coord') - try: - self.write_array_re(self.path_nuclei,'nucl_coord', rank,dims,dim_max,nucl_coord) - finally: - self.release_lock('nuclei_nucl_coord') - - nuclei_nucl_coord = property(fset=set_nuclei_nucl_coord,fget=get_nuclei_nucl_coord) - - def has_nuclei_nucl_coord(self): - return (os.access(self.path_nuclei+'/nucl_coord.gz',os.F_OK) == 1) - - - def get_path_jastrow(self): - result = self.filename.strip()+'/jastrow' - self.acquire_lock('jastrow') - try: - if not self.exists(result): - self.mkdir(result) - finally: - self.release_lock('jastrow') - return result - - path_jastrow = property(fget=get_path_jastrow) - - - def get_jastrow_j2e_type(self): - self.acquire_lock('jastrow_j2e_type') - try: - result = self.read_ch(self.path_jastrow,'j2e_type') - finally: - self.release_lock('jastrow_j2e_type') - return result - - def set_jastrow_j2e_type(self,j2e_type): - self.acquire_lock('jastrow_j2e_type') - try: - self.write_ch(self.path_jastrow,'j2e_type',j2e_type) - finally: - self.release_lock('jastrow_j2e_type') - - jastrow_j2e_type = property(fset=set_jastrow_j2e_type, fget=get_jastrow_j2e_type) - - def has_jastrow_j2e_type(self): - return (os.access(self.path_jastrow+'/j2e_type',os.F_OK) == 1) - - - def get_jastrow_j1e_type(self): - self.acquire_lock('jastrow_j1e_type') - try: - result = self.read_ch(self.path_jastrow,'j1e_type') - finally: - self.release_lock('jastrow_j1e_type') - return result - - def set_jastrow_j1e_type(self,j1e_type): - self.acquire_lock('jastrow_j1e_type') - try: - self.write_ch(self.path_jastrow,'j1e_type',j1e_type) - finally: - self.release_lock('jastrow_j1e_type') - - jastrow_j1e_type = property(fset=set_jastrow_j1e_type, fget=get_jastrow_j1e_type) - - def has_jastrow_j1e_type(self): - return (os.access(self.path_jastrow+'/j1e_type',os.F_OK) == 1) - - - def get_jastrow_env_type(self): - self.acquire_lock('jastrow_env_type') - try: - result = self.read_ch(self.path_jastrow,'env_type') - finally: - self.release_lock('jastrow_env_type') - return result - - def set_jastrow_env_type(self,env_type): - self.acquire_lock('jastrow_env_type') - try: - self.write_ch(self.path_jastrow,'env_type',env_type) - finally: - self.release_lock('jastrow_env_type') - - jastrow_env_type = property(fset=set_jastrow_env_type, fget=get_jastrow_env_type) - - def has_jastrow_env_type(self): - return (os.access(self.path_jastrow+'/env_type',os.F_OK) == 1) - - - def get_jastrow_jbh_size(self): - self.acquire_lock('jastrow_jbh_size') - try: - result = self.read_in(self.path_jastrow,'jbh_size') - finally: - self.release_lock('jastrow_jbh_size') - return result - - def set_jastrow_jbh_size(self,jbh_size): - self.acquire_lock('jastrow_jbh_size') - try: - self.write_in(self.path_jastrow,'jbh_size',jbh_size) - finally: - self.release_lock('jastrow_jbh_size') - - jastrow_jbh_size = property(fset=set_jastrow_jbh_size, fget=get_jastrow_jbh_size) - - def has_jastrow_jbh_size(self): - return (os.access(self.path_jastrow+'/jbh_size',os.F_OK) == 1) - - - def get_jastrow_jbh_ee(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_ee') - try: - result = self.read_array_re(self.path_jastrow,'jbh_ee', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jbh_ee') - return result - - def set_jastrow_jbh_ee(self,jbh_ee): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_ee') - try: - self.write_array_re(self.path_jastrow,'jbh_ee', rank,dims,dim_max,jbh_ee) - finally: - self.release_lock('jastrow_jbh_ee') - - jastrow_jbh_ee = property(fset=set_jastrow_jbh_ee,fget=get_jastrow_jbh_ee) - - def has_jastrow_jbh_ee(self): - return (os.access(self.path_jastrow+'/jbh_ee.gz',os.F_OK) == 1) - - - def get_jastrow_jbh_en(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_en') - try: - result = self.read_array_re(self.path_jastrow,'jbh_en', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jbh_en') - return result - - def set_jastrow_jbh_en(self,jbh_en): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_en') - try: - self.write_array_re(self.path_jastrow,'jbh_en', rank,dims,dim_max,jbh_en) - finally: - self.release_lock('jastrow_jbh_en') - - jastrow_jbh_en = property(fset=set_jastrow_jbh_en,fget=get_jastrow_jbh_en) - - def has_jastrow_jbh_en(self): - return (os.access(self.path_jastrow+'/jbh_en.gz',os.F_OK) == 1) - - - def get_jastrow_jbh_c(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_c') - try: - result = self.read_array_re(self.path_jastrow,'jbh_c', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jbh_c') - return result - - def set_jastrow_jbh_c(self,jbh_c): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_c') - try: - self.write_array_re(self.path_jastrow,'jbh_c', rank,dims,dim_max,jbh_c) - finally: - self.release_lock('jastrow_jbh_c') - - jastrow_jbh_c = property(fset=set_jastrow_jbh_c,fget=get_jastrow_jbh_c) - - def has_jastrow_jbh_c(self): - return (os.access(self.path_jastrow+'/jbh_c.gz',os.F_OK) == 1) - - - def get_jastrow_jbh_m(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_m') - try: - result = self.read_array_in(self.path_jastrow,'jbh_m', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jbh_m') - return result - - def set_jastrow_jbh_m(self,jbh_m): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_m') - try: - self.write_array_in(self.path_jastrow,'jbh_m', rank,dims,dim_max,jbh_m) - finally: - self.release_lock('jastrow_jbh_m') - - jastrow_jbh_m = property(fset=set_jastrow_jbh_m,fget=get_jastrow_jbh_m) - - def has_jastrow_jbh_m(self): - return (os.access(self.path_jastrow+'/jbh_m.gz',os.F_OK) == 1) - - - def get_jastrow_jbh_n(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_n') - try: - result = self.read_array_in(self.path_jastrow,'jbh_n', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jbh_n') - return result - - def set_jastrow_jbh_n(self,jbh_n): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_n') - try: - self.write_array_in(self.path_jastrow,'jbh_n', rank,dims,dim_max,jbh_n) - finally: - self.release_lock('jastrow_jbh_n') - - jastrow_jbh_n = property(fset=set_jastrow_jbh_n,fget=get_jastrow_jbh_n) - - def has_jastrow_jbh_n(self): - return (os.access(self.path_jastrow+'/jbh_n.gz',os.F_OK) == 1) - - - def get_jastrow_jbh_o(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_o') - try: - result = self.read_array_in(self.path_jastrow,'jbh_o', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jbh_o') - return result - - def set_jastrow_jbh_o(self,jbh_o): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jbh_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jbh_o') - try: - self.write_array_in(self.path_jastrow,'jbh_o', rank,dims,dim_max,jbh_o) - finally: - self.release_lock('jastrow_jbh_o') - - jastrow_jbh_o = property(fset=set_jastrow_jbh_o,fget=get_jastrow_jbh_o) - - def has_jastrow_jbh_o(self): - return (os.access(self.path_jastrow+'/jbh_o.gz',os.F_OK) == 1) - - - def get_jastrow_a_boys(self): - self.acquire_lock('jastrow_a_boys') - try: - result = self.read_re(self.path_jastrow,'a_boys') - finally: - self.release_lock('jastrow_a_boys') - return result - - def set_jastrow_a_boys(self,a_boys): - self.acquire_lock('jastrow_a_boys') - try: - self.write_re(self.path_jastrow,'a_boys',a_boys) - finally: - self.release_lock('jastrow_a_boys') - - jastrow_a_boys = property(fset=set_jastrow_a_boys, fget=get_jastrow_a_boys) - - def has_jastrow_a_boys(self): - return (os.access(self.path_jastrow+'/a_boys',os.F_OK) == 1) - - - def get_jastrow_nu_erf(self): - self.acquire_lock('jastrow_nu_erf') - try: - result = self.read_re(self.path_jastrow,'nu_erf') - finally: - self.release_lock('jastrow_nu_erf') - return result - - def set_jastrow_nu_erf(self,nu_erf): - self.acquire_lock('jastrow_nu_erf') - try: - self.write_re(self.path_jastrow,'nu_erf',nu_erf) - finally: - self.release_lock('jastrow_nu_erf') - - jastrow_nu_erf = property(fset=set_jastrow_nu_erf, fget=get_jastrow_nu_erf) - - def has_jastrow_nu_erf(self): - return (os.access(self.path_jastrow+'/nu_erf',os.F_OK) == 1) - - - def get_jastrow_env_expo(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_env_expo') - try: - result = self.read_array_re(self.path_jastrow,'env_expo', rank,dims,dim_max) - finally: - self.release_lock('jastrow_env_expo') - return result - - def set_jastrow_env_expo(self,env_expo): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_env_expo') - try: - self.write_array_re(self.path_jastrow,'env_expo', rank,dims,dim_max,env_expo) - finally: - self.release_lock('jastrow_env_expo') - - jastrow_env_expo = property(fset=set_jastrow_env_expo,fget=get_jastrow_env_expo) - - def has_jastrow_env_expo(self): - return (os.access(self.path_jastrow+'/env_expo.gz',os.F_OK) == 1) - - - def get_jastrow_env_coef(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_env_coef') - try: - result = self.read_array_re(self.path_jastrow,'env_coef', rank,dims,dim_max) - finally: - self.release_lock('jastrow_env_coef') - return result - - def set_jastrow_env_coef(self,env_coef): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_env_coef') - try: - self.write_array_re(self.path_jastrow,'env_coef', rank,dims,dim_max,env_coef) - finally: - self.release_lock('jastrow_env_coef') - - jastrow_env_coef = property(fset=set_jastrow_env_coef,fget=get_jastrow_env_coef) - - def has_jastrow_env_coef(self): - return (os.access(self.path_jastrow+'/env_coef.gz',os.F_OK) == 1) - - - def get_jastrow_j1e_size(self): - self.acquire_lock('jastrow_j1e_size') - try: - result = self.read_in(self.path_jastrow,'j1e_size') - finally: - self.release_lock('jastrow_j1e_size') - return result - - def set_jastrow_j1e_size(self,j1e_size): - self.acquire_lock('jastrow_j1e_size') - try: - self.write_in(self.path_jastrow,'j1e_size',j1e_size) - finally: - self.release_lock('jastrow_j1e_size') - - jastrow_j1e_size = property(fset=set_jastrow_j1e_size, fget=get_jastrow_j1e_size) - - def has_jastrow_j1e_size(self): - return (os.access(self.path_jastrow+'/j1e_size',os.F_OK) == 1) - - - def get_jastrow_j1e_expo(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_j1e_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_expo') - try: - result = self.read_array_re(self.path_jastrow,'j1e_expo', rank,dims,dim_max) - finally: - self.release_lock('jastrow_j1e_expo') - return result - - def set_jastrow_j1e_expo(self,j1e_expo): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_j1e_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_expo') - try: - self.write_array_re(self.path_jastrow,'j1e_expo', rank,dims,dim_max,j1e_expo) - finally: - self.release_lock('jastrow_j1e_expo') - - jastrow_j1e_expo = property(fset=set_jastrow_j1e_expo,fget=get_jastrow_j1e_expo) - - def has_jastrow_j1e_expo(self): - return (os.access(self.path_jastrow+'/j1e_expo.gz',os.F_OK) == 1) - - - def get_jastrow_j1e_coef(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_j1e_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_coef') - try: - result = self.read_array_re(self.path_jastrow,'j1e_coef', rank,dims,dim_max) - finally: - self.release_lock('jastrow_j1e_coef') - return result - - def set_jastrow_j1e_coef(self,j1e_coef): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.jastrow_j1e_size) - dims[1] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_coef') - try: - self.write_array_re(self.path_jastrow,'j1e_coef', rank,dims,dim_max,j1e_coef) - finally: - self.release_lock('jastrow_j1e_coef') - - jastrow_j1e_coef = property(fset=set_jastrow_j1e_coef,fget=get_jastrow_j1e_coef) - - def has_jastrow_j1e_coef(self): - return (os.access(self.path_jastrow+'/j1e_coef.gz',os.F_OK) == 1) - - - def get_jastrow_j1e_coef_ao(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_coef_ao') - try: - result = self.read_array_re(self.path_jastrow,'j1e_coef_ao', rank,dims,dim_max) - finally: - self.release_lock('jastrow_j1e_coef_ao') - return result - - def set_jastrow_j1e_coef_ao(self,j1e_coef_ao): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_coef_ao') - try: - self.write_array_re(self.path_jastrow,'j1e_coef_ao', rank,dims,dim_max,j1e_coef_ao) - finally: - self.release_lock('jastrow_j1e_coef_ao') - - jastrow_j1e_coef_ao = property(fset=set_jastrow_j1e_coef_ao,fget=get_jastrow_j1e_coef_ao) - - def has_jastrow_j1e_coef_ao(self): - return (os.access(self.path_jastrow+'/j1e_coef_ao.gz',os.F_OK) == 1) - - - def get_jastrow_j1e_coef_ao2(self): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_coef_ao2') - try: - result = self.read_array_re(self.path_jastrow,'j1e_coef_ao2', rank,dims,dim_max) - finally: - self.release_lock('jastrow_j1e_coef_ao2') - return result - - def set_jastrow_j1e_coef_ao2(self,j1e_coef_ao2): - rank = 2 - dims = list(range(rank)) - dims[0] = int(self.ao_basis_ao_num) - dims[1] = int(self.ao_basis_ao_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_j1e_coef_ao2') - try: - self.write_array_re(self.path_jastrow,'j1e_coef_ao2', rank,dims,dim_max,j1e_coef_ao2) - finally: - self.release_lock('jastrow_j1e_coef_ao2') - - jastrow_j1e_coef_ao2 = property(fset=set_jastrow_j1e_coef_ao2,fget=get_jastrow_j1e_coef_ao2) - - def has_jastrow_j1e_coef_ao2(self): - return (os.access(self.path_jastrow+'/j1e_coef_ao2.gz',os.F_OK) == 1) - - - def get_jastrow_mur_type(self): - self.acquire_lock('jastrow_mur_type') - try: - result = self.read_in(self.path_jastrow,'mur_type') - finally: - self.release_lock('jastrow_mur_type') - return result - - def set_jastrow_mur_type(self,mur_type): - self.acquire_lock('jastrow_mur_type') - try: - self.write_in(self.path_jastrow,'mur_type',mur_type) - finally: - self.release_lock('jastrow_mur_type') - - jastrow_mur_type = property(fset=set_jastrow_mur_type, fget=get_jastrow_mur_type) - - def has_jastrow_mur_type(self): - return (os.access(self.path_jastrow+'/mur_type',os.F_OK) == 1) - - - def get_jastrow_mu_r_ct(self): - self.acquire_lock('jastrow_mu_r_ct') - try: - result = self.read_re(self.path_jastrow,'mu_r_ct') - finally: - self.release_lock('jastrow_mu_r_ct') - return result - - def set_jastrow_mu_r_ct(self,mu_r_ct): - self.acquire_lock('jastrow_mu_r_ct') - try: - self.write_re(self.path_jastrow,'mu_r_ct',mu_r_ct) - finally: - self.release_lock('jastrow_mu_r_ct') - - jastrow_mu_r_ct = property(fset=set_jastrow_mu_r_ct, fget=get_jastrow_mu_r_ct) - - def has_jastrow_mu_r_ct(self): - return (os.access(self.path_jastrow+'/mu_r_ct',os.F_OK) == 1) - - - def get_jastrow_jpsi_type(self): - self.acquire_lock('jastrow_jpsi_type') - try: - result = self.read_ch(self.path_jastrow,'jpsi_type') - finally: - self.release_lock('jastrow_jpsi_type') - return result - - def set_jastrow_jpsi_type(self,jpsi_type): - self.acquire_lock('jastrow_jpsi_type') - try: - self.write_ch(self.path_jastrow,'jpsi_type',jpsi_type) - finally: - self.release_lock('jastrow_jpsi_type') - - jastrow_jpsi_type = property(fset=set_jastrow_jpsi_type, fget=get_jastrow_jpsi_type) - - def has_jastrow_jpsi_type(self): - return (os.access(self.path_jastrow+'/jpsi_type',os.F_OK) == 1) - - - def get_jastrow_inv_sgn_jast(self): - self.acquire_lock('jastrow_inv_sgn_jast') - try: - result = self.read_lo(self.path_jastrow,'inv_sgn_jast') - finally: - self.release_lock('jastrow_inv_sgn_jast') - return result - - def set_jastrow_inv_sgn_jast(self,inv_sgn_jast): - self.acquire_lock('jastrow_inv_sgn_jast') - try: - self.write_lo(self.path_jastrow,'inv_sgn_jast',inv_sgn_jast) - finally: - self.release_lock('jastrow_inv_sgn_jast') - - jastrow_inv_sgn_jast = property(fset=set_jastrow_inv_sgn_jast, fget=get_jastrow_inv_sgn_jast) - - def has_jastrow_inv_sgn_jast(self): - return (os.access(self.path_jastrow+'/inv_sgn_jast',os.F_OK) == 1) - - - def get_jastrow_jast_a_up_up(self): - self.acquire_lock('jastrow_jast_a_up_up') - try: - result = self.read_re(self.path_jastrow,'jast_a_up_up') - finally: - self.release_lock('jastrow_jast_a_up_up') - return result - - def set_jastrow_jast_a_up_up(self,jast_a_up_up): - self.acquire_lock('jastrow_jast_a_up_up') - try: - self.write_re(self.path_jastrow,'jast_a_up_up',jast_a_up_up) - finally: - self.release_lock('jastrow_jast_a_up_up') - - jastrow_jast_a_up_up = property(fset=set_jastrow_jast_a_up_up, fget=get_jastrow_jast_a_up_up) - - def has_jastrow_jast_a_up_up(self): - return (os.access(self.path_jastrow+'/jast_a_up_up',os.F_OK) == 1) - - - def get_jastrow_jast_a_up_dn(self): - self.acquire_lock('jastrow_jast_a_up_dn') - try: - result = self.read_re(self.path_jastrow,'jast_a_up_dn') - finally: - self.release_lock('jastrow_jast_a_up_dn') - return result - - def set_jastrow_jast_a_up_dn(self,jast_a_up_dn): - self.acquire_lock('jastrow_jast_a_up_dn') - try: - self.write_re(self.path_jastrow,'jast_a_up_dn',jast_a_up_dn) - finally: - self.release_lock('jastrow_jast_a_up_dn') - - jastrow_jast_a_up_dn = property(fset=set_jastrow_jast_a_up_dn, fget=get_jastrow_jast_a_up_dn) - - def has_jastrow_jast_a_up_dn(self): - return (os.access(self.path_jastrow+'/jast_a_up_dn',os.F_OK) == 1) - - - def get_jastrow_jast_b_up_up(self): - self.acquire_lock('jastrow_jast_b_up_up') - try: - result = self.read_re(self.path_jastrow,'jast_b_up_up') - finally: - self.release_lock('jastrow_jast_b_up_up') - return result - - def set_jastrow_jast_b_up_up(self,jast_b_up_up): - self.acquire_lock('jastrow_jast_b_up_up') - try: - self.write_re(self.path_jastrow,'jast_b_up_up',jast_b_up_up) - finally: - self.release_lock('jastrow_jast_b_up_up') - - jastrow_jast_b_up_up = property(fset=set_jastrow_jast_b_up_up, fget=get_jastrow_jast_b_up_up) - - def has_jastrow_jast_b_up_up(self): - return (os.access(self.path_jastrow+'/jast_b_up_up',os.F_OK) == 1) - - - def get_jastrow_jast_b_up_dn(self): - self.acquire_lock('jastrow_jast_b_up_dn') - try: - result = self.read_re(self.path_jastrow,'jast_b_up_dn') - finally: - self.release_lock('jastrow_jast_b_up_dn') - return result - - def set_jastrow_jast_b_up_dn(self,jast_b_up_dn): - self.acquire_lock('jastrow_jast_b_up_dn') - try: - self.write_re(self.path_jastrow,'jast_b_up_dn',jast_b_up_dn) - finally: - self.release_lock('jastrow_jast_b_up_dn') - - jastrow_jast_b_up_dn = property(fset=set_jastrow_jast_b_up_dn, fget=get_jastrow_jast_b_up_dn) - - def has_jastrow_jast_b_up_dn(self): - return (os.access(self.path_jastrow+'/jast_b_up_dn',os.F_OK) == 1) - - - def get_jastrow_jast_pen(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_pen') - try: - result = self.read_array_re(self.path_jastrow,'jast_pen', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_pen') - return result - - def set_jastrow_jast_pen(self,jast_pen): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_pen') - try: - self.write_array_re(self.path_jastrow,'jast_pen', rank,dims,dim_max,jast_pen) - finally: - self.release_lock('jastrow_jast_pen') - - jastrow_jast_pen = property(fset=set_jastrow_jast_pen,fget=get_jastrow_jast_pen) - - def has_jastrow_jast_pen(self): - return (os.access(self.path_jastrow+'/jast_pen.gz',os.F_OK) == 1) - - - def get_jastrow_jast_een_e_a(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_een_e_a') - try: - result = self.read_array_re(self.path_jastrow,'jast_een_e_a', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_een_e_a') - return result - - def set_jastrow_jast_een_e_a(self,jast_een_e_a): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_een_e_a') - try: - self.write_array_re(self.path_jastrow,'jast_een_e_a', rank,dims,dim_max,jast_een_e_a) - finally: - self.release_lock('jastrow_jast_een_e_a') - - jastrow_jast_een_e_a = property(fset=set_jastrow_jast_een_e_a,fget=get_jastrow_jast_een_e_a) - - def has_jastrow_jast_een_e_a(self): - return (os.access(self.path_jastrow+'/jast_een_e_a.gz',os.F_OK) == 1) - - - def get_jastrow_jast_een_e_b(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_een_e_b') - try: - result = self.read_array_re(self.path_jastrow,'jast_een_e_b', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_een_e_b') - return result - - def set_jastrow_jast_een_e_b(self,jast_een_e_b): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_een_e_b') - try: - self.write_array_re(self.path_jastrow,'jast_een_e_b', rank,dims,dim_max,jast_een_e_b) - finally: - self.release_lock('jastrow_jast_een_e_b') - - jastrow_jast_een_e_b = property(fset=set_jastrow_jast_een_e_b,fget=get_jastrow_jast_een_e_b) - - def has_jastrow_jast_een_e_b(self): - return (os.access(self.path_jastrow+'/jast_een_e_b.gz',os.F_OK) == 1) - - - def get_jastrow_jast_een_n(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_een_n') - try: - result = self.read_array_re(self.path_jastrow,'jast_een_n', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_een_n') - return result - - def set_jastrow_jast_een_n(self,jast_een_n): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_een_n') - try: - self.write_array_re(self.path_jastrow,'jast_een_n', rank,dims,dim_max,jast_een_n) - finally: - self.release_lock('jastrow_jast_een_n') - - jastrow_jast_een_n = property(fset=set_jastrow_jast_een_n,fget=get_jastrow_jast_een_n) - - def has_jastrow_jast_een_n(self): - return (os.access(self.path_jastrow+'/jast_een_n.gz',os.F_OK) == 1) - - - def get_jastrow_jast_core_a1(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_a1') - try: - result = self.read_array_re(self.path_jastrow,'jast_core_a1', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_core_a1') - return result - - def set_jastrow_jast_core_a1(self,jast_core_a1): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_a1') - try: - self.write_array_re(self.path_jastrow,'jast_core_a1', rank,dims,dim_max,jast_core_a1) - finally: - self.release_lock('jastrow_jast_core_a1') - - jastrow_jast_core_a1 = property(fset=set_jastrow_jast_core_a1,fget=get_jastrow_jast_core_a1) - - def has_jastrow_jast_core_a1(self): - return (os.access(self.path_jastrow+'/jast_core_a1.gz',os.F_OK) == 1) - - - def get_jastrow_jast_core_a2(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_a2') - try: - result = self.read_array_re(self.path_jastrow,'jast_core_a2', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_core_a2') - return result - - def set_jastrow_jast_core_a2(self,jast_core_a2): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_a2') - try: - self.write_array_re(self.path_jastrow,'jast_core_a2', rank,dims,dim_max,jast_core_a2) - finally: - self.release_lock('jastrow_jast_core_a2') - - jastrow_jast_core_a2 = property(fset=set_jastrow_jast_core_a2,fget=get_jastrow_jast_core_a2) - - def has_jastrow_jast_core_a2(self): - return (os.access(self.path_jastrow+'/jast_core_a2.gz',os.F_OK) == 1) - - - def get_jastrow_jast_core_b1(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_b1') - try: - result = self.read_array_re(self.path_jastrow,'jast_core_b1', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_core_b1') - return result - - def set_jastrow_jast_core_b1(self,jast_core_b1): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_b1') - try: - self.write_array_re(self.path_jastrow,'jast_core_b1', rank,dims,dim_max,jast_core_b1) - finally: - self.release_lock('jastrow_jast_core_b1') - - jastrow_jast_core_b1 = property(fset=set_jastrow_jast_core_b1,fget=get_jastrow_jast_core_b1) - - def has_jastrow_jast_core_b1(self): - return (os.access(self.path_jastrow+'/jast_core_b1.gz',os.F_OK) == 1) - - - def get_jastrow_jast_core_b2(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_b2') - try: - result = self.read_array_re(self.path_jastrow,'jast_core_b2', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_core_b2') - return result - - def set_jastrow_jast_core_b2(self,jast_core_b2): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_core_b2') - try: - self.write_array_re(self.path_jastrow,'jast_core_b2', rank,dims,dim_max,jast_core_b2) - finally: - self.release_lock('jastrow_jast_core_b2') - - jastrow_jast_core_b2 = property(fset=set_jastrow_jast_core_b2,fget=get_jastrow_jast_core_b2) - - def has_jastrow_jast_core_b2(self): - return (os.access(self.path_jastrow+'/jast_core_b2.gz',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_type_nucl_num(self): - self.acquire_lock('jastrow_jast_qmckl_type_nucl_num') - try: - result = self.read_in(self.path_jastrow,'jast_qmckl_type_nucl_num') - finally: - self.release_lock('jastrow_jast_qmckl_type_nucl_num') - return result - - def set_jastrow_jast_qmckl_type_nucl_num(self,jast_qmckl_type_nucl_num): - self.acquire_lock('jastrow_jast_qmckl_type_nucl_num') - try: - self.write_in(self.path_jastrow,'jast_qmckl_type_nucl_num',jast_qmckl_type_nucl_num) - finally: - self.release_lock('jastrow_jast_qmckl_type_nucl_num') - - jastrow_jast_qmckl_type_nucl_num = property(fset=set_jastrow_jast_qmckl_type_nucl_num, fget=get_jastrow_jast_qmckl_type_nucl_num) - - def has_jastrow_jast_qmckl_type_nucl_num(self): - return (os.access(self.path_jastrow+'/jast_qmckl_type_nucl_num',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_type_nucl_vector(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_type_nucl_vector') - try: - result = self.read_array_in(self.path_jastrow,'jast_qmckl_type_nucl_vector', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_qmckl_type_nucl_vector') - return result - - def set_jastrow_jast_qmckl_type_nucl_vector(self,jast_qmckl_type_nucl_vector): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.nuclei_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_type_nucl_vector') - try: - self.write_array_in(self.path_jastrow,'jast_qmckl_type_nucl_vector', rank,dims,dim_max,jast_qmckl_type_nucl_vector) - finally: - self.release_lock('jastrow_jast_qmckl_type_nucl_vector') - - jastrow_jast_qmckl_type_nucl_vector = property(fset=set_jastrow_jast_qmckl_type_nucl_vector,fget=get_jastrow_jast_qmckl_type_nucl_vector) - - def has_jastrow_jast_qmckl_type_nucl_vector(self): - return (os.access(self.path_jastrow+'/jast_qmckl_type_nucl_vector.gz',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_rescale_ee(self): - self.acquire_lock('jastrow_jast_qmckl_rescale_ee') - try: - result = self.read_do(self.path_jastrow,'jast_qmckl_rescale_ee') - finally: - self.release_lock('jastrow_jast_qmckl_rescale_ee') - return result - - def set_jastrow_jast_qmckl_rescale_ee(self,jast_qmckl_rescale_ee): - self.acquire_lock('jastrow_jast_qmckl_rescale_ee') - try: - self.write_do(self.path_jastrow,'jast_qmckl_rescale_ee',jast_qmckl_rescale_ee) - finally: - self.release_lock('jastrow_jast_qmckl_rescale_ee') - - jastrow_jast_qmckl_rescale_ee = property(fset=set_jastrow_jast_qmckl_rescale_ee, fget=get_jastrow_jast_qmckl_rescale_ee) - - def has_jastrow_jast_qmckl_rescale_ee(self): - return (os.access(self.path_jastrow+'/jast_qmckl_rescale_ee',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_rescale_en(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_rescale_en') - try: - result = self.read_array_do(self.path_jastrow,'jast_qmckl_rescale_en', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_qmckl_rescale_en') - return result - - def set_jastrow_jast_qmckl_rescale_en(self,jast_qmckl_rescale_en): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_rescale_en') - try: - self.write_array_do(self.path_jastrow,'jast_qmckl_rescale_en', rank,dims,dim_max,jast_qmckl_rescale_en) - finally: - self.release_lock('jastrow_jast_qmckl_rescale_en') - - jastrow_jast_qmckl_rescale_en = property(fset=set_jastrow_jast_qmckl_rescale_en,fget=get_jastrow_jast_qmckl_rescale_en) - - def has_jastrow_jast_qmckl_rescale_en(self): - return (os.access(self.path_jastrow+'/jast_qmckl_rescale_en.gz',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_aord_num(self): - self.acquire_lock('jastrow_jast_qmckl_aord_num') - try: - result = self.read_in(self.path_jastrow,'jast_qmckl_aord_num') - finally: - self.release_lock('jastrow_jast_qmckl_aord_num') - return result - - def set_jastrow_jast_qmckl_aord_num(self,jast_qmckl_aord_num): - self.acquire_lock('jastrow_jast_qmckl_aord_num') - try: - self.write_in(self.path_jastrow,'jast_qmckl_aord_num',jast_qmckl_aord_num) - finally: - self.release_lock('jastrow_jast_qmckl_aord_num') - - jastrow_jast_qmckl_aord_num = property(fset=set_jastrow_jast_qmckl_aord_num, fget=get_jastrow_jast_qmckl_aord_num) - - def has_jastrow_jast_qmckl_aord_num(self): - return (os.access(self.path_jastrow+'/jast_qmckl_aord_num',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_bord_num(self): - self.acquire_lock('jastrow_jast_qmckl_bord_num') - try: - result = self.read_in(self.path_jastrow,'jast_qmckl_bord_num') - finally: - self.release_lock('jastrow_jast_qmckl_bord_num') - return result - - def set_jastrow_jast_qmckl_bord_num(self,jast_qmckl_bord_num): - self.acquire_lock('jastrow_jast_qmckl_bord_num') - try: - self.write_in(self.path_jastrow,'jast_qmckl_bord_num',jast_qmckl_bord_num) - finally: - self.release_lock('jastrow_jast_qmckl_bord_num') - - jastrow_jast_qmckl_bord_num = property(fset=set_jastrow_jast_qmckl_bord_num, fget=get_jastrow_jast_qmckl_bord_num) - - def has_jastrow_jast_qmckl_bord_num(self): - return (os.access(self.path_jastrow+'/jast_qmckl_bord_num',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_cord_num(self): - self.acquire_lock('jastrow_jast_qmckl_cord_num') - try: - result = self.read_in(self.path_jastrow,'jast_qmckl_cord_num') - finally: - self.release_lock('jastrow_jast_qmckl_cord_num') - return result - - def set_jastrow_jast_qmckl_cord_num(self,jast_qmckl_cord_num): - self.acquire_lock('jastrow_jast_qmckl_cord_num') - try: - self.write_in(self.path_jastrow,'jast_qmckl_cord_num',jast_qmckl_cord_num) - finally: - self.release_lock('jastrow_jast_qmckl_cord_num') - - jastrow_jast_qmckl_cord_num = property(fset=set_jastrow_jast_qmckl_cord_num, fget=get_jastrow_jast_qmckl_cord_num) - - def has_jastrow_jast_qmckl_cord_num(self): - return (os.access(self.path_jastrow+'/jast_qmckl_cord_num',os.F_OK) == 1) - - - def get_jastrow_jast_qmckl_a_vector(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num*self.jastrow_jast_qmckl_aord_num+self.jastrow_jast_qmckl_type_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_a_vector') - try: - result = self.read_array_do(self.path_jastrow,'jast_qmckl_a_vector', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_qmckl_a_vector') - return result - - def set_jastrow_jast_qmckl_a_vector(self,jast_qmckl_a_vector): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num*self.jastrow_jast_qmckl_aord_num+self.jastrow_jast_qmckl_type_nucl_num) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_a_vector') - try: - self.write_array_do(self.path_jastrow,'jast_qmckl_a_vector', rank,dims,dim_max,jast_qmckl_a_vector) - finally: - self.release_lock('jastrow_jast_qmckl_a_vector') - - jastrow_jast_qmckl_a_vector = property(fset=set_jastrow_jast_qmckl_a_vector,fget=get_jastrow_jast_qmckl_a_vector) - - def has_jastrow_jast_qmckl_a_vector(self): - return (os.access(self.path_jastrow+'/jast_qmckl_a_vector.gz',os.F_OK) == 1) +def version(x): + b = [int(i) for i in x.split('.')] + return b[2] + b[1] * 100 + b[0] * 10000 - def get_jastrow_jast_qmckl_b_vector(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_bord_num+1) - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_b_vector') - try: - result = self.read_array_do(self.path_jastrow,'jast_qmckl_b_vector', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_qmckl_b_vector') - return result +def size(x): + return len(x) - def set_jastrow_jast_qmckl_b_vector(self,jast_qmckl_b_vector): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_bord_num+1) - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_b_vector') - try: - self.write_array_do(self.path_jastrow,'jast_qmckl_b_vector', rank,dims,dim_max,jast_qmckl_b_vector) - finally: - self.release_lock('jastrow_jast_qmckl_b_vector') +def flatten(l): + res = [] + for i in l: + if hasattr(i, '__iter__') and not isinstance(i, str): + res.extend(flatten(i)) + else: + res.append(i) + return res - jastrow_jast_qmckl_b_vector = property(fset=set_jastrow_jast_qmckl_b_vector,fget=get_jastrow_jast_qmckl_b_vector) - def has_jastrow_jast_qmckl_b_vector(self): - return (os.access(self.path_jastrow+'/jast_qmckl_b_vector.gz',os.F_OK) == 1) +def maxval(l): + return reduce(max, l, l[0]) - def get_jastrow_jast_qmckl_c_vector_size(self): - self.acquire_lock('jastrow_jast_qmckl_c_vector_size') - try: - result = self.read_in(self.path_jastrow,'jast_qmckl_c_vector_size') - finally: - self.release_lock('jastrow_jast_qmckl_c_vector_size') - return result +def minval(l): + return reduce(min, l, l[0]) - def set_jastrow_jast_qmckl_c_vector_size(self,jast_qmckl_c_vector_size): - self.acquire_lock('jastrow_jast_qmckl_c_vector_size') - try: - self.write_in(self.path_jastrow,'jast_qmckl_c_vector_size',jast_qmckl_c_vector_size) - finally: - self.release_lock('jastrow_jast_qmckl_c_vector_size') - jastrow_jast_qmckl_c_vector_size = property(fset=set_jastrow_jast_qmckl_c_vector_size, fget=get_jastrow_jast_qmckl_c_vector_size) +def reshape(l, shape): + l = flatten(l) + for d in shape[:-1]: + buffer = [] + buffer2 = [] + i = 0 + while i < len(l): + buffer2.append(l[i]) + if len(buffer2) == d: + buffer.append(buffer2) + buffer2 = [] + i += 1 + l = list(buffer) + return l - def has_jastrow_jast_qmckl_c_vector_size(self): - return (os.access(self.path_jastrow+'/jast_qmckl_c_vector_size',os.F_OK) == 1) +def at(array, index): + return array[index - 1] - def get_jastrow_jast_qmckl_c_vector(self): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_c_vector_size) - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_c_vector') - try: - result = self.read_array_do(self.path_jastrow,'jast_qmckl_c_vector', rank,dims,dim_max) - finally: - self.release_lock('jastrow_jast_qmckl_c_vector') +def n_count_ch(array, isize, val): + result = 0 + for i in array: + if i == val: + result += 1 return result - def set_jastrow_jast_qmckl_c_vector(self,jast_qmckl_c_vector): - rank = 1 - dims = list(range(rank)) - dims[0] = int(self.jastrow_jast_qmckl_c_vector_size) - - dim_max = 1 - for d in dims: - dim_max *= d - self.acquire_lock('jastrow_jast_qmckl_c_vector') - try: - self.write_array_do(self.path_jastrow,'jast_qmckl_c_vector', rank,dims,dim_max,jast_qmckl_c_vector) - finally: - self.release_lock('jastrow_jast_qmckl_c_vector') - - jastrow_jast_qmckl_c_vector = property(fset=set_jastrow_jast_qmckl_c_vector,fget=get_jastrow_jast_qmckl_c_vector) - - def has_jastrow_jast_qmckl_c_vector(self): - return (os.access(self.path_jastrow+'/jast_qmckl_c_vector.gz',os.F_OK) == 1) - - - def read_i8(self,dir,fil): - conv = get_conv("i8") - l_filename=dir.strip()+'/'+fil - try: - file = open(l_filename,"r") - except IOError: - self.error('read_i8', 'Attribute '+dir.strip()+'/'+fil+' is not set') - dat = file.readline().strip() - try: - dat = conv(dat) - except SyntaxError: - pass - file.close() - return dat - - def write_i8(self,dir,fil,dat): - if self.read_only: - self.error('Read-only file.') - conv = get_conv("i8") - l_filename= [ dir.strip()+'/.'+fil ] - l_filename += [ dir.strip()+'/'+fil ] - dat = conv(dat) - file = open(l_filename[0],'w') - print('%20d'%(dat,), file=file) - file.close() - os.rename(l_filename[0],l_filename[1]) - - def read_array_i8(self,dir,fil,rank,dims,dim_max): - l_filename=dir.strip()+'/'+fil+'.gz' - conv = get_conv("i8") - try: - file = GzipFile(filename=l_filename,mode='rb') - lines = file.read().splitlines() - rank_read = int(lines[0]) - assert (rank_read == rank) - - dims_read = map(int,lines[1].split()) - - for i,j in zip(dims_read,dims): - assert i == j - lines.pop(0) - lines.pop(0) - dat = map(conv,lines) - - file.close() - return reshape(dat,dims) - - except IOError: - self.error('read_array_i8', 'Attribute '+l_filename+' is not set') - - def write_array_i8(self,dir,fil,rank,dims,dim_max,dat): - if self.read_only: - self.error('Read-only file.') - l_filename = [ tempfile.mktemp(dir=dir.strip()), dir.strip()+'/'+fil+'.gz' ] - try: - file = StringIO.StringIO() - file.write("%3d\n"%(rank,)) - for d in dims: - file.write("%20d "%(d,)) - file.write("\n") - - dat = flatten(dat) - for i in range(dim_max): - file.write("%20d\n"%(dat[i],)) - file.flush() - buffer = file.getvalue() - file.close() - file = GzipFile(filename=l_filename[0],mode='wb') - file.write(buffer.encode()) - file.close() - os.rename(l_filename[0],l_filename[1]) - except: - self.error("write_array_i8", - "Unable to write "+l_filename[1]) - - - def read_in(self,dir,fil): - conv = get_conv("in") - l_filename=dir.strip()+'/'+fil - try: - file = open(l_filename,"r") - except IOError: - self.error('read_in', 'Attribute '+dir.strip()+'/'+fil+' is not set') - dat = file.readline().strip() - try: - dat = conv(dat) - except SyntaxError: - pass - file.close() - return dat - - def write_in(self,dir,fil,dat): - if self.read_only: - self.error('Read-only file.') - conv = get_conv("in") - l_filename= [ dir.strip()+'/.'+fil ] - l_filename += [ dir.strip()+'/'+fil ] - dat = conv(dat) - file = open(l_filename[0],'w') - print('%20d'%(dat,), file=file) - file.close() - os.rename(l_filename[0],l_filename[1]) - - def read_array_in(self,dir,fil,rank,dims,dim_max): - l_filename=dir.strip()+'/'+fil+'.gz' - conv = get_conv("in") - try: - file = GzipFile(filename=l_filename,mode='rb') - lines = file.read().splitlines() - rank_read = int(lines[0]) - assert (rank_read == rank) - - dims_read = map(int,lines[1].split()) - - for i,j in zip(dims_read,dims): - assert i == j - - lines.pop(0) - lines.pop(0) - dat = map(conv,lines) - - file.close() - return reshape(dat,dims) - - except IOError: - self.error('read_array_in', 'Attribute '+l_filename+' is not set') - - def write_array_in(self,dir,fil,rank,dims,dim_max,dat): - if self.read_only: - self.error('Read-only file.') - l_filename = [ tempfile.mktemp(dir=dir.strip()), dir.strip()+'/'+fil+'.gz' ] - try: - file = StringIO.StringIO() - file.write("%3d\n"%(rank,)) - for d in dims: - file.write("%20d "%(d,)) - file.write("\n") - - dat = flatten(dat) - for i in range(dim_max): - file.write("%20d\n"%(dat[i],)) - file.flush() - buffer = file.getvalue() - file.close() - file = GzipFile(filename=l_filename[0],mode='wb') - file.write(buffer.encode()) - file.close() - os.rename(l_filename[0],l_filename[1]) - except: - self.error("write_array_in", - "Unable to write "+l_filename[1]) - - - def read_re(self,dir,fil): - conv = get_conv("re") - l_filename=dir.strip()+'/'+fil - try: - file = open(l_filename,"r") - except IOError: - self.error('read_re', 'Attribute '+dir.strip()+'/'+fil+' is not set') - dat = file.readline().strip() - try: - dat = conv(dat) - except SyntaxError: - pass - file.close() - return dat - - def write_re(self,dir,fil,dat): - if self.read_only: - self.error('Read-only file.') - conv = get_conv("re") - l_filename= [ dir.strip()+'/.'+fil ] - l_filename += [ dir.strip()+'/'+fil ] - dat = conv(dat) - file = open(l_filename[0],'w') - print('%24.15E'%(dat,), file=file) - file.close() - os.rename(l_filename[0],l_filename[1]) - - def read_array_re(self,dir,fil,rank,dims,dim_max): - l_filename=dir.strip()+'/'+fil+'.gz' - conv = get_conv("re") - try: - file = GzipFile(filename=l_filename,mode='rb') - lines = file.read().splitlines() - rank_read = int(lines[0]) - assert (rank_read == rank) - - dims_read = map(int,lines[1].split()) - - for i,j in zip(dims_read,dims): - assert i == j - - lines.pop(0) - lines.pop(0) - dat = map(conv,lines) - - file.close() - return reshape(dat,dims) - - except IOError: - self.error('read_array_re', 'Attribute '+l_filename+' is not set') - - def write_array_re(self,dir,fil,rank,dims,dim_max,dat): - if self.read_only: - self.error('Read-only file.') - l_filename = [ tempfile.mktemp(dir=dir.strip()), dir.strip()+'/'+fil+'.gz' ] - try: - file = StringIO.StringIO() - file.write("%3d\n"%(rank,)) - for d in dims: - file.write("%20d "%(d,)) - file.write("\n") - - dat = flatten(dat) - for i in range(dim_max): - file.write("%24.15E\n"%(dat[i],)) - file.flush() - buffer = file.getvalue() - file.close() - file = GzipFile(filename=l_filename[0],mode='wb') - file.write(buffer.encode()) - file.close() - os.rename(l_filename[0],l_filename[1]) - except: - self.error("write_array_re", - "Unable to write "+l_filename[1]) - - - def read_do(self,dir,fil): - conv = get_conv("do") - l_filename=dir.strip()+'/'+fil - try: - file = open(l_filename,"r") - except IOError: - self.error('read_do', 'Attribute '+dir.strip()+'/'+fil+' is not set') - dat = file.readline().strip() - try: - dat = conv(dat) - except SyntaxError: - pass - file.close() - return dat - - def write_do(self,dir,fil,dat): - if self.read_only: - self.error('Read-only file.') - conv = get_conv("do") - l_filename= [ dir.strip()+'/.'+fil ] - l_filename += [ dir.strip()+'/'+fil ] - dat = conv(dat) - file = open(l_filename[0],'w') - print('%24.15E'%(dat,), file=file) - file.close() - os.rename(l_filename[0],l_filename[1]) - - def read_array_do(self,dir,fil,rank,dims,dim_max): - l_filename=dir.strip()+'/'+fil+'.gz' - conv = get_conv("do") - try: - file = GzipFile(filename=l_filename,mode='rb') - lines = file.read().splitlines() - rank_read = int(lines[0]) - assert (rank_read == rank) - - dims_read = map(int,lines[1].split()) - - for i,j in zip(dims_read,dims): - assert i == j - - lines.pop(0) - lines.pop(0) - dat = map(conv,lines) - - file.close() - return reshape(dat,dims) - - except IOError: - self.error('read_array_do', 'Attribute '+l_filename+' is not set') - - def write_array_do(self,dir,fil,rank,dims,dim_max,dat): - if self.read_only: - self.error('Read-only file.') - l_filename = [ tempfile.mktemp(dir=dir.strip()), dir.strip()+'/'+fil+'.gz' ] - try: - file = StringIO.StringIO() - file.write("%3d\n"%(rank,)) - for d in dims: - file.write("%20d "%(d,)) - file.write("\n") - - dat = flatten(dat) - for i in range(dim_max): - file.write("%24.15E\n"%(dat[i],)) - file.flush() - buffer = file.getvalue() - file.close() - file = GzipFile(filename=l_filename[0],mode='wb') - file.write(buffer.encode()) - file.close() - os.rename(l_filename[0],l_filename[1]) - except: - self.error("write_array_do", - "Unable to write "+l_filename[1]) - - - def read_lo(self,dir,fil): - conv = get_conv("lo") - l_filename=dir.strip()+'/'+fil - try: - file = open(l_filename,"r") - except IOError: - self.error('read_lo', 'Attribute '+dir.strip()+'/'+fil+' is not set') - dat = file.readline().strip() - try: - dat = conv(dat) - except SyntaxError: - pass - file.close() - return dat - - def write_lo(self,dir,fil,dat): - if self.read_only: - self.error('Read-only file.') - conv = get_conv("lo") - l_filename= [ dir.strip()+'/.'+fil ] - l_filename += [ dir.strip()+'/'+fil ] - dat = conv(dat) - file = open(l_filename[0],'w') - print('%c'%(dat,), file=file) - file.close() - os.rename(l_filename[0],l_filename[1]) - - def read_array_lo(self,dir,fil,rank,dims,dim_max): - l_filename=dir.strip()+'/'+fil+'.gz' - conv = get_conv("lo") - try: - file = GzipFile(filename=l_filename,mode='rb') - lines = file.read().splitlines() - rank_read = int(lines[0]) - assert (rank_read == rank) - - dims_read = map(int,lines[1].split()) - - for i,j in zip(dims_read,dims): - assert i == j - - lines.pop(0) - lines.pop(0) - dat = map(conv,lines) - - file.close() - return reshape(dat,dims) - - except IOError: - self.error('read_array_lo', 'Attribute '+l_filename+' is not set') - - def write_array_lo(self,dir,fil,rank,dims,dim_max,dat): - if self.read_only: - self.error('Read-only file.') - l_filename = [ tempfile.mktemp(dir=dir.strip()), dir.strip()+'/'+fil+'.gz' ] - try: - file = StringIO.StringIO() - file.write("%3d\n"%(rank,)) - for d in dims: - file.write("%20d "%(d,)) - file.write("\n") - - dat = flatten(dat) - for i in range(dim_max): - file.write("%c\n"%(dat[i],)) - file.flush() - buffer = file.getvalue() - file.close() - file = GzipFile(filename=l_filename[0],mode='wb') - file.write(buffer.encode()) - file.close() - os.rename(l_filename[0],l_filename[1]) - except: - self.error("write_array_lo", - "Unable to write "+l_filename[1]) - - - def read_ch(self,dir,fil): - conv = get_conv("ch") - l_filename=dir.strip()+'/'+fil - try: - file = open(l_filename,"r") - except IOError: - self.error('read_ch', 'Attribute '+dir.strip()+'/'+fil+' is not set') - dat = file.readline().strip() - try: - dat = conv(dat) - except SyntaxError: - pass - file.close() - return dat - - def write_ch(self,dir,fil,dat): - if self.read_only: - self.error('Read-only file.') - conv = get_conv("ch") - l_filename= [ dir.strip()+'/.'+fil ] - l_filename += [ dir.strip()+'/'+fil ] - dat = conv(dat) - file = open(l_filename[0],'w') - print('%s'%(dat,), file=file) - file.close() - os.rename(l_filename[0],l_filename[1]) - - def read_array_ch(self,dir,fil,rank,dims,dim_max): - l_filename=dir.strip()+'/'+fil+'.gz' - conv = get_conv("ch") - try: - file = GzipFile(filename=l_filename,mode='rb') - lines = file.read().splitlines() - rank_read = int(lines[0]) - assert (rank_read == rank) +n_count_in = n_count_ch +n_count_do = n_count_ch +n_count_lo = n_count_ch - dims_read = map(int,lines[1].split()) - for i,j in zip(dims_read,dims): - assert i == j +def get_conv(type): + if type in ['do', 're']: + conv = float + elif type in ['in', 'i8']: + conv = int + elif type == 'lo': + + def conv(a): + if a == True: + return 'T' + elif a == False: + return 'F' + elif a.lower() == 't': + return True + elif a.lower() == 'f': + return False + else: + raise TypeError + elif type == 'ch': + conv = lambda x: x.decode('utf-8').strip() if isinstance( + x, bytes) else x.strip() + else: + raise TypeError + return conv - lines.pop(0) - lines.pop(0) - dat = map(conv,lines) - file.close() - return reshape(dat,dims) +class ezfio_obj(object): + def __init__(self, read_only=False): + self._filename = 'EZFIO_File' + self.buffer_rank = -1 + self.read_only = read_only + self.locks = {} + + def acquire_lock(self, var): + locks = self.locks + try: + locks[var].acquire() + except: + locks[var] = threading.Lock() + locks[var].acquire() + + def release_lock(self, var): + self.locks[var].release() + + def set_read_only(self, v): + self.read_only = v + + def get_read_only(self): + return self.read_only + + def exists(self, path): + if os.access(path + '/.version', os.F_OK) == 1: + file = open(path + '/.version', 'r') + v = file.readline().strip() + file.close() + else: + return False + + def mkdir(self, path): + if self.read_only: + self.error('Read-only file.') + if self.exists(path): + self.error('mkdir', 'Group ' + path + ' exists') + try: + os.mkdir(path.strip()) + except OSError: + pass + file = open(path.strip() + '/.version', 'w') + print(self.version, file=file) + file.close() + + def error(self, where, txt): + print('------------------------------------------------------------') + print('EZFIO File : ' + self.filename) + print('EZFIO Error in : ' + where.strip()) + print('------------------------------------------------------------') + print('') + print(txt.strip()) + print('') + print('------------------------------------------------------------') + raise IOError + + def get_filename(self): + if not self.exists(self._filename): + self.mkdir(self._filename) + return self._filename + + def set_filename(self, filename): + self._filename = filename + + filename = property(fset=set_filename, fget=get_filename) + + def set_file(self, filename): + self.filename = filename + if not self.exists(filename): + self.mkdir(filename) + self.mkdir(filename + '/ezfio') + os.system(""" +LANG= date > %s/ezfio/creation +echo $USER > %s/ezfio/user +echo %s > %s/ezfio/library""" % (filename, filename, self.LIBRARY, filename)) + + def open_write_buffer(self, dir, fil, rank): + if self.read_only: + self.error('Read-only file.') + l_filename = dir.strip() + '/' + fil + '.gz' + if self.buffer_rank != -1: + self.error('open_write_buffer', + 'Another buffered file is already open.') + + self.buffer_rank = rank + assert (self.buffer_rank > 0) + + try: + self.file = GzipFile(filename=l_filename, mode='wb7') + except IOError: + self.error('open_write_buffer', 'Unable to open buffered file.') + + self.file.write('%2d\n' % (rank, )) + + def open_read_buffer(self, dir, fil, rank): + l_filename = dir.strip() + '/' + fil + '.gz' + + if self.buffer_rank != -1: + self.error('open_read_buffer', + 'Another buffered file is already open.') + + try: + self.file = GzipFile(filename=l_filename, mode='rb') + except IOError: + self.error('open_read_buffer', 'Unable to open buffered file.') + + try: + rank = eval(self.file.readline()) + except IOError: + self.error('open_read_buffer', 'Unable to read buffered file.') + + self.buffer_rank = rank + assert (self.buffer_rank > 0) + return rank + + def close_buffer(self): + assert (self.buffer_rank > 0) + self.buffer_rank = -1 + self.file.close() + + def read_buffer(self, isize): + + if self.buffer_rank == -1: + self.error('read_buffer', 'No buffered file is open.') + + indices = [] + values = [] + for i in range(isize): + try: + line = self.file.readline().split() + except: + return indices, values + if len(line) == 0: + return indices, values + indices.append([int(i) for i in line[:-1]]) + values.append(eval(line[-1])) + return indices, values - except IOError: - self.error('read_array_ch', 'Attribute '+l_filename+' is not set') + def write_buffer(self, indices, values, isize): + if self.read_only: + self.error('Read-only file.') + if self.buffer_rank == -1: + self.error('write_buffer', 'No buffered file is open.') + + for i in range(isize): + for j in indices[i]: + self.file.write('%4d ' % (j, )) + self.file.write('%24.15e\n' % (values[i], )) + + def get_version(self): + return '2.0.7' + + version = property(fset=None, fget=get_version) + + def get_path_ezfio(self): + result = self.filename.strip() + '/ezfio' + self.acquire_lock('ezfio') + try: + if not self.exists(result): + self.mkdir(result) + finally: + self.release_lock('ezfio') + return result + + path_ezfio = property(fget=get_path_ezfio) + + def get_ezfio_creation(self): + self.acquire_lock('ezfio_creation') + try: + result = self.read_ch(self.path_ezfio, 'creation') + finally: + self.release_lock('ezfio_creation') + return result + + def set_ezfio_creation(self, creation): + self.acquire_lock('ezfio_creation') + try: + self.write_ch(self.path_ezfio, 'creation', creation) + finally: + self.release_lock('ezfio_creation') + + ezfio_creation = property(fset=set_ezfio_creation, fget=get_ezfio_creation) + + def has_ezfio_creation(self): + return (os.access(self.path_ezfio + '/creation', os.F_OK) == 1) + + def get_ezfio_user(self): + self.acquire_lock('ezfio_user') + try: + result = self.read_ch(self.path_ezfio, 'user') + finally: + self.release_lock('ezfio_user') + return result + + def set_ezfio_user(self, user): + self.acquire_lock('ezfio_user') + try: + self.write_ch(self.path_ezfio, 'user', user) + finally: + self.release_lock('ezfio_user') + + ezfio_user = property(fset=set_ezfio_user, fget=get_ezfio_user) + + def has_ezfio_user(self): + return (os.access(self.path_ezfio + '/user', os.F_OK) == 1) + + def get_ezfio_library(self): + self.acquire_lock('ezfio_library') + try: + result = self.read_ch(self.path_ezfio, 'library') + finally: + self.release_lock('ezfio_library') + return result + + def set_ezfio_library(self, library): + self.acquire_lock('ezfio_library') + try: + self.write_ch(self.path_ezfio, 'library', library) + finally: + self.release_lock('ezfio_library') + + ezfio_library = property(fset=set_ezfio_library, fget=get_ezfio_library) + + def has_ezfio_library(self): + return (os.access(self.path_ezfio + '/library', os.F_OK) == 1) + + def get_ezfio_last_library(self): + self.acquire_lock('ezfio_last_library') + try: + result = self.read_ch(self.path_ezfio, 'last_library') + finally: + self.release_lock('ezfio_last_library') + return result + + def set_ezfio_last_library(self, last_library): + self.acquire_lock('ezfio_last_library') + try: + self.write_ch(self.path_ezfio, 'last_library', last_library) + finally: + self.release_lock('ezfio_last_library') + + ezfio_last_library = property(fset=set_ezfio_last_library, + fget=get_ezfio_last_library) + + def has_ezfio_last_library(self): + return (os.access(self.path_ezfio + '/last_library', os.F_OK) == 1) + + def get_path_ao_basis(self): + result = self.filename.strip() + '/ao_basis' + self.acquire_lock('ao_basis') + try: + if not self.exists(result): + self.mkdir(result) + finally: + self.release_lock('ao_basis') + return result + + path_ao_basis = property(fget=get_path_ao_basis) + + def get_ao_basis_ao_num(self): + self.acquire_lock('ao_basis_ao_num') + try: + result = self.read_in(self.path_ao_basis, 'ao_num') + finally: + self.release_lock('ao_basis_ao_num') + return result + + def set_ao_basis_ao_num(self, ao_num): + self.acquire_lock('ao_basis_ao_num') + try: + self.write_in(self.path_ao_basis, 'ao_num', ao_num) + finally: + self.release_lock('ao_basis_ao_num') + + ao_basis_ao_num = property(fset=set_ao_basis_ao_num, + fget=get_ao_basis_ao_num) + + def has_ao_basis_ao_num(self): + return (os.access(self.path_ao_basis + '/ao_num', os.F_OK) == 1) + + def get_ao_basis_ao_prim_num(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_prim_num') + try: + result = self.read_array_in(self.path_ao_basis, 'ao_prim_num', + rank, dims, dim_max) + finally: + self.release_lock('ao_basis_ao_prim_num') + return result + + def set_ao_basis_ao_prim_num(self, ao_prim_num): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_prim_num') + try: + self.write_array_in(self.path_ao_basis, 'ao_prim_num', rank, dims, + dim_max, ao_prim_num) + finally: + self.release_lock('ao_basis_ao_prim_num') + + ao_basis_ao_prim_num = property(fset=set_ao_basis_ao_prim_num, + fget=get_ao_basis_ao_prim_num) + + def has_ao_basis_ao_prim_num(self): + return (os.access(self.path_ao_basis + '/ao_prim_num.gz', + os.F_OK) == 1) + + def get_ao_basis_ao_nucl(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_nucl') + try: + result = self.read_array_in(self.path_ao_basis, 'ao_nucl', rank, + dims, dim_max) + finally: + self.release_lock('ao_basis_ao_nucl') + return result + + def set_ao_basis_ao_nucl(self, ao_nucl): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_nucl') + try: + self.write_array_in(self.path_ao_basis, 'ao_nucl', rank, dims, + dim_max, ao_nucl) + finally: + self.release_lock('ao_basis_ao_nucl') + + ao_basis_ao_nucl = property(fset=set_ao_basis_ao_nucl, + fget=get_ao_basis_ao_nucl) + + def has_ao_basis_ao_nucl(self): + return (os.access(self.path_ao_basis + '/ao_nucl.gz', os.F_OK) == 1) + + def get_ao_basis_ao_power(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(3) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_power') + try: + result = self.read_array_in(self.path_ao_basis, 'ao_power', rank, + dims, dim_max) + finally: + self.release_lock('ao_basis_ao_power') + return result + + def set_ao_basis_ao_power(self, ao_power): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(3) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_power') + try: + self.write_array_in(self.path_ao_basis, 'ao_power', rank, dims, + dim_max, ao_power) + finally: + self.release_lock('ao_basis_ao_power') + + ao_basis_ao_power = property(fset=set_ao_basis_ao_power, + fget=get_ao_basis_ao_power) + + def has_ao_basis_ao_power(self): + return (os.access(self.path_ao_basis + '/ao_power.gz', os.F_OK) == 1) + + def get_ao_basis_ao_prim_num_max(self): + return maxval(self.ao_basis_ao_prim_num) + + ao_basis_ao_prim_num_max = property(fget=get_ao_basis_ao_prim_num_max) + + def get_ao_basis_ao_coef(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(self.ao_basis_ao_prim_num_max) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_coef') + try: + result = self.read_array_re(self.path_ao_basis, 'ao_coef', rank, + dims, dim_max) + finally: + self.release_lock('ao_basis_ao_coef') + return result + + def set_ao_basis_ao_coef(self, ao_coef): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(self.ao_basis_ao_prim_num_max) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_coef') + try: + self.write_array_re(self.path_ao_basis, 'ao_coef', rank, dims, + dim_max, ao_coef) + finally: + self.release_lock('ao_basis_ao_coef') + + ao_basis_ao_coef = property(fset=set_ao_basis_ao_coef, + fget=get_ao_basis_ao_coef) + + def has_ao_basis_ao_coef(self): + return (os.access(self.path_ao_basis + '/ao_coef.gz', os.F_OK) == 1) + + def get_ao_basis_ao_expo(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(self.ao_basis_ao_prim_num_max) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_expo') + try: + result = self.read_array_re(self.path_ao_basis, 'ao_expo', rank, + dims, dim_max) + finally: + self.release_lock('ao_basis_ao_expo') + return result + + def set_ao_basis_ao_expo(self, ao_expo): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(self.ao_basis_ao_prim_num_max) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('ao_basis_ao_expo') + try: + self.write_array_re(self.path_ao_basis, 'ao_expo', rank, dims, + dim_max, ao_expo) + finally: + self.release_lock('ao_basis_ao_expo') + + ao_basis_ao_expo = property(fset=set_ao_basis_ao_expo, + fget=get_ao_basis_ao_expo) + + def has_ao_basis_ao_expo(self): + return (os.access(self.path_ao_basis + '/ao_expo.gz', os.F_OK) == 1) + + def get_path_nuclei(self): + result = self.filename.strip() + '/nuclei' + self.acquire_lock('nuclei') + try: + if not self.exists(result): + self.mkdir(result) + finally: + self.release_lock('nuclei') + return result + + path_nuclei = property(fget=get_path_nuclei) + + def get_nuclei_nucl_num(self): + self.acquire_lock('nuclei_nucl_num') + try: + result = self.read_in(self.path_nuclei, 'nucl_num') + finally: + self.release_lock('nuclei_nucl_num') + return result + + def set_nuclei_nucl_num(self, nucl_num): + self.acquire_lock('nuclei_nucl_num') + try: + self.write_in(self.path_nuclei, 'nucl_num', nucl_num) + finally: + self.release_lock('nuclei_nucl_num') + + nuclei_nucl_num = property(fset=set_nuclei_nucl_num, + fget=get_nuclei_nucl_num) + + def has_nuclei_nucl_num(self): + return (os.access(self.path_nuclei + '/nucl_num', os.F_OK) == 1) + + def get_nuclei_nucl_label(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('nuclei_nucl_label') + try: + result = self.read_array_ch(self.path_nuclei, 'nucl_label', rank, + dims, dim_max) + finally: + self.release_lock('nuclei_nucl_label') + return result + + def set_nuclei_nucl_label(self, nucl_label): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('nuclei_nucl_label') + try: + self.write_array_ch(self.path_nuclei, 'nucl_label', rank, dims, + dim_max, nucl_label) + finally: + self.release_lock('nuclei_nucl_label') + + nuclei_nucl_label = property(fset=set_nuclei_nucl_label, + fget=get_nuclei_nucl_label) + + def has_nuclei_nucl_label(self): + return (os.access(self.path_nuclei + '/nucl_label.gz', os.F_OK) == 1) + + def get_nuclei_nucl_charge(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('nuclei_nucl_charge') + try: + result = self.read_array_re(self.path_nuclei, 'nucl_charge', rank, + dims, dim_max) + finally: + self.release_lock('nuclei_nucl_charge') + return result + + def set_nuclei_nucl_charge(self, nucl_charge): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('nuclei_nucl_charge') + try: + self.write_array_re(self.path_nuclei, 'nucl_charge', rank, dims, + dim_max, nucl_charge) + finally: + self.release_lock('nuclei_nucl_charge') + + nuclei_nucl_charge = property(fset=set_nuclei_nucl_charge, + fget=get_nuclei_nucl_charge) + + def has_nuclei_nucl_charge(self): + return (os.access(self.path_nuclei + '/nucl_charge.gz', os.F_OK) == 1) + + def get_nuclei_nucl_coord(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + dims[1] = int(3) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('nuclei_nucl_coord') + try: + result = self.read_array_re(self.path_nuclei, 'nucl_coord', rank, + dims, dim_max) + finally: + self.release_lock('nuclei_nucl_coord') + return result + + def set_nuclei_nucl_coord(self, nucl_coord): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + dims[1] = int(3) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('nuclei_nucl_coord') + try: + self.write_array_re(self.path_nuclei, 'nucl_coord', rank, dims, + dim_max, nucl_coord) + finally: + self.release_lock('nuclei_nucl_coord') + + nuclei_nucl_coord = property(fset=set_nuclei_nucl_coord, + fget=get_nuclei_nucl_coord) + + def has_nuclei_nucl_coord(self): + return (os.access(self.path_nuclei + '/nucl_coord.gz', os.F_OK) == 1) + + def get_path_jastrow(self): + result = self.filename.strip() + '/jastrow' + self.acquire_lock('jastrow') + try: + if not self.exists(result): + self.mkdir(result) + finally: + self.release_lock('jastrow') + return result + + path_jastrow = property(fget=get_path_jastrow) + + def get_jastrow_j2e_type(self): + self.acquire_lock('jastrow_j2e_type') + try: + result = self.read_ch(self.path_jastrow, 'j2e_type') + finally: + self.release_lock('jastrow_j2e_type') + return result + + def set_jastrow_j2e_type(self, j2e_type): + self.acquire_lock('jastrow_j2e_type') + try: + self.write_ch(self.path_jastrow, 'j2e_type', j2e_type) + finally: + self.release_lock('jastrow_j2e_type') + + jastrow_j2e_type = property(fset=set_jastrow_j2e_type, + fget=get_jastrow_j2e_type) + + def has_jastrow_j2e_type(self): + return (os.access(self.path_jastrow + '/j2e_type', os.F_OK) == 1) + + def get_jastrow_j1e_type(self): + self.acquire_lock('jastrow_j1e_type') + try: + result = self.read_ch(self.path_jastrow, 'j1e_type') + finally: + self.release_lock('jastrow_j1e_type') + return result + + def set_jastrow_j1e_type(self, j1e_type): + self.acquire_lock('jastrow_j1e_type') + try: + self.write_ch(self.path_jastrow, 'j1e_type', j1e_type) + finally: + self.release_lock('jastrow_j1e_type') + + jastrow_j1e_type = property(fset=set_jastrow_j1e_type, + fget=get_jastrow_j1e_type) + + def has_jastrow_j1e_type(self): + return (os.access(self.path_jastrow + '/j1e_type', os.F_OK) == 1) + + def get_jastrow_env_type(self): + self.acquire_lock('jastrow_env_type') + try: + result = self.read_ch(self.path_jastrow, 'env_type') + finally: + self.release_lock('jastrow_env_type') + return result + + def set_jastrow_env_type(self, env_type): + self.acquire_lock('jastrow_env_type') + try: + self.write_ch(self.path_jastrow, 'env_type', env_type) + finally: + self.release_lock('jastrow_env_type') + + jastrow_env_type = property(fset=set_jastrow_env_type, + fget=get_jastrow_env_type) + + def has_jastrow_env_type(self): + return (os.access(self.path_jastrow + '/env_type', os.F_OK) == 1) + + def get_jastrow_jbh_size(self): + self.acquire_lock('jastrow_jbh_size') + try: + result = self.read_in(self.path_jastrow, 'jbh_size') + finally: + self.release_lock('jastrow_jbh_size') + return result + + def set_jastrow_jbh_size(self, jbh_size): + self.acquire_lock('jastrow_jbh_size') + try: + self.write_in(self.path_jastrow, 'jbh_size', jbh_size) + finally: + self.release_lock('jastrow_jbh_size') + + jastrow_jbh_size = property(fset=set_jastrow_jbh_size, + fget=get_jastrow_jbh_size) + + def has_jastrow_jbh_size(self): + return (os.access(self.path_jastrow + '/jbh_size', os.F_OK) == 1) + + def get_jastrow_jbh_ee(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_ee') + try: + result = self.read_array_re(self.path_jastrow, 'jbh_ee', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_jbh_ee') + return result + + def set_jastrow_jbh_ee(self, jbh_ee): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_ee') + try: + self.write_array_re(self.path_jastrow, 'jbh_ee', rank, dims, + dim_max, jbh_ee) + finally: + self.release_lock('jastrow_jbh_ee') + + jastrow_jbh_ee = property(fset=set_jastrow_jbh_ee, fget=get_jastrow_jbh_ee) + + def has_jastrow_jbh_ee(self): + return (os.access(self.path_jastrow + '/jbh_ee.gz', os.F_OK) == 1) + + def get_jastrow_jbh_en(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_en') + try: + result = self.read_array_re(self.path_jastrow, 'jbh_en', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_jbh_en') + return result + + def set_jastrow_jbh_en(self, jbh_en): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_en') + try: + self.write_array_re(self.path_jastrow, 'jbh_en', rank, dims, + dim_max, jbh_en) + finally: + self.release_lock('jastrow_jbh_en') + + jastrow_jbh_en = property(fset=set_jastrow_jbh_en, fget=get_jastrow_jbh_en) + + def has_jastrow_jbh_en(self): + return (os.access(self.path_jastrow + '/jbh_en.gz', os.F_OK) == 1) + + def get_jastrow_jbh_c(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_c') + try: + result = self.read_array_re(self.path_jastrow, 'jbh_c', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jbh_c') + return result + + def set_jastrow_jbh_c(self, jbh_c): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_c') + try: + self.write_array_re(self.path_jastrow, 'jbh_c', rank, dims, + dim_max, jbh_c) + finally: + self.release_lock('jastrow_jbh_c') + + jastrow_jbh_c = property(fset=set_jastrow_jbh_c, fget=get_jastrow_jbh_c) + + def has_jastrow_jbh_c(self): + return (os.access(self.path_jastrow + '/jbh_c.gz', os.F_OK) == 1) + + def get_jastrow_jbh_m(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_m') + try: + result = self.read_array_in(self.path_jastrow, 'jbh_m', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jbh_m') + return result + + def set_jastrow_jbh_m(self, jbh_m): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_m') + try: + self.write_array_in(self.path_jastrow, 'jbh_m', rank, dims, + dim_max, jbh_m) + finally: + self.release_lock('jastrow_jbh_m') + + jastrow_jbh_m = property(fset=set_jastrow_jbh_m, fget=get_jastrow_jbh_m) + + def has_jastrow_jbh_m(self): + return (os.access(self.path_jastrow + '/jbh_m.gz', os.F_OK) == 1) + + def get_jastrow_jbh_n(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_n') + try: + result = self.read_array_in(self.path_jastrow, 'jbh_n', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jbh_n') + return result + + def set_jastrow_jbh_n(self, jbh_n): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_n') + try: + self.write_array_in(self.path_jastrow, 'jbh_n', rank, dims, + dim_max, jbh_n) + finally: + self.release_lock('jastrow_jbh_n') + + jastrow_jbh_n = property(fset=set_jastrow_jbh_n, fget=get_jastrow_jbh_n) + + def has_jastrow_jbh_n(self): + return (os.access(self.path_jastrow + '/jbh_n.gz', os.F_OK) == 1) + + def get_jastrow_jbh_o(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_o') + try: + result = self.read_array_in(self.path_jastrow, 'jbh_o', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jbh_o') + return result + + def set_jastrow_jbh_o(self, jbh_o): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jbh_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jbh_o') + try: + self.write_array_in(self.path_jastrow, 'jbh_o', rank, dims, + dim_max, jbh_o) + finally: + self.release_lock('jastrow_jbh_o') + + jastrow_jbh_o = property(fset=set_jastrow_jbh_o, fget=get_jastrow_jbh_o) + + def has_jastrow_jbh_o(self): + return (os.access(self.path_jastrow + '/jbh_o.gz', os.F_OK) == 1) + + def get_jastrow_a_boys(self): + self.acquire_lock('jastrow_a_boys') + try: + result = self.read_re(self.path_jastrow, 'a_boys') + finally: + self.release_lock('jastrow_a_boys') + return result + + def set_jastrow_a_boys(self, a_boys): + self.acquire_lock('jastrow_a_boys') + try: + self.write_re(self.path_jastrow, 'a_boys', a_boys) + finally: + self.release_lock('jastrow_a_boys') + + jastrow_a_boys = property(fset=set_jastrow_a_boys, fget=get_jastrow_a_boys) + + def has_jastrow_a_boys(self): + return (os.access(self.path_jastrow + '/a_boys', os.F_OK) == 1) + + def get_jastrow_nu_erf(self): + self.acquire_lock('jastrow_nu_erf') + try: + result = self.read_re(self.path_jastrow, 'nu_erf') + finally: + self.release_lock('jastrow_nu_erf') + return result + + def set_jastrow_nu_erf(self, nu_erf): + self.acquire_lock('jastrow_nu_erf') + try: + self.write_re(self.path_jastrow, 'nu_erf', nu_erf) + finally: + self.release_lock('jastrow_nu_erf') + + jastrow_nu_erf = property(fset=set_jastrow_nu_erf, fget=get_jastrow_nu_erf) + + def has_jastrow_nu_erf(self): + return (os.access(self.path_jastrow + '/nu_erf', os.F_OK) == 1) + + def get_jastrow_env_expo(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_env_expo') + try: + result = self.read_array_re(self.path_jastrow, 'env_expo', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_env_expo') + return result + + def set_jastrow_env_expo(self, env_expo): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_env_expo') + try: + self.write_array_re(self.path_jastrow, 'env_expo', rank, dims, + dim_max, env_expo) + finally: + self.release_lock('jastrow_env_expo') + + jastrow_env_expo = property(fset=set_jastrow_env_expo, + fget=get_jastrow_env_expo) + + def has_jastrow_env_expo(self): + return (os.access(self.path_jastrow + '/env_expo.gz', os.F_OK) == 1) + + def get_jastrow_env_coef(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_env_coef') + try: + result = self.read_array_re(self.path_jastrow, 'env_coef', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_env_coef') + return result + + def set_jastrow_env_coef(self, env_coef): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_env_coef') + try: + self.write_array_re(self.path_jastrow, 'env_coef', rank, dims, + dim_max, env_coef) + finally: + self.release_lock('jastrow_env_coef') + + jastrow_env_coef = property(fset=set_jastrow_env_coef, + fget=get_jastrow_env_coef) + + def has_jastrow_env_coef(self): + return (os.access(self.path_jastrow + '/env_coef.gz', os.F_OK) == 1) + + def get_jastrow_j1e_size(self): + self.acquire_lock('jastrow_j1e_size') + try: + result = self.read_in(self.path_jastrow, 'j1e_size') + finally: + self.release_lock('jastrow_j1e_size') + return result + + def set_jastrow_j1e_size(self, j1e_size): + self.acquire_lock('jastrow_j1e_size') + try: + self.write_in(self.path_jastrow, 'j1e_size', j1e_size) + finally: + self.release_lock('jastrow_j1e_size') + + jastrow_j1e_size = property(fset=set_jastrow_j1e_size, + fget=get_jastrow_j1e_size) + + def has_jastrow_j1e_size(self): + return (os.access(self.path_jastrow + '/j1e_size', os.F_OK) == 1) + + def get_jastrow_j1e_expo(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_j1e_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_expo') + try: + result = self.read_array_re(self.path_jastrow, 'j1e_expo', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_j1e_expo') + return result + + def set_jastrow_j1e_expo(self, j1e_expo): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_j1e_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_expo') + try: + self.write_array_re(self.path_jastrow, 'j1e_expo', rank, dims, + dim_max, j1e_expo) + finally: + self.release_lock('jastrow_j1e_expo') + + jastrow_j1e_expo = property(fset=set_jastrow_j1e_expo, + fget=get_jastrow_j1e_expo) + + def has_jastrow_j1e_expo(self): + return (os.access(self.path_jastrow + '/j1e_expo.gz', os.F_OK) == 1) + + def get_jastrow_j1e_coef(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_j1e_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_coef') + try: + result = self.read_array_re(self.path_jastrow, 'j1e_coef', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_j1e_coef') + return result + + def set_jastrow_j1e_coef(self, j1e_coef): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.jastrow_j1e_size) + dims[1] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_coef') + try: + self.write_array_re(self.path_jastrow, 'j1e_coef', rank, dims, + dim_max, j1e_coef) + finally: + self.release_lock('jastrow_j1e_coef') + + jastrow_j1e_coef = property(fset=set_jastrow_j1e_coef, + fget=get_jastrow_j1e_coef) + + def has_jastrow_j1e_coef(self): + return (os.access(self.path_jastrow + '/j1e_coef.gz', os.F_OK) == 1) + + def get_jastrow_j1e_coef_ao(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_coef_ao') + try: + result = self.read_array_re(self.path_jastrow, 'j1e_coef_ao', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_j1e_coef_ao') + return result + + def set_jastrow_j1e_coef_ao(self, j1e_coef_ao): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_coef_ao') + try: + self.write_array_re(self.path_jastrow, 'j1e_coef_ao', rank, dims, + dim_max, j1e_coef_ao) + finally: + self.release_lock('jastrow_j1e_coef_ao') + + jastrow_j1e_coef_ao = property(fset=set_jastrow_j1e_coef_ao, + fget=get_jastrow_j1e_coef_ao) + + def has_jastrow_j1e_coef_ao(self): + return (os.access(self.path_jastrow + '/j1e_coef_ao.gz', os.F_OK) == 1) + + def get_jastrow_j1e_coef_ao2(self): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_coef_ao2') + try: + result = self.read_array_re(self.path_jastrow, 'j1e_coef_ao2', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_j1e_coef_ao2') + return result + + def set_jastrow_j1e_coef_ao2(self, j1e_coef_ao2): + rank = 2 + dims = list(range(rank)) + dims[0] = int(self.ao_basis_ao_num) + dims[1] = int(self.ao_basis_ao_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_j1e_coef_ao2') + try: + self.write_array_re(self.path_jastrow, 'j1e_coef_ao2', rank, dims, + dim_max, j1e_coef_ao2) + finally: + self.release_lock('jastrow_j1e_coef_ao2') + + jastrow_j1e_coef_ao2 = property(fset=set_jastrow_j1e_coef_ao2, + fget=get_jastrow_j1e_coef_ao2) + + def has_jastrow_j1e_coef_ao2(self): + return (os.access(self.path_jastrow + '/j1e_coef_ao2.gz', + os.F_OK) == 1) + + def get_jastrow_mur_type(self): + self.acquire_lock('jastrow_mur_type') + try: + result = self.read_in(self.path_jastrow, 'mur_type') + finally: + self.release_lock('jastrow_mur_type') + return result + + def set_jastrow_mur_type(self, mur_type): + self.acquire_lock('jastrow_mur_type') + try: + self.write_in(self.path_jastrow, 'mur_type', mur_type) + finally: + self.release_lock('jastrow_mur_type') + + jastrow_mur_type = property(fset=set_jastrow_mur_type, + fget=get_jastrow_mur_type) + + def has_jastrow_mur_type(self): + return (os.access(self.path_jastrow + '/mur_type', os.F_OK) == 1) + + def get_jastrow_mu_r_ct(self): + self.acquire_lock('jastrow_mu_r_ct') + try: + result = self.read_re(self.path_jastrow, 'mu_r_ct') + finally: + self.release_lock('jastrow_mu_r_ct') + return result + + def set_jastrow_mu_r_ct(self, mu_r_ct): + self.acquire_lock('jastrow_mu_r_ct') + try: + self.write_re(self.path_jastrow, 'mu_r_ct', mu_r_ct) + finally: + self.release_lock('jastrow_mu_r_ct') + + jastrow_mu_r_ct = property(fset=set_jastrow_mu_r_ct, + fget=get_jastrow_mu_r_ct) + + def has_jastrow_mu_r_ct(self): + return (os.access(self.path_jastrow + '/mu_r_ct', os.F_OK) == 1) + + def get_jastrow_jpsi_type(self): + self.acquire_lock('jastrow_jpsi_type') + try: + result = self.read_ch(self.path_jastrow, 'jpsi_type') + finally: + self.release_lock('jastrow_jpsi_type') + return result + + def set_jastrow_jpsi_type(self, jpsi_type): + self.acquire_lock('jastrow_jpsi_type') + try: + self.write_ch(self.path_jastrow, 'jpsi_type', jpsi_type) + finally: + self.release_lock('jastrow_jpsi_type') + + jastrow_jpsi_type = property(fset=set_jastrow_jpsi_type, + fget=get_jastrow_jpsi_type) + + def has_jastrow_jpsi_type(self): + return (os.access(self.path_jastrow + '/jpsi_type', os.F_OK) == 1) + + def get_jastrow_inv_sgn_jast(self): + self.acquire_lock('jastrow_inv_sgn_jast') + try: + result = self.read_lo(self.path_jastrow, 'inv_sgn_jast') + finally: + self.release_lock('jastrow_inv_sgn_jast') + return result + + def set_jastrow_inv_sgn_jast(self, inv_sgn_jast): + self.acquire_lock('jastrow_inv_sgn_jast') + try: + self.write_lo(self.path_jastrow, 'inv_sgn_jast', inv_sgn_jast) + finally: + self.release_lock('jastrow_inv_sgn_jast') + + jastrow_inv_sgn_jast = property(fset=set_jastrow_inv_sgn_jast, + fget=get_jastrow_inv_sgn_jast) + + def has_jastrow_inv_sgn_jast(self): + return (os.access(self.path_jastrow + '/inv_sgn_jast', os.F_OK) == 1) + + def get_jastrow_jast_a_up_up(self): + self.acquire_lock('jastrow_jast_a_up_up') + try: + result = self.read_re(self.path_jastrow, 'jast_a_up_up') + finally: + self.release_lock('jastrow_jast_a_up_up') + return result + + def set_jastrow_jast_a_up_up(self, jast_a_up_up): + self.acquire_lock('jastrow_jast_a_up_up') + try: + self.write_re(self.path_jastrow, 'jast_a_up_up', jast_a_up_up) + finally: + self.release_lock('jastrow_jast_a_up_up') + + jastrow_jast_a_up_up = property(fset=set_jastrow_jast_a_up_up, + fget=get_jastrow_jast_a_up_up) + + def has_jastrow_jast_a_up_up(self): + return (os.access(self.path_jastrow + '/jast_a_up_up', os.F_OK) == 1) + + def get_jastrow_jast_a_up_dn(self): + self.acquire_lock('jastrow_jast_a_up_dn') + try: + result = self.read_re(self.path_jastrow, 'jast_a_up_dn') + finally: + self.release_lock('jastrow_jast_a_up_dn') + return result + + def set_jastrow_jast_a_up_dn(self, jast_a_up_dn): + self.acquire_lock('jastrow_jast_a_up_dn') + try: + self.write_re(self.path_jastrow, 'jast_a_up_dn', jast_a_up_dn) + finally: + self.release_lock('jastrow_jast_a_up_dn') + + jastrow_jast_a_up_dn = property(fset=set_jastrow_jast_a_up_dn, + fget=get_jastrow_jast_a_up_dn) + + def has_jastrow_jast_a_up_dn(self): + return (os.access(self.path_jastrow + '/jast_a_up_dn', os.F_OK) == 1) + + def get_jastrow_jast_b_up_up(self): + self.acquire_lock('jastrow_jast_b_up_up') + try: + result = self.read_re(self.path_jastrow, 'jast_b_up_up') + finally: + self.release_lock('jastrow_jast_b_up_up') + return result + + def set_jastrow_jast_b_up_up(self, jast_b_up_up): + self.acquire_lock('jastrow_jast_b_up_up') + try: + self.write_re(self.path_jastrow, 'jast_b_up_up', jast_b_up_up) + finally: + self.release_lock('jastrow_jast_b_up_up') + + jastrow_jast_b_up_up = property(fset=set_jastrow_jast_b_up_up, + fget=get_jastrow_jast_b_up_up) + + def has_jastrow_jast_b_up_up(self): + return (os.access(self.path_jastrow + '/jast_b_up_up', os.F_OK) == 1) + + def get_jastrow_jast_b_up_dn(self): + self.acquire_lock('jastrow_jast_b_up_dn') + try: + result = self.read_re(self.path_jastrow, 'jast_b_up_dn') + finally: + self.release_lock('jastrow_jast_b_up_dn') + return result + + def set_jastrow_jast_b_up_dn(self, jast_b_up_dn): + self.acquire_lock('jastrow_jast_b_up_dn') + try: + self.write_re(self.path_jastrow, 'jast_b_up_dn', jast_b_up_dn) + finally: + self.release_lock('jastrow_jast_b_up_dn') + + jastrow_jast_b_up_dn = property(fset=set_jastrow_jast_b_up_dn, + fget=get_jastrow_jast_b_up_dn) + + def has_jastrow_jast_b_up_dn(self): + return (os.access(self.path_jastrow + '/jast_b_up_dn', os.F_OK) == 1) + + def get_jastrow_jast_pen(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_pen') + try: + result = self.read_array_re(self.path_jastrow, 'jast_pen', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_jast_pen') + return result + + def set_jastrow_jast_pen(self, jast_pen): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_pen') + try: + self.write_array_re(self.path_jastrow, 'jast_pen', rank, dims, + dim_max, jast_pen) + finally: + self.release_lock('jastrow_jast_pen') + + jastrow_jast_pen = property(fset=set_jastrow_jast_pen, + fget=get_jastrow_jast_pen) + + def has_jastrow_jast_pen(self): + return (os.access(self.path_jastrow + '/jast_pen.gz', os.F_OK) == 1) + + def get_jastrow_jast_een_e_a(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_een_e_a') + try: + result = self.read_array_re(self.path_jastrow, 'jast_een_e_a', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_jast_een_e_a') + return result + + def set_jastrow_jast_een_e_a(self, jast_een_e_a): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_een_e_a') + try: + self.write_array_re(self.path_jastrow, 'jast_een_e_a', rank, dims, + dim_max, jast_een_e_a) + finally: + self.release_lock('jastrow_jast_een_e_a') + + jastrow_jast_een_e_a = property(fset=set_jastrow_jast_een_e_a, + fget=get_jastrow_jast_een_e_a) + + def has_jastrow_jast_een_e_a(self): + return (os.access(self.path_jastrow + '/jast_een_e_a.gz', + os.F_OK) == 1) + + def get_jastrow_jast_een_e_b(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_een_e_b') + try: + result = self.read_array_re(self.path_jastrow, 'jast_een_e_b', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_jast_een_e_b') + return result + + def set_jastrow_jast_een_e_b(self, jast_een_e_b): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_een_e_b') + try: + self.write_array_re(self.path_jastrow, 'jast_een_e_b', rank, dims, + dim_max, jast_een_e_b) + finally: + self.release_lock('jastrow_jast_een_e_b') + + jastrow_jast_een_e_b = property(fset=set_jastrow_jast_een_e_b, + fget=get_jastrow_jast_een_e_b) + + def has_jastrow_jast_een_e_b(self): + return (os.access(self.path_jastrow + '/jast_een_e_b.gz', + os.F_OK) == 1) + + def get_jastrow_jast_een_n(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_een_n') + try: + result = self.read_array_re(self.path_jastrow, 'jast_een_n', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_jast_een_n') + return result + + def set_jastrow_jast_een_n(self, jast_een_n): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_een_n') + try: + self.write_array_re(self.path_jastrow, 'jast_een_n', rank, dims, + dim_max, jast_een_n) + finally: + self.release_lock('jastrow_jast_een_n') + + jastrow_jast_een_n = property(fset=set_jastrow_jast_een_n, + fget=get_jastrow_jast_een_n) + + def has_jastrow_jast_een_n(self): + return (os.access(self.path_jastrow + '/jast_een_n.gz', os.F_OK) == 1) + + def get_jastrow_jast_core_a1(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_a1') + try: + result = self.read_array_re(self.path_jastrow, 'jast_core_a1', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_jast_core_a1') + return result + + def set_jastrow_jast_core_a1(self, jast_core_a1): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_a1') + try: + self.write_array_re(self.path_jastrow, 'jast_core_a1', rank, dims, + dim_max, jast_core_a1) + finally: + self.release_lock('jastrow_jast_core_a1') + + jastrow_jast_core_a1 = property(fset=set_jastrow_jast_core_a1, + fget=get_jastrow_jast_core_a1) + + def has_jastrow_jast_core_a1(self): + return (os.access(self.path_jastrow + '/jast_core_a1.gz', + os.F_OK) == 1) + + def get_jastrow_jast_core_a2(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_a2') + try: + result = self.read_array_re(self.path_jastrow, 'jast_core_a2', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_jast_core_a2') + return result + + def set_jastrow_jast_core_a2(self, jast_core_a2): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_a2') + try: + self.write_array_re(self.path_jastrow, 'jast_core_a2', rank, dims, + dim_max, jast_core_a2) + finally: + self.release_lock('jastrow_jast_core_a2') + + jastrow_jast_core_a2 = property(fset=set_jastrow_jast_core_a2, + fget=get_jastrow_jast_core_a2) + + def has_jastrow_jast_core_a2(self): + return (os.access(self.path_jastrow + '/jast_core_a2.gz', + os.F_OK) == 1) + + def get_jastrow_jast_core_b1(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_b1') + try: + result = self.read_array_re(self.path_jastrow, 'jast_core_b1', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_jast_core_b1') + return result + + def set_jastrow_jast_core_b1(self, jast_core_b1): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_b1') + try: + self.write_array_re(self.path_jastrow, 'jast_core_b1', rank, dims, + dim_max, jast_core_b1) + finally: + self.release_lock('jastrow_jast_core_b1') + + jastrow_jast_core_b1 = property(fset=set_jastrow_jast_core_b1, + fget=get_jastrow_jast_core_b1) + + def has_jastrow_jast_core_b1(self): + return (os.access(self.path_jastrow + '/jast_core_b1.gz', + os.F_OK) == 1) + + def get_jastrow_jast_core_b2(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_b2') + try: + result = self.read_array_re(self.path_jastrow, 'jast_core_b2', + rank, dims, dim_max) + finally: + self.release_lock('jastrow_jast_core_b2') + return result + + def set_jastrow_jast_core_b2(self, jast_core_b2): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_core_b2') + try: + self.write_array_re(self.path_jastrow, 'jast_core_b2', rank, dims, + dim_max, jast_core_b2) + finally: + self.release_lock('jastrow_jast_core_b2') + + jastrow_jast_core_b2 = property(fset=set_jastrow_jast_core_b2, + fget=get_jastrow_jast_core_b2) + + def has_jastrow_jast_core_b2(self): + return (os.access(self.path_jastrow + '/jast_core_b2.gz', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_type_nucl_num(self): + self.acquire_lock('jastrow_jast_qmckl_type_nucl_num') + try: + result = self.read_in(self.path_jastrow, + 'jast_qmckl_type_nucl_num') + finally: + self.release_lock('jastrow_jast_qmckl_type_nucl_num') + return result + + def set_jastrow_jast_qmckl_type_nucl_num(self, jast_qmckl_type_nucl_num): + self.acquire_lock('jastrow_jast_qmckl_type_nucl_num') + try: + self.write_in(self.path_jastrow, 'jast_qmckl_type_nucl_num', + jast_qmckl_type_nucl_num) + finally: + self.release_lock('jastrow_jast_qmckl_type_nucl_num') + + jastrow_jast_qmckl_type_nucl_num = property( + fset=set_jastrow_jast_qmckl_type_nucl_num, + fget=get_jastrow_jast_qmckl_type_nucl_num) + + def has_jastrow_jast_qmckl_type_nucl_num(self): + return (os.access(self.path_jastrow + '/jast_qmckl_type_nucl_num', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_type_nucl_vector(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_type_nucl_vector') + try: + result = self.read_array_in(self.path_jastrow, + 'jast_qmckl_type_nucl_vector', rank, + dims, dim_max) + finally: + self.release_lock('jastrow_jast_qmckl_type_nucl_vector') + return result + + def set_jastrow_jast_qmckl_type_nucl_vector(self, + jast_qmckl_type_nucl_vector): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.nuclei_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_type_nucl_vector') + try: + self.write_array_in(self.path_jastrow, + 'jast_qmckl_type_nucl_vector', rank, dims, + dim_max, jast_qmckl_type_nucl_vector) + finally: + self.release_lock('jastrow_jast_qmckl_type_nucl_vector') + + jastrow_jast_qmckl_type_nucl_vector = property( + fset=set_jastrow_jast_qmckl_type_nucl_vector, + fget=get_jastrow_jast_qmckl_type_nucl_vector) + + def has_jastrow_jast_qmckl_type_nucl_vector(self): + return (os.access( + self.path_jastrow + '/jast_qmckl_type_nucl_vector.gz', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_rescale_ee(self): + self.acquire_lock('jastrow_jast_qmckl_rescale_ee') + try: + result = self.read_do(self.path_jastrow, 'jast_qmckl_rescale_ee') + finally: + self.release_lock('jastrow_jast_qmckl_rescale_ee') + return result + + def set_jastrow_jast_qmckl_rescale_ee(self, jast_qmckl_rescale_ee): + self.acquire_lock('jastrow_jast_qmckl_rescale_ee') + try: + self.write_do(self.path_jastrow, 'jast_qmckl_rescale_ee', + jast_qmckl_rescale_ee) + finally: + self.release_lock('jastrow_jast_qmckl_rescale_ee') + + jastrow_jast_qmckl_rescale_ee = property( + fset=set_jastrow_jast_qmckl_rescale_ee, + fget=get_jastrow_jast_qmckl_rescale_ee) + + def has_jastrow_jast_qmckl_rescale_ee(self): + return (os.access(self.path_jastrow + '/jast_qmckl_rescale_ee', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_rescale_en(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_rescale_en') + try: + result = self.read_array_do(self.path_jastrow, + 'jast_qmckl_rescale_en', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jast_qmckl_rescale_en') + return result + + def set_jastrow_jast_qmckl_rescale_en(self, jast_qmckl_rescale_en): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_rescale_en') + try: + self.write_array_do(self.path_jastrow, 'jast_qmckl_rescale_en', + rank, dims, dim_max, jast_qmckl_rescale_en) + finally: + self.release_lock('jastrow_jast_qmckl_rescale_en') + + jastrow_jast_qmckl_rescale_en = property( + fset=set_jastrow_jast_qmckl_rescale_en, + fget=get_jastrow_jast_qmckl_rescale_en) + + def has_jastrow_jast_qmckl_rescale_en(self): + return (os.access(self.path_jastrow + '/jast_qmckl_rescale_en.gz', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_aord_num(self): + self.acquire_lock('jastrow_jast_qmckl_aord_num') + try: + result = self.read_in(self.path_jastrow, 'jast_qmckl_aord_num') + finally: + self.release_lock('jastrow_jast_qmckl_aord_num') + return result + + def set_jastrow_jast_qmckl_aord_num(self, jast_qmckl_aord_num): + self.acquire_lock('jastrow_jast_qmckl_aord_num') + try: + self.write_in(self.path_jastrow, 'jast_qmckl_aord_num', + jast_qmckl_aord_num) + finally: + self.release_lock('jastrow_jast_qmckl_aord_num') + + jastrow_jast_qmckl_aord_num = property( + fset=set_jastrow_jast_qmckl_aord_num, + fget=get_jastrow_jast_qmckl_aord_num) + + def has_jastrow_jast_qmckl_aord_num(self): + return (os.access(self.path_jastrow + '/jast_qmckl_aord_num', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_bord_num(self): + self.acquire_lock('jastrow_jast_qmckl_bord_num') + try: + result = self.read_in(self.path_jastrow, 'jast_qmckl_bord_num') + finally: + self.release_lock('jastrow_jast_qmckl_bord_num') + return result + + def set_jastrow_jast_qmckl_bord_num(self, jast_qmckl_bord_num): + self.acquire_lock('jastrow_jast_qmckl_bord_num') + try: + self.write_in(self.path_jastrow, 'jast_qmckl_bord_num', + jast_qmckl_bord_num) + finally: + self.release_lock('jastrow_jast_qmckl_bord_num') + + jastrow_jast_qmckl_bord_num = property( + fset=set_jastrow_jast_qmckl_bord_num, + fget=get_jastrow_jast_qmckl_bord_num) + + def has_jastrow_jast_qmckl_bord_num(self): + return (os.access(self.path_jastrow + '/jast_qmckl_bord_num', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_cord_num(self): + self.acquire_lock('jastrow_jast_qmckl_cord_num') + try: + result = self.read_in(self.path_jastrow, 'jast_qmckl_cord_num') + finally: + self.release_lock('jastrow_jast_qmckl_cord_num') + return result + + def set_jastrow_jast_qmckl_cord_num(self, jast_qmckl_cord_num): + self.acquire_lock('jastrow_jast_qmckl_cord_num') + try: + self.write_in(self.path_jastrow, 'jast_qmckl_cord_num', + jast_qmckl_cord_num) + finally: + self.release_lock('jastrow_jast_qmckl_cord_num') + + jastrow_jast_qmckl_cord_num = property( + fset=set_jastrow_jast_qmckl_cord_num, + fget=get_jastrow_jast_qmckl_cord_num) + + def has_jastrow_jast_qmckl_cord_num(self): + return (os.access(self.path_jastrow + '/jast_qmckl_cord_num', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_a_vector(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num * + self.jastrow_jast_qmckl_aord_num + + self.jastrow_jast_qmckl_type_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_a_vector') + try: + result = self.read_array_do(self.path_jastrow, + 'jast_qmckl_a_vector', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jast_qmckl_a_vector') + return result + + def set_jastrow_jast_qmckl_a_vector(self, jast_qmckl_a_vector): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_type_nucl_num * + self.jastrow_jast_qmckl_aord_num + + self.jastrow_jast_qmckl_type_nucl_num) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_a_vector') + try: + self.write_array_do(self.path_jastrow, 'jast_qmckl_a_vector', rank, + dims, dim_max, jast_qmckl_a_vector) + finally: + self.release_lock('jastrow_jast_qmckl_a_vector') + + jastrow_jast_qmckl_a_vector = property( + fset=set_jastrow_jast_qmckl_a_vector, + fget=get_jastrow_jast_qmckl_a_vector) + + def has_jastrow_jast_qmckl_a_vector(self): + return (os.access(self.path_jastrow + '/jast_qmckl_a_vector.gz', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_b_vector(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_bord_num + 1) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_b_vector') + try: + result = self.read_array_do(self.path_jastrow, + 'jast_qmckl_b_vector', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jast_qmckl_b_vector') + return result + + def set_jastrow_jast_qmckl_b_vector(self, jast_qmckl_b_vector): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_bord_num + 1) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_b_vector') + try: + self.write_array_do(self.path_jastrow, 'jast_qmckl_b_vector', rank, + dims, dim_max, jast_qmckl_b_vector) + finally: + self.release_lock('jastrow_jast_qmckl_b_vector') + + jastrow_jast_qmckl_b_vector = property( + fset=set_jastrow_jast_qmckl_b_vector, + fget=get_jastrow_jast_qmckl_b_vector) + + def has_jastrow_jast_qmckl_b_vector(self): + return (os.access(self.path_jastrow + '/jast_qmckl_b_vector.gz', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_c_vector_size(self): + self.acquire_lock('jastrow_jast_qmckl_c_vector_size') + try: + result = self.read_in(self.path_jastrow, + 'jast_qmckl_c_vector_size') + finally: + self.release_lock('jastrow_jast_qmckl_c_vector_size') + return result + + def set_jastrow_jast_qmckl_c_vector_size(self, jast_qmckl_c_vector_size): + self.acquire_lock('jastrow_jast_qmckl_c_vector_size') + try: + self.write_in(self.path_jastrow, 'jast_qmckl_c_vector_size', + jast_qmckl_c_vector_size) + finally: + self.release_lock('jastrow_jast_qmckl_c_vector_size') + + jastrow_jast_qmckl_c_vector_size = property( + fset=set_jastrow_jast_qmckl_c_vector_size, + fget=get_jastrow_jast_qmckl_c_vector_size) + + def has_jastrow_jast_qmckl_c_vector_size(self): + return (os.access(self.path_jastrow + '/jast_qmckl_c_vector_size', + os.F_OK) == 1) + + def get_jastrow_jast_qmckl_c_vector(self): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_c_vector_size) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_c_vector') + try: + result = self.read_array_do(self.path_jastrow, + 'jast_qmckl_c_vector', rank, dims, + dim_max) + finally: + self.release_lock('jastrow_jast_qmckl_c_vector') + return result + + def set_jastrow_jast_qmckl_c_vector(self, jast_qmckl_c_vector): + rank = 1 + dims = list(range(rank)) + dims[0] = int(self.jastrow_jast_qmckl_c_vector_size) + + dim_max = 1 + for d in dims: + dim_max *= d + self.acquire_lock('jastrow_jast_qmckl_c_vector') + try: + self.write_array_do(self.path_jastrow, 'jast_qmckl_c_vector', rank, + dims, dim_max, jast_qmckl_c_vector) + finally: + self.release_lock('jastrow_jast_qmckl_c_vector') + + jastrow_jast_qmckl_c_vector = property( + fset=set_jastrow_jast_qmckl_c_vector, + fget=get_jastrow_jast_qmckl_c_vector) + + def has_jastrow_jast_qmckl_c_vector(self): + return (os.access(self.path_jastrow + '/jast_qmckl_c_vector.gz', + os.F_OK) == 1) + + def read_i8(self, dir, fil): + conv = get_conv('i8') + l_filename = dir.strip() + '/' + fil + try: + file = open(l_filename, 'r') + except IOError: + self.error('read_i8', + 'Attribute ' + dir.strip() + '/' + fil + ' is not set') + dat = file.readline().strip() + try: + dat = conv(dat) + except SyntaxError: + pass + file.close() + return dat + + def write_i8(self, dir, fil, dat): + if self.read_only: + self.error('Read-only file.') + conv = get_conv('i8') + l_filename = [dir.strip() + '/.' + fil] + l_filename += [dir.strip() + '/' + fil] + dat = conv(dat) + file = open(l_filename[0], 'w') + print('%20d' % (dat, ), file=file) + file.close() + os.rename(l_filename[0], l_filename[1]) + + def read_array_i8(self, dir, fil, rank, dims, dim_max): + l_filename = dir.strip() + '/' + fil + '.gz' + conv = get_conv('i8') + try: + file = GzipFile(filename=l_filename, mode='rb') + lines = file.read().splitlines() + rank_read = int(lines[0]) + assert (rank_read == rank) + + dims_read = map(int, lines[1].split()) + + for i, j in zip(dims_read, dims): + assert i == j + + lines.pop(0) + lines.pop(0) + dat = map(conv, lines) + + file.close() + return reshape(dat, dims) + + except IOError: + self.error('read_array_i8', + 'Attribute ' + l_filename + ' is not set') + + def write_array_i8(self, dir, fil, rank, dims, dim_max, dat): + if self.read_only: + self.error('Read-only file.') + l_filename = [ + tempfile.mktemp(dir=dir.strip()), + dir.strip() + '/' + fil + '.gz' + ] + try: + file = StringIO.StringIO() + file.write('%3d\n' % (rank, )) + for d in dims: + file.write('%20d ' % (d, )) + file.write('\n') + + dat = flatten(dat) + for i in range(dim_max): + file.write('%20d\n' % (dat[i], )) + file.flush() + buffer = file.getvalue() + file.close() + file = GzipFile(filename=l_filename[0], mode='wb') + file.write(buffer.encode()) + file.close() + os.rename(l_filename[0], l_filename[1]) + except: + self.error('write_array_i8', 'Unable to write ' + l_filename[1]) + + def read_in(self, dir, fil): + conv = get_conv('in') + l_filename = dir.strip() + '/' + fil + try: + file = open(l_filename, 'r') + except IOError: + self.error('read_in', + 'Attribute ' + dir.strip() + '/' + fil + ' is not set') + dat = file.readline().strip() + try: + dat = conv(dat) + except SyntaxError: + pass + file.close() + return dat + + def write_in(self, dir, fil, dat): + if self.read_only: + self.error('Read-only file.') + conv = get_conv('in') + l_filename = [dir.strip() + '/.' + fil] + l_filename += [dir.strip() + '/' + fil] + dat = conv(dat) + file = open(l_filename[0], 'w') + print('%20d' % (dat, ), file=file) + file.close() + os.rename(l_filename[0], l_filename[1]) + + def read_array_in(self, dir, fil, rank, dims, dim_max): + l_filename = dir.strip() + '/' + fil + '.gz' + conv = get_conv('in') + try: + file = GzipFile(filename=l_filename, mode='rb') + lines = file.read().splitlines() + rank_read = int(lines[0]) + assert (rank_read == rank) + + dims_read = map(int, lines[1].split()) + + for i, j in zip(dims_read, dims): + assert i == j + + lines.pop(0) + lines.pop(0) + dat = map(conv, lines) + + file.close() + return reshape(dat, dims) + + except IOError: + self.error('read_array_in', + 'Attribute ' + l_filename + ' is not set') + + def write_array_in(self, dir, fil, rank, dims, dim_max, dat): + if self.read_only: + self.error('Read-only file.') + l_filename = [ + tempfile.mktemp(dir=dir.strip()), + dir.strip() + '/' + fil + '.gz' + ] + try: + file = StringIO.StringIO() + file.write('%3d\n' % (rank, )) + for d in dims: + file.write('%20d ' % (d, )) + file.write('\n') + + dat = flatten(dat) + for i in range(dim_max): + file.write('%20d\n' % (dat[i], )) + file.flush() + buffer = file.getvalue() + file.close() + file = GzipFile(filename=l_filename[0], mode='wb') + file.write(buffer.encode()) + file.close() + os.rename(l_filename[0], l_filename[1]) + except: + self.error('write_array_in', 'Unable to write ' + l_filename[1]) + + def read_re(self, dir, fil): + conv = get_conv('re') + l_filename = dir.strip() + '/' + fil + try: + file = open(l_filename, 'r') + except IOError: + self.error('read_re', + 'Attribute ' + dir.strip() + '/' + fil + ' is not set') + dat = file.readline().strip() + try: + dat = conv(dat) + except SyntaxError: + pass + file.close() + return dat + + def write_re(self, dir, fil, dat): + if self.read_only: + self.error('Read-only file.') + conv = get_conv('re') + l_filename = [dir.strip() + '/.' + fil] + l_filename += [dir.strip() + '/' + fil] + dat = conv(dat) + file = open(l_filename[0], 'w') + print('%24.15E' % (dat, ), file=file) + file.close() + os.rename(l_filename[0], l_filename[1]) + + def read_array_re(self, dir, fil, rank, dims, dim_max): + l_filename = dir.strip() + '/' + fil + '.gz' + conv = get_conv('re') + try: + file = GzipFile(filename=l_filename, mode='rb') + lines = file.read().splitlines() + rank_read = int(lines[0]) + assert (rank_read == rank) + + dims_read = map(int, lines[1].split()) + + for i, j in zip(dims_read, dims): + assert i == j + + lines.pop(0) + lines.pop(0) + dat = map(conv, lines) + + file.close() + return reshape(dat, dims) + + except IOError: + self.error('read_array_re', + 'Attribute ' + l_filename + ' is not set') + + def write_array_re(self, dir, fil, rank, dims, dim_max, dat): + if self.read_only: + self.error('Read-only file.') + l_filename = [ + tempfile.mktemp(dir=dir.strip()), + dir.strip() + '/' + fil + '.gz' + ] + try: + file = StringIO.StringIO() + file.write('%3d\n' % (rank, )) + for d in dims: + file.write('%20d ' % (d, )) + file.write('\n') + + dat = flatten(dat) + for i in range(dim_max): + file.write('%24.15E\n' % (dat[i], )) + file.flush() + buffer = file.getvalue() + file.close() + file = GzipFile(filename=l_filename[0], mode='wb') + file.write(buffer.encode()) + file.close() + os.rename(l_filename[0], l_filename[1]) + except: + self.error('write_array_re', 'Unable to write ' + l_filename[1]) + + def read_do(self, dir, fil): + conv = get_conv('do') + l_filename = dir.strip() + '/' + fil + try: + file = open(l_filename, 'r') + except IOError: + self.error('read_do', + 'Attribute ' + dir.strip() + '/' + fil + ' is not set') + dat = file.readline().strip() + try: + dat = conv(dat) + except SyntaxError: + pass + file.close() + return dat + + def write_do(self, dir, fil, dat): + if self.read_only: + self.error('Read-only file.') + conv = get_conv('do') + l_filename = [dir.strip() + '/.' + fil] + l_filename += [dir.strip() + '/' + fil] + dat = conv(dat) + file = open(l_filename[0], 'w') + print('%24.15E' % (dat, ), file=file) + file.close() + os.rename(l_filename[0], l_filename[1]) + + def read_array_do(self, dir, fil, rank, dims, dim_max): + l_filename = dir.strip() + '/' + fil + '.gz' + conv = get_conv('do') + try: + file = GzipFile(filename=l_filename, mode='rb') + lines = file.read().splitlines() + rank_read = int(lines[0]) + assert (rank_read == rank) + + dims_read = map(int, lines[1].split()) + + for i, j in zip(dims_read, dims): + assert i == j + + lines.pop(0) + lines.pop(0) + dat = map(conv, lines) + + file.close() + return reshape(dat, dims) + + except IOError: + self.error('read_array_do', + 'Attribute ' + l_filename + ' is not set') + + def write_array_do(self, dir, fil, rank, dims, dim_max, dat): + if self.read_only: + self.error('Read-only file.') + l_filename = [ + tempfile.mktemp(dir=dir.strip()), + dir.strip() + '/' + fil + '.gz' + ] + try: + file = StringIO.StringIO() + file.write('%3d\n' % (rank, )) + for d in dims: + file.write('%20d ' % (d, )) + file.write('\n') + + dat = flatten(dat) + for i in range(dim_max): + file.write('%24.15E\n' % (dat[i], )) + file.flush() + buffer = file.getvalue() + file.close() + file = GzipFile(filename=l_filename[0], mode='wb') + file.write(buffer.encode()) + file.close() + os.rename(l_filename[0], l_filename[1]) + except: + self.error('write_array_do', 'Unable to write ' + l_filename[1]) + + def read_lo(self, dir, fil): + conv = get_conv('lo') + l_filename = dir.strip() + '/' + fil + try: + file = open(l_filename, 'r') + except IOError: + self.error('read_lo', + 'Attribute ' + dir.strip() + '/' + fil + ' is not set') + dat = file.readline().strip() + try: + dat = conv(dat) + except SyntaxError: + pass + file.close() + return dat + + def write_lo(self, dir, fil, dat): + if self.read_only: + self.error('Read-only file.') + conv = get_conv('lo') + l_filename = [dir.strip() + '/.' + fil] + l_filename += [dir.strip() + '/' + fil] + dat = conv(dat) + file = open(l_filename[0], 'w') + print('%c' % (dat, ), file=file) + file.close() + os.rename(l_filename[0], l_filename[1]) + + def read_array_lo(self, dir, fil, rank, dims, dim_max): + l_filename = dir.strip() + '/' + fil + '.gz' + conv = get_conv('lo') + try: + file = GzipFile(filename=l_filename, mode='rb') + lines = file.read().splitlines() + rank_read = int(lines[0]) + assert (rank_read == rank) + + dims_read = map(int, lines[1].split()) + + for i, j in zip(dims_read, dims): + assert i == j + + lines.pop(0) + lines.pop(0) + dat = map(conv, lines) + + file.close() + return reshape(dat, dims) + + except IOError: + self.error('read_array_lo', + 'Attribute ' + l_filename + ' is not set') + + def write_array_lo(self, dir, fil, rank, dims, dim_max, dat): + if self.read_only: + self.error('Read-only file.') + l_filename = [ + tempfile.mktemp(dir=dir.strip()), + dir.strip() + '/' + fil + '.gz' + ] + try: + file = StringIO.StringIO() + file.write('%3d\n' % (rank, )) + for d in dims: + file.write('%20d ' % (d, )) + file.write('\n') + + dat = flatten(dat) + for i in range(dim_max): + file.write('%c\n' % (dat[i], )) + file.flush() + buffer = file.getvalue() + file.close() + file = GzipFile(filename=l_filename[0], mode='wb') + file.write(buffer.encode()) + file.close() + os.rename(l_filename[0], l_filename[1]) + except: + self.error('write_array_lo', 'Unable to write ' + l_filename[1]) + + def read_ch(self, dir, fil): + conv = get_conv('ch') + l_filename = dir.strip() + '/' + fil + try: + file = open(l_filename, 'r') + except IOError: + self.error('read_ch', + 'Attribute ' + dir.strip() + '/' + fil + ' is not set') + dat = file.readline().strip() + try: + dat = conv(dat) + except SyntaxError: + pass + file.close() + return dat + + def write_ch(self, dir, fil, dat): + if self.read_only: + self.error('Read-only file.') + conv = get_conv('ch') + l_filename = [dir.strip() + '/.' + fil] + l_filename += [dir.strip() + '/' + fil] + dat = conv(dat) + file = open(l_filename[0], 'w') + print('%s' % (dat, ), file=file) + file.close() + os.rename(l_filename[0], l_filename[1]) + + def read_array_ch(self, dir, fil, rank, dims, dim_max): + l_filename = dir.strip() + '/' + fil + '.gz' + conv = get_conv('ch') + try: + file = GzipFile(filename=l_filename, mode='rb') + lines = file.read().splitlines() + rank_read = int(lines[0]) + assert (rank_read == rank) + + dims_read = map(int, lines[1].split()) + + for i, j in zip(dims_read, dims): + assert i == j + + lines.pop(0) + lines.pop(0) + dat = map(conv, lines) + + file.close() + return reshape(dat, dims) + + except IOError: + self.error('read_array_ch', + 'Attribute ' + l_filename + ' is not set') + + def write_array_ch(self, dir, fil, rank, dims, dim_max, dat): + if self.read_only: + self.error('Read-only file.') + l_filename = [ + tempfile.mktemp(dir=dir.strip()), + dir.strip() + '/' + fil + '.gz' + ] + try: + file = StringIO.StringIO() + file.write('%3d\n' % (rank, )) + for d in dims: + file.write('%20d ' % (d, )) + file.write('\n') + + dat = flatten(dat) + for i in range(dim_max): + file.write('%s\n' % (dat[i], )) + file.flush() + buffer = file.getvalue() + file.close() + file = GzipFile(filename=l_filename[0], mode='wb') + file.write(buffer.encode()) + file.close() + os.rename(l_filename[0], l_filename[1]) + except: + self.error('write_array_ch', 'Unable to write ' + l_filename[1]) + + LIBRARY = '/home/addman/Software/EZFIO/' - def write_array_ch(self,dir,fil,rank,dims,dim_max,dat): - if self.read_only: - self.error('Read-only file.') - l_filename = [ tempfile.mktemp(dir=dir.strip()), dir.strip()+'/'+fil+'.gz' ] - try: - file = StringIO.StringIO() - file.write("%3d\n"%(rank,)) - for d in dims: - file.write("%20d "%(d,)) - file.write("\n") - - dat = flatten(dat) - for i in range(dim_max): - file.write("%s\n"%(dat[i],)) - file.flush() - buffer = file.getvalue() - file.close() - file = GzipFile(filename=l_filename[0],mode='wb') - file.write(buffer.encode()) - file.close() - os.rename(l_filename[0],l_filename[1]) - except: - self.error("write_array_ch", - "Unable to write "+l_filename[1]) - - - LIBRARY = "/home/addman/Software/EZFIO/" # EZFIO is an automatic generator of I/O libraries # Copyright (C) 2009 Anthony SCEMAMA, CNRS @@ -2548,69 +2678,67 @@ def write_array_ch(self,dir,fil,rank,dims,dim_max,dat): # Anthony Scemama # LCPQ - IRSAMC - CNRS # Universite Paul Sabatier -# 118, route de Narbonne -# 31062 Toulouse Cedex 4 +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 # scemama@irsamc.ups-tlse.fr ezfio = ezfio_obj() -def main(): - import pprint - import sys - import os - - try: - EZFIO_FILE = os.environ["EZFIO_FILE"] - except KeyError: - print("EZFIO_FILE not defined") - return 1 - - ezfio.set_file(EZFIO_FILE) - - command = '_'.join(sys.argv[1:]).lower() - - try: - f = getattr(ezfio,command) - except AttributeError: - print("{0} not found".format(command)) - return 1 - - if command.startswith('has'): - if f(): return 0 - else : return 1 - - elif command.startswith('get'): - result = f() - pprint.pprint( result, width=60, depth=3, indent=4 ) - return 0 - - elif command.startswith('set'): - text = sys.stdin.read() - true = True - false = False - TRUE = True - FALSE = False - T = True - F = False - try: - data = eval(text) - except NameError: - data = text - except: - print("Syntax Error") - return 1 - if data is None: - data = "None" - f(data) - return 0 - - else: - return 1 - -if __name__ == '__main__': - rc = main() - sys.exit(rc) +def main(): + import pprint + import sys + import os + + try: + EZFIO_FILE = os.environ['EZFIO_FILE'] + except KeyError: + print('EZFIO_FILE not defined') + return 1 + + ezfio.set_file(EZFIO_FILE) + + command = '_'.join(sys.argv[1:]).lower() + + try: + f = getattr(ezfio, command) + except AttributeError: + print('{0} not found'.format(command)) + return 1 + + if command.startswith('has'): + if f(): return 0 + else: return 1 + + elif command.startswith('get'): + result = f() + pprint.pprint(result, width=60, depth=3, indent=4) + return 0 + + elif command.startswith('set'): + text = sys.stdin.read() + true = True + false = False + TRUE = True + FALSE = False + T = True + F = False + try: + data = eval(text) + except NameError: + data = text + except: + print('Syntax Error') + return 1 + if data is None: + data = 'None' + f(data) + return 0 + else: + return 1 +if __name__ == '__main__': + rc = main() + sys.exit(rc) diff --git a/aiida_qp2/utils/jast_opt.py b/aiida_qp2/utils/jast_opt.py index 4934489..29d87ee 100644 --- a/aiida_qp2/utils/jast_opt.py +++ b/aiida_qp2/utils/jast_opt.py @@ -17,8 +17,8 @@ Calculation = CalculationFactory('qp2.run') -class JastOpt(): +class JastOpt(): def __init__(self, wavefunction: SinglefileData, code: Code, @@ -50,6 +50,5 @@ def run(self, parameters: dict): def set_parameters(self, parameters): operation = self.parameter_setter(parameters) - self.wavefunction = wavefunction_handler(self._wavefunction, operation)["wavefunction"] - - + self.wavefunction = wavefunction_handler(self._wavefunction, + operation)['wavefunction'] diff --git a/aiida_qp2/utils/wavefunction_handler.py b/aiida_qp2/utils/wavefunction_handler.py index 345ae27..ab47690 100644 --- a/aiida_qp2/utils/wavefunction_handler.py +++ b/aiida_qp2/utils/wavefunction_handler.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - """ This module contains the wavefunction handler funcion """ @@ -11,13 +10,14 @@ import tarfile import os + @calcfunction def wavefunction_handler(wavefunction, operations): """ This function handles the wavefunction """ - _WF_NAME = "wavefunction.wf.tar.gz" + _WF_NAME = 'wavefunction.wf.tar.gz' changed = False data = [] @@ -30,29 +30,28 @@ def wavefunction_handler(wavefunction, operations): # untar the wavefunction with tarfile.open(wf_path, 'r:gz') as tar: tar.extractall(temp_dir) - ezfio_path = os.path.join(temp_dir, "aiida.ezfio") + ezfio_path = os.path.join(temp_dir, 'aiida.ezfio') ezfio.set_file(ezfio_path) for t, k, v in operations.get_list(): - if t == "get": - method = getattr(ezfio, f"{t}_{k}", None) + if t == 'get': + method = getattr(ezfio, f'{t}_{k}', None) if method: data.append([k, method()]) - if t == "set": - method = getattr(ezfio, f"{t}_{k}", None) + if t == 'set': + method = getattr(ezfio, f'{t}_{k}', None) if method: method(v) changed = True if changed: with tarfile.open(wf_path, 'w:gz') as tar: - tar.add(ezfio_path, arcname="aiida.ezfio") + tar.add(ezfio_path, arcname='aiida.ezfio') with open(wf_path, 'rb') as handle: wavefunction = SinglefileData(file=handle) - - ret = {"data": List(list=data)} + ret = {'data': List(list=data)} if changed: - ret["wavefunction"] = wavefunction - wavefunction.base.attributes.all["wavefunction"] = True + ret['wavefunction'] = wavefunction + wavefunction.base.attributes.all['wavefunction'] = True return ret diff --git a/examples/jast_opt.py b/examples/jast_opt.py index 213fedd..e8ebc45 100644 --- a/examples/jast_opt.py +++ b/examples/jast_opt.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import numpy as np from aiida.plugins import DataFactory, CalculationFactory @@ -15,11 +16,10 @@ Calculation = CalculationFactory('qp2.run') - load_profile() -class JastOpt(): +class JastOpt(): def __init__(self, wavefunction: SinglefileData, code: Code, @@ -51,23 +51,24 @@ def run(self, parameters: dict): def set_parameters(self, parameters): operation = self.parameter_setter(parameters) - self.wavefunction = wavefunction_handler(self._wavefunction, operation)["wavefunction"] - + self.wavefunction = wavefunction_handler(self._wavefunction, + operation)['wavefunction'] - -if __name__ == "__main__": +if __name__ == '__main__': def p_setter(x): x = np.abs(x[0]) - operation = [ ["set", "jastrow_jast_b_up_up", x ], - ["set", "jastrow_jast_b_up_dn", x ], - ] + operation = [ + ['set', 'jastrow_jast_b_up_up', x], + ['set', 'jastrow_jast_b_up_dn', x], + ] return List(operation) + wf = load_node(779) code = load_code('qmc-docker-new@bobor2') - prepend = ["-t 60", "-l 10"] + prepend = ['-t 60', '-l 10'] jast = JastOpt(wavefunction=wf, code=code, parameter_setter=p_setter, @@ -76,11 +77,9 @@ def p_setter(x): data = [] for x in np.linspace(0.001, 0.012, 5): print(x) - data.append([ x.value for x in jast.run((x,))]) + data.append([x.value for x in jast.run((x, ))]) print(data[-1]) import pickle with open('jast_opt.pickle', 'wb') as f: pickle.dump(data, f) - - diff --git a/test/data/H2.xyz b/test/data/H2.xyz index 7a02f43..33052a5 100644 --- a/test/data/H2.xyz +++ b/test/data/H2.xyz @@ -1,4 +1,4 @@ 2 -H 0.0 0.0 0.0 -H 0.7 0.0 0.0 +H 0.0 0.0 0.0 +H 0.7 0.0 0.0 diff --git a/test/test_create.py b/test/test_create.py index b1c0890..b758796 100644 --- a/test/test_create.py +++ b/test/test_create.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - """ Testing the QPCreate class and its parser """ @@ -9,6 +8,7 @@ from pathlib import Path DATA_DIR = Path(__file__).resolve().parent / 'data' + @pytest.mark.filterwarnings('ignore:Creating AiiDA') def test_create(aiida_profile_clean): from aiida.orm import StructureData, Dict, QueryBuilder, Code @@ -41,8 +41,8 @@ def test_create(aiida_profile_clean): # get code code = Calc.get_code() - calc = Calc(inputs={'structure': structure, - 'parameters': parameters, - 'code': code}) - - + calc = Calc(inputs={ + 'structure': structure, + 'parameters': parameters, + 'code': code + })