############# # Catalysis # ############# job = Entity(name='job', desc='DFT job', attrs=[ Attr('stordir', Varchar, desc='Directory containing log file', id=True), Attr('job_name', Varchar, desc='Name of job - arbitrary'), Attr('user', Varchar, desc='Owner of job'), Attr('energy', Double, desc='Energy result of job') ], fks=[FK('struct'), FK('calc')]) elem = Entity(name='element', desc='chemical element', attrs=[ Attr('atomic_number', desc='# of protons', id=True), Attr('symbol', Varchar, desc='E.g. He, K, Li'), Attr('name', Varchar) ]) species = Entity( name='species', desc="""Abstraction of a struct which throws away position info. Composition is a python dictionary mapping atomic number to NORMALIZED stoich""", attrs=[
# Compute the L² Norm of three 3D vectors ] + [SQLAttr(structs,abc,Double, Sum([structs['%s%d'%(xyz,i)] ** Literal(2) for i in range(1,4)]) ** Literal(0.5)) for abc,xyz in zip('abc','xyz') ] + [SQLAttr(calcs,attr,Varchar,Literal(constval)) for attr,constval in calc_constants.items()], # 1.4: Attrs computed in CQL (can use Java functions + info from multiple tables) #--------------------------------------------------------------------------- new_attr1 = [NewAttr(structs,'composition', String, mcd(structs['comp'])), NewAttr(structs,'raw', Text, msj(*msj_args)), NewAttr(atoms,'ind',Int,bigint_to_int(atoms['bigind']))], # 1.5: New Entities computed in CQL #---------------------------------- new_ent1 = [NewEntity(name = 'struct_composition', gens = [s0, l0], where = [EQ(gt(elemcount, zero) , JLit('true',Boolean))], attrs = {Attr('num',Int) : elemcount}, fks = {FK('struct','structures') : s0, FK('element','elements') : l0}), NewEntity(name = 'bulk', gens = [s0], fks = {FK('struct','structures') : s0})] )
rots = Entity(name='rotations', id='id', attrs=[ Attr('a%d%d' % (i, j), Double, id=True) for i in range(3) for j in range(3) ]) trans = Entity(name='translations', id='id', attrs=[Attr(x, Double, id=True) for x in 'xyz']) operations = Entity(name='operations', id='id', fks=[ FK('rotation_id', 'rotations', id=True), FK('translation_id', 'translations', id=True) ]) elems = Entity(name='elements', id='z', attrs=[ Attr('z', Int, desc='atomic number', id=True), Attr('name', Varchar, desc='full atomic name'), Attr('symbol', Varchar, desc='atomic symbol'), Attr('group', ), Attr('period', ), Attr('mass', Double), Attr('specific_heat', Double), Attr('s_elec', ), Attr('p_elec', ),
# External from typing import Callable as C # Internal from cdi import Schema, Entity, Attr, Varchar, FK, Instance, Gen, JLit, Integer ################################################################################ Chap = Entity(name='Chap', desc="A chapter within a book", id='id', attrs=[ Attr('num', id=True, desc='Chapter #'), Attr('text', Varchar, desc='Full text of a chapter') ], fks=[FK('novel_id', 'Nov', id=True)]) Nov = Entity(name='Nov', desc='A book', id='id', attrs=[ Attr('aname', Varchar, desc='Author name'), Attr('title', Varchar, id=True, desc='Book title '), Attr('year', desc='Book publish date') ]) Readr = Entity( name='Readr', desc='A reader', id='id', attrs=[ Attr('rname', Varchar, desc='Reader name'), Attr('borrowed', Varchar,
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=[ EQ( matches(readr['borrowed'], concat(wild, nov['title'], wild)), Lit('true', Boolean)) ], attrs={ Attr('total_len', Integer): plus(Len(readr['rname']), Len(nov['title'])) }, fks={