def example_opt_restart(orca_code, opt_calc_pk=None, submit=True): """Run simple DFT calculation""" # This line is needed for tests only if opt_calc_pk is None: opt_calc_pk = pytest.opt_calc_pk # pylint: disable=no-member # structure thisdir = os.path.dirname(os.path.realpath(__file__)) xyz_path = os.path.join(thisdir, 'h2co.xyz') structure = StructureData( pymatgen_molecule=mg.Molecule.from_file(xyz_path)) # old gbw file retr_fldr = load_node(opt_calc_pk).outputs.retrieved gbw_file = SinglefileData( os.path.join(retr_fldr._repository._get_base_folder().abspath, 'aiida.gbw')) #pylint: disable=protected-access # parameters parameters = Dict( dict={ 'charge': 0, 'multiplicity': 1, 'input_blocks': { 'scf': { 'convergence': 'tight', 'moinp': '"aiida_old.gbw"', }, 'pal': { 'nproc': 2, }, }, 'input_keywords': ['B3LYP/G', 'def2-TZVP', 'Opt'], 'extra_input_keywords': ['MOREAD'], }) # Construct process builder builder = OrcaCalculation.get_builder() builder.structure = structure builder.parameters = parameters builder.code = orca_code builder.file = { 'gbw': gbw_file, } builder.metadata.options.resources = { 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 10 * 60 if submit: print('Testing Orca Opt Calculations...') res, pk = run_get_pk(builder) print('calculation pk: ', pk) print('SCF Energy is :', res['output_parameters'].dict['scfenergies']) else: builder.metadata.dry_run = True builder.metadata.store_provenance = False
def example_restart_numfreq(orca_code, freq_calc_pk=None, submit=True): """Run restart numerical Freq Calculation using AiiDA-Orca""" # This line is needed for tests only if freq_calc_pk is None: freq_calc_pk = pytest.freq_calc_pk # pylint: disable=no-member # old hess file retr_fldr = load_node(freq_calc_pk).outputs.retrieved hess_file = SinglefileData( os.path.join(retr_fldr._repository._get_base_folder().abspath, 'aiida.hess')) #pylint: disable=protected-access # parameters parameters = Dict( dict={ 'charge': 0, 'multiplicity': 1, 'input_blocks': { 'scf': { 'convergence': 'tight', }, 'pal': { 'nproc': 2, }, 'freq': { 'restart': 'True', 'temp': 273, } }, 'input_kewords': ['RKS', 'BP', 'def2-TZVP', 'RI', 'def2/J'], 'extra_input_keywords': ['Grid5', 'NoFinalGrid', 'NumFreq'], }) # Construct process builder builder = OrcaCalculation.get_builder() builder.structure = load_node(freq_calc_pk).outputs.relaxed_structure builder.parameters = parameters builder.code = orca_code builder.file = { 'hess': hess_file, } builder.metadata.options.resources = { 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 10 * 60 if submit: print('Testing ORCA restart numerical Frequency Calculation...') res, pk = run_get_pk(builder) print('calculation pk: ', pk) print('Enthalpy is :', res['output_parameters'].dict['enthalpy']) else: builder.metadata.dry_run = True builder.metadata.store_provenance = False
def submit_workchain(structure, daemon, protocol, parameters, pseudo_family, num_machines, num_mpiprocs_per_machine=4, set_2d_mesh=False): print("running dft band structure calculation for {}".format( structure.get_formula())) # Set custom pseudo modifiers = {'parameters': parameters} """ if pseudo_family is not None: from aiida_quantumespresso.utils.protocols.pw import _load_pseudo_metadata pseudo_data = _load_pseudo_metadata(pseudo_family) modifiers.update({'pseudo': 'custom', 'pseudo_data': pseudo_data}) """ # if pseudo_family is not None: # from aiida_quantumespresso.utils.pseudopotential import get_pseudos_from_structure # pseudo_data = get_pseudos_from_structure(structure, pseudo_family) # modifiers.update({'pseudo': 'custom', 'pseudo_data': pseudo_data}) # Submit the DFT bands workchain pwbands_workchain_parameters = { 'code': code, 'structure': structure, 'protocol': orm.Dict(dict={ 'name': protocol, 'modifiers': modifiers }), 'options': orm.Dict( dict={ 'resources': { 'num_machines': num_machines, 'num_mpiprocs_per_machine': num_mpiprocs_per_machine }, 'max_wallclock_seconds': 3600 * 5, 'withmpi': True, }), 'set_2d_mesh': orm.Bool(set_2d_mesh) } if pseudo_family is not None: pwbands_workchain_parameters['pseudo_family'] = orm.Str(pseudo_family) if daemon: dft_workchain = submit(PwBandStructureWorkChain, **pwbands_workchain_parameters) else: from aiida.engine import run_get_pk dft_workchain = run_get_pk(PwBandStructureWorkChain, **pwbands_workchain_parameters) return dft_workchain
def example_ev(julia_code, submit=True): """ Example to prepare and run a Sinlge Component """ pwd = os.path.dirname(os.path.realpath(__file__)) framework = CifData(file=os.path.join(pwd, 'files', 'HKUST1.cif')).store() acc_voronoi_nodes = SinglefileData( file=os.path.join(pwd, 'files', 'HKUST1.voro_accessible')).store() data_path = os.path.join(pwd, 'data') print(data_path) parameters = Dict( dict={ 'data_path': data_path, 'ff': 'UFF.csv', 'cutoff': 12.5, 'mixing': 'Lorentz-Berthelot', 'framework': framework.filename, 'frameworkname': framework.filename[:-4], 'adsorbate': "Xe", 'temperature': 298.0, 'output_filename': "Ev_" + framework.filename[:-4] + ".csv", 'input_template': 'ev_vdw_kh_1comp_template', 'ev_setting': [99, 95, 90, 80, 50 ], # if not defined the default is [90,80,50] }) builder = PorousMaterialsCalculation.get_builder() builder.structure = {framework.filename[:-4]: framework} builder.parameters = parameters builder.acc_voronoi_nodes = {framework.filename[:-4]: acc_voronoi_nodes} builder.code = julia_code builder.metadata.options.resources = { #pylint: disable = no-member 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 30 * 60 #pylint: disable = no-member builder.metadata.options.withmpi = False #pylint: disable = no-member if submit: print('Testing PorousMaterials Ev for single component...') res, pk = run_get_pk(builder) print('Voronoi Energy is: ', res['output_parameters'].dict.HKUST1['Ev_probe']['Ev_minimum']) print('calculation pk: ', pk) print('OK, calculation has completed successfully') pytest.base_calc_pk = pk else: print('Generating test input ...') builder.metadata.dry_run = True #pylint: disable = no-member builder.metadata.store_provenance = False #pylint: disable = no-member run(builder) print('submission test successful') print("In order to actually submit, add '--submit'") print('-----------')
def example_simple_tddft(orca_code, opt_calc_pk=None, submit=True): """Run simple TDDFT Calculation using AiiDA-Orca""" # This line is needed for tests only if opt_calc_pk is None: opt_calc_pk = pytest.opt_calc_pk # pylint: disable=no-member # parameters parameters = Dict( dict={ 'charge': 0, 'multiplicity': 1, 'input_blocks': { 'scf': { 'convergence': 'tight', }, 'pal': { 'nproc': 2, }, 'tddft': { 'nroots': 8, 'maxdim': 2, 'triplets': 'true', } }, 'input_kewords': ['RKS', 'B3LYP/G', 'SV(P)'], 'extra_input_keywords': [], } ) # Construct process builder builder = OrcaCalculation.get_builder() builder.structure = load_node(opt_calc_pk).outputs.relaxed_structure builder.parameters = parameters builder.code = orca_code builder.metadata.options.resources = { 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 10 * 60 if submit: print('Testing ORCA simple TDDFT Calculation...') res, pk = run_get_pk(builder) print('calculation pk: ', pk) print('1st ET energy is :', res['output_parameters'].dict['etenergies'][0]) else: builder.metadata.dry_run = True builder.metadata.store_provenance = False
def example_opt(orca_code, submit=True): """Run simple DFT calculation""" # structure thisdir = os.path.dirname(os.path.realpath(__file__)) xyz_path = os.path.join(thisdir, 'h2co.xyz') structure = StructureData( pymatgen_molecule=mg.Molecule.from_file(xyz_path)) # parameters parameters = Dict( dict={ 'charge': 0, 'multiplicity': 1, 'input_blocks': { 'scf': { 'convergence': 'tight', }, 'pal': { #Uncomment for parallel run. 'nproc': 2, } }, 'input_keywords': ['B3LYP/G', 'SV(P)', 'Opt'], 'extra_input_keywords': [], }) # Construct process builder builder = OrcaCalculation.get_builder() builder.structure = structure builder.parameters = parameters builder.code = orca_code builder.metadata.options.resources = { 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 10 * 60 if submit: print('Testing Orca Opt Calculations...') res, pk = run_get_pk(builder) print('calculation pk: ', pk) print('SCF Energy is :', res['output_parameters'].dict['scfenergies']) pytest.opt_calc_pk = pk else: builder.metadata.dry_run = True builder.metadata.store_provenance = False
def example_opt_numfreq(orca_code, submit=True): """Run Opt and Numerical Calculation using AiiDA-Orca""" # structure thisdir = os.path.dirname(os.path.realpath(__file__)) xyz_path = os.path.join(thisdir, 'h2co.xyz') structure = StructureData( pymatgen_molecule=mg.Molecule.from_file(xyz_path)) # parameters parameters = Dict( dict={ 'charge': 0, 'multiplicity': 1, 'input_blocks': { 'scf': { 'convergence': 'tight', }, 'pal': { 'nproc': 2, }, }, 'input_kewords': ['RKS', 'BP', 'def2-SVP', 'RI', 'def2/J'], 'extra_input_keywords': ['Grid2', 'NoFinalGrid', 'NumFreq', 'OPT'], }) # Construct process builder builder = OrcaCalculation.get_builder() builder.structure = structure builder.parameters = parameters builder.code = orca_code builder.metadata.options.resources = { 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 10 * 60 if submit: print('Testing ORCA and Numerical Frequency Calculation...') res, pk = run_get_pk(builder) print('calculation pk: ', pk) print('Enthalpy is :', res['output_parameters'].dict['enthalpy']) pytest.freq_calc_pk = pk else: builder.metadata.dry_run = True builder.metadata.store_provenance = False
def run_eigenvals(): """ Creates and runs the eigenvals calculation. """ builder = EigenvalsCalculation.get_builder() builder.code = Code.get_from_string('tbmodels') builder.tb_model = get_singlefile_instance( description=u'InSb TB model', path='./reference_input/model.hdf5') # single-core on local machine builder.metadata.options = dict(resources=dict(num_machines=1, tot_num_mpiprocs=1), withmpi=False) builder.kpoints = DataFactory('array.kpoints')() builder.kpoints.set_kpoints_mesh([4, 4, 4], offset=[0, 0, 0]) result, pid = run_get_pk(builder) print('\nRan calculation with PID', pid) print('Result:', result)
def example_ff_files(raspa_code, submit=True): """Prepare and submit RASPA calculation with components mixture.""" # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfInitializationCycles": 200, "NumberOfCycles": 300, "PrintEvery": 100, "Forcefield": "Local", "ChargeMethod": "Ewald", "EwaldPrecision": 1e-6, "CutOff": 12.0, }, "System": { "irmof_1": { "type": "Framework", "UnitCells": "1 1 1", "HeliumVoidFraction": 0.149, "ExternalTemperature": 300.0, "ExternalPressure": 1e5, } }, "Component": { "CO2": { "MoleculeDefinition": "Local", "MolFraction": 0.30, "TranslationProbability": 1.0, "RotationProbability": 1.0, "ReinsertionProbability": 1.0, "SwapProbability": 1.0, "CreateNumberOfMolecules": 0, }, "N2": { "MoleculeDefinition": "Local", "MolFraction": 0.70, "TranslationProbability": 1.0, "RotationProbability": 1.0, "ReinsertionProbability": 1.0, "SwapProbability": 1.0, "CreateNumberOfMolecules": 0, }, }, }) # Contructing builder pwd = os.path.dirname(os.path.realpath(__file__)) builder = raspa_code.get_builder() builder.framework = { "irmof_1": CifData(file=os.path.join(pwd, '..', 'files', 'IRMOF-1_eqeq.cif')), } # Note: Here the SinglefileData in the dict are stored otherwise the dry_run crashes. # However, this is not needed for real calculations (e.g., using --submit), since the work chains stores them. builder.file = { "file_1": SinglefileData(file=os.path.join( pwd, '..', 'files', 'force_field_mixing_rules.def')).store(), "file_2": SinglefileData( file=os.path.join(pwd, '..', 'files', 'pseudo_atoms.def')).store(), "file_3": SinglefileData( file=os.path.join(pwd, '..', 'files', 'CO2.def')).store(), "file_4": SinglefileData( file=os.path.join(pwd, '..', 'files', 'N2.def')).store(), } builder.parameters = parameters builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print( "Testing RASPA CO2/N2 adsorption in IRMOF-1, using Local force field ..." ) res, pk = run_get_pk(builder) print("calculation pk: ", pk) print("CO2/N2 uptake ({:s}): {:.2f}/{:.2f} ".format( res['output_parameters']["irmof_1"]["components"]['N2'] ["loading_absolute_unit"], res['output_parameters']["irmof_1"]["components"]['CO2'] ["loading_absolute_average"], res['output_parameters']["irmof_1"]["components"]['N2'] ["loading_absolute_average"], )) print("OK, calculation has completed successfully") else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("Submission test successful") print("In order to actually submit, add '--submit'") print("-----")
def test_seal(self): _, p_k = run_get_pk(test_processes.DummyProcess) self.assertTrue(orm.load_node(pk=p_k).is_sealed)
def example_base(raspa_code, submit=True): """Prepare and submit simple RASPA calculation.""" # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfCycles": 400, "NumberOfInitializationCycles": 200, "PrintEvery": 200, "Forcefield": "GenericMOFs", "EwaldPrecision": 1e-6, "CutOff": 12.0, "WriteBinaryRestartFileEvery": 200, }, "System": { "tcc1rs": { "type": "Framework", "UnitCells": "1 1 1", "HeliumVoidFraction": 0.149, "ExternalTemperature": 300.0, "ExternalPressure": 5e5, }, }, "Component": { "methane": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 0.5, "ReinsertionProbability": 0.5, "SwapProbability": 1.0, "CreateNumberOfMolecules": 0, } }, }) # framework framework = CifData( file=os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'files', 'TCC1RS.cif')) # Contructing builder builder = raspa_code.get_builder() builder.framework = { "tcc1rs": framework, } builder.parameters = parameters builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print("Testing RASPA with simple input ...") res, pk = run_get_pk(builder) print("calculation pk: ", pk) print( "Total Energy average (tcc1rs):", res['output_parameters'].dict.tcc1rs['general'] ['total_energy_average']) print("OK, calculation has completed successfully") pytest.base_calc_pk = pk else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("Submission test successful") print("In order to actually submit, add '--submit'") print("-----")
def submit_workchain(structure_file, num_machines, num_mpiprocs_per_machine, protocol, parameters, pseudo_family, only_valence, do_disentanglement, do_mlwf, retrieve_hamiltonian, group_name, daemon, set_2d_mesh): codes = check_codes() group_name = update_group_name( group_name, only_valence, do_disentanglement, do_mlwf ) if isinstance(structure_file, orm.StructureData): structure = structure_file else: structure = read_structure(structure_file) controls = { 'retrieve_hamiltonian': orm.Bool(retrieve_hamiltonian), 'only_valence': orm.Bool(only_valence), 'do_disentanglement': orm.Bool(do_disentanglement), 'do_mlwf': orm.Bool(do_mlwf) } if only_valence: print( "Running only_valence/insulating for {}".format( structure.get_formula() ) ) else: print( "Running with conduction bands for {}".format( structure.get_formula() ) ) modifiers = { 'parameters': parameters } # if pseudo_family is not None: # from aiida_quantumespresso.utils.pseudopotential import get_pseudos_from_structure # pseudo_data = get_pseudos_from_structure(structure, pseudo_family) # modifiers.update({'pseudo': pseudo_family}) wannier90_workchain_parameters = { "code": { 'pw': codes['pw_code'], 'pw2wannier90': codes['pw2wannier90_code'], 'projwfc': codes['projwfc_code'], 'wannier90': codes['wannier90_code'] }, "protocol": orm.Dict(dict={'name': protocol, 'modifiers': modifiers}), "structure": structure, "controls": controls, "options": orm.Dict(dict={ 'resources': { 'num_machines': num_machines, 'num_mpiprocs_per_machine': num_mpiprocs_per_machine }, 'max_wallclock_seconds': 3600 * 5, 'withmpi': True }), 'set_2d_mesh': orm.Bool(set_2d_mesh), } if pseudo_family is not None: wannier90_workchain_parameters['pseudo_family'] = orm.Str( pseudo_family) if daemon is not None: workchain = submit( Wannier90BandsWorkChain, **wannier90_workchain_parameters ) else: from aiida.engine import run_get_pk from aiida.orm import load_node workchain = run_get_pk(Wannier90BandsWorkChain, **wannier90_workchain_parameters) add_to_group(workchain, group_name) print_help(workchain, structure) return workchain.pk
def example_binary_misture(raspa_code, submit=True): """Prepare and submit RASPA calculation with components mixture.""" # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfCycles": 400, "NumberOfInitializationCycles": 200, "PrintEvery": 200, "Forcefield": "GenericMOFs", "EwaldPrecision": 1e-6, "CutOff": 12.0, }, "System": { "box_25_angstrom": { "type": "Box", "BoxLengths": "25 25 25", "ExternalTemperature": 300.0, "ExternalPressure": 5e5, }, }, "Component": { "propane": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 1.0, "RotationProbability": 1.0, "ReinsertionProbability": 1.0, "SwapProbability": 1.0, "CreateNumberOfMolecules": 30, }, "butane": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 1.0, "RotationProbability": 1.0, "ReinsertionProbability": 1.0, "SwapProbability": 1.0, "CreateNumberOfMolecules": 30, }, }, }) # Contructing builder builder = raspa_code.get_builder() builder.parameters = parameters builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print("Testing RASPA with binary mixture (propane/butane) ...") res, pk = run_get_pk(builder) print("calculation pk: ", pk) print( "Total Energy average (box_25_angstrom):", res['output_parameters'].dict.box_25_angstrom['general'] ['total_energy_average']) print("OK, calculation has completed successfully") else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("Submission test successful") print("In order to actually submit, add '--submit'") print("-----")
def example_ev_kh_multi_pld(julia_code, submit=True): """ Test for Multi Comp PLD based with Kh """ pwd = os.path.dirname(os.path.realpath(__file__)) framework = CifData(file=os.path.join(pwd, 'files', 'HKUST1.cif')).store() acc_voronoi_nodes_xe = SinglefileData(file=os.path.join( pwd, 'files', 'xenon_probe', 'out.visVoro.voro_accessible')).store() acc_voronoi_nodes_kr = SinglefileData(file=os.path.join( pwd, 'files', 'krypton_probe', 'out.visVoro.voro_accessible')).store() acc_voronoi_nodes_pld = SinglefileData(file=os.path.join( pwd, 'files', 'pld_probe', 'out.visVoro.voro_accessible')).store() data_path = os.path.join(pwd, 'data') parameters = Dict( dict={ 'data_path': data_path, 'ff': 'UFF.csv', 'cutoff': 12.5, 'mixing': 'Lorentz-Berthelot', 'framework': framework.filename, 'frameworkname': framework.filename[:-4], 'adsorbates': '["Xe","Kr"]', 'temperature': 298.0, 'input_template': 'ev_vdw_kh_multicomp_pld_template', 'ev_setting': [99, 95, 90, 80, 50 ], # if not defined the default is [90,80,50] }) voro_label_xe = framework.filename[:-4] + "_Xe" voro_label_kr = framework.filename[:-4] + "_Kr" voro_label_pld = framework.filename[:-4] + "_PLD" builder = PorousMaterialsCalculation.get_builder() builder.structure = {framework.filename[:-4]: framework} builder.parameters = parameters builder.acc_voronoi_nodes = { voro_label_xe: acc_voronoi_nodes_xe, voro_label_kr: acc_voronoi_nodes_kr, voro_label_pld: acc_voronoi_nodes_pld, } builder.code = julia_code builder.metadata.options.resources = { #pylint: disable = no-member 'num_machines': 1, 'num_mpiprocs_per_machine': 1, } builder.metadata.options.max_wallclock_seconds = 1 * 30 * 60 #pylint: disable = no-member builder.metadata.options.withmpi = False #pylint: disable = no-member if submit: print('Testing PorousMaterials Ev for multi-component PLD probe...') res, pk = run_get_pk(builder) print('Ev Xe is: ', res['output_parameters'].dict.Xe['Xe_probe']['Ev_minimum']) print('Ev Kr is: ', res['output_parameters'].dict.Kr['Kr_probe']['Ev_minimum']) print('Ev Xe PLD is: ', res['output_parameters'].dict.Xe['PLD_probe']['Ev_minimum']) print('Ev Kr PLD is: ', res['output_parameters'].dict.Kr['PLD_probe']['Ev_minimum']) print('calculation pk: ', pk) print('OK, calculation has completed successfully') pytest.base_calc_pk = pk else: builder.metadata.dry_run = True #pylint: disable = no-member builder.metadata.store_provenance = False #pylint: disable = no-member run(builder) print('submission test successful') print("In order to actually submit, add '--submit'")
def example_framework_box_restart(raspa_code, framework_box_calc_pk=None, submit=True): """Prepare and submit simple RASPA calculation.""" # This line is needed for tests only if framework_box_calc_pk is None: framework_box_calc_pk = pytest.framework_box_calc_pk # pylint: disable=no-member # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfCycles": 50, "NumberOfInitializationCycles": 50, "PrintEvery": 10, "Forcefield": "GenericMOFs", "EwaldPrecision": 1e-6, "WriteBinaryRestartFileEvery": 10, }, "System": { "tcc1rs": { "type": "Framework", "UnitCells": "1 1 1", "ExternalTemperature": 350.0, "ExternalPressure": 6e5, "HeliumVoidFraction": 0.149, }, "box_25_angstroms": { "type": "Box", "BoxLengths": "25 25 25", "ExternalTemperature": 350.0, "ExternalPressure": 6e5, }, }, "Component": { "methane": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 0.5, "ReinsertionProbability": 0.5, "SwapProbability": 1.0, } }, }) # framework framework = CifData( file=os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'files', 'TCC1RS.cif')) # restart file retrieved_parent_folder = load_node( framework_box_calc_pk).outputs.retrieved # Contructing builder builder = raspa_code.get_builder() builder.framework = { "tcc1rs": framework, } builder.parameters = parameters builder.retrieved_parent_folder = retrieved_parent_folder builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print("Testing RASPA with framework and box, restart ...") res, pk = run_get_pk(builder) print("calculation pk: ", pk) print( "Average number of methane molecules/uc (tcc1rs):", res['output_parameters'].dict.tcc1rs['components']['methane'] ['loading_absolute_average']) print( "Average number of methane molecules/uc (box):", res['output_parameters'].dict.box_25_angstroms['components'] ['methane']['loading_absolute_average']) print("OK, calculation has completed successfully") else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("submission test successful") print("In order to actually submit, add '--submit'") print("-----")
# -*- coding: utf-8 -*- from aiida.engine import calcfunction, run, run_get_node, run_get_pk from aiida.orm import Int @calcfunction def add(x, y): return x + y x = Int(1) y = Int(2) result = run(add, x, y) result, node = run_get_node(add, x, y) result, pk = run_get_pk(add, x, y)
# -*- coding: utf-8 -*- from aiida.engine import run_get_node, run_get_pk from aiida.orm import Int result, node = run_get_node(AddAndMultiplyWorkChain, a=Int(1), b=Int(2), c=Int(3)) result, pk = run_get_pk(AddAndMultiplyWorkChain, a=Int(1), b=Int(2), c=Int(3))
# -*- coding: utf-8 -*- from aiida import orm from aiida.engine import run_get_node, run_get_pk ArithmeticAddCalculation = CalculationFactory('arithmetic.add') result, node = run_get_node(ArithmeticAddCalculation, x=orm.Int(1), y=orm.Int(2)) result, pk = run_get_pk(ArithmeticAddCalculation, x=orm.Int(1), y=orm.Int(2))
def example_henry(raspa_code, submit=True): """Prepare and submit simple RASPA calculation to compute Henry coefficient.""" # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfCycles": 400, "PrintEvery": 200, "Forcefield": "GenericMOFs", "EwaldPrecision": 1e-6, "CutOff": 12.0, }, "System": { "tcc1rs": { "type": "Framework", "UnitCells": "1 1 1", "HeliumVoidFraction": 0.149, "ExternalTemperature": 300.0, } }, "Component": { "methane": { "MoleculeDefinition": "TraPPE", "WidomProbability": 1.0, "CreateNumberOfMolecules": 0, } }, }) # framework pwd = os.path.dirname(os.path.realpath(__file__)) framework = CifData(file=os.path.join(pwd, '..', 'files', 'TCC1RS.cif')) # Contructing builder builder = raspa_code.get_builder() builder.framework = { "tcc1rs": framework, } builder.parameters = parameters builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print("Testing RASPA on computing Henry coefficient ...") res, pk = run_get_pk(builder) print("calculation pk: ", pk) print("Average Henry coefficient (methane in tcc1rs):", res['output_parameters'].dict.tcc1rs['components']['methane']['henry_coefficient_average']) print("OK, calculation has completed successfully") else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("submission test successful") print("In order to actually submit, add '--submit'") print("-----")
def example_gemc_single_comp(raspa_code, gemc_single_comp_calc_pk=None, submit=True): """Prepare and submit RASPA calculation with components mixture.""" # This line is needed for tests only if gemc_single_comp_calc_pk is None: gemc_single_comp_calc_pk = pytest.gemc_single_comp_calc_pk # pylint: disable=no-member # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfCycles": 50, "NumberOfInitializationCycles": 50, "PrintEvery": 10, "Forcefield": "GenericMOFs", "EwaldPrecision": 1e-6, "CutOff": 12.0, "GibbsVolumeChangeProbability": 0.1, }, "System": { "box_one": { "type": "Box", "BoxLengths": "25 25 25", "BoxAngles": "90 90 90", "ExternalTemperature": 200.0, }, "box_two": { "type": "Box", "BoxLengths": "25 25 25", "BoxAngles": "90 90 90", "ExternalTemperature": 200.0, } }, "Component": { "methane": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 1.0, "ReinsertionProbability": 1.0, "GibbsSwapProbability": 1.0, "CreateNumberOfMolecules": { "box_one": 50, "box_two": 50, }, }, }, }) # restart file retrieved_parent_folder = load_node( gemc_single_comp_calc_pk).outputs.retrieved # Contructing builder builder = raspa_code.get_builder() builder.parameters = parameters builder.retrieved_parent_folder = retrieved_parent_folder builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print("Testing RASPA GEMC with methane (Restart)...") res, pk = run_get_pk(builder) print("calculation pk: ", pk) print( "Average number of methane molecules/uc (box_one):", res['output_parameters'].dict.box_one['components']['methane'] ['loading_absolute_average']) print( "Average number of methane molecules/uc (box_two):", res['output_parameters'].dict.box_two['components']['methane'] ['loading_absolute_average']) print("OK, calculation has completed successfully") else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("Submission test successful") print("In order to actually submit, add '--submit'") print("-----")
def example_block_pockets(raspa_code, submit=True): """Prepare and submit RASPA calculation with blocked pockets.""" # parameters parameters = Dict( dict={ "GeneralSettings": { "SimulationType": "MonteCarlo", "NumberOfCycles": 50, "NumberOfInitializationCycles": 50, "PrintEvery": 10, "Forcefield": "GenericMOFs", "RemoveAtomNumberCodeFromLabel": True, "EwaldPrecision": 1e-6, "CutOff": 12.0, }, "System": { "irmof_1": { "type": "Framework", "UnitCells": "1 1 1", "HeliumVoidFraction": 0.149, "ExternalTemperature": 300.0, "ExternalPressure": 1e5, }, "irmof_10": { "type": "Framework", "UnitCells": "1 1 1", "HeliumVoidFraction": 0.149, "ExternalTemperature": 300.0, "ExternalPressure": 1e5, } }, "Component": { "methane": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 0.5, "ReinsertionProbability": 0.5, "SwapProbability": 1.0, "CreateNumberOfMolecules": { "irmof_1": 1, "irmof_10": 2, }, "BlockPocketsFileName": { "irmof_1": "irmof_1_test", "irmof_10": "irmof_10_test", }, }, "xenon": { "MoleculeDefinition": "TraPPE", "TranslationProbability": 0.5, "ReinsertionProbability": 0.5, "SwapProbability": 1.0, "CreateNumberOfMolecules": { "irmof_1": 3, "irmof_10": 4, }, "BlockPocketsFileName": { "irmof_1": "irmof_1_test", "irmof_10": "irmof_10_test", }, }, }, }) # frameworks pwd = os.path.dirname(os.path.realpath(__file__)) framework_1 = CifData(file=os.path.join(pwd, '..', 'files', 'IRMOF-1.cif')) framework_10 = CifData(file=os.path.join(pwd, '..', 'files', 'IRMOF-10.cif')) # block pocket block_pocket_1 = SinglefileData(file=os.path.join(pwd, '..', 'files', 'IRMOF-1_test.block')).store() block_pocket_10 = SinglefileData(file=os.path.join(pwd, '..', 'files', 'IRMOF-10_test.block')).store() # Contructing builder builder = raspa_code.get_builder() builder.framework = { "irmof_1": framework_1, "irmof_10": framework_10, } builder.block_pocket = { "irmof_1_test": block_pocket_1, "irmof_10_test": block_pocket_10, } builder.parameters = parameters builder.metadata.options = { "resources": { "num_machines": 1, "num_mpiprocs_per_machine": 1, }, "max_wallclock_seconds": 1 * 30 * 60, # 30 min "withmpi": False, } builder.metadata.dry_run = False builder.metadata.store_provenance = True if submit: print("Testing RASPA calculation with two frameworks each one " "containing 2 molecules (metahne/xenon) and block pockets ...") res, pk = run_get_pk(builder) print("calculation pk: ", pk) print("Average number of methane molecules/uc (irmof-1):", res['output_parameters'].dict.irmof_1['components']['methane']['loading_absolute_average']) print("Average number of methane molecules/uc (irmof-10):", res['output_parameters'].dict.irmof_1['components']['methane']['loading_absolute_average']) print("OK, calculation has completed successfully") else: print("Generating test input ...") builder.metadata.dry_run = True builder.metadata.store_provenance = False run(builder) print("Submission test successful") print("In order to actually submit, add '--submit'")