attrs=[
                  Attr('facet', Varchar, desc="Autodetected facet"),
                  Attr('vacuum', Decimal, desc='Layer separation (Angstrom)')
              ],
              fks=[FK('struct', id=True)])

rich_objs = [
    job, elem, species, struct, cell, atom, calc, struct_comp, bulk, mol, surf
]

################################################################################
# Path Equations
################
b0, m0, s0 = Gen('b0', bulk), Gen('m0', mol), Gen('s0', surf)
st0, a0 = Gen('st0', struct), Gen('a0', atom)

rich_pe = [
    PathEQ(Path(atom['number']), Path(atom['element'], elem['atomic_number'])),
    PathEQ(Path(b0['struct'], struct['system_type']),
           Path(JLit('bulk', String))),
    PathEQ(Path(m0['struct'], struct['system_type']),
           Path(JLit('molecule', String))),
    PathEQ(Path(s0['struct'], struct['system_type']),
           Path(JLit('surface', String))),
    PathEQ(Path(st0['species'], species['phase']), Path(st0['system_type'])),
    PathEQ(Path(gteq(a0['x'], JLit("0.000", Double))),
           Path(JLit('true', Boolean)))
]

rich = Schema('catalysis', rich_objs, rich_pe)
Example #2
0
def Rename_attrs(obj1: Entity, obj2: Entity, attrs: D[str, str]) -> L[PathEQ]:
    '''Shorthand function for identifying columns/FKs of two entities'''
    return [
        PathEQ(Path(obj1[col1]), Path(obj2[col2]))
        for col1, col2 in attrs.items()
    ]
Example #3
0
hc = Entity(name='hubbard_corrections',
            id='id',
            desc='Energy correction for DFT+U energies',
            attrs=[Attr('value', Double, desc='Correction energy (eV/atom)')],
            fks=[FK(x[:-1] + '_id', x, id=True) for x in hcs])

####################################################################
objs = [
    journals, authors, elems, hubbards, species, md, sg, comp, ces, pubs, pas,
    entries, ees, emd, structs, calc, cmd, caes, sites, proto, atoms, ses, smd,
    sss, fits, fd, re, hc, ess
]

pes = [
    PathEQ(Path(atoms['structure_id']),
           Path(atoms['site_id'], sites['structure_id'])),
    PathEQ(Path(calc['energy']), Path(calc['output_id'], structs['energy'])),
    PathEQ(Path(calc['natoms']),
           Path(calc['input_id'], structs['entry_id'], entries['natoms'])),
    PathEQ(Path(calc['output_id'], structs['entry_id']),
           Path(calc['input_id'], structs['entry_id']))
]

oqmd = Schema('oqmd', objs, pes)

################################################################################
###############################
# 2: Filter on records landed #
###############################

# don't include any records by default
Example #4
0
elemcount = countsubstr(s0['comp'], cat(l0['symbol'], JLit(',', String)))

msj_kwargs = ['comp', 'xs', 'ys', 'zs'] + [a + b for a in 'xyz' for b in '123']
msj_args = [structs[x] for x in msj_kwargs]

#######################################
# Section 1: Specification of overlap #
#######################################

overlap = Overlap(s1=oqmd, s2=rich,

    paths=[
            # 1.1: Path equalities specified one at a time
            #----------------------------------------
            PathEQ(Path(elems['z']),Path(elem['atomic_number'])),

            # 1.2: Path Equalities defined with some sort of loop
            #-----------------------------------------------
        ] + ID_attrs(calcs,job, ['energy','user','job_name'])                   \
          + ID_attrs(atoms,atom,['x','y','z','ind'])                            \
          + ID_attrs(elems,elem,['symbol','name'])                              \
          + Rename_attrs(calcs,job,{'path':'stordir','output_id':'struct'})     \
          + Rename_attrs(structs,struct,{'natoms'       : 'n_atoms',
                                         'system_type'  : 'system_type'})       \
          + Rename_attrs(atoms,atom,{'structure_id' : 'struct',
                                         'element_id'   : 'element'})           \
         + [PathEQ(Path(calcs[col]),
                    Path(job['calc'],calc[col]))
              for col in ['dftcode','xc','pw','psp']
        ]
Example #5
0
matches = JavaFunc('matches', [String, String], Boolean,
                   "return input[0].matches(input[1])")
cat = JavaFunc('cat', [String, String], String, "return input[0] + input[1]")

funcs = [count_words, Len, plus, matches, cat]

########################################################################
# Map any relevant objs/attrs/relations in source onto paths in target #
########################################################################
chap, nov, readr = Gen('Chap', Chap), Gen('Nov', Nov), Gen('Readr', Readr)

overlap = Overlap(
    s1=src,
    s2=tar,
    paths=[
        PathEQ(Path(Nov['title']), Path(Novel['title'])),
        PathEQ(Path(Nov['aname']), Path(Novel['wrote'], Author['authorname'])),
        PathEQ(Path(Chap['num']), Path(Chapter['num'])),
        PathEQ(Path(Chap['novel_id']), Path(Chapter['novel'])),
        PathEQ(Path(Readr['rname']), Path(Reader['readername'])),
        PathEQ(Path(Readr['fav']), Path(Reader['favorite']))
    ],
    new_attr1=[
        NewAttr(Chap, 'n_words', Integer, count_words(chap['text'])),
    ],
    new_fk1=[NewFK(Nov, FK('wrote', 'Author'), nov)],
    new_ent1=[
        NewEntity(name='Author', gens=[nov]),
        NewEntity(name='Borrow',
                  gens=[nov, readr],
                  where=[