def report_running(node): print(get_workchain_report(node, 'REPORT')) desc = list(node.called_descendants) if not len(desc): print('_____________________________________ NO CALLED DESC') return desc.sort(key=lambda x: x.pk) last = desc[-1] if not isinstance(last, orm.CalcJobNode): print('_____________________________________ NO CALCJOB') return try: remote = last.outputs.remote_folder except: print('_____________________________________ NO REMOTE YET!!!') return pc = last.process_class files = remote.listdir() if pc._DEFAULT_OUTPUT_FILE not in files: print('_____________________________________ IN QUEUE') else: print('_____________________________________ RUNNING')
def test_fleur_scf_non_convergence(run_with_cache, clear_database, fleur_local_code, inpgen_local_code, generate_structure2, clear_spec): """ Full regression test of FleurScfWorkchain starting with a crystal structure and parameters Check if calc parameters are given through, check if wf default parameters are updated """ # prepare input nodes and dicts options = { 'resources': { 'num_machines': 1, 'num_mpiprocs_per_machine': 1 }, 'max_wallclock_seconds': 5 * 60, 'withmpi': False, 'custom_scheduler_commands': '' } FleurCode = fleur_local_code InpgenCode = inpgen_local_code wf_parameters = {'add_comp_para': {'serial': True}, 'itmax_per_run': 3} calc_parameters = { 'atom': { 'element': 'Si', 'rmt': 2.1, 'jri': 981, 'lmax': 8, 'lnonsph': 6 }, 'comp': { 'kmax': 3.4 }, 'kpt': { 'div1': 10, 'div2': 10, 'div3': 10, 'tkb': 0.0005 } } # create process builder to set parameters builder = FleurScfWorkChain.get_builder() builder.metadata.description = 'Simple Fleur SCF test for Si bulk which does not converge' builder.metadata.label = 'FleurSCF_test_Si_bulk' builder.structure = generate_structure2().store() builder.options = Dict(dict=options).store() builder.calc_parameters = Dict(dict=calc_parameters).store() builder.wf_parameters = Dict(dict=wf_parameters).store() builder.fleur = FleurCode.store() builder.inpgen = InpgenCode.store() print(builder) # now run scf with cache fixture out, node = run_with_cache(builder) print(out) print(node) print(get_workchain_report(node, 'REPORT')) assert not node.is_finished_ok assert node.exit_status == 362
def test_run_prop_mgo_no_scf(db_test_app, sanitise_calc_attr, data_regression): """Test the workchains when a folder is supplied that contains the wavefunction file.""" clear_spec() wc_builder = CryPropertiesWorkChain.get_builder() with open_resource_binary("doss", "mgo_sto3g_scf", "fort.9") as handle: wc_builder.wf_folder = SinglefileData(handle) wc_builder.doss.code = db_test_app.get_or_create_code("crystal17.doss") wc_builder.doss.parameters = get_parameters()["doss"] wc_builder.doss.metadata = db_test_app.get_default_metadata() wc_builder.ech3.code = db_test_app.get_or_create_code("crystal17.ech3") wc_builder.ech3.parameters = get_parameters()["ech3"] wc_builder.ech3.metadata = db_test_app.get_default_metadata() outputs, wc_node = run_get_node(wc_builder) sys.stderr.write(get_workchain_report(wc_node, "REPORT")) wk_attributes = sanitise_calc_attr(wc_node.attributes) data_regression.check({ "calc_node": wk_attributes, "incoming": sorted(wc_node.get_incoming().all_link_labels()), "outgoing": sorted(wc_node.get_outgoing().all_link_labels()), # "results": outputs["results"].attributes })
def test_fleur_scf_fleurinp_Si( #run_with_cache, with_export_cache, fleur_local_code, create_fleurinp, clear_database, clear_spec): """ full example using scf workflow with just a fleurinp data as input. Several fleur runs needed till convergence """ options = { 'resources': { 'num_machines': 1, 'num_mpiprocs_per_machine': 1 }, 'max_wallclock_seconds': 5 * 60, 'withmpi': False, 'custom_scheduler_commands': '' } FleurCode = fleur_local_code # create process builder to set parameters builder = FleurScfWorkChain.get_builder() builder.metadata.description = 'Simple Fleur SCF test for Si bulk with fleurinp data given' builder.metadata.label = 'FleurSCF_test_Si_bulk' builder.fleurinp = create_fleurinp(TEST_INP_XML_PATH).store() builder.options = Dict(dict=options).store() builder.fleur = FleurCode #print(builder) # now run calculation #run_with_cache(builder) data_dir_path = os.path.join( aiida_path, '../tests/workflows/caches/fleur_scf_fleurinp_Si.tar.gz') with with_export_cache(data_dir_abspath=data_dir_path): out, node = run_get_node(builder) #print(out) #print(node) print(get_workchain_report(node, 'REPORT')) #assert node.is_finished_ok # check output n = out['output_scf_wc_para'] n = n.get_dict() print(get_calcjob_report(load_node(n['last_calc_uuid']))) #print(n) assert abs(n.get('distance_charge') - 9.8993e-06) < 2.0e-6 assert n.get('errors') == []
def update(self): """Update report that is shown.""" if self.process is None: return if isinstance(self.process, CalcJobNode): string = get_calcjob_report(self.process) elif isinstance(self.process, WorkChainNode): string = get_workchain_report(self.process, self.levelname, self.indent_size, self.max_depth) elif isinstance(self.process, (CalcFunctionNode, WorkFunctionNode)): string = get_process_function_report(self.process) else: string = 'Nothing to show for node type {}'.format(self.process.__class__) self.value = string.replace('\n', '<br/>')
def process_report(processes, levelname, indent_size, max_depth): """Show the log report for one or multiple processes.""" from aiida.cmdline.utils.common import get_calcjob_report, get_workchain_report, get_process_function_report from aiida.orm import CalcJobNode, WorkChainNode, CalcFunctionNode, WorkFunctionNode for process in processes: if isinstance(process, CalcJobNode): echo.echo(get_calcjob_report(process)) elif isinstance(process, WorkChainNode): echo.echo( get_workchain_report(process, levelname, indent_size, max_depth)) elif isinstance(process, (CalcFunctionNode, WorkFunctionNode)): echo.echo(get_process_function_report(process)) else: echo.echo(f'Nothing to show for node type {process.__class__}')
def do_report(self, arg): # pylint: disable=unused-argument """Show the report, if the node is a ProcessNode""" from aiida.cmdline.utils.common import get_calcjob_report, get_workchain_report, get_process_function_report from aiida.orm import CalcJobNode, WorkChainNode, CalcFunctionNode, WorkFunctionNode process = self._current_node if isinstance(process, CalcJobNode): print(get_calcjob_report(process), file=self.stdout) elif isinstance(process, WorkChainNode): print(get_workchain_report(process, arg.levelname, arg.indent_size, arg.max_depth), file=self.stdout) elif isinstance(process, (CalcFunctionNode, WorkFunctionNode)): print(get_process_function_report(process), file=self.stdout) else: print('Nothing to show for node type {}'.format(process.__class__), file=self.stdout)
def test_run_prop_mgo_with_scf( db_test_app, get_structure_and_symm, upload_basis_set_family, sanitise_calc_attr, data_regression, ): """Test the workchains when computation inputs are supplied to calculate the wavefunction.""" clear_spec() wc_builder = CryPropertiesWorkChain.get_builder() structure, symmetry = get_structure_and_symm("MgO") wc_builder.scf.code = db_test_app.get_or_create_code("crystal17.main") wc_builder.scf.structure = structure wc_builder.scf.symmetry = symmetry wc_builder.scf.parameters = get_parameters()["scf"] wc_builder.scf.basissets = { k: v for k, v in upload_basis_set_family().items() if k in ["Mg", "O"] } wc_builder.scf.metadata = db_test_app.get_default_metadata() wc_builder.doss.code = db_test_app.get_or_create_code("crystal17.doss") wc_builder.doss.parameters = get_parameters()["doss"] wc_builder.doss.metadata = db_test_app.get_default_metadata() wc_builder.clean_workdir = Bool(True) outputs, wc_node = run_get_node(wc_builder) sys.stderr.write(get_workchain_report(wc_node, "REPORT")) wk_attributes = sanitise_calc_attr(wc_node.attributes) data_regression.check({ "calc_node": wk_attributes, "incoming": sorted(wc_node.get_incoming().all_link_labels()), "outgoing": sorted(wc_node.get_outgoing().all_link_labels()), # "results": outputs["results"].attributes })
def test_init_steps(db_test_app, data_regression): clear_spec() wc_builder = CryPropertiesWorkChain.get_builder() with open_resource_binary("doss", "mgo_sto3g_scf", "fort.9") as handle: wc_builder.wf_folder = SinglefileData(handle) wc_builder.doss.code = db_test_app.get_or_create_code("crystal17.doss") wc_builder.doss.parameters = get_parameters()["doss"] wc_builder.doss.metadata = db_test_app.get_default_metadata() wc_builder.test_run = True steps = ["check_inputs", "check_wf_folder"] wkchain, step_outcomes, context = db_test_app.generate_context( CryPropertiesWorkChain, wc_builder, steps) data_regression.check(context) try: assert step_outcomes[0] is None assert step_outcomes[1] is False except Exception: sys.stderr.write(get_workchain_report(wkchain, "REPORT")) raise
def test_fleur_scf_structure_Si(run_with_cache, with_export_cache, clear_database, fleur_local_code, inpgen_local_code, generate_structure2, clear_spec): """ Full regression test of FleurScfWorkchain starting with a crystal structure and parameters Check if calc parameters are given through, check if wf default parameters are updated """ # prepare input nodes and dicts options = { 'resources': { 'num_machines': 1, 'num_mpiprocs_per_machine': 1 }, 'max_wallclock_seconds': 5 * 60, 'withmpi': False, 'custom_scheduler_commands': '' } FleurCode = fleur_local_code InpgenCode = inpgen_local_code wf_parameters = {'add_comp_para': {'serial': True}, 'itmax_per_run': 30} calc_parameters = { 'atom': { 'element': 'Si', 'rmt': 2.1, 'jri': 981, 'lmax': 8, 'lnonsph': 6 }, 'comp': { 'kmax': 3.4 }, 'kpt': { 'div1': 10, 'div2': 10, 'div3': 10, 'tkb': 0.0005 } } #calc_parameters = {'atom': {'element': "W", 'rmt': 2.3, 'jri': 981, 'lmax': 10, # 'lnonsph': 6, 'econfig': '[Kr] 4d10 4f14 | 5s2 5p6 6s2 5d4', 'lo': '5s 5p'}, # 'comp': {'kmax': 3.5}, # 'kpt': {'div1': 15, 'div2': 15, 'div3': 15, 'tkb': 0.0005}} # create process builder to set parameters builder = FleurScfWorkChain.get_builder() builder.metadata.description = 'Simple Fleur SCF test for Si bulk with structure, calc para and wf para given' builder.metadata.label = 'FleurSCF_test_Si_bulk' builder.structure = generate_structure2().store() builder.options = Dict(dict=options).store() builder.calc_parameters = Dict(dict=calc_parameters).store() builder.wf_parameters = Dict(dict=wf_parameters).store() builder.fleur = FleurCode.store() builder.inpgen = InpgenCode.store() print(builder) # now run scf with cache fixture data_dir_path = os.path.join( aiida_path, '../tests/workflows/caches/fleur_scf_structure_Si.tar.gz') with with_export_cache(data_dir_abspath=data_dir_path): out, node = run_get_node(builder) print(out) print(node) print(get_workchain_report(node, 'REPORT')) assert node.is_finished_ok # check output n = out['output_scf_wc_para'] n = n.get_dict() print(n) assert abs(n.get('distance_charge') - 8.0987e-06) < 2.0e-6 assert n.get('errors') == []
def test_fleur_scf_fleurinp_Si_modifications( #run_with_cache, with_export_cache, #mock_code_factory, #aiida_local_code_factory, fleur_local_code, create_fleurinp, clear_database, clear_spec): """ Full regression test of FleurScfWorkchain starting with a fleurinp data, but adjusting the Fleur input file before the fleur run. """ wf_parameters = { 'fleur_runmax': 4, 'density_converged': 0.0002, 'energy_converged': 0.002, 'force_converged': 0.002, 'mode': 'density', # 'density', 'energy' or 'force' 'add_comp_para': { 'serial': True, }, 'itmax_per_run': 30, 'force_dict': { 'qfix': 2, 'forcealpha': 0.5, 'forcemix': 'BFGS' }, 'inpxml_changes': [('set_inpchanges', { 'change_dict': { 'Kmax': 3.8 } })], } options = { 'resources': { 'num_machines': 1, 'num_mpiprocs_per_machine': 1 }, 'max_wallclock_seconds': 5 * 60, 'withmpi': False, 'custom_scheduler_commands': '' } FleurCode = fleur_local_code # create process builder to set parameters builder = FleurScfWorkChain.get_builder() builder.metadata.description = 'Simple Fleur SCF test for Si bulk with fleurinp data given and mod request' builder.metadata.label = 'FleurSCF_test_Si_bulk_mod' builder.fleurinp = create_fleurinp(TEST_INP_XML_PATH).store() builder.options = Dict(dict=options).store() builder.wf_parameters = Dict(dict=wf_parameters).store() builder.fleur = FleurCode #print(builder) # now run calculation #run_with_cache(builder) data_dir_path = os.path.join( aiida_path, '../tests/workflows/caches/fleur_scf_fleurinp_Si_mod.tar.gz') with with_export_cache(data_dir_abspath=data_dir_path): out, node = run_get_node(builder) print(out) #print(node) print(get_workchain_report(node, 'REPORT')) assert node.is_finished_ok # check output n = out['output_scf_wc_para'] n = n.get_dict() lasto = out['last_fleur_calc_output'] calc = lasto.get_incoming().all()[0].node print(calc) print(calc.get_cache_source()) lasto = lasto.get_dict() print(n) #get kmax and minDistance assert abs(n.get('distance_charge') - 0.0001671267) < 2.0e-6 assert n.get('errors') == [] assert lasto['kmax'] == 3.8