def test_workchain(self): """ Verify that the attributes of the TestWorkChain can be set but defaults are not there """ builder = TestWorkChain.get_builder() builder.a = Int(2) builder.b = Float(2.3) builder.c.d = Bool(True) self.assertEquals(builder, { 'a': Int(2), 'b': Float(2.3), 'c': { 'd': Bool(True) } })
def test_dynamic_getters_value(self): """ Verify that getters will return the actual value """ builder = TestWorkChain.get_builder() builder.a = Int(2) builder.b = Float(2.3) builder.c.d = Bool(True) # Verify that the correct type is returned by the getter self.assertTrue(isinstance(builder.a, Int)) self.assertTrue(isinstance(builder.b, Float)) self.assertTrue(isinstance(builder.c.d, Bool)) # Verify that the correct value is returned by the getter self.assertEquals(builder.a, Int(2)) self.assertEquals(builder.b, Float(2.3)) self.assertEquals(builder.c.d, Bool(True))
def launch_calculations(self): self.ctx.launched = {} for s in (0.96, 0.98, 1., 1.02, 1.04): scaled = rescale(self.inputs.structure, Float(s)) inputs = generate_scf_input_params(scaled, self.inputs.code, self.inputs.pseudo_family) pid = submit(Proc, **inputs) self.ctx.launched[str(s)] = pid self.insert_barrier(Calc(pid))
def main(): inputs = {'a': Float(3.14), 'b': Int(4), 'c': Int(6)} results = work.run(SumWorkChain, **inputs) print 'Result of SumWorkChain: {}'.format(results) results = work.run(ProductWorkChain, **inputs) print 'Result of ProductWorkChain: {}'.format(results) results = work.run(SumProductWorkChain, **inputs) print 'Result of SumProductWorkChain: {}'.format(results)
def eos(structure, codename, pseudo_family): Proc = PwCalculation.process() results = {} for s in (0.98, 0.99, 1.0, 1.02, 1.04): rescaled = rescale(structure, Float(s)) inputs = generate_scf_input_params(rescaled, codename, pseudo_family) outputs = run(Proc, **inputs) res = outputs['output_parameters'].dict results[str(s)] = res return results
def setUpClass(cls, *args, **kwargs): super(TestVerdiRehash, cls).setUpClass(*args, **kwargs) from aiida.orm import Node from aiida.orm.data.bool import Bool from aiida.orm.data.float import Float from aiida.orm.data.int import Int cls.node_base = Node().store() cls.node_bool_true = Bool(True).store() cls.node_bool_false = Bool(False).store() cls.node_float = Float(1.0).store() cls.node_int = Int(1).store()
def launch_calculations(self): launched = {} for s in (0.96, 0.98, 1., 1.02, 1.04): scaled = rescale(self.inputs.structure, Float(s)) inputs = generate_scf_input_params(scaled, self.inputs.code, self.inputs.pseudo_family) pid = submit(Proc, **inputs) launched["s_" + str(s)] = pid return ToContext(r=Calc(1234), s=Outputs(1234)) return ToContext(**launched)
def main(): a = Float(3.14) b = Int(4) c = Int(6) results = sum(a, b) print 'Result of sum: {}'.format(results) results = product(a, b) print 'Result of product: {}'.format(results) results = sumproduct(a, b, c) print 'Result of sumproduct: {}'.format(results)
def test_nested_expose(self): res = work.run(GrandParentExposeWorkChain, sub=dict(sub=dict( a=Int(1), sub_1={ 'b': Float(2.3), 'c': Bool(True) }, sub_2={ 'b': Float(1.2), 'sub_3': { 'c': Bool(False) } }, ))) self.assertEquals( res, { 'sub.sub.a': Float(2.2), 'sub.sub.sub_1.b': Float(2.3), 'sub.sub.sub_1.c': Bool(True), 'sub.sub.sub_2.b': Float(1.2), 'sub.sub.sub_2.sub_3.c': Bool(False) })
def test_expose(self): res = work.run( ParentExposeWorkChain, a=Int(1), sub_1={ 'b': Float(2.3), 'c': Bool(True) }, sub_2={ 'b': Float(1.2), 'sub_3': { 'c': Bool(False) } }, ) self.assertEquals( res, { 'a': Float(2.2), 'sub_1.b': Float(2.3), 'sub_1.c': Bool(True), 'sub_2.b': Float(1.2), 'sub_2.sub_3.c': Bool(False) })
#!/usr/bin/env runaiida from __future__ import print_function from aiida.orm.data.bool import Bool from aiida.orm.data.float import Float from aiida.orm.data.int import Int from aiida.work import run from complex_parent import ComplexParentWorkChain if __name__ == '__main__': result = run(ComplexParentWorkChain, a=Int(1), child_1=dict(b=Float(1.2), c=Bool(True)), child_2=dict(b=Float(2.3), c=Bool(False))) print(result) # { # u'e': 1.2, # u'child_1.d': 1, u'child_1.f': True, # u'child_2.d': 1, u'child_2.f': False # }
#!/usr/bin/env runaiida from __future__ import print_function from aiida.orm.data.bool import Bool from aiida.orm.data.float import Float from aiida.orm.data.int import Int from aiida.work import run from simple_parent import SimpleParentWorkChain if __name__ == '__main__': result = run(SimpleParentWorkChain, a=Int(1), b=Float(1.2), c=Bool(True)) print(result) # {u'e': 1.2, u'd': 1, u'f': True}