def test_del_state(self): "Atom: delete state" Fe57 = Atom( 'Fe', mass=57 ) Fe57.velocity = (0,0,1) del Fe57.velocity self._assertRaises( AttributeError, 'Fe57.velocity', locals()) return
def test_del_state(self): "Atom: delete state" Fe57 = Atom('Fe', mass=57) Fe57.velocity = (0, 0, 1) del Fe57.velocity self._assertRaises(AttributeError, 'Fe57.velocity', locals()) return
def test_setable_state(self): "Atom: setable state" Fe57 = Atom('Fe', mass=57) v = (0, 0, 1) print '- Set velocity to %s ... ' % (v, ), Fe57.velocity = v print ' velocity = %s ' % (Fe57.velocity, ) print "- velocity's documentation: %s " % Atom.velocity.doc return
def test_setable_state(self): "Atom: setable state" Fe57 = Atom( 'Fe', mass=57 ) v = (0,0,1) print '- Set velocity to %s ... ' % (v,), Fe57.velocity = v print ' velocity = %s ' % (Fe57.velocity,) print "- velocity's documentation: %s " % Atom.velocity.doc return
def test_writeStr_xyz(self): """check string representation of normal xyz file""" stru = self.stru stru.description = "test of writeStr" stru.lattice = Lattice(1.0, 2.0, 3.0, 90.0, 90.0, 90.0) stru[:] = [Atom('H', [1., 1., 1.]), Atom('Cl', [3., 2., 1.])] s1 = stru.writeStr(self.format) s1 = re.sub('[ \t]+', ' ', s1) s0 = "2\n%s\nH 1 2 3\nCl 3 4 3\n" % stru.description self.assertEqual(s1, s0)
def test_writeStr_xyz_Supercell(self): at1 = Atom('Al', [0.0, 0.0, 0.0]) at2 = Atom('Al', [0.0, 0.5, 0.5]) at3 = Atom('Al', [0.5, 0.0, 0.5]) at4 = Atom('Al', [0.5, 0.5, 0.0]) self.stru4 = Structure([at1, at2, at3, at4], lattice=Lattice(4.05, 4.05, 4.05, 90, 90, 90), sgid=225) from danse.ins.matter.expansion import supercell al_333 = supercell(self.stru4, (3, 3, 3)) s1 = al_333.writeStr(self.format)
def test_write_xyz(self): """check writing of normal xyz file""" stru = self.stru stru.description = "test of writeStr" stru.lattice = Lattice(1.0, 2.0, 3.0, 90.0, 90.0, 90.0) stru[:] = [Atom('H', [1., 1., 1.]), Atom('Cl', [3., 2., 1.])] stru.write(self.tmpname, self.format) f_s = open(self.tmpname).read() f_s = re.sub('[ \t]+', ' ', f_s) s_s = "2\n%s\nH 1 2 3\nCl 3 4 3\n" % stru.description self.assertEqual(f_s, s_s)
def test_xyz(self): "Atom: xyz cartesian attribute" from danse.ins.matter import Lattice C = Atom('C', [0.1, 0.2, 0.3], lattice=Lattice(2, 2, 2, 90, 90, 90)) print "fractional pos=%s" % C.xyz print "cartesian pos=%s" % C.xyz_cartn return
def test_writeStr_rawxyz(self): """check writing of normal xyz file""" stru = self.stru stru.description = "test of writeStr" stru.lattice = Lattice(1.0, 2.0, 3.0, 90.0, 90.0, 90.0) # plain version stru[:] = [Atom('H', [1., 1., 1.])] s1 = stru.writeStr(self.format) s1 = re.sub('[ \t]+', ' ', s1) s0 = "H 1 2 3\n"
def test_dsaworm(self): 'Atom: dsaw orm' Fe57 = Atom('Fe', mass=57) orm = self.orm Fe57record = orm(Fe57) orm.save(Fe57) Fe57_loaded = orm.load(Atom, Fe57record.id) props = ['symbol', 'label', 'occupancy'] for prop in props: self.assertEqual(getattr(Fe57_loaded, prop), getattr(Fe57, prop)) continue return
def test_natural_element(self): "Atom: natural element ctor" Fe = Atom('Fe') print Fe return
def test_str(self): "Atom: __str__" Fe57 = Atom('Fe', mass=57) Fe57.velocity = (0, 0, 1) print Fe57 return
def test_del_ctorarg(self): "Atom: delete ctor arg" Fe57 = Atom('Fe', mass=57) self._assertRaises(AttributeError, "del Fe57.Z", locals()) return
def test_undefined_state(self): "Atom: undefined state" Fe57 = Atom('Fe', mass=57) self._assertRaises(AttributeError, "Fe57.velocity", locals()) return
def test_isotope_ctor(self): "Atom: isotope ctor" Fe57 = Atom('Fe', mass=57) print "- Z=%s" % Fe57.Z print "- mass=%s" % Fe57.mass return
def test_str(self): "Atom: __str__" Fe57 = Atom( 'Fe', mass=57 ) Fe57.velocity = (0,0,1) print Fe57 return