コード例 #1
0
def runscript(value=1):
    if value == 0:
        inp = createscript()
    if value == 1:
        inpufile = input('Input file name [inputnam.format]:')
        with open(inpufile, 'r') as myfile:
            inp = myfile.read()
    if value == 0:
        structurename = input('Input structure name (name.cif): ')
        structur = structurename.split('.')
        strc = next(pybel.readfile(structur[1], structurename))
        strc.unitcell.FillUnitCell(strc.OBMol)
        strc.calccharges("eqeq")
        out = RASPA2.run_script(inp, strc)
    if value == 1:
        while value == 1:
            structurename = input('Structure (Optional) [name.cif/None]: ')
            if structurename == 'None':
                value = 2
                out = RASPA2.run_script(inp)
            if structurename != 'None':
                structur = structurename.split('.')
                strc = next(pybel.readfile(structur[1], structurename))
                strc.unitcell.FillUnitCell(strc.OBMol)
                strc.calccharges("eqeq")
                value = 2
                out = RASPA2.run_script(inp, strc)
    return out, inp
コード例 #2
0
def getheliumvoidfraction():
    print('Define the following parameter:')
    print(
        '            *for default option, you must introduce the exactly default ex:CrystalGenerator'
    )
    print('')
    structurename = input('Input structure name (name.cif): ')
    structur = structurename.split('.')
    strc = next(pybel.readfile(structur[1], structurename))
    strc.unitcell.FillUnitCell(strc.OBMol)
    strc.calccharges("eqeq")
    unitcells = input('unit_cells [default=(1,1,1)]: ')
    unitcells = unitcells.split(',')
    a = unitcells[0]
    a = a[1]
    b = unitcells[1]
    c = unitcells[2]
    c = c[0]
    cycles = int(input('cycles [default=2000]: '))
    forcefield = input('forcefield [default=CrystalGenerator]: ')
    voidfrac = RASPA2.get_helium_void_fraction(strc,
                                               unit_cells=(a, b, c),
                                               cycles=cycles,
                                               input_file_type="cif",
                                               forcefield=forcefield)
    print('The helium void fraction is ' + str(voidfrac))
    return voidfrac
コード例 #3
0
def getgeometricsurfacearea():
    print('Define the following parameter:')
    print(
        '            *for default option, you must introduce the exactly default ex:CrystalGenerator'
    )
    print('')
    structurename = input('Input structure name (name.cif): ')
    structur = structurename.split('.')
    strc = next(pybel.readfile(structur[1], structurename))
    strc.unitcell.FillUnitCell(strc.OBMol)
    strc.calccharges("eqeq")
    unitcells = input('unit_cells [default=(1,1,1)]: ')
    unitcells = unitcells.split(',')
    a = unitcells[0]
    a = a[1]
    b = unitcells[1]
    c = unitcells[2]
    c = c[0]
    cycles = int(input('cycles [default=500]: '))
    forcefield = input('forcefield [default=CrystalGenerator]: ')
    srfcarea = RASPA2.get_geometric_surface_area(strc,
                                                 unit_cells=(a, b, c),
                                                 cycles=cycles,
                                                 input_file_type="cif",
                                                 units="m^2/g",
                                                 forcefield=forcefield)
    print('The geometric surface area=' + str(srfcarea) + 'm^2/g')
    return srfcarea
コード例 #4
0
def runmixture():
    structurename = input('Input structure name (name.cif): ')
    structur = structurename.split('.')
    strc = next(pybel.readfile(structur[1], structurename))
    strc.unitcell.FillUnitCell(strc.OBMol)
    strc.calccharges("eqeq")
    unitcells = input('unit_cells [default=(1,1,1)]: ')
    unitcells = unitcells.split(',')
    a = unitcells[0]
    a = a[1]
    b = unitcells[1]
    c = unitcells[2]
    c = c[0]
    cycles = int(input('cycles [default=500]: '))
    forcefield = input('forcefield [default=CrystalGenerator]: ')
    simulationtype = input('Simulation type [default=MonteCarlo]: ')
    print(
        'Now you will be asked for the number ofdifferent molecules, their names and the mol fraction of each one [number of molecules and names introduce must match ]'
    )
    nummolecules = int(input('Number of molecules to test: '))
    molecules = []
    molfractions = []
    control = 1
    temperature = int(float(input('Temperature (K) [default=273.15]: ')))
    pressure = int(float(input('Pressure (Pa) [default=101325]: ')))
    while control == 1:
        print('Want to calculate the helium void fraction or add it manully?')
        des = input('[calculate/ manual [default=1.0]:')
        if des != 'calculate' and des != 'manual':
            continue
        if des == 'calculate':
            void = int(float(getheliumvoidfraction()))
        if des == 'manual':
            void = int(float(input('Value= ')))
    for i in range(nummolecules):
        mol = input('Molecule name [name]:')
        molfr = int(float(input('Mol fraction: ')))
        molecules.append(mol)
        molfractions.append(molfr)

    out = RASPA2.run_mixture(strc,
                             molecules=molecules,
                             mol_fractions=molfractions,
                             temperature=temperature,
                             pressure=pressure,
                             helium_void_fraction=void,
                             unit_cells=(a, b, c),
                             simulation_type=simulationtype,
                             cycles=cycles,
                             init_cycles="auto",
                             forcefield=forcefield,
                             input_file_type="cif")
    return out
コード例 #5
0
ファイル: raspa_task.py プロジェクト: golemfactory/golemrpc
def raspa_task(args):
    '''Task to compute provider side (RASPA specific).
    It's possible to import RASPA2 package on remote side because
    it's preinstalled in a docker environment we are about to use to
    run this task. Every non standard package has to be installed
    in the remote environment first.
    '''
    import RASPA2
    import pybel

    mol = pybel.readstring('cif', args['mol'])

    return RASPA2.get_helium_void_fraction(mol)
コード例 #6
0
def runn():
    structurename = input('Input structure name (name.cif): ')
    structur = structurename.split('.')
    strc = next(pybel.readfile(structur[1], structurename))
    strc.unitcell.FillUnitCell(strc.OBMol)
    strc.calccharges("eqeq")
    unitcells = input('unit_cells [default=(1,1,1)]: ')
    unitcells = unitcells.split(',')
    a = unitcells[0]
    a = a[1]
    b = unitcells[1]
    c = unitcells[2]
    c = c[0]
    temperature = int(float(input('Temperature (K) [default=273.15]: ')))
    presure = int(float(input('Pressure (Pa) [default=101325]: ')))
    cycles = int(input('cycles [default=2000]: '))
    forcefield = input('forcefield [default=CrystalGenerator]: ')
    simulationtype = input('Simulation type [default=MonteCarlo]: ')
    molecule = input('Molecule name [name]: ')
    frameworkname = input('Framework name [default=streamed]')
    control = 1
    while control == 1:
        print('Want to calculate the helium void fraction or add it manully?')
        des = input('[calculate/ manual :')
        if des != 'calculate' and des != 'manual':
            continue
        if des == 'calculate':
            void = int(float(getheliumvoidfraction()))
            control = 2
        if des == 'manual':
            void = int(float(input('Value [default=1.0]= ')))
            control = 2
    out = RASPA2.run(strc,
                     molecule,
                     temperature=temperature,
                     pressure=presure,
                     helium_void_fraction=void,
                     unit_cells=(a, b, c),
                     framework_name=frameworkname,
                     simulation_type=simulationtype,
                     cycles=cycles,
                     init_cycles="auto",
                     forcefield=forcefield,
                     input_file_type="cif")
    return out
コード例 #7
0
def getporesizedistribution():
    print(
        'Returns a list of the form [[x1, x2, ..., xn], [y1, y2, ..., yn]], where x is the binned pore size (in Angstroms) and y is the partial pore volume (in cm^3 / g).'
    )
    print('Define the following parameter:')
    print(
        '            *for default option, you must introduce the exactly default ex:CrystalGenerator'
    )
    print('')
    structurename = input('Input structure name (name.cif): ')
    structur = structurename.split('.')
    strc = next(pybel.readfile(structur[1], structurename))
    strc.unitcell.FillUnitCell(strc.OBMol)
    strc.calccharges("eqeq")
    unitcells = input('unit_cells [default=(1,1,1)]: ')
    unitcells = unitcells.split(',')
    a = unitcells[0]
    a = a[1]
    b = unitcells[1]
    c = unitcells[2]
    c = c[0]
    cycles = int(input('cycles [default=500]: '))
    forcefield = input('forcefield [default=CrystalGenerator]: ')
    bins = int(input('bin number of the histogram output [default=50]: '))
    porsedistrib = RASPA2.get_pore_size_distribution(strc,
                                                     unit_cells=(a, b, c),
                                                     cycles=cycles,
                                                     input_file_type="cif",
                                                     forcefield=forcefield,
                                                     bins=bins)
    x = porsedistrib[0]
    y = porsedistrib[1]
    mtplot.plot(x, y)
    mtplot.xlabel('Binned pore size (Angstrom)')
    mtplot.ylabel('Partial pore volume (cm^3 / g)')
    mtplot.show()

    return porsedistrib
コード例 #8
0
def createscript():
    molecule = input('Molecule name [name]: ')
    unitcells = input('unit_cells [default=(1,1,1)]: ')
    unitcells = unitcells.split(',')
    a = unitcells[0]
    a = a[1]
    b = unitcells[1]
    c = unitcells[2]
    c = c[0]
    temperature = int(float(input('Temperature (K) [default=273.15]: ')))
    presure = int(float(input('Pressure (Pa) [default=101325]: ')))
    cycles = int(input('cycles [default=2000]: '))
    forcefield = input('forcefield [default=CrystalGenerator]: ')
    simulationtype = input('Simulation type [default=MonteCarlo]: ')
    control = 1
    while control == 1:
        print('Want to calculate the helium void fraction or add it manully?')
        des = input('[calculate/ manual :')
        if des != 'calculate' and des != 'manual':
            continue
        if des == 'calculate':
            void = int(float(getheliumvoidfraction()))
            control = 2
        if des == 'manual':
            void = int(float(input('Value [default=1.0]= ')))
            control = 2
    out = RASPA2.create_script(molecule,
                               temperature=temperature,
                               pressure=presure,
                               helium_void_fraction=void,
                               unit_cells=(a, b, c),
                               simulation_type=simulationtype,
                               cycles=cycles,
                               init_cycles="auto",
                               forcefield=forcefield,
                               input_file_type="cif")
    return out
コード例 #9
0
import RASPA2

input_script = RASPA2.create_script("H2",
                                    temperature=298,
                                    pressure=1000000,
                                    helium_void_fraction=1.0,
                                    input_file_type="cif")
print input_script
コード例 #10
0
import pybel
import RASPA2
import pandas as pd
#import matplotlib.pyplot as plt

# Set up
gas = "H2"
#pressures = [1e4 * 10**(0.1 * i) for i in range(31)]
pressures = [3.5e7,7.0e7,10.0e7]
# Use pybel to parse, fill, and charge cif structure
my_structure = pybel.readfile("cif", "IRMOF-1.cif").next()
#my_structure.unitcell.FillUnitCell(mol.OBMol)
#my_structure.calccharges("eqeq")

# Run
results = [RASPA2.run(my_structure, gas, temperature=298, pressure=pressure) for pressure in pressures]

# Parse
uptakes = [r["Number of molecules"][gas]["Average loading absolute [cm^3 (STP)/cm^3 framework]"][0] for r in results]

# print
z = [pressures,uptakes]
df = pd.DataFrame(z).T
df.to_csv("Pa_vs_NumAbsGas.csv")

# Plot
#plt.plot(pressures, uptakes)
#plt.show()
コード例 #11
0
def f(mof):
    import RASPA2
    output = RASPA2.run(mof["cif"], "H2", temperature=298, pressure=65e5, helium_void_fraction=mof["helium void fraction"], input_file_type="cif")
    return output["Number of molecules"]["H2"]["Average loading absolute [milligram/gram framework]"][0]